babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277
  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. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1053. * @param fallback defines the fallback internal texture if any
  1054. * @param isBase64 defines whether the texture is encoded as a base64
  1055. * @param isBuffer defines whether the texture data are stored as a buffer
  1056. * @returns true if the loader can load the specified file
  1057. */
  1058. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1059. /**
  1060. * Transform the url before loading if required.
  1061. * @param rootUrl the url of the texture
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @returns the transformed texture
  1064. */
  1065. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1066. /**
  1067. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1068. * @param rootUrl the url of the texture
  1069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1070. * @returns the fallback texture
  1071. */
  1072. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1073. /**
  1074. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1075. * @param data contains the texture data
  1076. * @param texture defines the BabylonJS internal texture
  1077. * @param createPolynomials will be true if polynomials have been requested
  1078. * @param onLoad defines the callback to trigger once the texture is ready
  1079. * @param onError defines the callback to trigger in case of error
  1080. */
  1081. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1082. /**
  1083. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1084. * @param data contains the texture data
  1085. * @param texture defines the BabylonJS internal texture
  1086. * @param callback defines the method to call once ready to upload
  1087. */
  1088. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1089. }
  1090. }
  1091. declare module "babylonjs/Engines/IPipelineContext" {
  1092. /**
  1093. * Class used to store and describe the pipeline context associated with an effect
  1094. */
  1095. export interface IPipelineContext {
  1096. /**
  1097. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1098. */
  1099. isAsync: boolean;
  1100. /**
  1101. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1102. */
  1103. isReady: boolean;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module "babylonjs/Meshes/dataBuffer" {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1143. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1144. /** @hidden */
  1145. export interface ProcessingOptions {
  1146. defines: string[];
  1147. indexParameters: any;
  1148. isFragment: boolean;
  1149. shouldUseHighPrecisionShader: boolean;
  1150. supportsUniformBuffers: boolean;
  1151. shadersRepository: string;
  1152. includesShadersStore: {
  1153. [key: string]: string;
  1154. };
  1155. processor?: IShaderProcessor;
  1156. version: string;
  1157. platformName: string;
  1158. lookForClosingBracketForUniformBuffer?: boolean;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1162. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1163. /** @hidden */
  1164. export class ShaderCodeNode {
  1165. line: string;
  1166. children: ShaderCodeNode[];
  1167. additionalDefineKey?: string;
  1168. additionalDefineValue?: string;
  1169. isValid(preprocessors: {
  1170. [key: string]: string;
  1171. }): boolean;
  1172. process(preprocessors: {
  1173. [key: string]: string;
  1174. }, options: ProcessingOptions): string;
  1175. }
  1176. }
  1177. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1178. /** @hidden */
  1179. export class ShaderCodeCursor {
  1180. private _lines;
  1181. lineIndex: number;
  1182. get currentLine(): string;
  1183. get canRead(): boolean;
  1184. set lines(value: string[]);
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1190. /** @hidden */
  1191. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1192. process(preprocessors: {
  1193. [key: string]: string;
  1194. }, options: ProcessingOptions): string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1198. /** @hidden */
  1199. export class ShaderDefineExpression {
  1200. isTrue(preprocessors: {
  1201. [key: string]: string;
  1202. }): boolean;
  1203. }
  1204. }
  1205. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1206. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1207. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1208. /** @hidden */
  1209. export class ShaderCodeTestNode extends ShaderCodeNode {
  1210. testExpression: ShaderDefineExpression;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1220. define: string;
  1221. not: boolean;
  1222. constructor(define: string, not?: boolean);
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1254. define: string;
  1255. operand: string;
  1256. testValue: string;
  1257. constructor(define: string, operand: string, testValue: string);
  1258. isTrue(preprocessors: {
  1259. [key: string]: string;
  1260. }): boolean;
  1261. }
  1262. }
  1263. declare module "babylonjs/Offline/IOfflineProvider" {
  1264. /**
  1265. * Class used to enable access to offline support
  1266. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1267. */
  1268. export interface IOfflineProvider {
  1269. /**
  1270. * Gets a boolean indicating if scene must be saved in the database
  1271. */
  1272. enableSceneOffline: boolean;
  1273. /**
  1274. * Gets a boolean indicating if textures must be saved in the database
  1275. */
  1276. enableTexturesOffline: boolean;
  1277. /**
  1278. * Open the offline support and make it available
  1279. * @param successCallback defines the callback to call on success
  1280. * @param errorCallback defines the callback to call on error
  1281. */
  1282. open(successCallback: () => void, errorCallback: () => void): void;
  1283. /**
  1284. * Loads an image from the offline support
  1285. * @param url defines the url to load from
  1286. * @param image defines the target DOM image
  1287. */
  1288. loadImage(url: string, image: HTMLImageElement): void;
  1289. /**
  1290. * Loads a file from offline support
  1291. * @param url defines the URL to load from
  1292. * @param sceneLoaded defines a callback to call on success
  1293. * @param progressCallBack defines a callback to call when progress changed
  1294. * @param errorCallback defines a callback to call on error
  1295. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1296. */
  1297. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/filesInputStore" {
  1301. /**
  1302. * Class used to help managing file picking and drag'n'drop
  1303. * File Storage
  1304. */
  1305. export class FilesInputStore {
  1306. /**
  1307. * List of files ready to be loaded
  1308. */
  1309. static FilesToLoad: {
  1310. [key: string]: File;
  1311. };
  1312. }
  1313. }
  1314. declare module "babylonjs/Misc/retryStrategy" {
  1315. import { WebRequest } from "babylonjs/Misc/webRequest";
  1316. /**
  1317. * Class used to define a retry strategy when error happens while loading assets
  1318. */
  1319. export class RetryStrategy {
  1320. /**
  1321. * Function used to defines an exponential back off strategy
  1322. * @param maxRetries defines the maximum number of retries (3 by default)
  1323. * @param baseInterval defines the interval between retries
  1324. * @returns the strategy function to use
  1325. */
  1326. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1327. }
  1328. }
  1329. declare module "babylonjs/Misc/baseError" {
  1330. /**
  1331. * @ignore
  1332. * Application error to support additional information when loading a file
  1333. */
  1334. export abstract class BaseError extends Error {
  1335. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1336. }
  1337. }
  1338. declare module "babylonjs/Misc/fileTools" {
  1339. import { WebRequest } from "babylonjs/Misc/webRequest";
  1340. import { Nullable } from "babylonjs/types";
  1341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1343. import { BaseError } from "babylonjs/Misc/baseError";
  1344. /** @ignore */
  1345. export class LoadFileError extends BaseError {
  1346. request?: WebRequest;
  1347. file?: File;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, object?: WebRequest | File);
  1355. }
  1356. /** @ignore */
  1357. export class RequestFileError extends BaseError {
  1358. request: WebRequest;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. */
  1364. constructor(message: string, request: WebRequest);
  1365. }
  1366. /** @ignore */
  1367. export class ReadFileError extends BaseError {
  1368. file: File;
  1369. /**
  1370. * Creates a new ReadFileError
  1371. * @param message defines the message of the error
  1372. * @param file defines the optional file
  1373. */
  1374. constructor(message: string, file: File);
  1375. }
  1376. /**
  1377. * @hidden
  1378. */
  1379. export class FileTools {
  1380. /**
  1381. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1382. */
  1383. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1384. /**
  1385. * Gets or sets the base URL to use to load assets
  1386. */
  1387. static BaseUrl: string;
  1388. /**
  1389. * Default behaviour for cors in the application.
  1390. * It can be a string if the expected behavior is identical in the entire app.
  1391. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1392. */
  1393. static CorsBehavior: string | ((url: string | string[]) => string);
  1394. /**
  1395. * Gets or sets a function used to pre-process url before using them to load assets
  1396. */
  1397. static PreprocessUrl: (url: string) => string;
  1398. /**
  1399. * Removes unwanted characters from an url
  1400. * @param url defines the url to clean
  1401. * @returns the cleaned url
  1402. */
  1403. private static _CleanUrl;
  1404. /**
  1405. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1406. * @param url define the url we are trying
  1407. * @param element define the dom element where to configure the cors policy
  1408. */
  1409. static SetCorsBehavior(url: string | string[], element: {
  1410. crossOrigin: string | null;
  1411. }): void;
  1412. /**
  1413. * Loads an image as an HTMLImageElement.
  1414. * @param input url string, ArrayBuffer, or Blob to load
  1415. * @param onLoad callback called when the image successfully loads
  1416. * @param onError callback called when the image fails to load
  1417. * @param offlineProvider offline provider for caching
  1418. * @param mimeType optional mime type
  1419. * @returns the HTMLImageElement of the loaded image
  1420. */
  1421. 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>;
  1422. /**
  1423. * Reads a file from a File object
  1424. * @param file defines the file to load
  1425. * @param onSuccess defines the callback to call when data is loaded
  1426. * @param onProgress defines the callback to call during loading process
  1427. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1428. * @param onError defines the callback to call when an error occurs
  1429. * @returns a file request object
  1430. */
  1431. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file from a url
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param offlineProvider defines the offline provider for caching
  1438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1439. * @param onError callback called when the file fails to load
  1440. * @returns a file request object
  1441. */
  1442. 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;
  1443. /**
  1444. * Loads a file
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @param onOpened callback called when the web request is opened
  1451. * @returns a file request object
  1452. */
  1453. 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;
  1454. /**
  1455. * Checks if the loaded document was accessed via `file:`-Protocol.
  1456. * @returns boolean
  1457. */
  1458. static IsFileURL(): boolean;
  1459. }
  1460. }
  1461. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1462. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1463. import { WebRequest } from "babylonjs/Misc/webRequest";
  1464. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1465. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1466. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. 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;
  1492. }
  1493. }
  1494. declare module "babylonjs/Maths/math.like" {
  1495. import { float, int, DeepImmutable } from "babylonjs/types";
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IColor4Like {
  1500. r: float;
  1501. g: float;
  1502. b: float;
  1503. a: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IColor3Like {
  1509. r: float;
  1510. g: float;
  1511. b: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector4Like {
  1517. x: float;
  1518. y: float;
  1519. z: float;
  1520. w: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IVector3Like {
  1526. x: float;
  1527. y: float;
  1528. z: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IVector2Like {
  1534. x: float;
  1535. y: float;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IMatrixLike {
  1541. toArray(): DeepImmutable<Float32Array>;
  1542. updateFlag: int;
  1543. }
  1544. /**
  1545. * @hidden
  1546. */
  1547. export interface IViewportLike {
  1548. x: float;
  1549. y: float;
  1550. width: float;
  1551. height: float;
  1552. }
  1553. /**
  1554. * @hidden
  1555. */
  1556. export interface IPlaneLike {
  1557. normal: IVector3Like;
  1558. d: float;
  1559. normalize(): void;
  1560. }
  1561. }
  1562. declare module "babylonjs/Materials/iEffectFallbacks" {
  1563. import { Effect } from "babylonjs/Materials/effect";
  1564. /**
  1565. * Interface used to define common properties for effect fallbacks
  1566. */
  1567. export interface IEffectFallbacks {
  1568. /**
  1569. * Removes the defines that should be removed when falling back.
  1570. * @param currentDefines defines the current define statements for the shader.
  1571. * @param effect defines the current effect we try to compile
  1572. * @returns The resulting defines with defines of the current rank removed.
  1573. */
  1574. reduce(currentDefines: string, effect: Effect): string;
  1575. /**
  1576. * Removes the fallback from the bound mesh.
  1577. */
  1578. unBindMesh(): void;
  1579. /**
  1580. * Checks to see if more fallbacks are still availible.
  1581. */
  1582. hasMoreFallbacks: boolean;
  1583. }
  1584. }
  1585. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1586. /**
  1587. * Class used to evalaute queries containing `and` and `or` operators
  1588. */
  1589. export class AndOrNotEvaluator {
  1590. /**
  1591. * Evaluate a query
  1592. * @param query defines the query to evaluate
  1593. * @param evaluateCallback defines the callback used to filter result
  1594. * @returns true if the query matches
  1595. */
  1596. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1597. private static _HandleParenthesisContent;
  1598. private static _SimplifyNegation;
  1599. }
  1600. }
  1601. declare module "babylonjs/Misc/tags" {
  1602. /**
  1603. * Class used to store custom tags
  1604. */
  1605. export class Tags {
  1606. /**
  1607. * Adds support for tags on the given object
  1608. * @param obj defines the object to use
  1609. */
  1610. static EnableFor(obj: any): void;
  1611. /**
  1612. * Removes tags support
  1613. * @param obj defines the object to use
  1614. */
  1615. static DisableFor(obj: any): void;
  1616. /**
  1617. * Gets a boolean indicating if the given object has tags
  1618. * @param obj defines the object to use
  1619. * @returns a boolean
  1620. */
  1621. static HasTags(obj: any): boolean;
  1622. /**
  1623. * Gets the tags available on a given object
  1624. * @param obj defines the object to use
  1625. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1626. * @returns the tags
  1627. */
  1628. static GetTags(obj: any, asString?: boolean): any;
  1629. /**
  1630. * Adds tags to an object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1633. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1634. */
  1635. static AddTagsTo(obj: any, tagsString: string): void;
  1636. /**
  1637. * @hidden
  1638. */
  1639. static _AddTagTo(obj: any, tag: string): void;
  1640. /**
  1641. * Removes specific tags from a specific object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tags to remove
  1644. */
  1645. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _RemoveTagFrom(obj: any, tag: string): void;
  1650. /**
  1651. * Defines if tags hosted on an object match a given query
  1652. * @param obj defines the object to use
  1653. * @param tagsQuery defines the tag query
  1654. * @returns a boolean
  1655. */
  1656. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1657. }
  1658. }
  1659. declare module "babylonjs/Maths/math.scalar" {
  1660. /**
  1661. * Scalar computation library
  1662. */
  1663. export class Scalar {
  1664. /**
  1665. * Two pi constants convenient for computation.
  1666. */
  1667. static TwoPi: number;
  1668. /**
  1669. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1670. * @param a number
  1671. * @param b number
  1672. * @param epsilon (default = 1.401298E-45)
  1673. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1674. */
  1675. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1676. /**
  1677. * Returns a string : the upper case translation of the number i to hexadecimal.
  1678. * @param i number
  1679. * @returns the upper case translation of the number i to hexadecimal.
  1680. */
  1681. static ToHex(i: number): string;
  1682. /**
  1683. * Returns -1 if value is negative and +1 is value is positive.
  1684. * @param value the value
  1685. * @returns the value itself if it's equal to zero.
  1686. */
  1687. static Sign(value: number): number;
  1688. /**
  1689. * Returns the value itself if it's between min and max.
  1690. * Returns min if the value is lower than min.
  1691. * Returns max if the value is greater than max.
  1692. * @param value the value to clmap
  1693. * @param min the min value to clamp to (default: 0)
  1694. * @param max the max value to clamp to (default: 1)
  1695. * @returns the clamped value
  1696. */
  1697. static Clamp(value: number, min?: number, max?: number): number;
  1698. /**
  1699. * the log2 of value.
  1700. * @param value the value to compute log2 of
  1701. * @returns the log2 of value.
  1702. */
  1703. static Log2(value: number): number;
  1704. /**
  1705. * Loops the value, so that it is never larger than length and never smaller than 0.
  1706. *
  1707. * This is similar to the modulo operator but it works with floating point numbers.
  1708. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1709. * With t = 5 and length = 2.5, the result would be 0.0.
  1710. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1711. * @param value the value
  1712. * @param length the length
  1713. * @returns the looped value
  1714. */
  1715. static Repeat(value: number, length: number): number;
  1716. /**
  1717. * Normalize the value between 0.0 and 1.0 using min and max values
  1718. * @param value value to normalize
  1719. * @param min max to normalize between
  1720. * @param max min to normalize between
  1721. * @returns the normalized value
  1722. */
  1723. static Normalize(value: number, min: number, max: number): number;
  1724. /**
  1725. * Denormalize the value from 0.0 and 1.0 using min and max values
  1726. * @param normalized value to denormalize
  1727. * @param min max to denormalize between
  1728. * @param max min to denormalize between
  1729. * @returns the denormalized value
  1730. */
  1731. static Denormalize(normalized: number, min: number, max: number): number;
  1732. /**
  1733. * Calculates the shortest difference between two given angles given in degrees.
  1734. * @param current current angle in degrees
  1735. * @param target target angle in degrees
  1736. * @returns the delta
  1737. */
  1738. static DeltaAngle(current: number, target: number): number;
  1739. /**
  1740. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1741. * @param tx value
  1742. * @param length length
  1743. * @returns The returned value will move back and forth between 0 and length
  1744. */
  1745. static PingPong(tx: number, length: number): number;
  1746. /**
  1747. * Interpolates between min and max with smoothing at the limits.
  1748. *
  1749. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1750. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1751. * @param from from
  1752. * @param to to
  1753. * @param tx value
  1754. * @returns the smooth stepped value
  1755. */
  1756. static SmoothStep(from: number, to: number, tx: number): number;
  1757. /**
  1758. * Moves a value current towards target.
  1759. *
  1760. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1761. * Negative values of maxDelta pushes the value away from target.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting value
  1766. */
  1767. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. *
  1771. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1772. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting angle
  1777. */
  1778. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1781. * @param start start value
  1782. * @param end target value
  1783. * @param amount amount to lerp between
  1784. * @returns the lerped value
  1785. */
  1786. static Lerp(start: number, end: number, amount: number): number;
  1787. /**
  1788. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1789. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1790. * @param start start value
  1791. * @param end target value
  1792. * @param amount amount to lerp between
  1793. * @returns the lerped value
  1794. */
  1795. static LerpAngle(start: number, end: number, amount: number): number;
  1796. /**
  1797. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1798. * @param a start value
  1799. * @param b target value
  1800. * @param value value between a and b
  1801. * @returns the inverseLerp value
  1802. */
  1803. static InverseLerp(a: number, b: number, value: number): number;
  1804. /**
  1805. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1806. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1807. * @param value1 spline value
  1808. * @param tangent1 spline value
  1809. * @param value2 spline value
  1810. * @param tangent2 spline value
  1811. * @param amount input value
  1812. * @returns hermite result
  1813. */
  1814. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1815. /**
  1816. * Returns a random float number between and min and max values
  1817. * @param min min value of random
  1818. * @param max max value of random
  1819. * @returns random value
  1820. */
  1821. static RandomRange(min: number, max: number): number;
  1822. /**
  1823. * This function returns percentage of a number in a given range.
  1824. *
  1825. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1826. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1827. * @param number to convert to percentage
  1828. * @param min min range
  1829. * @param max max range
  1830. * @returns the percentage
  1831. */
  1832. static RangeToPercent(number: number, min: number, max: number): number;
  1833. /**
  1834. * This function returns number that corresponds to the percentage in a given range.
  1835. *
  1836. * PercentToRange(0.34,0,100) will return 34.
  1837. * @param percent to convert to number
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the number
  1841. */
  1842. static PercentToRange(percent: number, min: number, max: number): number;
  1843. /**
  1844. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1845. * @param angle The angle to normalize in radian.
  1846. * @return The converted angle.
  1847. */
  1848. static NormalizeRadians(angle: number): number;
  1849. }
  1850. }
  1851. declare module "babylonjs/Maths/math.constants" {
  1852. /**
  1853. * Constant used to convert a value to gamma space
  1854. * @ignorenaming
  1855. */
  1856. export const ToGammaSpace: number;
  1857. /**
  1858. * Constant used to convert a value to linear space
  1859. * @ignorenaming
  1860. */
  1861. export const ToLinearSpace = 2.2;
  1862. /**
  1863. * Constant used to define the minimal number value in Babylon.js
  1864. * @ignorenaming
  1865. */
  1866. let Epsilon: number;
  1867. export { Epsilon };
  1868. }
  1869. declare module "babylonjs/Maths/math.viewport" {
  1870. /**
  1871. * Class used to represent a viewport on screen
  1872. */
  1873. export class Viewport {
  1874. /** viewport left coordinate */
  1875. x: number;
  1876. /** viewport top coordinate */
  1877. y: number;
  1878. /**viewport width */
  1879. width: number;
  1880. /** viewport height */
  1881. height: number;
  1882. /**
  1883. * Creates a Viewport object located at (x, y) and sized (width, height)
  1884. * @param x defines viewport left coordinate
  1885. * @param y defines viewport top coordinate
  1886. * @param width defines the viewport width
  1887. * @param height defines the viewport height
  1888. */
  1889. constructor(
  1890. /** viewport left coordinate */
  1891. x: number,
  1892. /** viewport top coordinate */
  1893. y: number,
  1894. /**viewport width */
  1895. width: number,
  1896. /** viewport height */
  1897. height: number);
  1898. /**
  1899. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @returns a new Viewport
  1903. */
  1904. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1905. /**
  1906. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1907. * @param renderWidth defines the rendering width
  1908. * @param renderHeight defines the rendering height
  1909. * @param ref defines the target viewport
  1910. * @returns the current viewport
  1911. */
  1912. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1913. /**
  1914. * Returns a new Viewport copied from the current one
  1915. * @returns a new Viewport
  1916. */
  1917. clone(): Viewport;
  1918. }
  1919. }
  1920. declare module "babylonjs/Misc/arrayTools" {
  1921. /**
  1922. * Class containing a set of static utilities functions for arrays.
  1923. */
  1924. export class ArrayTools {
  1925. /**
  1926. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1927. * @param size the number of element to construct and put in the array
  1928. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1929. * @returns a new array filled with new objects
  1930. */
  1931. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1932. }
  1933. }
  1934. declare module "babylonjs/Maths/math.vector" {
  1935. import { Viewport } from "babylonjs/Maths/math.viewport";
  1936. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1937. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1938. /**
  1939. * Class representing a vector containing 2 coordinates
  1940. */
  1941. export class Vector2 {
  1942. /** defines the first coordinate */
  1943. x: number;
  1944. /** defines the second coordinate */
  1945. y: number;
  1946. /**
  1947. * Creates a new Vector2 from the given x and y coordinates
  1948. * @param x defines the first coordinate
  1949. * @param y defines the second coordinate
  1950. */
  1951. constructor(
  1952. /** defines the first coordinate */
  1953. x?: number,
  1954. /** defines the second coordinate */
  1955. y?: number);
  1956. /**
  1957. * Gets a string with the Vector2 coordinates
  1958. * @returns a string with the Vector2 coordinates
  1959. */
  1960. toString(): string;
  1961. /**
  1962. * Gets class name
  1963. * @returns the string "Vector2"
  1964. */
  1965. getClassName(): string;
  1966. /**
  1967. * Gets current vector hash code
  1968. * @returns the Vector2 hash code as a number
  1969. */
  1970. getHashCode(): number;
  1971. /**
  1972. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1973. * @param array defines the source array
  1974. * @param index defines the offset in source array
  1975. * @returns the current Vector2
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector2;
  1978. /**
  1979. * Copy the current vector to an array
  1980. * @returns a new array with 2 elements: the Vector2 coordinates.
  1981. */
  1982. asArray(): number[];
  1983. /**
  1984. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1985. * @param source defines the source Vector2
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. copyFromFloats(x: number, y: number): Vector2;
  1996. /**
  1997. * Sets the Vector2 coordinates with the given floats
  1998. * @param x defines the first coordinate
  1999. * @param y defines the second coordinate
  2000. * @returns the current updated Vector2
  2001. */
  2002. set(x: number, y: number): Vector2;
  2003. /**
  2004. * Add another vector with the current one
  2005. * @param otherVector defines the other vector
  2006. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2007. */
  2008. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2009. /**
  2010. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2011. * @param otherVector defines the other vector
  2012. * @param result defines the target vector
  2013. * @returns the unmodified current Vector2
  2014. */
  2015. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2016. /**
  2017. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. addVector3(otherVector: Vector3): Vector2;
  2028. /**
  2029. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2030. * @param otherVector defines the other vector
  2031. * @returns a new Vector2
  2032. */
  2033. subtract(otherVector: Vector2): Vector2;
  2034. /**
  2035. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2036. * @param otherVector defines the other vector
  2037. * @param result defines the target vector
  2038. * @returns the unmodified current Vector2
  2039. */
  2040. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2041. /**
  2042. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @returns the current updated Vector2
  2045. */
  2046. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2047. /**
  2048. * Multiplies in place the current Vector2 coordinates by the given ones
  2049. * @param otherVector defines the other vector
  2050. * @returns the current updated Vector2
  2051. */
  2052. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2053. /**
  2054. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns a new Vector2
  2057. */
  2058. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2061. * @param otherVector defines the other vector
  2062. * @param result defines the target vector
  2063. * @returns the unmodified current Vector2
  2064. */
  2065. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2066. /**
  2067. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns a new Vector2
  2071. */
  2072. multiplyByFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2075. * @param otherVector defines the other vector
  2076. * @returns a new Vector2
  2077. */
  2078. divide(otherVector: Vector2): Vector2;
  2079. /**
  2080. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2081. * @param otherVector defines the other vector
  2082. * @param result defines the target vector
  2083. * @returns the unmodified current Vector2
  2084. */
  2085. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2086. /**
  2087. * Divides the current Vector2 coordinates by the given ones
  2088. * @param otherVector defines the other vector
  2089. * @returns the current updated Vector2
  2090. */
  2091. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2092. /**
  2093. * Gets a new Vector2 with current Vector2 negated coordinates
  2094. * @returns a new Vector2
  2095. */
  2096. negate(): Vector2;
  2097. /**
  2098. * Negate this vector in place
  2099. * @returns this
  2100. */
  2101. negateInPlace(): Vector2;
  2102. /**
  2103. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2104. * @param result defines the Vector3 object where to store the result
  2105. * @returns the current Vector2
  2106. */
  2107. negateToRef(result: Vector2): Vector2;
  2108. /**
  2109. * Multiply the Vector2 coordinates by scale
  2110. * @param scale defines the scaling factor
  2111. * @returns the current updated Vector2
  2112. */
  2113. scaleInPlace(scale: number): Vector2;
  2114. /**
  2115. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2116. * @param scale defines the scaling factor
  2117. * @returns a new Vector2
  2118. */
  2119. scale(scale: number): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2129. * @param scale defines the scale factor
  2130. * @param result defines the Vector2 object where to store the result
  2131. * @returns the unmodified current Vector2
  2132. */
  2133. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2134. /**
  2135. * Gets a boolean if two vectors are equals
  2136. * @param otherVector defines the other vector
  2137. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2138. */
  2139. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2140. /**
  2141. * Gets a boolean if two vectors are equals (using an epsilon value)
  2142. * @param otherVector defines the other vector
  2143. * @param epsilon defines the minimal distance to consider equality
  2144. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2145. */
  2146. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2147. /**
  2148. * Gets a new Vector2 from current Vector2 floored values
  2149. * @returns a new Vector2
  2150. */
  2151. floor(): Vector2;
  2152. /**
  2153. * Gets a new Vector2 from current Vector2 floored values
  2154. * @returns a new Vector2
  2155. */
  2156. fract(): Vector2;
  2157. /**
  2158. * Gets the length of the vector
  2159. * @returns the vector length (float)
  2160. */
  2161. length(): number;
  2162. /**
  2163. * Gets the vector squared length
  2164. * @returns the vector squared length (float)
  2165. */
  2166. lengthSquared(): number;
  2167. /**
  2168. * Normalize the vector
  2169. * @returns the current updated Vector2
  2170. */
  2171. normalize(): Vector2;
  2172. /**
  2173. * Gets a new Vector2 copied from the Vector2
  2174. * @returns a new Vector2
  2175. */
  2176. clone(): Vector2;
  2177. /**
  2178. * Gets a new Vector2(0, 0)
  2179. * @returns a new Vector2
  2180. */
  2181. static Zero(): Vector2;
  2182. /**
  2183. * Gets a new Vector2(1, 1)
  2184. * @returns a new Vector2
  2185. */
  2186. static One(): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @returns a new Vector2
  2192. */
  2193. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2194. /**
  2195. * Sets "result" from the given index element of the given array
  2196. * @param array defines the data source
  2197. * @param offset defines the offset in the data source
  2198. * @param result defines the target vector
  2199. */
  2200. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2201. /**
  2202. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2203. * @param value1 defines 1st point of control
  2204. * @param value2 defines 2nd point of control
  2205. * @param value3 defines 3rd point of control
  2206. * @param value4 defines 4th point of control
  2207. * @param amount defines the interpolation factor
  2208. * @returns a new Vector2
  2209. */
  2210. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2211. /**
  2212. * 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".
  2213. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2214. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2215. * @param value defines the value to clamp
  2216. * @param min defines the lower limit
  2217. * @param max defines the upper limit
  2218. * @returns a new Vector2
  2219. */
  2220. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2223. * @param value1 defines the 1st control point
  2224. * @param tangent1 defines the outgoing tangent
  2225. * @param value2 defines the 2nd control point
  2226. * @param tangent2 defines the incoming tangent
  2227. * @param amount defines the interpolation factor
  2228. * @returns a new Vector2
  2229. */
  2230. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2231. /**
  2232. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2233. * @param start defines the start vector
  2234. * @param end defines the end vector
  2235. * @param amount defines the interpolation factor
  2236. * @returns a new Vector2
  2237. */
  2238. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2239. /**
  2240. * Gets the dot product of the vector "left" and the vector "right"
  2241. * @param left defines first vector
  2242. * @param right defines second vector
  2243. * @returns the dot product (float)
  2244. */
  2245. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2246. /**
  2247. * Returns a new Vector2 equal to the normalized given vector
  2248. * @param vector defines the vector to normalize
  2249. * @returns a new Vector2
  2250. */
  2251. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2261. * @param left defines 1st vector
  2262. * @param right defines 2nd vector
  2263. * @returns a new Vector2
  2264. */
  2265. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2266. /**
  2267. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @returns a new Vector2
  2271. */
  2272. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2273. /**
  2274. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2275. * @param vector defines the vector to transform
  2276. * @param transformation defines the matrix to apply
  2277. * @param result defines the target vector
  2278. */
  2279. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2280. /**
  2281. * Determines if a given vector is included in a triangle
  2282. * @param p defines the vector to test
  2283. * @param p0 defines 1st triangle point
  2284. * @param p1 defines 2nd triangle point
  2285. * @param p2 defines 3rd triangle point
  2286. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2287. */
  2288. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2289. /**
  2290. * Gets the distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the distance between vectors
  2294. */
  2295. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Returns the squared distance between the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns the squared distance between vectors
  2301. */
  2302. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2303. /**
  2304. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2305. * @param value1 defines first vector
  2306. * @param value2 defines second vector
  2307. * @returns a new Vector2
  2308. */
  2309. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2310. /**
  2311. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2312. * @param p defines the middle point
  2313. * @param segA defines one point of the segment
  2314. * @param segB defines the other point of the segment
  2315. * @returns the shortest distance
  2316. */
  2317. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2318. }
  2319. /**
  2320. * Class used to store (x,y,z) vector representation
  2321. * A Vector3 is the main object used in 3D geometry
  2322. * It can represent etiher the coordinates of a point the space, either a direction
  2323. * Reminder: js uses a left handed forward facing system
  2324. */
  2325. export class Vector3 {
  2326. /**
  2327. * Defines the first coordinates (on X axis)
  2328. */
  2329. x: number;
  2330. /**
  2331. * Defines the second coordinates (on Y axis)
  2332. */
  2333. y: number;
  2334. /**
  2335. * Defines the third coordinates (on Z axis)
  2336. */
  2337. z: number;
  2338. private static _UpReadOnly;
  2339. private static _ZeroReadOnly;
  2340. /**
  2341. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2342. * @param x defines the first coordinates (on X axis)
  2343. * @param y defines the second coordinates (on Y axis)
  2344. * @param z defines the third coordinates (on Z axis)
  2345. */
  2346. constructor(
  2347. /**
  2348. * Defines the first coordinates (on X axis)
  2349. */
  2350. x?: number,
  2351. /**
  2352. * Defines the second coordinates (on Y axis)
  2353. */
  2354. y?: number,
  2355. /**
  2356. * Defines the third coordinates (on Z axis)
  2357. */
  2358. z?: number);
  2359. /**
  2360. * Creates a string representation of the Vector3
  2361. * @returns a string with the Vector3 coordinates.
  2362. */
  2363. toString(): string;
  2364. /**
  2365. * Gets the class name
  2366. * @returns the string "Vector3"
  2367. */
  2368. getClassName(): string;
  2369. /**
  2370. * Creates the Vector3 hash code
  2371. * @returns a number which tends to be unique between Vector3 instances
  2372. */
  2373. getHashCode(): number;
  2374. /**
  2375. * Creates an array containing three elements : the coordinates of the Vector3
  2376. * @returns a new array of numbers
  2377. */
  2378. asArray(): number[];
  2379. /**
  2380. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2381. * @param array defines the destination array
  2382. * @param index defines the offset in the destination array
  2383. * @returns the current Vector3
  2384. */
  2385. toArray(array: FloatArray, index?: number): Vector3;
  2386. /**
  2387. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2388. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2389. */
  2390. toQuaternion(): Quaternion;
  2391. /**
  2392. * Adds the given vector to the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the current updated Vector3
  2395. */
  2396. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Adds the given coordinates to the current Vector3
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the current updated Vector3
  2403. */
  2404. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2407. * @param otherVector defines the second operand
  2408. * @returns the resulting Vector3
  2409. */
  2410. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2411. /**
  2412. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2413. * @param otherVector defines the second operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2418. /**
  2419. * Subtract the given vector from the current Vector3
  2420. * @param otherVector defines the second operand
  2421. * @returns the current updated Vector3
  2422. */
  2423. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2424. /**
  2425. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2426. * @param otherVector defines the second operand
  2427. * @returns the resulting Vector3
  2428. */
  2429. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2430. /**
  2431. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2432. * @param otherVector defines the second operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2439. * @param x defines the x coordinate of the operand
  2440. * @param y defines the y coordinate of the operand
  2441. * @param z defines the z coordinate of the operand
  2442. * @returns the resulting Vector3
  2443. */
  2444. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2445. /**
  2446. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2447. * @param x defines the x coordinate of the operand
  2448. * @param y defines the y coordinate of the operand
  2449. * @param z defines the z coordinate of the operand
  2450. * @param result defines the Vector3 object where to store the result
  2451. * @returns the current Vector3
  2452. */
  2453. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2454. /**
  2455. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2456. * @returns a new Vector3
  2457. */
  2458. negate(): Vector3;
  2459. /**
  2460. * Negate this vector in place
  2461. * @returns this
  2462. */
  2463. negateInPlace(): Vector3;
  2464. /**
  2465. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the current Vector3
  2468. */
  2469. negateToRef(result: Vector3): Vector3;
  2470. /**
  2471. * Multiplies the Vector3 coordinates by the float "scale"
  2472. * @param scale defines the multiplier factor
  2473. * @returns the current updated Vector3
  2474. */
  2475. scaleInPlace(scale: number): Vector3;
  2476. /**
  2477. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2478. * @param scale defines the multiplier factor
  2479. * @returns a new Vector3
  2480. */
  2481. scale(scale: number): Vector3;
  2482. /**
  2483. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2484. * @param scale defines the multiplier factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the current Vector3
  2487. */
  2488. scaleToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2491. * @param scale defines the scale factor
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the unmodified current Vector3
  2494. */
  2495. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2496. /**
  2497. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2498. * @param otherVector defines the second operand
  2499. * @returns true if both vectors are equals
  2500. */
  2501. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2504. * @param otherVector defines the second operand
  2505. * @param epsilon defines the minimal distance to define values as equals
  2506. * @returns true if both vectors are distant less than epsilon
  2507. */
  2508. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2509. /**
  2510. * Returns true if the current Vector3 coordinates equals the given floats
  2511. * @param x defines the x coordinate of the operand
  2512. * @param y defines the y coordinate of the operand
  2513. * @param z defines the z coordinate of the operand
  2514. * @returns true if both vectors are equals
  2515. */
  2516. equalsToFloats(x: number, y: number, z: number): boolean;
  2517. /**
  2518. * Multiplies the current Vector3 coordinates by the given ones
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2523. /**
  2524. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2525. * @param otherVector defines the second operand
  2526. * @returns the new Vector3
  2527. */
  2528. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2531. * @param otherVector defines the second operand
  2532. * @param result defines the Vector3 object where to store the result
  2533. * @returns the current Vector3
  2534. */
  2535. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2536. /**
  2537. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the new Vector3
  2542. */
  2543. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2546. * @param otherVector defines the second operand
  2547. * @returns the new Vector3
  2548. */
  2549. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2552. * @param otherVector defines the second operand
  2553. * @param result defines the Vector3 object where to store the result
  2554. * @returns the current Vector3
  2555. */
  2556. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2557. /**
  2558. * Divides the current Vector3 coordinates by the given ones.
  2559. * @param otherVector defines the second operand
  2560. * @returns the current updated Vector3
  2561. */
  2562. divideInPlace(otherVector: Vector3): Vector3;
  2563. /**
  2564. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2565. * @param other defines the second operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2569. /**
  2570. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2571. * @param other defines the second operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2575. /**
  2576. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2577. * @param x defines the x coordinate of the operand
  2578. * @param y defines the y coordinate of the operand
  2579. * @param z defines the z coordinate of the operand
  2580. * @returns the current updated Vector3
  2581. */
  2582. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2583. /**
  2584. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2585. * @param x defines the x coordinate of the operand
  2586. * @param y defines the y coordinate of the operand
  2587. * @param z defines the z coordinate of the operand
  2588. * @returns the current updated Vector3
  2589. */
  2590. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2591. /**
  2592. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2593. * Check if is non uniform within a certain amount of decimal places to account for this
  2594. * @param epsilon the amount the values can differ
  2595. * @returns if the the vector is non uniform to a certain number of decimal places
  2596. */
  2597. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2598. /**
  2599. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2600. */
  2601. get isNonUniform(): boolean;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. floor(): Vector3;
  2607. /**
  2608. * Gets a new Vector3 from current Vector3 floored values
  2609. * @returns a new Vector3
  2610. */
  2611. fract(): Vector3;
  2612. /**
  2613. * Gets the length of the Vector3
  2614. * @returns the length of the Vector3
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Gets the squared length of the Vector3
  2619. * @returns squared length of the Vector3
  2620. */
  2621. lengthSquared(): number;
  2622. /**
  2623. * Normalize the current Vector3.
  2624. * Please note that this is an in place operation.
  2625. * @returns the current updated Vector3
  2626. */
  2627. normalize(): Vector3;
  2628. /**
  2629. * Reorders the x y z properties of the vector in place
  2630. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2631. * @returns the current updated vector
  2632. */
  2633. reorderInPlace(order: string): this;
  2634. /**
  2635. * Rotates the vector around 0,0,0 by a quaternion
  2636. * @param quaternion the rotation quaternion
  2637. * @param result vector to store the result
  2638. * @returns the resulting vector
  2639. */
  2640. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2641. /**
  2642. * Rotates a vector around a given point
  2643. * @param quaternion the rotation quaternion
  2644. * @param point the point to rotate around
  2645. * @param result vector to store the result
  2646. * @returns the resulting vector
  2647. */
  2648. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2649. /**
  2650. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2651. * The cross product is then orthogonal to both current and "other"
  2652. * @param other defines the right operand
  2653. * @returns the cross product
  2654. */
  2655. cross(other: Vector3): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 with the given input length.
  2658. * Please note that this is an in place operation.
  2659. * @param len the length of the vector
  2660. * @returns the current updated Vector3
  2661. */
  2662. normalizeFromLength(len: number): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to a new vector
  2665. * @returns the new Vector3
  2666. */
  2667. normalizeToNew(): Vector3;
  2668. /**
  2669. * Normalize the current Vector3 to the reference
  2670. * @param reference define the Vector3 to update
  2671. * @returns the updated Vector3
  2672. */
  2673. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Creates a new Vector3 copied from the current Vector3
  2676. * @returns the new Vector3
  2677. */
  2678. clone(): Vector3;
  2679. /**
  2680. * Copies the given vector coordinates to the current Vector3 ones
  2681. * @param source defines the source Vector3
  2682. * @returns the current updated Vector3
  2683. */
  2684. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Copies the given floats to the current Vector3 coordinates
  2687. * @param x defines the x coordinate of the operand
  2688. * @param y defines the y coordinate of the operand
  2689. * @param z defines the z coordinate of the operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. copyFromFloats(x: number, y: number, z: number): Vector3;
  2693. /**
  2694. * Copies the given floats to the current Vector3 coordinates
  2695. * @param x defines the x coordinate of the operand
  2696. * @param y defines the y coordinate of the operand
  2697. * @param z defines the z coordinate of the operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. set(x: number, y: number, z: number): Vector3;
  2701. /**
  2702. * Copies the given float to the current Vector3 coordinates
  2703. * @param v defines the x, y and z coordinates of the operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. setAll(v: number): Vector3;
  2707. /**
  2708. * Get the clip factor between two vectors
  2709. * @param vector0 defines the first operand
  2710. * @param vector1 defines the second operand
  2711. * @param axis defines the axis to use
  2712. * @param size defines the size along the axis
  2713. * @returns the clip factor
  2714. */
  2715. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2716. /**
  2717. * Get angle between two vectors
  2718. * @param vector0 angle between vector0 and vector1
  2719. * @param vector1 angle between vector0 and vector1
  2720. * @param normal direction of the normal
  2721. * @return the angle between vector0 and vector1
  2722. */
  2723. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. */
  2730. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2731. /**
  2732. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2733. * @param array defines the source array
  2734. * @param offset defines the offset in the source array
  2735. * @returns the new Vector3
  2736. * @deprecated Please use FromArray instead.
  2737. */
  2738. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. */
  2745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2746. /**
  2747. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2748. * @param array defines the source array
  2749. * @param offset defines the offset in the source array
  2750. * @param result defines the Vector3 where to store the result
  2751. * @deprecated Please use FromArrayToRef instead.
  2752. */
  2753. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2754. /**
  2755. * Sets the given vector "result" with the given floats.
  2756. * @param x defines the x coordinate of the source
  2757. * @param y defines the y coordinate of the source
  2758. * @param z defines the z coordinate of the source
  2759. * @param result defines the Vector3 where to store the result
  2760. */
  2761. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2764. * @returns a new empty Vector3
  2765. */
  2766. static Zero(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2769. * @returns a new unit Vector3
  2770. */
  2771. static One(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2774. * @returns a new up Vector3
  2775. */
  2776. static Up(): Vector3;
  2777. /**
  2778. * Gets a up Vector3 that must not be updated
  2779. */
  2780. static get UpReadOnly(): DeepImmutable<Vector3>;
  2781. /**
  2782. * Gets a zero Vector3 that must not be updated
  2783. */
  2784. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2787. * @returns a new down Vector3
  2788. */
  2789. static Down(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Forward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2797. * @returns a new forward Vector3
  2798. */
  2799. static Backward(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2802. * @returns a new right Vector3
  2803. */
  2804. static Right(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2807. * @returns a new left Vector3
  2808. */
  2809. static Left(): Vector3;
  2810. /**
  2811. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2812. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2813. * @param vector defines the Vector3 to transform
  2814. * @param transformation defines the transformation matrix
  2815. * @returns the transformed Vector3
  2816. */
  2817. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2818. /**
  2819. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2820. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2828. * This method computes tranformed coordinates only, not transformed direction vectors
  2829. * @param x define the x coordinate of the source vector
  2830. * @param y define the y coordinate of the source vector
  2831. * @param z define the z coordinate of the source vector
  2832. * @param transformation defines the transformation matrix
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2838. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2839. * @param vector defines the Vector3 to transform
  2840. * @param transformation defines the transformation matrix
  2841. * @returns the new Vector3
  2842. */
  2843. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2844. /**
  2845. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2846. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2847. * @param vector defines the Vector3 to transform
  2848. * @param transformation defines the transformation matrix
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2852. /**
  2853. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2854. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2855. * @param x define the x coordinate of the source vector
  2856. * @param y define the y coordinate of the source vector
  2857. * @param z define the z coordinate of the source vector
  2858. * @param transformation defines the transformation matrix
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2862. /**
  2863. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2864. * @param value1 defines the first control point
  2865. * @param value2 defines the second control point
  2866. * @param value3 defines the third control point
  2867. * @param value4 defines the fourth control point
  2868. * @param amount defines the amount on the spline to use
  2869. * @returns the new Vector3
  2870. */
  2871. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2872. /**
  2873. * 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"
  2874. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2875. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2876. * @param value defines the current value
  2877. * @param min defines the lower range value
  2878. * @param max defines the upper range value
  2879. * @returns the new Vector3
  2880. */
  2881. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * 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"
  2884. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2885. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2886. * @param value defines the current value
  2887. * @param min defines the lower range value
  2888. * @param max defines the upper range value
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2892. /**
  2893. * Checks if a given vector is inside a specific range
  2894. * @param v defines the vector to test
  2895. * @param min defines the minimum range
  2896. * @param max defines the maximum range
  2897. */
  2898. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2899. /**
  2900. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2901. * @param value1 defines the first control point
  2902. * @param tangent1 defines the first tangent vector
  2903. * @param value2 defines the second control point
  2904. * @param tangent2 defines the second tangent vector
  2905. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2906. * @returns the new Vector3
  2907. */
  2908. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2909. /**
  2910. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2911. * @param start defines the start value
  2912. * @param end defines the end value
  2913. * @param amount max defines amount between both (between 0 and 1)
  2914. * @returns the new Vector3
  2915. */
  2916. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2917. /**
  2918. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2919. * @param start defines the start value
  2920. * @param end defines the end value
  2921. * @param amount max defines amount between both (between 0 and 1)
  2922. * @param result defines the Vector3 where to store the result
  2923. */
  2924. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2925. /**
  2926. * Returns the dot product (float) between the vectors "left" and "right"
  2927. * @param left defines the left operand
  2928. * @param right defines the right operand
  2929. * @returns the dot product
  2930. */
  2931. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2932. /**
  2933. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2934. * The cross product is then orthogonal to both "left" and "right"
  2935. * @param left defines the left operand
  2936. * @param right defines the right operand
  2937. * @returns the cross product
  2938. */
  2939. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2940. /**
  2941. * Sets the given vector "result" with the cross product of "left" and "right"
  2942. * The cross product is then orthogonal to both "left" and "right"
  2943. * @param left defines the left operand
  2944. * @param right defines the right operand
  2945. * @param result defines the Vector3 where to store the result
  2946. */
  2947. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2948. /**
  2949. * Returns a new Vector3 as the normalization of the given vector
  2950. * @param vector defines the Vector3 to normalize
  2951. * @returns the new Vector3
  2952. */
  2953. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2954. /**
  2955. * Sets the given vector "result" with the normalization of the given first vector
  2956. * @param vector defines the Vector3 to normalize
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2960. /**
  2961. * Project a Vector3 onto screen space
  2962. * @param vector defines the Vector3 to project
  2963. * @param world defines the world matrix to use
  2964. * @param transform defines the transform (view x projection) matrix to use
  2965. * @param viewport defines the screen viewport to use
  2966. * @returns the new Vector3
  2967. */
  2968. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2969. /** @hidden */
  2970. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2971. /**
  2972. * Unproject from screen space to object space
  2973. * @param source defines the screen space Vector3 to use
  2974. * @param viewportWidth defines the current width of the viewport
  2975. * @param viewportHeight defines the current height of the viewport
  2976. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2977. * @param transform defines the transform (view x projection) matrix to use
  2978. * @returns the new Vector3
  2979. */
  2980. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Unproject from screen space to object space
  2983. * @param source defines the screen space Vector3 to use
  2984. * @param viewportWidth defines the current width of the viewport
  2985. * @param viewportHeight defines the current height of the viewport
  2986. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2987. * @param view defines the view matrix to use
  2988. * @param projection defines the projection matrix to use
  2989. * @returns the new Vector3
  2990. */
  2991. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2992. /**
  2993. * Unproject from screen space to object space
  2994. * @param source defines the screen space Vector3 to use
  2995. * @param viewportWidth defines the current width of the viewport
  2996. * @param viewportHeight defines the current height of the viewport
  2997. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2998. * @param view defines the view matrix to use
  2999. * @param projection defines the projection matrix to use
  3000. * @param result defines the Vector3 where to store the result
  3001. */
  3002. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3003. /**
  3004. * Unproject from screen space to object space
  3005. * @param sourceX defines the screen space x coordinate to use
  3006. * @param sourceY defines the screen space y coordinate to use
  3007. * @param sourceZ defines the screen space z coordinate to use
  3008. * @param viewportWidth defines the current width of the viewport
  3009. * @param viewportHeight defines the current height of the viewport
  3010. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3011. * @param view defines the view matrix to use
  3012. * @param projection defines the projection matrix to use
  3013. * @param result defines the Vector3 where to store the result
  3014. */
  3015. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3016. /**
  3017. * Gets the minimal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Gets the maximal coordinate values between two Vector3
  3025. * @param left defines the first operand
  3026. * @param right defines the second operand
  3027. * @returns the new Vector3
  3028. */
  3029. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3030. /**
  3031. * Returns the distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the distance
  3035. */
  3036. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns the squared distance between the vectors "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the squared distance
  3042. */
  3043. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3044. /**
  3045. * Returns a new Vector3 located at the center between "value1" and "value2"
  3046. * @param value1 defines the first operand
  3047. * @param value2 defines the second operand
  3048. * @returns the new Vector3
  3049. */
  3050. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3053. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3054. * to something in order to rotate it from its local system to the given target system
  3055. * Note: axis1, axis2 and axis3 are normalized during this operation
  3056. * @param axis1 defines the first axis
  3057. * @param axis2 defines the second axis
  3058. * @param axis3 defines the third axis
  3059. * @returns a new Vector3
  3060. */
  3061. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3062. /**
  3063. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3064. * @param axis1 defines the first axis
  3065. * @param axis2 defines the second axis
  3066. * @param axis3 defines the third axis
  3067. * @param ref defines the Vector3 where to store the result
  3068. */
  3069. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3070. }
  3071. /**
  3072. * Vector4 class created for EulerAngle class conversion to Quaternion
  3073. */
  3074. export class Vector4 {
  3075. /** x value of the vector */
  3076. x: number;
  3077. /** y value of the vector */
  3078. y: number;
  3079. /** z value of the vector */
  3080. z: number;
  3081. /** w value of the vector */
  3082. w: number;
  3083. /**
  3084. * Creates a Vector4 object from the given floats.
  3085. * @param x x value of the vector
  3086. * @param y y value of the vector
  3087. * @param z z value of the vector
  3088. * @param w w value of the vector
  3089. */
  3090. constructor(
  3091. /** x value of the vector */
  3092. x: number,
  3093. /** y value of the vector */
  3094. y: number,
  3095. /** z value of the vector */
  3096. z: number,
  3097. /** w value of the vector */
  3098. w: number);
  3099. /**
  3100. * Returns the string with the Vector4 coordinates.
  3101. * @returns a string containing all the vector values
  3102. */
  3103. toString(): string;
  3104. /**
  3105. * Returns the string "Vector4".
  3106. * @returns "Vector4"
  3107. */
  3108. getClassName(): string;
  3109. /**
  3110. * Returns the Vector4 hash code.
  3111. * @returns a unique hash code
  3112. */
  3113. getHashCode(): number;
  3114. /**
  3115. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3116. * @returns the resulting array
  3117. */
  3118. asArray(): number[];
  3119. /**
  3120. * Populates the given array from the given index with the Vector4 coordinates.
  3121. * @param array array to populate
  3122. * @param index index of the array to start at (default: 0)
  3123. * @returns the Vector4.
  3124. */
  3125. toArray(array: FloatArray, index?: number): Vector4;
  3126. /**
  3127. * Adds the given vector to the current Vector4.
  3128. * @param otherVector the vector to add
  3129. * @returns the updated Vector4.
  3130. */
  3131. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3132. /**
  3133. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3134. * @param otherVector the vector to add
  3135. * @returns the resulting vector
  3136. */
  3137. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3138. /**
  3139. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3140. * @param otherVector the vector to add
  3141. * @param result the vector to store the result
  3142. * @returns the current Vector4.
  3143. */
  3144. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3145. /**
  3146. * Subtract in place the given vector from the current Vector4.
  3147. * @param otherVector the vector to subtract
  3148. * @returns the updated Vector4.
  3149. */
  3150. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3151. /**
  3152. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3153. * @param otherVector the vector to add
  3154. * @returns the new vector with the result
  3155. */
  3156. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3157. /**
  3158. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3159. * @param otherVector the vector to subtract
  3160. * @param result the vector to store the result
  3161. * @returns the current Vector4.
  3162. */
  3163. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3166. */
  3167. /**
  3168. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3169. * @param x value to subtract
  3170. * @param y value to subtract
  3171. * @param z value to subtract
  3172. * @param w value to subtract
  3173. * @returns new vector containing the result
  3174. */
  3175. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3176. /**
  3177. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3178. * @param x value to subtract
  3179. * @param y value to subtract
  3180. * @param z value to subtract
  3181. * @param w value to subtract
  3182. * @param result the vector to store the result in
  3183. * @returns the current Vector4.
  3184. */
  3185. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3188. * @returns a new vector with the negated values
  3189. */
  3190. negate(): Vector4;
  3191. /**
  3192. * Negate this vector in place
  3193. * @returns this
  3194. */
  3195. negateInPlace(): Vector4;
  3196. /**
  3197. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3198. * @param result defines the Vector3 object where to store the result
  3199. * @returns the current Vector4
  3200. */
  3201. negateToRef(result: Vector4): Vector4;
  3202. /**
  3203. * Multiplies the current Vector4 coordinates by scale (float).
  3204. * @param scale the number to scale with
  3205. * @returns the updated Vector4.
  3206. */
  3207. scaleInPlace(scale: number): Vector4;
  3208. /**
  3209. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3210. * @param scale the number to scale with
  3211. * @returns a new vector with the result
  3212. */
  3213. scale(scale: number): Vector4;
  3214. /**
  3215. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3216. * @param scale the number to scale with
  3217. * @param result a vector to store the result in
  3218. * @returns the current Vector4.
  3219. */
  3220. scaleToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3223. * @param scale defines the scale factor
  3224. * @param result defines the Vector4 object where to store the result
  3225. * @returns the unmodified current Vector4
  3226. */
  3227. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3228. /**
  3229. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3230. * @param otherVector the vector to compare against
  3231. * @returns true if they are equal
  3232. */
  3233. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3234. /**
  3235. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3236. * @param otherVector vector to compare against
  3237. * @param epsilon (Default: very small number)
  3238. * @returns true if they are equal
  3239. */
  3240. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3241. /**
  3242. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3243. * @param x x value to compare against
  3244. * @param y y value to compare against
  3245. * @param z z value to compare against
  3246. * @param w w value to compare against
  3247. * @returns true if equal
  3248. */
  3249. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3250. /**
  3251. * Multiplies in place the current Vector4 by the given one.
  3252. * @param otherVector vector to multiple with
  3253. * @returns the updated Vector4.
  3254. */
  3255. multiplyInPlace(otherVector: Vector4): Vector4;
  3256. /**
  3257. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3258. * @param otherVector vector to multiple with
  3259. * @returns resulting new vector
  3260. */
  3261. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3264. * @param otherVector vector to multiple with
  3265. * @param result vector to store the result
  3266. * @returns the current Vector4.
  3267. */
  3268. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3269. /**
  3270. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3271. * @param x x value multiply with
  3272. * @param y y value multiply with
  3273. * @param z z value multiply with
  3274. * @param w w value multiply with
  3275. * @returns resulting new vector
  3276. */
  3277. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3278. /**
  3279. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3280. * @param otherVector vector to devide with
  3281. * @returns resulting new vector
  3282. */
  3283. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3284. /**
  3285. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3286. * @param otherVector vector to devide with
  3287. * @param result vector to store the result
  3288. * @returns the current Vector4.
  3289. */
  3290. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3291. /**
  3292. * Divides the current Vector3 coordinates by the given ones.
  3293. * @param otherVector vector to devide with
  3294. * @returns the updated Vector3.
  3295. */
  3296. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3297. /**
  3298. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3299. * @param other defines the second operand
  3300. * @returns the current updated Vector4
  3301. */
  3302. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3303. /**
  3304. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3305. * @param other defines the second operand
  3306. * @returns the current updated Vector4
  3307. */
  3308. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3309. /**
  3310. * Gets a new Vector4 from current Vector4 floored values
  3311. * @returns a new Vector4
  3312. */
  3313. floor(): Vector4;
  3314. /**
  3315. * Gets a new Vector4 from current Vector3 floored values
  3316. * @returns a new Vector4
  3317. */
  3318. fract(): Vector4;
  3319. /**
  3320. * Returns the Vector4 length (float).
  3321. * @returns the length
  3322. */
  3323. length(): number;
  3324. /**
  3325. * Returns the Vector4 squared length (float).
  3326. * @returns the length squared
  3327. */
  3328. lengthSquared(): number;
  3329. /**
  3330. * Normalizes in place the Vector4.
  3331. * @returns the updated Vector4.
  3332. */
  3333. normalize(): Vector4;
  3334. /**
  3335. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3336. * @returns this converted to a new vector3
  3337. */
  3338. toVector3(): Vector3;
  3339. /**
  3340. * Returns a new Vector4 copied from the current one.
  3341. * @returns the new cloned vector
  3342. */
  3343. clone(): Vector4;
  3344. /**
  3345. * Updates the current Vector4 with the given one coordinates.
  3346. * @param source the source vector to copy from
  3347. * @returns the updated Vector4.
  3348. */
  3349. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Updates the current Vector4 coordinates with the given floats.
  3352. * @param x float to copy from
  3353. * @param y float to copy from
  3354. * @param z float to copy from
  3355. * @param w float to copy from
  3356. * @returns the updated Vector4.
  3357. */
  3358. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Updates the current Vector4 coordinates with the given floats.
  3361. * @param x float to set from
  3362. * @param y float to set from
  3363. * @param z float to set from
  3364. * @param w float to set from
  3365. * @returns the updated Vector4.
  3366. */
  3367. set(x: number, y: number, z: number, w: number): Vector4;
  3368. /**
  3369. * Copies the given float to the current Vector3 coordinates
  3370. * @param v defines the x, y, z and w coordinates of the operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. setAll(v: number): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @returns the new vector
  3379. */
  3380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" from the starting index of the given Float32Array.
  3390. * @param array the array to pull values from
  3391. * @param offset the offset into the array to start at
  3392. * @param result the vector to store the result in
  3393. */
  3394. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3395. /**
  3396. * Updates the given vector "result" coordinates from the given floats.
  3397. * @param x float to set from
  3398. * @param y float to set from
  3399. * @param z float to set from
  3400. * @param w float to set from
  3401. * @param result the vector to the floats in
  3402. */
  3403. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3404. /**
  3405. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3406. * @returns the new vector
  3407. */
  3408. static Zero(): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3411. * @returns the new vector
  3412. */
  3413. static One(): Vector4;
  3414. /**
  3415. * Returns a new normalized Vector4 from the given one.
  3416. * @param vector the vector to normalize
  3417. * @returns the vector
  3418. */
  3419. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3420. /**
  3421. * Updates the given vector "result" from the normalization of the given one.
  3422. * @param vector the vector to normalize
  3423. * @param result the vector to store the result in
  3424. */
  3425. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3426. /**
  3427. * Returns a vector with the minimum values from the left and right vectors
  3428. * @param left left vector to minimize
  3429. * @param right right vector to minimize
  3430. * @returns a new vector with the minimum of the left and right vector values
  3431. */
  3432. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns a vector with the maximum values from the left and right vectors
  3435. * @param left left vector to maximize
  3436. * @param right right vector to maximize
  3437. * @returns a new vector with the maximum of the left and right vector values
  3438. */
  3439. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Returns the distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors
  3445. */
  3446. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the distance between
  3450. * @param value2 value to calulate the distance between
  3451. * @return the distance between the two vectors squared
  3452. */
  3453. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3454. /**
  3455. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3456. * @param value1 value to calulate the center between
  3457. * @param value2 value to calulate the center between
  3458. * @return the center between the two vectors
  3459. */
  3460. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param vector the vector to transform
  3465. * @param transformation the transformation matrix to apply
  3466. * @returns the new vector
  3467. */
  3468. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3469. /**
  3470. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3471. * This methods computes transformed normalized direction vectors only.
  3472. * @param vector the vector to transform
  3473. * @param transformation the transformation matrix to apply
  3474. * @param result the vector to store the result in
  3475. */
  3476. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3477. /**
  3478. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3479. * This methods computes transformed normalized direction vectors only.
  3480. * @param x value to transform
  3481. * @param y value to transform
  3482. * @param z value to transform
  3483. * @param w value to transform
  3484. * @param transformation the transformation matrix to apply
  3485. * @param result the vector to store the results in
  3486. */
  3487. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3488. /**
  3489. * Creates a new Vector4 from a Vector3
  3490. * @param source defines the source data
  3491. * @param w defines the 4th component (default is 0)
  3492. * @returns a new Vector4
  3493. */
  3494. static FromVector3(source: Vector3, w?: number): Vector4;
  3495. }
  3496. /**
  3497. * Class used to store quaternion data
  3498. * @see https://en.wikipedia.org/wiki/Quaternion
  3499. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3500. */
  3501. export class Quaternion {
  3502. /** defines the first component (0 by default) */
  3503. x: number;
  3504. /** defines the second component (0 by default) */
  3505. y: number;
  3506. /** defines the third component (0 by default) */
  3507. z: number;
  3508. /** defines the fourth component (1.0 by default) */
  3509. w: number;
  3510. /**
  3511. * Creates a new Quaternion from the given floats
  3512. * @param x defines the first component (0 by default)
  3513. * @param y defines the second component (0 by default)
  3514. * @param z defines the third component (0 by default)
  3515. * @param w defines the fourth component (1.0 by default)
  3516. */
  3517. constructor(
  3518. /** defines the first component (0 by default) */
  3519. x?: number,
  3520. /** defines the second component (0 by default) */
  3521. y?: number,
  3522. /** defines the third component (0 by default) */
  3523. z?: number,
  3524. /** defines the fourth component (1.0 by default) */
  3525. w?: number);
  3526. /**
  3527. * Gets a string representation for the current quaternion
  3528. * @returns a string with the Quaternion coordinates
  3529. */
  3530. toString(): string;
  3531. /**
  3532. * Gets the class name of the quaternion
  3533. * @returns the string "Quaternion"
  3534. */
  3535. getClassName(): string;
  3536. /**
  3537. * Gets a hash code for this quaternion
  3538. * @returns the quaternion hash code
  3539. */
  3540. getHashCode(): number;
  3541. /**
  3542. * Copy the quaternion to an array
  3543. * @returns a new array populated with 4 elements from the quaternion coordinates
  3544. */
  3545. asArray(): number[];
  3546. /**
  3547. * Check if two quaternions are equals
  3548. * @param otherQuaternion defines the second operand
  3549. * @return true if the current quaternion and the given one coordinates are strictly equals
  3550. */
  3551. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3552. /**
  3553. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3554. * @param otherQuaternion defines the other quaternion
  3555. * @param epsilon defines the minimal distance to consider equality
  3556. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3557. */
  3558. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3559. /**
  3560. * Clone the current quaternion
  3561. * @returns a new quaternion copied from the current one
  3562. */
  3563. clone(): Quaternion;
  3564. /**
  3565. * Copy a quaternion to the current one
  3566. * @param other defines the other quaternion
  3567. * @returns the updated current quaternion
  3568. */
  3569. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Updates the current quaternion with the given float coordinates
  3572. * @param x defines the x coordinate
  3573. * @param y defines the y coordinate
  3574. * @param z defines the z coordinate
  3575. * @param w defines the w coordinate
  3576. * @returns the updated current quaternion
  3577. */
  3578. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3579. /**
  3580. * Updates the current quaternion from the given float coordinates
  3581. * @param x defines the x coordinate
  3582. * @param y defines the y coordinate
  3583. * @param z defines the z coordinate
  3584. * @param w defines the w coordinate
  3585. * @returns the updated current quaternion
  3586. */
  3587. set(x: number, y: number, z: number, w: number): Quaternion;
  3588. /**
  3589. * Adds two quaternions
  3590. * @param other defines the second operand
  3591. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3592. */
  3593. add(other: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Add a quaternion to the current one
  3596. * @param other defines the quaternion to add
  3597. * @returns the current quaternion
  3598. */
  3599. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Subtract two quaternions
  3602. * @param other defines the second operand
  3603. * @returns a new quaternion as the subtraction result of the given one from the current one
  3604. */
  3605. subtract(other: Quaternion): Quaternion;
  3606. /**
  3607. * Multiplies the current quaternion by a scale factor
  3608. * @param value defines the scale factor
  3609. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3610. */
  3611. scale(value: number): Quaternion;
  3612. /**
  3613. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3614. * @param scale defines the scale factor
  3615. * @param result defines the Quaternion object where to store the result
  3616. * @returns the unmodified current quaternion
  3617. */
  3618. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3619. /**
  3620. * Multiplies in place the current quaternion by a scale factor
  3621. * @param value defines the scale factor
  3622. * @returns the current modified quaternion
  3623. */
  3624. scaleInPlace(value: number): Quaternion;
  3625. /**
  3626. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3627. * @param scale defines the scale factor
  3628. * @param result defines the Quaternion object where to store the result
  3629. * @returns the unmodified current quaternion
  3630. */
  3631. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3632. /**
  3633. * Multiplies two quaternions
  3634. * @param q1 defines the second operand
  3635. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3636. */
  3637. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3638. /**
  3639. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @param result defines the target quaternion
  3642. * @returns the current quaternion
  3643. */
  3644. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3645. /**
  3646. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3647. * @param q1 defines the second operand
  3648. * @returns the currentupdated quaternion
  3649. */
  3650. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3651. /**
  3652. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3653. * @param ref defines the target quaternion
  3654. * @returns the current quaternion
  3655. */
  3656. conjugateToRef(ref: Quaternion): Quaternion;
  3657. /**
  3658. * Conjugates in place (1-q) the current quaternion
  3659. * @returns the current updated quaternion
  3660. */
  3661. conjugateInPlace(): Quaternion;
  3662. /**
  3663. * Conjugates in place (1-q) the current quaternion
  3664. * @returns a new quaternion
  3665. */
  3666. conjugate(): Quaternion;
  3667. /**
  3668. * Gets length of current quaternion
  3669. * @returns the quaternion length (float)
  3670. */
  3671. length(): number;
  3672. /**
  3673. * Normalize in place the current quaternion
  3674. * @returns the current updated quaternion
  3675. */
  3676. normalize(): Quaternion;
  3677. /**
  3678. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns a new Vector3 containing the Euler angles
  3681. */
  3682. toEulerAngles(order?: string): Vector3;
  3683. /**
  3684. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3685. * @param result defines the vector which will be filled with the Euler angles
  3686. * @param order is a reserved parameter and is ignore for now
  3687. * @returns the current unchanged quaternion
  3688. */
  3689. toEulerAnglesToRef(result: Vector3): Quaternion;
  3690. /**
  3691. * Updates the given rotation matrix with the current quaternion values
  3692. * @param result defines the target matrix
  3693. * @returns the current unchanged quaternion
  3694. */
  3695. toRotationMatrix(result: Matrix): Quaternion;
  3696. /**
  3697. * Updates the current quaternion from the given rotation matrix values
  3698. * @param matrix defines the source matrix
  3699. * @returns the current updated quaternion
  3700. */
  3701. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from a rotation matrix
  3704. * @param matrix defines the source matrix
  3705. * @returns a new quaternion created from the given rotation matrix values
  3706. */
  3707. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3708. /**
  3709. * Updates the given quaternion with the given rotation matrix values
  3710. * @param matrix defines the source matrix
  3711. * @param result defines the target quaternion
  3712. */
  3713. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3714. /**
  3715. * Returns the dot product (float) between the quaternions "left" and "right"
  3716. * @param left defines the left operand
  3717. * @param right defines the right operand
  3718. * @returns the dot product
  3719. */
  3720. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3721. /**
  3722. * Checks if the two quaternions are close to each other
  3723. * @param quat0 defines the first quaternion to check
  3724. * @param quat1 defines the second quaternion to check
  3725. * @returns true if the two quaternions are close to each other
  3726. */
  3727. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Creates an empty quaternion
  3730. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3731. */
  3732. static Zero(): Quaternion;
  3733. /**
  3734. * Inverse a given quaternion
  3735. * @param q defines the source quaternion
  3736. * @returns a new quaternion as the inverted current quaternion
  3737. */
  3738. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Inverse a given quaternion
  3741. * @param q defines the source quaternion
  3742. * @param result the quaternion the result will be stored in
  3743. * @returns the result quaternion
  3744. */
  3745. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3746. /**
  3747. * Creates an identity quaternion
  3748. * @returns the identity quaternion
  3749. */
  3750. static Identity(): Quaternion;
  3751. /**
  3752. * Gets a boolean indicating if the given quaternion is identity
  3753. * @param quaternion defines the quaternion to check
  3754. * @returns true if the quaternion is identity
  3755. */
  3756. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3757. /**
  3758. * Creates a quaternion from a rotation around an axis
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3762. */
  3763. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3764. /**
  3765. * Creates a rotation around an axis and stores it into the given quaternion
  3766. * @param axis defines the axis to use
  3767. * @param angle defines the angle to use
  3768. * @param result defines the target quaternion
  3769. * @returns the target quaternion
  3770. */
  3771. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Creates a new quaternion from data stored into an array
  3774. * @param array defines the data source
  3775. * @param offset defines the offset in the source array where the data starts
  3776. * @returns a new quaternion
  3777. */
  3778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * 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)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * 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
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. 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;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. 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;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * 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"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * 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".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * 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.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * 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)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @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
  4958. * @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
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. 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);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. }
  7245. }
  7246. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7247. import { FloatArray, Nullable } from "babylonjs/types";
  7248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7250. module "babylonjs/Engines/thinEngine" {
  7251. interface ThinEngine {
  7252. /**
  7253. * Create an uniform buffer
  7254. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7255. * @param elements defines the content of the uniform buffer
  7256. * @returns the webGL uniform buffer
  7257. */
  7258. createUniformBuffer(elements: FloatArray): DataBuffer;
  7259. /**
  7260. * Create a dynamic uniform buffer
  7261. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7262. * @param elements defines the content of the uniform buffer
  7263. * @returns the webGL uniform buffer
  7264. */
  7265. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7266. /**
  7267. * Update an existing uniform buffer
  7268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7269. * @param uniformBuffer defines the target uniform buffer
  7270. * @param elements defines the content to update
  7271. * @param offset defines the offset in the uniform buffer where update should start
  7272. * @param count defines the size of the data to update
  7273. */
  7274. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7275. /**
  7276. * Bind an uniform buffer to the current webGL context
  7277. * @param buffer defines the buffer to bind
  7278. */
  7279. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7280. /**
  7281. * Bind a buffer to the current webGL context at a given location
  7282. * @param buffer defines the buffer to bind
  7283. * @param location defines the index where to bind the buffer
  7284. */
  7285. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7286. /**
  7287. * Bind a specific block at a given index in a specific shader program
  7288. * @param pipelineContext defines the pipeline context to use
  7289. * @param blockName defines the block name
  7290. * @param index defines the index where to bind the block
  7291. */
  7292. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7293. }
  7294. }
  7295. }
  7296. declare module "babylonjs/Materials/uniformBuffer" {
  7297. import { Nullable, FloatArray } from "babylonjs/types";
  7298. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7299. import { Engine } from "babylonjs/Engines/engine";
  7300. import { Effect } from "babylonjs/Materials/effect";
  7301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7302. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7303. import { Color3 } from "babylonjs/Maths/math.color";
  7304. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7305. /**
  7306. * Uniform buffer objects.
  7307. *
  7308. * Handles blocks of uniform on the GPU.
  7309. *
  7310. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7311. *
  7312. * For more information, please refer to :
  7313. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7314. */
  7315. export class UniformBuffer {
  7316. private _engine;
  7317. private _buffer;
  7318. private _data;
  7319. private _bufferData;
  7320. private _dynamic?;
  7321. private _uniformLocations;
  7322. private _uniformSizes;
  7323. private _uniformLocationPointer;
  7324. private _needSync;
  7325. private _noUBO;
  7326. private _currentEffect;
  7327. /** @hidden */
  7328. _alreadyBound: boolean;
  7329. private static _MAX_UNIFORM_SIZE;
  7330. private static _tempBuffer;
  7331. /**
  7332. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7337. /**
  7338. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7343. /**
  7344. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7349. /**
  7350. * Lambda to Update a vec2 of float in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7355. /**
  7356. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7361. /**
  7362. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7373. /**
  7374. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7379. /**
  7380. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateVector4: (name: string, vector: Vector4) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7397. /**
  7398. * Instantiates a new Uniform buffer objects.
  7399. *
  7400. * Handles blocks of uniform on the GPU.
  7401. *
  7402. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7403. *
  7404. * For more information, please refer to :
  7405. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7406. * @param engine Define the engine the buffer is associated with
  7407. * @param data Define the data contained in the buffer
  7408. * @param dynamic Define if the buffer is updatable
  7409. */
  7410. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7411. /**
  7412. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7413. * or just falling back on setUniformXXX calls.
  7414. */
  7415. get useUbo(): boolean;
  7416. /**
  7417. * Indicates if the WebGL underlying uniform buffer is in sync
  7418. * with the javascript cache data.
  7419. */
  7420. get isSync(): boolean;
  7421. /**
  7422. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7423. * Also, a dynamic UniformBuffer will disable cache verification and always
  7424. * update the underlying WebGL uniform buffer to the GPU.
  7425. * @returns if Dynamic, otherwise false
  7426. */
  7427. isDynamic(): boolean;
  7428. /**
  7429. * The data cache on JS side.
  7430. * @returns the underlying data as a float array
  7431. */
  7432. getData(): Float32Array;
  7433. /**
  7434. * The underlying WebGL Uniform buffer.
  7435. * @returns the webgl buffer
  7436. */
  7437. getBuffer(): Nullable<DataBuffer>;
  7438. /**
  7439. * std140 layout specifies how to align data within an UBO structure.
  7440. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7441. * for specs.
  7442. */
  7443. private _fillAlignment;
  7444. /**
  7445. * Adds an uniform in the buffer.
  7446. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7447. * for the layout to be correct !
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. * @param size Data size, or data directly.
  7450. */
  7451. addUniform(name: string, size: number | number[]): void;
  7452. /**
  7453. * Adds a Matrix 4x4 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. * @param mat A 4x4 matrix.
  7456. */
  7457. addMatrix(name: string, mat: Matrix): void;
  7458. /**
  7459. * Adds a vec2 to the uniform buffer.
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param x Define the x component value of the vec2
  7462. * @param y Define the y component value of the vec2
  7463. */
  7464. addFloat2(name: string, x: number, y: number): void;
  7465. /**
  7466. * Adds a vec3 to the uniform buffer.
  7467. * @param name Name of the uniform, as used in the uniform block in the shader.
  7468. * @param x Define the x component value of the vec3
  7469. * @param y Define the y component value of the vec3
  7470. * @param z Define the z component value of the vec3
  7471. */
  7472. addFloat3(name: string, x: number, y: number, z: number): void;
  7473. /**
  7474. * Adds a vec3 to the uniform buffer.
  7475. * @param name Name of the uniform, as used in the uniform block in the shader.
  7476. * @param color Define the vec3 from a Color
  7477. */
  7478. addColor3(name: string, color: Color3): void;
  7479. /**
  7480. * Adds a vec4 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. * @param color Define the rgb components from a Color
  7483. * @param alpha Define the a component of the vec4
  7484. */
  7485. addColor4(name: string, color: Color3, alpha: number): void;
  7486. /**
  7487. * Adds a vec3 to the uniform buffer.
  7488. * @param name Name of the uniform, as used in the uniform block in the shader.
  7489. * @param vector Define the vec3 components from a Vector
  7490. */
  7491. addVector3(name: string, vector: Vector3): void;
  7492. /**
  7493. * Adds a Matrix 3x3 to the uniform buffer.
  7494. * @param name Name of the uniform, as used in the uniform block in the shader.
  7495. */
  7496. addMatrix3x3(name: string): void;
  7497. /**
  7498. * Adds a Matrix 2x2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. */
  7501. addMatrix2x2(name: string): void;
  7502. /**
  7503. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7504. */
  7505. create(): void;
  7506. /** @hidden */
  7507. _rebuild(): void;
  7508. /**
  7509. * Updates the WebGL Uniform Buffer on the GPU.
  7510. * If the `dynamic` flag is set to true, no cache comparison is done.
  7511. * Otherwise, the buffer will be updated only if the cache differs.
  7512. */
  7513. update(): void;
  7514. /**
  7515. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7516. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7517. * @param data Define the flattened data
  7518. * @param size Define the size of the data.
  7519. */
  7520. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7521. private _valueCache;
  7522. private _cacheMatrix;
  7523. private _updateMatrix3x3ForUniform;
  7524. private _updateMatrix3x3ForEffect;
  7525. private _updateMatrix2x2ForEffect;
  7526. private _updateMatrix2x2ForUniform;
  7527. private _updateFloatForEffect;
  7528. private _updateFloatForUniform;
  7529. private _updateFloat2ForEffect;
  7530. private _updateFloat2ForUniform;
  7531. private _updateFloat3ForEffect;
  7532. private _updateFloat3ForUniform;
  7533. private _updateFloat4ForEffect;
  7534. private _updateFloat4ForUniform;
  7535. private _updateMatrixForEffect;
  7536. private _updateMatrixForUniform;
  7537. private _updateVector3ForEffect;
  7538. private _updateVector3ForUniform;
  7539. private _updateVector4ForEffect;
  7540. private _updateVector4ForUniform;
  7541. private _updateColor3ForEffect;
  7542. private _updateColor3ForUniform;
  7543. private _updateColor4ForEffect;
  7544. private _updateColor4ForUniform;
  7545. /**
  7546. * Sets a sampler uniform on the effect.
  7547. * @param name Define the name of the sampler.
  7548. * @param texture Define the texture to set in the sampler
  7549. */
  7550. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7551. /**
  7552. * Directly updates the value of the uniform in the cache AND on the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. */
  7556. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7557. /**
  7558. * Binds this uniform buffer to an effect.
  7559. * @param effect Define the effect to bind the buffer to
  7560. * @param name Name of the uniform block in the shader.
  7561. */
  7562. bindToEffect(effect: Effect, name: string): void;
  7563. /**
  7564. * Disposes the uniform buffer.
  7565. */
  7566. dispose(): void;
  7567. }
  7568. }
  7569. declare module "babylonjs/Misc/iInspectable" {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4,
  7594. /**
  7595. * String
  7596. */
  7597. String = 5
  7598. }
  7599. /**
  7600. * Interface used to define custom inspectable properties.
  7601. * This interface is used by the inspector to display custom property grids
  7602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7603. */
  7604. export interface IInspectable {
  7605. /**
  7606. * Gets the label to display
  7607. */
  7608. label: string;
  7609. /**
  7610. * Gets the name of the property to edit
  7611. */
  7612. propertyName: string;
  7613. /**
  7614. * Gets the type of the editor to use
  7615. */
  7616. type: InspectableType;
  7617. /**
  7618. * Gets the minimum value of the property when using in "slider" mode
  7619. */
  7620. min?: number;
  7621. /**
  7622. * Gets the maximum value of the property when using in "slider" mode
  7623. */
  7624. max?: number;
  7625. /**
  7626. * Gets the setp to use when using in "slider" mode
  7627. */
  7628. step?: number;
  7629. }
  7630. }
  7631. declare module "babylonjs/Misc/timingTools" {
  7632. /**
  7633. * Class used to provide helper for timing
  7634. */
  7635. export class TimingTools {
  7636. /**
  7637. * Polyfill for setImmediate
  7638. * @param action defines the action to execute after the current execution block
  7639. */
  7640. static SetImmediate(action: () => void): void;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/instantiationTools" {
  7644. /**
  7645. * Class used to enable instatition of objects by class name
  7646. */
  7647. export class InstantiationTools {
  7648. /**
  7649. * Use this object to register external classes like custom textures or material
  7650. * to allow the laoders to instantiate them
  7651. */
  7652. static RegisteredExternalClasses: {
  7653. [key: string]: Object;
  7654. };
  7655. /**
  7656. * Tries to instantiate a new object from a given class name
  7657. * @param className defines the class name to instantiate
  7658. * @returns the new object or null if the system was not able to do the instantiation
  7659. */
  7660. static Instantiate(className: string): any;
  7661. }
  7662. }
  7663. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7664. /**
  7665. * Define options used to create a depth texture
  7666. */
  7667. export class DepthTextureCreationOptions {
  7668. /** Specifies whether or not a stencil should be allocated in the texture */
  7669. generateStencil?: boolean;
  7670. /** Specifies whether or not bilinear filtering is enable on the texture */
  7671. bilinearFiltering?: boolean;
  7672. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7673. comparisonFunction?: number;
  7674. /** Specifies if the created texture is a cube texture */
  7675. isCube?: boolean;
  7676. }
  7677. }
  7678. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7680. import { Nullable } from "babylonjs/types";
  7681. import { Scene } from "babylonjs/scene";
  7682. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7683. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7684. module "babylonjs/Engines/thinEngine" {
  7685. interface ThinEngine {
  7686. /**
  7687. * Creates a depth stencil cube texture.
  7688. * This is only available in WebGL 2.
  7689. * @param size The size of face edge in the cube texture.
  7690. * @param options The options defining the cube texture.
  7691. * @returns The cube texture
  7692. */
  7693. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7694. /**
  7695. * Creates a cube texture
  7696. * @param rootUrl defines the url where the files to load is located
  7697. * @param scene defines the current scene
  7698. * @param files defines the list of files to load (1 per face)
  7699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7700. * @param onLoad defines an optional callback raised when the texture is loaded
  7701. * @param onError defines an optional callback raised if there is an issue to load the texture
  7702. * @param format defines the format of the data
  7703. * @param forcedExtension defines the extension to use to pick the right loader
  7704. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7707. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. 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;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. 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;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. /**
  7763. * Class for creating a cube texture
  7764. */
  7765. export class CubeTexture extends BaseTexture {
  7766. private _delayedOnLoad;
  7767. /**
  7768. * The url of the texture
  7769. */
  7770. url: string;
  7771. /**
  7772. * Gets or sets the center of the bounding box associated with the cube texture.
  7773. * It must define where the camera used to render the texture was set
  7774. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7775. */
  7776. boundingBoxPosition: Vector3;
  7777. private _boundingBoxSize;
  7778. /**
  7779. * Gets or sets the size of the bounding box associated with the cube texture
  7780. * When defined, the cubemap will switch to local mode
  7781. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7782. * @example https://www.babylonjs-playground.com/#RNASML
  7783. */
  7784. set boundingBoxSize(value: Vector3);
  7785. /**
  7786. * Returns the bounding box size
  7787. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7788. */
  7789. get boundingBoxSize(): Vector3;
  7790. protected _rotationY: number;
  7791. /**
  7792. * Sets texture matrix rotation angle around Y axis in radians.
  7793. */
  7794. set rotationY(value: number);
  7795. /**
  7796. * Gets texture matrix rotation angle around Y axis radians.
  7797. */
  7798. get rotationY(): number;
  7799. /**
  7800. * Are mip maps generated for this texture or not.
  7801. */
  7802. get noMipmap(): boolean;
  7803. private _noMipmap;
  7804. private _files;
  7805. protected _forcedExtension: Nullable<string>;
  7806. private _extensions;
  7807. private _textureMatrix;
  7808. private _format;
  7809. private _createPolynomials;
  7810. /** @hidden */
  7811. _prefiltered: boolean;
  7812. /**
  7813. * Creates a cube texture from an array of image urls
  7814. * @param files defines an array of image urls
  7815. * @param scene defines the hosting scene
  7816. * @param noMipmap specifies if mip maps are not used
  7817. * @returns a cube texture
  7818. */
  7819. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7820. /**
  7821. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7822. * @param url defines the url of the prefiltered texture
  7823. * @param scene defines the scene the texture is attached to
  7824. * @param forcedExtension defines the extension of the file if different from the url
  7825. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7826. * @return the prefiltered texture
  7827. */
  7828. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7829. /**
  7830. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7831. * as prefiltered data.
  7832. * @param rootUrl defines the url of the texture or the root name of the six images
  7833. * @param scene defines the scene the texture is attached to
  7834. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7835. * @param noMipmap defines if mipmaps should be created or not
  7836. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7837. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7838. * @param onError defines a callback triggered in case of error during load
  7839. * @param format defines the internal format to use for the texture once loaded
  7840. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7841. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7842. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7843. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7844. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7845. * @return the cube texture
  7846. */
  7847. 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);
  7848. /**
  7849. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7850. */
  7851. get isPrefiltered(): boolean;
  7852. /**
  7853. * Get the current class name of the texture useful for serialization or dynamic coding.
  7854. * @returns "CubeTexture"
  7855. */
  7856. getClassName(): string;
  7857. /**
  7858. * Update the url (and optional buffer) of this texture if url was null during construction.
  7859. * @param url the url of the texture
  7860. * @param forcedExtension defines the extension to use
  7861. * @param onLoad callback called when the texture is loaded (defaults to null)
  7862. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7863. */
  7864. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7865. /**
  7866. * Delays loading of the cube texture
  7867. * @param forcedExtension defines the extension to use
  7868. */
  7869. delayLoad(forcedExtension?: string): void;
  7870. /**
  7871. * Returns the reflection texture matrix
  7872. * @returns the reflection texture matrix
  7873. */
  7874. getReflectionTextureMatrix(): Matrix;
  7875. /**
  7876. * Sets the reflection texture matrix
  7877. * @param value Reflection texture matrix
  7878. */
  7879. setReflectionTextureMatrix(value: Matrix): void;
  7880. /**
  7881. * Parses text to create a cube texture
  7882. * @param parsedTexture define the serialized text to read from
  7883. * @param scene defines the hosting scene
  7884. * @param rootUrl defines the root url of the cube texture
  7885. * @returns a cube texture
  7886. */
  7887. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7888. /**
  7889. * Makes a clone, or deep copy, of the cube texture
  7890. * @returns a new cube texture
  7891. */
  7892. clone(): CubeTexture;
  7893. }
  7894. }
  7895. declare module "babylonjs/Materials/materialDefines" {
  7896. /**
  7897. * Manages the defines for the Material
  7898. */
  7899. export class MaterialDefines {
  7900. /** @hidden */
  7901. protected _keys: string[];
  7902. private _isDirty;
  7903. /** @hidden */
  7904. _renderId: number;
  7905. /** @hidden */
  7906. _areLightsDirty: boolean;
  7907. /** @hidden */
  7908. _areLightsDisposed: boolean;
  7909. /** @hidden */
  7910. _areAttributesDirty: boolean;
  7911. /** @hidden */
  7912. _areTexturesDirty: boolean;
  7913. /** @hidden */
  7914. _areFresnelDirty: boolean;
  7915. /** @hidden */
  7916. _areMiscDirty: boolean;
  7917. /** @hidden */
  7918. _areImageProcessingDirty: boolean;
  7919. /** @hidden */
  7920. _normals: boolean;
  7921. /** @hidden */
  7922. _uvs: boolean;
  7923. /** @hidden */
  7924. _needNormals: boolean;
  7925. /** @hidden */
  7926. _needUVs: boolean;
  7927. [id: string]: any;
  7928. /**
  7929. * Specifies if the material needs to be re-calculated
  7930. */
  7931. get isDirty(): boolean;
  7932. /**
  7933. * Marks the material to indicate that it has been re-calculated
  7934. */
  7935. markAsProcessed(): void;
  7936. /**
  7937. * Marks the material to indicate that it needs to be re-calculated
  7938. */
  7939. markAsUnprocessed(): void;
  7940. /**
  7941. * Marks the material to indicate all of its defines need to be re-calculated
  7942. */
  7943. markAllAsDirty(): void;
  7944. /**
  7945. * Marks the material to indicate that image processing needs to be re-calculated
  7946. */
  7947. markAsImageProcessingDirty(): void;
  7948. /**
  7949. * Marks the material to indicate the lights need to be re-calculated
  7950. * @param disposed Defines whether the light is dirty due to dispose or not
  7951. */
  7952. markAsLightDirty(disposed?: boolean): void;
  7953. /**
  7954. * Marks the attribute state as changed
  7955. */
  7956. markAsAttributesDirty(): void;
  7957. /**
  7958. * Marks the texture state as changed
  7959. */
  7960. markAsTexturesDirty(): void;
  7961. /**
  7962. * Marks the fresnel state as changed
  7963. */
  7964. markAsFresnelDirty(): void;
  7965. /**
  7966. * Marks the misc state as changed
  7967. */
  7968. markAsMiscDirty(): void;
  7969. /**
  7970. * Rebuilds the material defines
  7971. */
  7972. rebuild(): void;
  7973. /**
  7974. * Specifies if two material defines are equal
  7975. * @param other - A material define instance to compare to
  7976. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7977. */
  7978. isEqual(other: MaterialDefines): boolean;
  7979. /**
  7980. * Clones this instance's defines to another instance
  7981. * @param other - material defines to clone values to
  7982. */
  7983. cloneTo(other: MaterialDefines): void;
  7984. /**
  7985. * Resets the material define values
  7986. */
  7987. reset(): void;
  7988. /**
  7989. * Converts the material define values to a string
  7990. * @returns - String of material define information
  7991. */
  7992. toString(): string;
  7993. }
  7994. }
  7995. declare module "babylonjs/Materials/colorCurves" {
  7996. import { Effect } from "babylonjs/Materials/effect";
  7997. /**
  7998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8000. * 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;
  8001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8002. */
  8003. export class ColorCurves {
  8004. private _dirty;
  8005. private _tempColor;
  8006. private _globalCurve;
  8007. private _highlightsCurve;
  8008. private _midtonesCurve;
  8009. private _shadowsCurve;
  8010. private _positiveCurve;
  8011. private _negativeCurve;
  8012. private _globalHue;
  8013. private _globalDensity;
  8014. private _globalSaturation;
  8015. private _globalExposure;
  8016. /**
  8017. * Gets the global Hue value.
  8018. * 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).
  8019. */
  8020. get globalHue(): number;
  8021. /**
  8022. * Sets the global Hue value.
  8023. * 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).
  8024. */
  8025. set globalHue(value: number);
  8026. /**
  8027. * Gets the global Density value.
  8028. * 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.
  8029. * Values less than zero provide a filter of opposite hue.
  8030. */
  8031. get globalDensity(): number;
  8032. /**
  8033. * Sets the global Density value.
  8034. * 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.
  8035. * Values less than zero provide a filter of opposite hue.
  8036. */
  8037. set globalDensity(value: number);
  8038. /**
  8039. * Gets the global Saturation value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8041. */
  8042. get globalSaturation(): number;
  8043. /**
  8044. * Sets the global Saturation value.
  8045. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8046. */
  8047. set globalSaturation(value: number);
  8048. /**
  8049. * Gets the global Exposure value.
  8050. * 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.
  8051. */
  8052. get globalExposure(): number;
  8053. /**
  8054. * Sets the global Exposure value.
  8055. * 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.
  8056. */
  8057. set globalExposure(value: number);
  8058. private _highlightsHue;
  8059. private _highlightsDensity;
  8060. private _highlightsSaturation;
  8061. private _highlightsExposure;
  8062. /**
  8063. * Gets the highlights Hue value.
  8064. * 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).
  8065. */
  8066. get highlightsHue(): number;
  8067. /**
  8068. * Sets the highlights Hue value.
  8069. * 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).
  8070. */
  8071. set highlightsHue(value: number);
  8072. /**
  8073. * Gets the highlights Density value.
  8074. * 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.
  8075. * Values less than zero provide a filter of opposite hue.
  8076. */
  8077. get highlightsDensity(): number;
  8078. /**
  8079. * Sets the highlights Density value.
  8080. * 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.
  8081. * Values less than zero provide a filter of opposite hue.
  8082. */
  8083. set highlightsDensity(value: number);
  8084. /**
  8085. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  8087. */
  8088. get highlightsSaturation(): number;
  8089. /**
  8090. * Sets the highlights Saturation value.
  8091. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8092. */
  8093. set highlightsSaturation(value: number);
  8094. /**
  8095. * Gets the highlights Exposure value.
  8096. * 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.
  8097. */
  8098. get highlightsExposure(): number;
  8099. /**
  8100. * Sets the highlights Exposure value.
  8101. * 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.
  8102. */
  8103. set highlightsExposure(value: number);
  8104. private _midtonesHue;
  8105. private _midtonesDensity;
  8106. private _midtonesSaturation;
  8107. private _midtonesExposure;
  8108. /**
  8109. * Gets the midtones Hue value.
  8110. * 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).
  8111. */
  8112. get midtonesHue(): number;
  8113. /**
  8114. * Sets the midtones Hue value.
  8115. * 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).
  8116. */
  8117. set midtonesHue(value: number);
  8118. /**
  8119. * Gets the midtones Density value.
  8120. * 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.
  8121. * Values less than zero provide a filter of opposite hue.
  8122. */
  8123. get midtonesDensity(): number;
  8124. /**
  8125. * Sets the midtones Density value.
  8126. * 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.
  8127. * Values less than zero provide a filter of opposite hue.
  8128. */
  8129. set midtonesDensity(value: number);
  8130. /**
  8131. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  8133. */
  8134. get midtonesSaturation(): number;
  8135. /**
  8136. * Sets the midtones Saturation value.
  8137. * 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.
  8138. */
  8139. set midtonesSaturation(value: number);
  8140. /**
  8141. * Gets the midtones Exposure value.
  8142. * 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.
  8143. */
  8144. get midtonesExposure(): number;
  8145. /**
  8146. * Sets the midtones Exposure value.
  8147. * 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.
  8148. */
  8149. set midtonesExposure(value: number);
  8150. private _shadowsHue;
  8151. private _shadowsDensity;
  8152. private _shadowsSaturation;
  8153. private _shadowsExposure;
  8154. /**
  8155. * Gets the shadows Hue value.
  8156. * 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).
  8157. */
  8158. get shadowsHue(): number;
  8159. /**
  8160. * Sets the shadows Hue value.
  8161. * 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).
  8162. */
  8163. set shadowsHue(value: number);
  8164. /**
  8165. * Gets the shadows Density value.
  8166. * 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.
  8167. * Values less than zero provide a filter of opposite hue.
  8168. */
  8169. get shadowsDensity(): number;
  8170. /**
  8171. * Sets the shadows Density value.
  8172. * 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.
  8173. * Values less than zero provide a filter of opposite hue.
  8174. */
  8175. set shadowsDensity(value: number);
  8176. /**
  8177. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  8179. */
  8180. get shadowsSaturation(): number;
  8181. /**
  8182. * Sets the shadows Saturation value.
  8183. * 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.
  8184. */
  8185. set shadowsSaturation(value: number);
  8186. /**
  8187. * Gets the shadows Exposure value.
  8188. * 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.
  8189. */
  8190. get shadowsExposure(): number;
  8191. /**
  8192. * Sets the shadows Exposure value.
  8193. * 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.
  8194. */
  8195. set shadowsExposure(value: number);
  8196. /**
  8197. * Returns the class name
  8198. * @returns The class name
  8199. */
  8200. getClassName(): string;
  8201. /**
  8202. * Binds the color curves to the shader.
  8203. * @param colorCurves The color curve to bind
  8204. * @param effect The effect to bind to
  8205. * @param positiveUniform The positive uniform shader parameter
  8206. * @param neutralUniform The neutral uniform shader parameter
  8207. * @param negativeUniform The negative uniform shader parameter
  8208. */
  8209. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8210. /**
  8211. * Prepare the list of uniforms associated with the ColorCurves effects.
  8212. * @param uniformsList The list of uniforms used in the effect
  8213. */
  8214. static PrepareUniforms(uniformsList: string[]): void;
  8215. /**
  8216. * Returns color grading data based on a hue, density, saturation and exposure value.
  8217. * @param filterHue The hue of the color filter.
  8218. * @param filterDensity The density of the color filter.
  8219. * @param saturation The saturation.
  8220. * @param exposure The exposure.
  8221. * @param result The result data container.
  8222. */
  8223. private getColorGradingDataToRef;
  8224. /**
  8225. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8226. * @param value The input slider value in range [-100,100].
  8227. * @returns Adjusted value.
  8228. */
  8229. private static applyColorGradingSliderNonlinear;
  8230. /**
  8231. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8232. * @param hue The hue (H) input.
  8233. * @param saturation The saturation (S) input.
  8234. * @param brightness The brightness (B) input.
  8235. * @result An RGBA color represented as Vector4.
  8236. */
  8237. private static fromHSBToRef;
  8238. /**
  8239. * Returns a value clamped between min and max
  8240. * @param value The value to clamp
  8241. * @param min The minimum of value
  8242. * @param max The maximum of value
  8243. * @returns The clamped value.
  8244. */
  8245. private static clamp;
  8246. /**
  8247. * Clones the current color curve instance.
  8248. * @return The cloned curves
  8249. */
  8250. clone(): ColorCurves;
  8251. /**
  8252. * Serializes the current color curve instance to a json representation.
  8253. * @return a JSON representation
  8254. */
  8255. serialize(): any;
  8256. /**
  8257. * Parses the color curve from a json representation.
  8258. * @param source the JSON source to parse
  8259. * @return The parsed curves
  8260. */
  8261. static Parse(source: any): ColorCurves;
  8262. }
  8263. }
  8264. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8265. import { Observable } from "babylonjs/Misc/observable";
  8266. import { Nullable } from "babylonjs/types";
  8267. import { Color4 } from "babylonjs/Maths/math.color";
  8268. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8269. import { Effect } from "babylonjs/Materials/effect";
  8270. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8271. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8272. /**
  8273. * Interface to follow in your material defines to integrate easily the
  8274. * Image proccessing functions.
  8275. * @hidden
  8276. */
  8277. export interface IImageProcessingConfigurationDefines {
  8278. IMAGEPROCESSING: boolean;
  8279. VIGNETTE: boolean;
  8280. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8281. VIGNETTEBLENDMODEOPAQUE: boolean;
  8282. TONEMAPPING: boolean;
  8283. TONEMAPPING_ACES: boolean;
  8284. CONTRAST: boolean;
  8285. EXPOSURE: boolean;
  8286. COLORCURVES: boolean;
  8287. COLORGRADING: boolean;
  8288. COLORGRADING3D: boolean;
  8289. SAMPLER3DGREENDEPTH: boolean;
  8290. SAMPLER3DBGRMAP: boolean;
  8291. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8292. }
  8293. /**
  8294. * @hidden
  8295. */
  8296. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8297. IMAGEPROCESSING: boolean;
  8298. VIGNETTE: boolean;
  8299. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8300. VIGNETTEBLENDMODEOPAQUE: boolean;
  8301. TONEMAPPING: boolean;
  8302. TONEMAPPING_ACES: boolean;
  8303. CONTRAST: boolean;
  8304. COLORCURVES: boolean;
  8305. COLORGRADING: boolean;
  8306. COLORGRADING3D: boolean;
  8307. SAMPLER3DGREENDEPTH: boolean;
  8308. SAMPLER3DBGRMAP: boolean;
  8309. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8310. EXPOSURE: boolean;
  8311. constructor();
  8312. }
  8313. /**
  8314. * This groups together the common properties used for image processing either in direct forward pass
  8315. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8316. * or not.
  8317. */
  8318. export class ImageProcessingConfiguration {
  8319. /**
  8320. * Default tone mapping applied in BabylonJS.
  8321. */
  8322. static readonly TONEMAPPING_STANDARD: number;
  8323. /**
  8324. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8325. * to other engines rendering to increase portability.
  8326. */
  8327. static readonly TONEMAPPING_ACES: number;
  8328. /**
  8329. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8330. */
  8331. colorCurves: Nullable<ColorCurves>;
  8332. private _colorCurvesEnabled;
  8333. /**
  8334. * Gets wether the color curves effect is enabled.
  8335. */
  8336. get colorCurvesEnabled(): boolean;
  8337. /**
  8338. * Sets wether the color curves effect is enabled.
  8339. */
  8340. set colorCurvesEnabled(value: boolean);
  8341. private _colorGradingTexture;
  8342. /**
  8343. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8344. */
  8345. get colorGradingTexture(): Nullable<BaseTexture>;
  8346. /**
  8347. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8348. */
  8349. set colorGradingTexture(value: Nullable<BaseTexture>);
  8350. private _colorGradingEnabled;
  8351. /**
  8352. * Gets wether the color grading effect is enabled.
  8353. */
  8354. get colorGradingEnabled(): boolean;
  8355. /**
  8356. * Sets wether the color grading effect is enabled.
  8357. */
  8358. set colorGradingEnabled(value: boolean);
  8359. private _colorGradingWithGreenDepth;
  8360. /**
  8361. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8362. */
  8363. get colorGradingWithGreenDepth(): boolean;
  8364. /**
  8365. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8366. */
  8367. set colorGradingWithGreenDepth(value: boolean);
  8368. private _colorGradingBGR;
  8369. /**
  8370. * Gets wether the color grading texture contains BGR values.
  8371. */
  8372. get colorGradingBGR(): boolean;
  8373. /**
  8374. * Sets wether the color grading texture contains BGR values.
  8375. */
  8376. set colorGradingBGR(value: boolean);
  8377. /** @hidden */
  8378. _exposure: number;
  8379. /**
  8380. * Gets the Exposure used in the effect.
  8381. */
  8382. get exposure(): number;
  8383. /**
  8384. * Sets the Exposure used in the effect.
  8385. */
  8386. set exposure(value: number);
  8387. private _toneMappingEnabled;
  8388. /**
  8389. * Gets wether the tone mapping effect is enabled.
  8390. */
  8391. get toneMappingEnabled(): boolean;
  8392. /**
  8393. * Sets wether the tone mapping effect is enabled.
  8394. */
  8395. set toneMappingEnabled(value: boolean);
  8396. private _toneMappingType;
  8397. /**
  8398. * Gets the type of tone mapping effect.
  8399. */
  8400. get toneMappingType(): number;
  8401. /**
  8402. * Sets the type of tone mapping effect used in BabylonJS.
  8403. */
  8404. set toneMappingType(value: number);
  8405. protected _contrast: number;
  8406. /**
  8407. * Gets the contrast used in the effect.
  8408. */
  8409. get contrast(): number;
  8410. /**
  8411. * Sets the contrast used in the effect.
  8412. */
  8413. set contrast(value: number);
  8414. /**
  8415. * Vignette stretch size.
  8416. */
  8417. vignetteStretch: number;
  8418. /**
  8419. * Vignette centre X Offset.
  8420. */
  8421. vignetteCentreX: number;
  8422. /**
  8423. * Vignette centre Y Offset.
  8424. */
  8425. vignetteCentreY: number;
  8426. /**
  8427. * Vignette weight or intensity of the vignette effect.
  8428. */
  8429. vignetteWeight: number;
  8430. /**
  8431. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8432. * if vignetteEnabled is set to true.
  8433. */
  8434. vignetteColor: Color4;
  8435. /**
  8436. * Camera field of view used by the Vignette effect.
  8437. */
  8438. vignetteCameraFov: number;
  8439. private _vignetteBlendMode;
  8440. /**
  8441. * Gets the vignette blend mode allowing different kind of effect.
  8442. */
  8443. get vignetteBlendMode(): number;
  8444. /**
  8445. * Sets the vignette blend mode allowing different kind of effect.
  8446. */
  8447. set vignetteBlendMode(value: number);
  8448. private _vignetteEnabled;
  8449. /**
  8450. * Gets wether the vignette effect is enabled.
  8451. */
  8452. get vignetteEnabled(): boolean;
  8453. /**
  8454. * Sets wether the vignette effect is enabled.
  8455. */
  8456. set vignetteEnabled(value: boolean);
  8457. private _applyByPostProcess;
  8458. /**
  8459. * Gets wether the image processing is applied through a post process or not.
  8460. */
  8461. get applyByPostProcess(): boolean;
  8462. /**
  8463. * Sets wether the image processing is applied through a post process or not.
  8464. */
  8465. set applyByPostProcess(value: boolean);
  8466. private _isEnabled;
  8467. /**
  8468. * Gets wether the image processing is enabled or not.
  8469. */
  8470. get isEnabled(): boolean;
  8471. /**
  8472. * Sets wether the image processing is enabled or not.
  8473. */
  8474. set isEnabled(value: boolean);
  8475. /**
  8476. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8477. */
  8478. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8479. /**
  8480. * Method called each time the image processing information changes requires to recompile the effect.
  8481. */
  8482. protected _updateParameters(): void;
  8483. /**
  8484. * Gets the current class name.
  8485. * @return "ImageProcessingConfiguration"
  8486. */
  8487. getClassName(): string;
  8488. /**
  8489. * Prepare the list of uniforms associated with the Image Processing effects.
  8490. * @param uniforms The list of uniforms used in the effect
  8491. * @param defines the list of defines currently in use
  8492. */
  8493. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8494. /**
  8495. * Prepare the list of samplers associated with the Image Processing effects.
  8496. * @param samplersList The list of uniforms used in the effect
  8497. * @param defines the list of defines currently in use
  8498. */
  8499. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8500. /**
  8501. * Prepare the list of defines associated to the shader.
  8502. * @param defines the list of defines to complete
  8503. * @param forPostProcess Define if we are currently in post process mode or not
  8504. */
  8505. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8506. /**
  8507. * Returns true if all the image processing information are ready.
  8508. * @returns True if ready, otherwise, false
  8509. */
  8510. isReady(): boolean;
  8511. /**
  8512. * Binds the image processing to the shader.
  8513. * @param effect The effect to bind to
  8514. * @param overrideAspectRatio Override the aspect ratio of the effect
  8515. */
  8516. bind(effect: Effect, overrideAspectRatio?: number): void;
  8517. /**
  8518. * Clones the current image processing instance.
  8519. * @return The cloned image processing
  8520. */
  8521. clone(): ImageProcessingConfiguration;
  8522. /**
  8523. * Serializes the current image processing instance to a json representation.
  8524. * @return a JSON representation
  8525. */
  8526. serialize(): any;
  8527. /**
  8528. * Parses the image processing from a json representation.
  8529. * @param source the JSON source to parse
  8530. * @return The parsed image processing
  8531. */
  8532. static Parse(source: any): ImageProcessingConfiguration;
  8533. private static _VIGNETTEMODE_MULTIPLY;
  8534. private static _VIGNETTEMODE_OPAQUE;
  8535. /**
  8536. * Used to apply the vignette as a mix with the pixel color.
  8537. */
  8538. static get VIGNETTEMODE_MULTIPLY(): number;
  8539. /**
  8540. * Used to apply the vignette as a replacement of the pixel color.
  8541. */
  8542. static get VIGNETTEMODE_OPAQUE(): number;
  8543. }
  8544. }
  8545. declare module "babylonjs/Shaders/postprocess.vertex" {
  8546. /** @hidden */
  8547. export var postprocessVertexShader: {
  8548. name: string;
  8549. shader: string;
  8550. };
  8551. }
  8552. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8554. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8555. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8556. module "babylonjs/Engines/thinEngine" {
  8557. interface ThinEngine {
  8558. /**
  8559. * Creates a new render target texture
  8560. * @param size defines the size of the texture
  8561. * @param options defines the options used to create the texture
  8562. * @returns a new render target texture stored in an InternalTexture
  8563. */
  8564. createRenderTargetTexture(size: number | {
  8565. width: number;
  8566. height: number;
  8567. layers?: number;
  8568. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8569. /**
  8570. * Creates a depth stencil texture.
  8571. * This is only available in WebGL 2 or with the depth texture extension available.
  8572. * @param size The size of face edge in the texture.
  8573. * @param options The options defining the texture.
  8574. * @returns The texture
  8575. */
  8576. createDepthStencilTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: DepthTextureCreationOptions): InternalTexture;
  8581. /** @hidden */
  8582. _createDepthStencilTexture(size: number | {
  8583. width: number;
  8584. height: number;
  8585. layers?: number;
  8586. }, options: DepthTextureCreationOptions): InternalTexture;
  8587. }
  8588. }
  8589. }
  8590. declare module "babylonjs/Maths/math.axis" {
  8591. import { Vector3 } from "babylonjs/Maths/math.vector";
  8592. /** Defines supported spaces */
  8593. export enum Space {
  8594. /** Local (object) space */
  8595. LOCAL = 0,
  8596. /** World space */
  8597. WORLD = 1,
  8598. /** Bone space */
  8599. BONE = 2
  8600. }
  8601. /** Defines the 3 main axes */
  8602. export class Axis {
  8603. /** X axis */
  8604. static X: Vector3;
  8605. /** Y axis */
  8606. static Y: Vector3;
  8607. /** Z axis */
  8608. static Z: Vector3;
  8609. }
  8610. }
  8611. declare module "babylonjs/Cameras/targetCamera" {
  8612. import { Nullable } from "babylonjs/types";
  8613. import { Camera } from "babylonjs/Cameras/camera";
  8614. import { Scene } from "babylonjs/scene";
  8615. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8616. /**
  8617. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8618. * This is the base of the follow, arc rotate cameras and Free camera
  8619. * @see http://doc.babylonjs.com/features/cameras
  8620. */
  8621. export class TargetCamera extends Camera {
  8622. private static _RigCamTransformMatrix;
  8623. private static _TargetTransformMatrix;
  8624. private static _TargetFocalPoint;
  8625. /**
  8626. * Define the current direction the camera is moving to
  8627. */
  8628. cameraDirection: Vector3;
  8629. /**
  8630. * Define the current rotation the camera is rotating to
  8631. */
  8632. cameraRotation: Vector2;
  8633. /**
  8634. * When set, the up vector of the camera will be updated by the rotation of the camera
  8635. */
  8636. updateUpVectorFromRotation: boolean;
  8637. private _tmpQuaternion;
  8638. /**
  8639. * Define the current rotation of the camera
  8640. */
  8641. rotation: Vector3;
  8642. /**
  8643. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8644. */
  8645. rotationQuaternion: Quaternion;
  8646. /**
  8647. * Define the current speed of the camera
  8648. */
  8649. speed: number;
  8650. /**
  8651. * Add constraint to the camera to prevent it to move freely in all directions and
  8652. * around all axis.
  8653. */
  8654. noRotationConstraint: boolean;
  8655. /**
  8656. * Define the current target of the camera as an object or a position.
  8657. */
  8658. lockedTarget: any;
  8659. /** @hidden */
  8660. _currentTarget: Vector3;
  8661. /** @hidden */
  8662. _initialFocalDistance: number;
  8663. /** @hidden */
  8664. _viewMatrix: Matrix;
  8665. /** @hidden */
  8666. _camMatrix: Matrix;
  8667. /** @hidden */
  8668. _cameraTransformMatrix: Matrix;
  8669. /** @hidden */
  8670. _cameraRotationMatrix: Matrix;
  8671. /** @hidden */
  8672. _referencePoint: Vector3;
  8673. /** @hidden */
  8674. _transformedReferencePoint: Vector3;
  8675. protected _globalCurrentTarget: Vector3;
  8676. protected _globalCurrentUpVector: Vector3;
  8677. /** @hidden */
  8678. _reset: () => void;
  8679. private _defaultUp;
  8680. /**
  8681. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8682. * This is the base of the follow, arc rotate cameras and Free camera
  8683. * @see http://doc.babylonjs.com/features/cameras
  8684. * @param name Defines the name of the camera in the scene
  8685. * @param position Defines the start position of the camera in the scene
  8686. * @param scene Defines the scene the camera belongs to
  8687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8688. */
  8689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8690. /**
  8691. * Gets the position in front of the camera at a given distance.
  8692. * @param distance The distance from the camera we want the position to be
  8693. * @returns the position
  8694. */
  8695. getFrontPosition(distance: number): Vector3;
  8696. /** @hidden */
  8697. _getLockedTargetPosition(): Nullable<Vector3>;
  8698. private _storedPosition;
  8699. private _storedRotation;
  8700. private _storedRotationQuaternion;
  8701. /**
  8702. * Store current camera state of the camera (fov, position, rotation, etc..)
  8703. * @returns the camera
  8704. */
  8705. storeState(): Camera;
  8706. /**
  8707. * Restored camera state. You must call storeState() first
  8708. * @returns whether it was successful or not
  8709. * @hidden
  8710. */
  8711. _restoreStateValues(): boolean;
  8712. /** @hidden */
  8713. _initCache(): void;
  8714. /** @hidden */
  8715. _updateCache(ignoreParentClass?: boolean): void;
  8716. /** @hidden */
  8717. _isSynchronizedViewMatrix(): boolean;
  8718. /** @hidden */
  8719. _computeLocalCameraSpeed(): number;
  8720. /**
  8721. * Defines the target the camera should look at.
  8722. * @param target Defines the new target as a Vector or a mesh
  8723. */
  8724. setTarget(target: Vector3): void;
  8725. /**
  8726. * Return the current target position of the camera. This value is expressed in local space.
  8727. * @returns the target position
  8728. */
  8729. getTarget(): Vector3;
  8730. /** @hidden */
  8731. _decideIfNeedsToMove(): boolean;
  8732. /** @hidden */
  8733. _updatePosition(): void;
  8734. /** @hidden */
  8735. _checkInputs(): void;
  8736. protected _updateCameraRotationMatrix(): void;
  8737. /**
  8738. * 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)
  8739. * @returns the current camera
  8740. */
  8741. private _rotateUpVectorWithCameraRotationMatrix;
  8742. private _cachedRotationZ;
  8743. private _cachedQuaternionRotationZ;
  8744. /** @hidden */
  8745. _getViewMatrix(): Matrix;
  8746. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8747. /**
  8748. * @hidden
  8749. */
  8750. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8751. /**
  8752. * @hidden
  8753. */
  8754. _updateRigCameras(): void;
  8755. private _getRigCamPositionAndTarget;
  8756. /**
  8757. * Gets the current object class name.
  8758. * @return the class name
  8759. */
  8760. getClassName(): string;
  8761. }
  8762. }
  8763. declare module "babylonjs/Events/keyboardEvents" {
  8764. /**
  8765. * Gather the list of keyboard event types as constants.
  8766. */
  8767. export class KeyboardEventTypes {
  8768. /**
  8769. * The keydown event is fired when a key becomes active (pressed).
  8770. */
  8771. static readonly KEYDOWN: number;
  8772. /**
  8773. * The keyup event is fired when a key has been released.
  8774. */
  8775. static readonly KEYUP: number;
  8776. }
  8777. /**
  8778. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8779. */
  8780. export class KeyboardInfo {
  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. * Instantiates a new keyboard info.
  8791. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8792. * @param type Defines the type of event (KeyboardEventTypes)
  8793. * @param event Defines the related dom event
  8794. */
  8795. constructor(
  8796. /**
  8797. * Defines the type of event (KeyboardEventTypes)
  8798. */
  8799. type: number,
  8800. /**
  8801. * Defines the related dom event
  8802. */
  8803. event: KeyboardEvent);
  8804. }
  8805. /**
  8806. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8807. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8808. */
  8809. export class KeyboardInfoPre extends KeyboardInfo {
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number;
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent;
  8818. /**
  8819. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8820. */
  8821. skipOnPointerObservable: boolean;
  8822. /**
  8823. * Instantiates a new keyboard pre info.
  8824. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8825. * @param type Defines the type of event (KeyboardEventTypes)
  8826. * @param event Defines the related dom event
  8827. */
  8828. constructor(
  8829. /**
  8830. * Defines the type of event (KeyboardEventTypes)
  8831. */
  8832. type: number,
  8833. /**
  8834. * Defines the related dom event
  8835. */
  8836. event: KeyboardEvent);
  8837. }
  8838. }
  8839. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8840. import { Nullable } from "babylonjs/types";
  8841. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8843. /**
  8844. * Manage the keyboard inputs to control the movement of a free camera.
  8845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8846. */
  8847. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8848. /**
  8849. * Defines the camera the input is attached to.
  8850. */
  8851. camera: FreeCamera;
  8852. /**
  8853. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8854. */
  8855. keysUp: number[];
  8856. /**
  8857. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8858. */
  8859. keysDown: number[];
  8860. /**
  8861. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8862. */
  8863. keysLeft: number[];
  8864. /**
  8865. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8866. */
  8867. keysRight: number[];
  8868. private _keys;
  8869. private _onCanvasBlurObserver;
  8870. private _onKeyboardObserver;
  8871. private _engine;
  8872. private _scene;
  8873. /**
  8874. * Attach the input controls to a specific dom element to get the input from.
  8875. * @param element Defines the element the controls should be listened from
  8876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8877. */
  8878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8879. /**
  8880. * Detach the current controls from the specified dom element.
  8881. * @param element Defines the element to stop listening the inputs from
  8882. */
  8883. detachControl(element: Nullable<HTMLElement>): void;
  8884. /**
  8885. * Update the current camera state depending on the inputs that have been used this frame.
  8886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8887. */
  8888. checkInputs(): void;
  8889. /**
  8890. * Gets the class name of the current intput.
  8891. * @returns the class name
  8892. */
  8893. getClassName(): string;
  8894. /** @hidden */
  8895. _onLostFocus(): void;
  8896. /**
  8897. * Get the friendly name associated with the input class.
  8898. * @returns the input friendly name
  8899. */
  8900. getSimpleName(): string;
  8901. }
  8902. }
  8903. declare module "babylonjs/Lights/shadowLight" {
  8904. import { Camera } from "babylonjs/Cameras/camera";
  8905. import { Scene } from "babylonjs/scene";
  8906. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8908. import { Light } from "babylonjs/Lights/light";
  8909. /**
  8910. * Interface describing all the common properties and methods a shadow light needs to implement.
  8911. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8912. * as well as binding the different shadow properties to the effects.
  8913. */
  8914. export interface IShadowLight extends Light {
  8915. /**
  8916. * The light id in the scene (used in scene.findLighById for instance)
  8917. */
  8918. id: string;
  8919. /**
  8920. * The position the shdow will be casted from.
  8921. */
  8922. position: Vector3;
  8923. /**
  8924. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8925. */
  8926. direction: Vector3;
  8927. /**
  8928. * The transformed position. Position of the light in world space taking parenting in account.
  8929. */
  8930. transformedPosition: Vector3;
  8931. /**
  8932. * The transformed direction. Direction of the light in world space taking parenting in account.
  8933. */
  8934. transformedDirection: Vector3;
  8935. /**
  8936. * The friendly name of the light in the scene.
  8937. */
  8938. name: string;
  8939. /**
  8940. * Defines the shadow projection clipping minimum z value.
  8941. */
  8942. shadowMinZ: number;
  8943. /**
  8944. * Defines the shadow projection clipping maximum z value.
  8945. */
  8946. shadowMaxZ: number;
  8947. /**
  8948. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8949. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8950. */
  8951. computeTransformedInformation(): boolean;
  8952. /**
  8953. * Gets the scene the light belongs to.
  8954. * @returns The scene
  8955. */
  8956. getScene(): Scene;
  8957. /**
  8958. * Callback defining a custom Projection Matrix Builder.
  8959. * This can be used to override the default projection matrix computation.
  8960. */
  8961. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8962. /**
  8963. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8964. * @param matrix The materix to updated with the projection information
  8965. * @param viewMatrix The transform matrix of the light
  8966. * @param renderList The list of mesh to render in the map
  8967. * @returns The current light
  8968. */
  8969. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8970. /**
  8971. * Gets the current depth scale used in ESM.
  8972. * @returns The scale
  8973. */
  8974. getDepthScale(): number;
  8975. /**
  8976. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8977. * @returns true if a cube texture needs to be use
  8978. */
  8979. needCube(): boolean;
  8980. /**
  8981. * Detects if the projection matrix requires to be recomputed this frame.
  8982. * @returns true if it requires to be recomputed otherwise, false.
  8983. */
  8984. needProjectionMatrixCompute(): boolean;
  8985. /**
  8986. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8987. */
  8988. forceProjectionMatrixCompute(): void;
  8989. /**
  8990. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8991. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8992. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8993. */
  8994. getShadowDirection(faceIndex?: number): Vector3;
  8995. /**
  8996. * Gets the minZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the min for
  8998. * @returns the depth min z
  8999. */
  9000. getDepthMinZ(activeCamera: Camera): number;
  9001. /**
  9002. * Gets the maxZ used for shadow according to both the scene and the light.
  9003. * @param activeCamera The camera we are returning the max for
  9004. * @returns the depth max z
  9005. */
  9006. getDepthMaxZ(activeCamera: Camera): number;
  9007. }
  9008. /**
  9009. * Base implementation IShadowLight
  9010. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9011. */
  9012. export abstract class ShadowLight extends Light implements IShadowLight {
  9013. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9014. protected _position: Vector3;
  9015. protected _setPosition(value: Vector3): void;
  9016. /**
  9017. * Sets the position the shadow will be casted from. Also use as the light position for both
  9018. * point and spot lights.
  9019. */
  9020. get position(): Vector3;
  9021. /**
  9022. * Sets the position the shadow will be casted from. Also use as the light position for both
  9023. * point and spot lights.
  9024. */
  9025. set position(value: Vector3);
  9026. protected _direction: Vector3;
  9027. protected _setDirection(value: Vector3): void;
  9028. /**
  9029. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9030. * Also use as the light direction on spot and directional lights.
  9031. */
  9032. get direction(): Vector3;
  9033. /**
  9034. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9035. * Also use as the light direction on spot and directional lights.
  9036. */
  9037. set direction(value: Vector3);
  9038. protected _shadowMinZ: number;
  9039. /**
  9040. * Gets the shadow projection clipping minimum z value.
  9041. */
  9042. get shadowMinZ(): number;
  9043. /**
  9044. * Sets the shadow projection clipping minimum z value.
  9045. */
  9046. set shadowMinZ(value: number);
  9047. protected _shadowMaxZ: number;
  9048. /**
  9049. * Sets the shadow projection clipping maximum z value.
  9050. */
  9051. get shadowMaxZ(): number;
  9052. /**
  9053. * Gets the shadow projection clipping maximum z value.
  9054. */
  9055. set shadowMaxZ(value: number);
  9056. /**
  9057. * Callback defining a custom Projection Matrix Builder.
  9058. * This can be used to override the default projection matrix computation.
  9059. */
  9060. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9061. /**
  9062. * The transformed position. Position of the light in world space taking parenting in account.
  9063. */
  9064. transformedPosition: Vector3;
  9065. /**
  9066. * The transformed direction. Direction of the light in world space taking parenting in account.
  9067. */
  9068. transformedDirection: Vector3;
  9069. private _needProjectionMatrixCompute;
  9070. /**
  9071. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9072. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9073. */
  9074. computeTransformedInformation(): boolean;
  9075. /**
  9076. * Return the depth scale used for the shadow map.
  9077. * @returns the depth scale.
  9078. */
  9079. getDepthScale(): number;
  9080. /**
  9081. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9082. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9083. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9084. */
  9085. getShadowDirection(faceIndex?: number): Vector3;
  9086. /**
  9087. * Returns the ShadowLight absolute position in the World.
  9088. * @returns the position vector in world space
  9089. */
  9090. getAbsolutePosition(): Vector3;
  9091. /**
  9092. * Sets the ShadowLight direction toward the passed target.
  9093. * @param target The point to target in local space
  9094. * @returns the updated ShadowLight direction
  9095. */
  9096. setDirectionToTarget(target: Vector3): Vector3;
  9097. /**
  9098. * Returns the light rotation in euler definition.
  9099. * @returns the x y z rotation in local space.
  9100. */
  9101. getRotation(): Vector3;
  9102. /**
  9103. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9104. * @returns true if a cube texture needs to be use
  9105. */
  9106. needCube(): boolean;
  9107. /**
  9108. * Detects if the projection matrix requires to be recomputed this frame.
  9109. * @returns true if it requires to be recomputed otherwise, false.
  9110. */
  9111. needProjectionMatrixCompute(): boolean;
  9112. /**
  9113. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9114. */
  9115. forceProjectionMatrixCompute(): void;
  9116. /** @hidden */
  9117. _initCache(): void;
  9118. /** @hidden */
  9119. _isSynchronized(): boolean;
  9120. /**
  9121. * Computes the world matrix of the node
  9122. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9123. * @returns the world matrix
  9124. */
  9125. computeWorldMatrix(force?: boolean): Matrix;
  9126. /**
  9127. * Gets the minZ used for shadow according to both the scene and the light.
  9128. * @param activeCamera The camera we are returning the min for
  9129. * @returns the depth min z
  9130. */
  9131. getDepthMinZ(activeCamera: Camera): number;
  9132. /**
  9133. * Gets the maxZ used for shadow according to both the scene and the light.
  9134. * @param activeCamera The camera we are returning the max for
  9135. * @returns the depth max z
  9136. */
  9137. getDepthMaxZ(activeCamera: Camera): number;
  9138. /**
  9139. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9140. * @param matrix The materix to updated with the projection information
  9141. * @param viewMatrix The transform matrix of the light
  9142. * @param renderList The list of mesh to render in the map
  9143. * @returns The current light
  9144. */
  9145. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9146. }
  9147. }
  9148. declare module "babylonjs/Materials/effectFallbacks" {
  9149. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9150. import { Effect } from "babylonjs/Materials/effect";
  9151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9152. /**
  9153. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9154. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9155. */
  9156. export class EffectFallbacks implements IEffectFallbacks {
  9157. private _defines;
  9158. private _currentRank;
  9159. private _maxRank;
  9160. private _mesh;
  9161. /**
  9162. * Removes the fallback from the bound mesh.
  9163. */
  9164. unBindMesh(): void;
  9165. /**
  9166. * Adds a fallback on the specified property.
  9167. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9168. * @param define The name of the define in the shader
  9169. */
  9170. addFallback(rank: number, define: string): void;
  9171. /**
  9172. * Sets the mesh to use CPU skinning when needing to fallback.
  9173. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9174. * @param mesh The mesh to use the fallbacks.
  9175. */
  9176. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9177. /**
  9178. * Checks to see if more fallbacks are still availible.
  9179. */
  9180. get hasMoreFallbacks(): boolean;
  9181. /**
  9182. * Removes the defines that should be removed when falling back.
  9183. * @param currentDefines defines the current define statements for the shader.
  9184. * @param effect defines the current effect we try to compile
  9185. * @returns The resulting defines with defines of the current rank removed.
  9186. */
  9187. reduce(currentDefines: string, effect: Effect): string;
  9188. }
  9189. }
  9190. declare module "babylonjs/Materials/materialHelper" {
  9191. import { Nullable } from "babylonjs/types";
  9192. import { Scene } from "babylonjs/scene";
  9193. import { Engine } from "babylonjs/Engines/engine";
  9194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9195. import { Light } from "babylonjs/Lights/light";
  9196. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9197. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9199. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9200. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9201. /**
  9202. * "Static Class" containing the most commonly used helper while dealing with material for
  9203. * rendering purpose.
  9204. *
  9205. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9206. *
  9207. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9208. */
  9209. export class MaterialHelper {
  9210. /**
  9211. * Bind the current view position to an effect.
  9212. * @param effect The effect to be bound
  9213. * @param scene The scene the eyes position is used from
  9214. */
  9215. static BindEyePosition(effect: Effect, scene: Scene): void;
  9216. /**
  9217. * Helps preparing the defines values about the UVs in used in the effect.
  9218. * UVs are shared as much as we can accross channels in the shaders.
  9219. * @param texture The texture we are preparing the UVs for
  9220. * @param defines The defines to update
  9221. * @param key The channel key "diffuse", "specular"... used in the shader
  9222. */
  9223. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9224. /**
  9225. * Binds a texture matrix value to its corrsponding uniform
  9226. * @param texture The texture to bind the matrix for
  9227. * @param uniformBuffer The uniform buffer receivin the data
  9228. * @param key The channel key "diffuse", "specular"... used in the shader
  9229. */
  9230. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9231. /**
  9232. * Gets the current status of the fog (should it be enabled?)
  9233. * @param mesh defines the mesh to evaluate for fog support
  9234. * @param scene defines the hosting scene
  9235. * @returns true if fog must be enabled
  9236. */
  9237. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9238. /**
  9239. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9240. * @param mesh defines the current mesh
  9241. * @param scene defines the current scene
  9242. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9243. * @param pointsCloud defines if point cloud rendering has to be turned on
  9244. * @param fogEnabled defines if fog has to be turned on
  9245. * @param alphaTest defines if alpha testing has to be turned on
  9246. * @param defines defines the current list of defines
  9247. */
  9248. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9249. /**
  9250. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9251. * @param scene defines the current scene
  9252. * @param engine defines the current engine
  9253. * @param defines specifies the list of active defines
  9254. * @param useInstances defines if instances have to be turned on
  9255. * @param useClipPlane defines if clip plane have to be turned on
  9256. */
  9257. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9258. /**
  9259. * Prepares the defines for bones
  9260. * @param mesh The mesh containing the geometry data we will draw
  9261. * @param defines The defines to update
  9262. */
  9263. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9264. /**
  9265. * Prepares the defines for morph targets
  9266. * @param mesh The mesh containing the geometry data we will draw
  9267. * @param defines The defines to update
  9268. */
  9269. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9270. /**
  9271. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9272. * @param mesh The mesh containing the geometry data we will draw
  9273. * @param defines The defines to update
  9274. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9275. * @param useBones Precise whether bones should be used or not (override mesh info)
  9276. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9277. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9278. * @returns false if defines are considered not dirty and have not been checked
  9279. */
  9280. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9281. /**
  9282. * Prepares the defines related to multiview
  9283. * @param scene The scene we are intending to draw
  9284. * @param defines The defines to update
  9285. */
  9286. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9287. /**
  9288. * Prepares the defines related to the light information passed in parameter
  9289. * @param scene The scene we are intending to draw
  9290. * @param mesh The mesh the effect is compiling for
  9291. * @param light The light the effect is compiling for
  9292. * @param lightIndex The index of the light
  9293. * @param defines The defines to update
  9294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9295. * @param state Defines the current state regarding what is needed (normals, etc...)
  9296. */
  9297. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9298. needNormals: boolean;
  9299. needRebuild: boolean;
  9300. shadowEnabled: boolean;
  9301. specularEnabled: boolean;
  9302. lightmapMode: boolean;
  9303. }): void;
  9304. /**
  9305. * Prepares the defines related to the light information passed in parameter
  9306. * @param scene The scene we are intending to draw
  9307. * @param mesh The mesh the effect is compiling for
  9308. * @param defines The defines to update
  9309. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9310. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9311. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9312. * @returns true if normals will be required for the rest of the effect
  9313. */
  9314. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9315. /**
  9316. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9317. * @param lightIndex defines the light index
  9318. * @param uniformsList The uniform list
  9319. * @param samplersList The sampler list
  9320. * @param projectedLightTexture defines if projected texture must be used
  9321. * @param uniformBuffersList defines an optional list of uniform buffers
  9322. */
  9323. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9324. /**
  9325. * Prepares the uniforms and samplers list to be used in the effect
  9326. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9327. * @param samplersList The sampler list
  9328. * @param defines The defines helping in the list generation
  9329. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9330. */
  9331. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9332. /**
  9333. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9334. * @param defines The defines to update while falling back
  9335. * @param fallbacks The authorized effect fallbacks
  9336. * @param maxSimultaneousLights The maximum number of lights allowed
  9337. * @param rank the current rank of the Effect
  9338. * @returns The newly affected rank
  9339. */
  9340. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9341. private static _TmpMorphInfluencers;
  9342. /**
  9343. * Prepares the list of attributes required for morph targets according to the effect defines.
  9344. * @param attribs The current list of supported attribs
  9345. * @param mesh The mesh to prepare the morph targets attributes for
  9346. * @param influencers The number of influencers
  9347. */
  9348. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9349. /**
  9350. * Prepares the list of attributes required for morph targets according to the effect defines.
  9351. * @param attribs The current list of supported attribs
  9352. * @param mesh The mesh to prepare the morph targets attributes for
  9353. * @param defines The current Defines of the effect
  9354. */
  9355. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9356. /**
  9357. * Prepares the list of attributes required for bones according to the effect defines.
  9358. * @param attribs The current list of supported attribs
  9359. * @param mesh The mesh to prepare the bones attributes for
  9360. * @param defines The current Defines of the effect
  9361. * @param fallbacks The current efffect fallback strategy
  9362. */
  9363. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9364. /**
  9365. * Check and prepare the list of attributes required for instances according to the effect defines.
  9366. * @param attribs The current list of supported attribs
  9367. * @param defines The current MaterialDefines of the effect
  9368. */
  9369. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9370. /**
  9371. * Add the list of attributes required for instances to the attribs array.
  9372. * @param attribs The current list of supported attribs
  9373. */
  9374. static PushAttributesForInstances(attribs: string[]): void;
  9375. /**
  9376. * Binds the light information to the effect.
  9377. * @param light The light containing the generator
  9378. * @param effect The effect we are binding the data to
  9379. * @param lightIndex The light index in the effect used to render
  9380. */
  9381. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9382. /**
  9383. * Binds the lights information from the scene to the effect for the given mesh.
  9384. * @param light Light to bind
  9385. * @param lightIndex Light index
  9386. * @param scene The scene where the light belongs to
  9387. * @param effect The effect we are binding the data to
  9388. * @param useSpecular Defines if specular is supported
  9389. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9390. */
  9391. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9392. /**
  9393. * Binds the lights information from the scene to the effect for the given mesh.
  9394. * @param scene The scene the lights belongs to
  9395. * @param mesh The mesh we are binding the information to render
  9396. * @param effect The effect we are binding the data to
  9397. * @param defines The generated defines for the effect
  9398. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9399. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9400. */
  9401. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9402. private static _tempFogColor;
  9403. /**
  9404. * Binds the fog information from the scene to the effect for the given mesh.
  9405. * @param scene The scene the lights belongs to
  9406. * @param mesh The mesh we are binding the information to render
  9407. * @param effect The effect we are binding the data to
  9408. * @param linearSpace Defines if the fog effect is applied in linear space
  9409. */
  9410. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9411. /**
  9412. * Binds the bones information from the mesh to the effect.
  9413. * @param mesh The mesh we are binding the information to render
  9414. * @param effect The effect we are binding the data to
  9415. */
  9416. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9417. /**
  9418. * Binds the morph targets information from the mesh to the effect.
  9419. * @param abstractMesh The mesh we are binding the information to render
  9420. * @param effect The effect we are binding the data to
  9421. */
  9422. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9423. /**
  9424. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9425. * @param defines The generated defines used in the effect
  9426. * @param effect The effect we are binding the data to
  9427. * @param scene The scene we are willing to render with logarithmic scale for
  9428. */
  9429. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9430. /**
  9431. * Binds the clip plane information from the scene to the effect.
  9432. * @param scene The scene the clip plane information are extracted from
  9433. * @param effect The effect we are binding the data to
  9434. */
  9435. static BindClipPlane(effect: Effect, scene: Scene): void;
  9436. }
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9439. /** @hidden */
  9440. export var packingFunctions: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9446. /** @hidden */
  9447. export var clipPlaneFragmentDeclaration: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9453. /** @hidden */
  9454. export var clipPlaneFragment: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9460. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9461. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9463. /** @hidden */
  9464. export var shadowMapPixelShader: {
  9465. name: string;
  9466. shader: string;
  9467. };
  9468. }
  9469. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9470. /** @hidden */
  9471. export var bonesDeclaration: {
  9472. name: string;
  9473. shader: string;
  9474. };
  9475. }
  9476. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9477. /** @hidden */
  9478. export var morphTargetsVertexGlobalDeclaration: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9484. /** @hidden */
  9485. export var morphTargetsVertexDeclaration: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9491. /** @hidden */
  9492. export var instancesDeclaration: {
  9493. name: string;
  9494. shader: string;
  9495. };
  9496. }
  9497. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9498. /** @hidden */
  9499. export var helperFunctions: {
  9500. name: string;
  9501. shader: string;
  9502. };
  9503. }
  9504. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9505. /** @hidden */
  9506. export var clipPlaneVertexDeclaration: {
  9507. name: string;
  9508. shader: string;
  9509. };
  9510. }
  9511. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9512. /** @hidden */
  9513. export var morphTargetsVertex: {
  9514. name: string;
  9515. shader: string;
  9516. };
  9517. }
  9518. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9519. /** @hidden */
  9520. export var instancesVertex: {
  9521. name: string;
  9522. shader: string;
  9523. };
  9524. }
  9525. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9526. /** @hidden */
  9527. export var bonesVertex: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9533. /** @hidden */
  9534. export var clipPlaneVertex: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9540. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9543. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9544. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9545. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9549. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9550. /** @hidden */
  9551. export var shadowMapVertexShader: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9557. /** @hidden */
  9558. export var depthBoxBlurPixelShader: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9564. import { SmartArray } from "babylonjs/Misc/smartArray";
  9565. import { Nullable } from "babylonjs/types";
  9566. import { Scene } from "babylonjs/scene";
  9567. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9570. import { Mesh } from "babylonjs/Meshes/mesh";
  9571. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9572. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9573. import { Effect } from "babylonjs/Materials/effect";
  9574. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9575. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  9576. import "babylonjs/Shaders/shadowMap.fragment";
  9577. import "babylonjs/Shaders/shadowMap.vertex";
  9578. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9579. import { Observable } from "babylonjs/Misc/observable";
  9580. /**
  9581. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9582. */
  9583. export interface ICustomShaderOptions {
  9584. /**
  9585. * Gets or sets the custom shader name to use
  9586. */
  9587. shaderName: string;
  9588. /**
  9589. * The list of attribute names used in the shader
  9590. */
  9591. attributes?: string[];
  9592. /**
  9593. * The list of unifrom names used in the shader
  9594. */
  9595. uniforms?: string[];
  9596. /**
  9597. * The list of sampler names used in the shader
  9598. */
  9599. samplers?: string[];
  9600. /**
  9601. * The list of defines used in the shader
  9602. */
  9603. defines?: string[];
  9604. }
  9605. /**
  9606. * Interface to implement to create a shadow generator compatible with BJS.
  9607. */
  9608. export interface IShadowGenerator {
  9609. /**
  9610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9611. * @returns The render target texture if present otherwise, null
  9612. */
  9613. getShadowMap(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9616. * @param subMesh The submesh we want to render in the shadow map
  9617. * @param useInstances Defines wether will draw in the map using instances
  9618. * @returns true if ready otherwise, false
  9619. */
  9620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9621. /**
  9622. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9623. * @param defines Defines of the material we want to update
  9624. * @param lightIndex Index of the light in the enabled light list of the material
  9625. */
  9626. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9627. /**
  9628. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9629. * defined in the generator but impacting the effect).
  9630. * It implies the unifroms available on the materials are the standard BJS ones.
  9631. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9632. * @param effect The effect we are binfing the information for
  9633. */
  9634. bindShadowLight(lightIndex: string, effect: Effect): void;
  9635. /**
  9636. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9637. * (eq to shadow prjection matrix * light transform matrix)
  9638. * @returns The transform matrix used to create the shadow map
  9639. */
  9640. getTransformMatrix(): Matrix;
  9641. /**
  9642. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9643. * Cube and 2D textures for instance.
  9644. */
  9645. recreateShadowMap(): void;
  9646. /**
  9647. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9648. * @param onCompiled Callback triggered at the and of the effects compilation
  9649. * @param options Sets of optional options forcing the compilation with different modes
  9650. */
  9651. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9652. useInstances: boolean;
  9653. }>): void;
  9654. /**
  9655. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9656. * @param options Sets of optional options forcing the compilation with different modes
  9657. * @returns A promise that resolves when the compilation completes
  9658. */
  9659. forceCompilationAsync(options?: Partial<{
  9660. useInstances: boolean;
  9661. }>): Promise<void>;
  9662. /**
  9663. * Serializes the shadow generator setup to a json object.
  9664. * @returns The serialized JSON object
  9665. */
  9666. serialize(): any;
  9667. /**
  9668. * Disposes the Shadow map and related Textures and effects.
  9669. */
  9670. dispose(): void;
  9671. }
  9672. /**
  9673. * Default implementation IShadowGenerator.
  9674. * This is the main object responsible of generating shadows in the framework.
  9675. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9676. */
  9677. export class ShadowGenerator implements IShadowGenerator {
  9678. /**
  9679. * Name of the shadow generator class
  9680. */
  9681. static CLASSNAME: string;
  9682. /**
  9683. * Shadow generator mode None: no filtering applied.
  9684. */
  9685. static readonly FILTER_NONE: number;
  9686. /**
  9687. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9688. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9689. */
  9690. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9691. /**
  9692. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9693. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9694. */
  9695. static readonly FILTER_POISSONSAMPLING: number;
  9696. /**
  9697. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9698. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9699. */
  9700. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9701. /**
  9702. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9703. * edge artifacts on steep falloff.
  9704. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9705. */
  9706. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9707. /**
  9708. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9709. * edge artifacts on steep falloff.
  9710. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9711. */
  9712. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9713. /**
  9714. * Shadow generator mode PCF: Percentage Closer Filtering
  9715. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9716. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9717. */
  9718. static readonly FILTER_PCF: number;
  9719. /**
  9720. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9721. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9722. * Contact Hardening
  9723. */
  9724. static readonly FILTER_PCSS: number;
  9725. /**
  9726. * Reserved for PCF and PCSS
  9727. * Highest Quality.
  9728. *
  9729. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9730. *
  9731. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9732. */
  9733. static readonly QUALITY_HIGH: number;
  9734. /**
  9735. * Reserved for PCF and PCSS
  9736. * Good tradeoff for quality/perf cross devices
  9737. *
  9738. * Execute PCF on a 3*3 kernel.
  9739. *
  9740. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9741. */
  9742. static readonly QUALITY_MEDIUM: number;
  9743. /**
  9744. * Reserved for PCF and PCSS
  9745. * The lowest quality but the fastest.
  9746. *
  9747. * Execute PCF on a 1*1 kernel.
  9748. *
  9749. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9750. */
  9751. static readonly QUALITY_LOW: number;
  9752. /** Gets or sets the custom shader name to use */
  9753. customShaderOptions: ICustomShaderOptions;
  9754. /**
  9755. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9756. */
  9757. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9758. /**
  9759. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9760. */
  9761. onAfterShadowMapRenderObservable: Observable<Effect>;
  9762. /**
  9763. * Observable triggered before a mesh is rendered in the shadow map.
  9764. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9765. */
  9766. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9767. /**
  9768. * Observable triggered after a mesh is rendered in the shadow map.
  9769. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9770. */
  9771. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9772. protected _bias: number;
  9773. /**
  9774. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9775. */
  9776. get bias(): number;
  9777. /**
  9778. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9779. */
  9780. set bias(bias: number);
  9781. protected _normalBias: number;
  9782. /**
  9783. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9784. */
  9785. get normalBias(): number;
  9786. /**
  9787. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9788. */
  9789. set normalBias(normalBias: number);
  9790. protected _blurBoxOffset: number;
  9791. /**
  9792. * Gets the blur box offset: offset applied during the blur pass.
  9793. * Only useful if useKernelBlur = false
  9794. */
  9795. get blurBoxOffset(): number;
  9796. /**
  9797. * Sets the blur box offset: offset applied during the blur pass.
  9798. * Only useful if useKernelBlur = false
  9799. */
  9800. set blurBoxOffset(value: number);
  9801. protected _blurScale: number;
  9802. /**
  9803. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9804. * 2 means half of the size.
  9805. */
  9806. get blurScale(): number;
  9807. /**
  9808. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9809. * 2 means half of the size.
  9810. */
  9811. set blurScale(value: number);
  9812. protected _blurKernel: number;
  9813. /**
  9814. * Gets the blur kernel: kernel size of the blur pass.
  9815. * Only useful if useKernelBlur = true
  9816. */
  9817. get blurKernel(): number;
  9818. /**
  9819. * Sets the blur kernel: kernel size of the blur pass.
  9820. * Only useful if useKernelBlur = true
  9821. */
  9822. set blurKernel(value: number);
  9823. protected _useKernelBlur: boolean;
  9824. /**
  9825. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9826. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9827. */
  9828. get useKernelBlur(): boolean;
  9829. /**
  9830. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9831. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9832. */
  9833. set useKernelBlur(value: boolean);
  9834. protected _depthScale: number;
  9835. /**
  9836. * Gets the depth scale used in ESM mode.
  9837. */
  9838. get depthScale(): number;
  9839. /**
  9840. * Sets the depth scale used in ESM mode.
  9841. * This can override the scale stored on the light.
  9842. */
  9843. set depthScale(value: number);
  9844. protected _validateFilter(filter: number): number;
  9845. protected _filter: number;
  9846. /**
  9847. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9848. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9849. */
  9850. get filter(): number;
  9851. /**
  9852. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9853. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9854. */
  9855. set filter(value: number);
  9856. /**
  9857. * Gets if the current filter is set to Poisson Sampling.
  9858. */
  9859. get usePoissonSampling(): boolean;
  9860. /**
  9861. * Sets the current filter to Poisson Sampling.
  9862. */
  9863. set usePoissonSampling(value: boolean);
  9864. /**
  9865. * Gets if the current filter is set to ESM.
  9866. */
  9867. get useExponentialShadowMap(): boolean;
  9868. /**
  9869. * Sets the current filter is to ESM.
  9870. */
  9871. set useExponentialShadowMap(value: boolean);
  9872. /**
  9873. * Gets if the current filter is set to filtered ESM.
  9874. */
  9875. get useBlurExponentialShadowMap(): boolean;
  9876. /**
  9877. * Gets if the current filter is set to filtered ESM.
  9878. */
  9879. set useBlurExponentialShadowMap(value: boolean);
  9880. /**
  9881. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9882. * exponential to prevent steep falloff artifacts).
  9883. */
  9884. get useCloseExponentialShadowMap(): boolean;
  9885. /**
  9886. * Sets the current filter to "close ESM" (using the inverse of the
  9887. * exponential to prevent steep falloff artifacts).
  9888. */
  9889. set useCloseExponentialShadowMap(value: boolean);
  9890. /**
  9891. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9892. * exponential to prevent steep falloff artifacts).
  9893. */
  9894. get useBlurCloseExponentialShadowMap(): boolean;
  9895. /**
  9896. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9897. * exponential to prevent steep falloff artifacts).
  9898. */
  9899. set useBlurCloseExponentialShadowMap(value: boolean);
  9900. /**
  9901. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9902. */
  9903. get usePercentageCloserFiltering(): boolean;
  9904. /**
  9905. * Sets the current filter to "PCF" (percentage closer filtering).
  9906. */
  9907. set usePercentageCloserFiltering(value: boolean);
  9908. protected _filteringQuality: number;
  9909. /**
  9910. * Gets the PCF or PCSS Quality.
  9911. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9912. */
  9913. get filteringQuality(): number;
  9914. /**
  9915. * Sets the PCF or PCSS Quality.
  9916. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9917. */
  9918. set filteringQuality(filteringQuality: number);
  9919. /**
  9920. * Gets if the current filter is set to "PCSS" (contact hardening).
  9921. */
  9922. get useContactHardeningShadow(): boolean;
  9923. /**
  9924. * Sets the current filter to "PCSS" (contact hardening).
  9925. */
  9926. set useContactHardeningShadow(value: boolean);
  9927. protected _contactHardeningLightSizeUVRatio: number;
  9928. /**
  9929. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9930. * Using a ratio helps keeping shape stability independently of the map size.
  9931. *
  9932. * It does not account for the light projection as it was having too much
  9933. * instability during the light setup or during light position changes.
  9934. *
  9935. * Only valid if useContactHardeningShadow is true.
  9936. */
  9937. get contactHardeningLightSizeUVRatio(): number;
  9938. /**
  9939. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9940. * Using a ratio helps keeping shape stability independently of the map size.
  9941. *
  9942. * It does not account for the light projection as it was having too much
  9943. * instability during the light setup or during light position changes.
  9944. *
  9945. * Only valid if useContactHardeningShadow is true.
  9946. */
  9947. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9948. protected _darkness: number;
  9949. /** Gets or sets the actual darkness of a shadow */
  9950. get darkness(): number;
  9951. set darkness(value: number);
  9952. /**
  9953. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9954. * 0 means strongest and 1 would means no shadow.
  9955. * @returns the darkness.
  9956. */
  9957. getDarkness(): number;
  9958. /**
  9959. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9960. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9961. * @returns the shadow generator allowing fluent coding.
  9962. */
  9963. setDarkness(darkness: number): ShadowGenerator;
  9964. protected _transparencyShadow: boolean;
  9965. /** Gets or sets the ability to have transparent shadow */
  9966. get transparencyShadow(): boolean;
  9967. set transparencyShadow(value: boolean);
  9968. /**
  9969. * Sets the ability to have transparent shadow (boolean).
  9970. * @param transparent True if transparent else False
  9971. * @returns the shadow generator allowing fluent coding
  9972. */
  9973. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9974. protected _shadowMap: Nullable<RenderTargetTexture>;
  9975. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9976. /**
  9977. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9978. * @returns The render target texture if present otherwise, null
  9979. */
  9980. getShadowMap(): Nullable<RenderTargetTexture>;
  9981. /**
  9982. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9983. * @returns The render target texture if the shadow map is present otherwise, null
  9984. */
  9985. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9986. /**
  9987. * Gets the class name of that object
  9988. * @returns "ShadowGenerator"
  9989. */
  9990. getClassName(): string;
  9991. /**
  9992. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9993. * @param mesh Mesh to add
  9994. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9995. * @returns the Shadow Generator itself
  9996. */
  9997. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9998. /**
  9999. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10000. * @param mesh Mesh to remove
  10001. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10002. * @returns the Shadow Generator itself
  10003. */
  10004. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10005. /**
  10006. * Controls the extent to which the shadows fade out at the edge of the frustum
  10007. */
  10008. frustumEdgeFalloff: number;
  10009. protected _light: IShadowLight;
  10010. /**
  10011. * Returns the associated light object.
  10012. * @returns the light generating the shadow
  10013. */
  10014. getLight(): IShadowLight;
  10015. /**
  10016. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10017. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10018. * It might on the other hand introduce peter panning.
  10019. */
  10020. forceBackFacesOnly: boolean;
  10021. protected _scene: Scene;
  10022. protected _lightDirection: Vector3;
  10023. protected _effect: Effect;
  10024. protected _viewMatrix: Matrix;
  10025. protected _projectionMatrix: Matrix;
  10026. protected _transformMatrix: Matrix;
  10027. protected _cachedPosition: Vector3;
  10028. protected _cachedDirection: Vector3;
  10029. protected _cachedDefines: string;
  10030. protected _currentRenderID: number;
  10031. protected _boxBlurPostprocess: Nullable<PostProcess>;
  10032. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  10033. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  10034. protected _blurPostProcesses: PostProcess[];
  10035. protected _mapSize: number;
  10036. protected _currentFaceIndex: number;
  10037. protected _currentFaceIndexCache: number;
  10038. protected _textureType: number;
  10039. protected _defaultTextureMatrix: Matrix;
  10040. protected _storedUniqueId: Nullable<number>;
  10041. /** @hidden */
  10042. static _SceneComponentInitialization: (scene: Scene) => void;
  10043. /**
  10044. * Creates a ShadowGenerator object.
  10045. * A ShadowGenerator is the required tool to use the shadows.
  10046. * Each light casting shadows needs to use its own ShadowGenerator.
  10047. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10048. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10049. * @param light The light object generating the shadows.
  10050. * @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.
  10051. */
  10052. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10053. protected _initializeGenerator(): void;
  10054. protected _createTargetRenderTexture(): void;
  10055. protected _initializeShadowMap(): void;
  10056. protected _initializeBlurRTTAndPostProcesses(): void;
  10057. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  10058. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  10059. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  10060. protected _applyFilterValues(): void;
  10061. /**
  10062. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10063. * @param onCompiled Callback triggered at the and of the effects compilation
  10064. * @param options Sets of optional options forcing the compilation with different modes
  10065. */
  10066. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  10067. useInstances: boolean;
  10068. }>): void;
  10069. /**
  10070. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10071. * @param options Sets of optional options forcing the compilation with different modes
  10072. * @returns A promise that resolves when the compilation completes
  10073. */
  10074. forceCompilationAsync(options?: Partial<{
  10075. useInstances: boolean;
  10076. }>): Promise<void>;
  10077. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  10078. /**
  10079. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10080. * @param subMesh The submesh we want to render in the shadow map
  10081. * @param useInstances Defines wether will draw in the map using instances
  10082. * @returns true if ready otherwise, false
  10083. */
  10084. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10085. /**
  10086. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10087. * @param defines Defines of the material we want to update
  10088. * @param lightIndex Index of the light in the enabled light list of the material
  10089. */
  10090. prepareDefines(defines: any, lightIndex: number): void;
  10091. /**
  10092. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10093. * defined in the generator but impacting the effect).
  10094. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10095. * @param effect The effect we are binfing the information for
  10096. */
  10097. bindShadowLight(lightIndex: string, effect: Effect): void;
  10098. /**
  10099. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10100. * (eq to shadow prjection matrix * light transform matrix)
  10101. * @returns The transform matrix used to create the shadow map
  10102. */
  10103. getTransformMatrix(): Matrix;
  10104. /**
  10105. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10106. * Cube and 2D textures for instance.
  10107. */
  10108. recreateShadowMap(): void;
  10109. protected _disposeBlurPostProcesses(): void;
  10110. protected _disposeRTTandPostProcesses(): void;
  10111. /**
  10112. * Disposes the ShadowGenerator.
  10113. * Returns nothing.
  10114. */
  10115. dispose(): void;
  10116. /**
  10117. * Serializes the shadow generator setup to a json object.
  10118. * @returns The serialized JSON object
  10119. */
  10120. serialize(): any;
  10121. /**
  10122. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10123. * @param parsedShadowGenerator The JSON object to parse
  10124. * @param scene The scene to create the shadow map for
  10125. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  10126. * @returns The parsed shadow generator
  10127. */
  10128. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  10129. }
  10130. }
  10131. declare module "babylonjs/Lights/light" {
  10132. import { Nullable } from "babylonjs/types";
  10133. import { Scene } from "babylonjs/scene";
  10134. import { Vector3 } from "babylonjs/Maths/math.vector";
  10135. import { Color3 } from "babylonjs/Maths/math.color";
  10136. import { Node } from "babylonjs/node";
  10137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10138. import { Effect } from "babylonjs/Materials/effect";
  10139. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10140. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10141. /**
  10142. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10143. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10144. * 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.
  10145. */
  10146. export abstract class Light extends Node {
  10147. /**
  10148. * Falloff Default: light is falling off following the material specification:
  10149. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10150. */
  10151. static readonly FALLOFF_DEFAULT: number;
  10152. /**
  10153. * Falloff Physical: light is falling off following the inverse squared distance law.
  10154. */
  10155. static readonly FALLOFF_PHYSICAL: number;
  10156. /**
  10157. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10158. * to enhance interoperability with other engines.
  10159. */
  10160. static readonly FALLOFF_GLTF: number;
  10161. /**
  10162. * Falloff Standard: light is falling off like in the standard material
  10163. * to enhance interoperability with other materials.
  10164. */
  10165. static readonly FALLOFF_STANDARD: number;
  10166. /**
  10167. * If every light affecting the material is in this lightmapMode,
  10168. * material.lightmapTexture adds or multiplies
  10169. * (depends on material.useLightmapAsShadowmap)
  10170. * after every other light calculations.
  10171. */
  10172. static readonly LIGHTMAP_DEFAULT: number;
  10173. /**
  10174. * material.lightmapTexture as only diffuse lighting from this light
  10175. * adds only specular lighting from this light
  10176. * adds dynamic shadows
  10177. */
  10178. static readonly LIGHTMAP_SPECULAR: number;
  10179. /**
  10180. * material.lightmapTexture as only lighting
  10181. * no light calculation from this light
  10182. * only adds dynamic shadows from this light
  10183. */
  10184. static readonly LIGHTMAP_SHADOWSONLY: number;
  10185. /**
  10186. * Each light type uses the default quantity according to its type:
  10187. * point/spot lights use luminous intensity
  10188. * directional lights use illuminance
  10189. */
  10190. static readonly INTENSITYMODE_AUTOMATIC: number;
  10191. /**
  10192. * lumen (lm)
  10193. */
  10194. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10195. /**
  10196. * candela (lm/sr)
  10197. */
  10198. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10199. /**
  10200. * lux (lm/m^2)
  10201. */
  10202. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10203. /**
  10204. * nit (cd/m^2)
  10205. */
  10206. static readonly INTENSITYMODE_LUMINANCE: number;
  10207. /**
  10208. * Light type const id of the point light.
  10209. */
  10210. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10211. /**
  10212. * Light type const id of the directional light.
  10213. */
  10214. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10215. /**
  10216. * Light type const id of the spot light.
  10217. */
  10218. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10219. /**
  10220. * Light type const id of the hemispheric light.
  10221. */
  10222. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10223. /**
  10224. * Diffuse gives the basic color to an object.
  10225. */
  10226. diffuse: Color3;
  10227. /**
  10228. * Specular produces a highlight color on an object.
  10229. * Note: This is note affecting PBR materials.
  10230. */
  10231. specular: Color3;
  10232. /**
  10233. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10234. * falling off base on range or angle.
  10235. * This can be set to any values in Light.FALLOFF_x.
  10236. *
  10237. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10238. * other types of materials.
  10239. */
  10240. falloffType: number;
  10241. /**
  10242. * Strength of the light.
  10243. * Note: By default it is define in the framework own unit.
  10244. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10245. */
  10246. intensity: number;
  10247. private _range;
  10248. protected _inverseSquaredRange: number;
  10249. /**
  10250. * Defines how far from the source the light is impacting in scene units.
  10251. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10252. */
  10253. get range(): number;
  10254. /**
  10255. * Defines how far from the source the light is impacting in scene units.
  10256. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10257. */
  10258. set range(value: number);
  10259. /**
  10260. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10261. * of light.
  10262. */
  10263. private _photometricScale;
  10264. private _intensityMode;
  10265. /**
  10266. * Gets the photometric scale used to interpret the intensity.
  10267. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10268. */
  10269. get intensityMode(): number;
  10270. /**
  10271. * Sets the photometric scale used to interpret the intensity.
  10272. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10273. */
  10274. set intensityMode(value: number);
  10275. private _radius;
  10276. /**
  10277. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10278. */
  10279. get radius(): number;
  10280. /**
  10281. * sets the light radius used by PBR Materials to simulate soft area lights.
  10282. */
  10283. set radius(value: number);
  10284. private _renderPriority;
  10285. /**
  10286. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10287. * exceeding the number allowed of the materials.
  10288. */
  10289. renderPriority: number;
  10290. private _shadowEnabled;
  10291. /**
  10292. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10293. * the current shadow generator.
  10294. */
  10295. get shadowEnabled(): boolean;
  10296. /**
  10297. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10298. * the current shadow generator.
  10299. */
  10300. set shadowEnabled(value: boolean);
  10301. private _includedOnlyMeshes;
  10302. /**
  10303. * Gets the only meshes impacted by this light.
  10304. */
  10305. get includedOnlyMeshes(): AbstractMesh[];
  10306. /**
  10307. * Sets the only meshes impacted by this light.
  10308. */
  10309. set includedOnlyMeshes(value: AbstractMesh[]);
  10310. private _excludedMeshes;
  10311. /**
  10312. * Gets the meshes not impacted by this light.
  10313. */
  10314. get excludedMeshes(): AbstractMesh[];
  10315. /**
  10316. * Sets the meshes not impacted by this light.
  10317. */
  10318. set excludedMeshes(value: AbstractMesh[]);
  10319. private _excludeWithLayerMask;
  10320. /**
  10321. * Gets the layer id use to find what meshes are not impacted by the light.
  10322. * Inactive if 0
  10323. */
  10324. get excludeWithLayerMask(): number;
  10325. /**
  10326. * Sets the layer id use to find what meshes are not impacted by the light.
  10327. * Inactive if 0
  10328. */
  10329. set excludeWithLayerMask(value: number);
  10330. private _includeOnlyWithLayerMask;
  10331. /**
  10332. * Gets the layer id use to find what meshes are impacted by the light.
  10333. * Inactive if 0
  10334. */
  10335. get includeOnlyWithLayerMask(): number;
  10336. /**
  10337. * Sets the layer id use to find what meshes are impacted by the light.
  10338. * Inactive if 0
  10339. */
  10340. set includeOnlyWithLayerMask(value: number);
  10341. private _lightmapMode;
  10342. /**
  10343. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10344. */
  10345. get lightmapMode(): number;
  10346. /**
  10347. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10348. */
  10349. set lightmapMode(value: number);
  10350. /**
  10351. * Shadow generator associted to the light.
  10352. * @hidden Internal use only.
  10353. */
  10354. _shadowGenerator: Nullable<IShadowGenerator>;
  10355. /**
  10356. * @hidden Internal use only.
  10357. */
  10358. _excludedMeshesIds: string[];
  10359. /**
  10360. * @hidden Internal use only.
  10361. */
  10362. _includedOnlyMeshesIds: string[];
  10363. /**
  10364. * The current light unifom buffer.
  10365. * @hidden Internal use only.
  10366. */
  10367. _uniformBuffer: UniformBuffer;
  10368. /** @hidden */
  10369. _renderId: number;
  10370. /**
  10371. * Creates a Light object in the scene.
  10372. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10373. * @param name The firendly name of the light
  10374. * @param scene The scene the light belongs too
  10375. */
  10376. constructor(name: string, scene: Scene);
  10377. protected abstract _buildUniformLayout(): void;
  10378. /**
  10379. * Sets the passed Effect "effect" with the Light information.
  10380. * @param effect The effect to update
  10381. * @param lightIndex The index of the light in the effect to update
  10382. * @returns The light
  10383. */
  10384. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10385. /**
  10386. * Sets the passed Effect "effect" with the Light textures.
  10387. * @param effect The effect to update
  10388. * @param lightIndex The index of the light in the effect to update
  10389. * @returns The light
  10390. */
  10391. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10392. /**
  10393. * Binds the lights information from the scene to the effect for the given mesh.
  10394. * @param lightIndex Light index
  10395. * @param scene The scene where the light belongs to
  10396. * @param effect The effect we are binding the data to
  10397. * @param useSpecular Defines if specular is supported
  10398. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10399. */
  10400. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10401. /**
  10402. * Sets the passed Effect "effect" with the Light information.
  10403. * @param effect The effect to update
  10404. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10405. * @returns The light
  10406. */
  10407. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10408. /**
  10409. * Returns the string "Light".
  10410. * @returns the class name
  10411. */
  10412. getClassName(): string;
  10413. /** @hidden */
  10414. readonly _isLight: boolean;
  10415. /**
  10416. * Converts the light information to a readable string for debug purpose.
  10417. * @param fullDetails Supports for multiple levels of logging within scene loading
  10418. * @returns the human readable light info
  10419. */
  10420. toString(fullDetails?: boolean): string;
  10421. /** @hidden */
  10422. protected _syncParentEnabledState(): void;
  10423. /**
  10424. * Set the enabled state of this node.
  10425. * @param value - the new enabled state
  10426. */
  10427. setEnabled(value: boolean): void;
  10428. /**
  10429. * Returns the Light associated shadow generator if any.
  10430. * @return the associated shadow generator.
  10431. */
  10432. getShadowGenerator(): Nullable<IShadowGenerator>;
  10433. /**
  10434. * Returns a Vector3, the absolute light position in the World.
  10435. * @returns the world space position of the light
  10436. */
  10437. getAbsolutePosition(): Vector3;
  10438. /**
  10439. * Specifies if the light will affect the passed mesh.
  10440. * @param mesh The mesh to test against the light
  10441. * @return true the mesh is affected otherwise, false.
  10442. */
  10443. canAffectMesh(mesh: AbstractMesh): boolean;
  10444. /**
  10445. * Sort function to order lights for rendering.
  10446. * @param a First Light object to compare to second.
  10447. * @param b Second Light object to compare first.
  10448. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10449. */
  10450. static CompareLightsPriority(a: Light, b: Light): number;
  10451. /**
  10452. * Releases resources associated with this node.
  10453. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10454. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10455. */
  10456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10457. /**
  10458. * Returns the light type ID (integer).
  10459. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10460. */
  10461. getTypeID(): number;
  10462. /**
  10463. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10464. * @returns the scaled intensity in intensity mode unit
  10465. */
  10466. getScaledIntensity(): number;
  10467. /**
  10468. * Returns a new Light object, named "name", from the current one.
  10469. * @param name The name of the cloned light
  10470. * @returns the new created light
  10471. */
  10472. clone(name: string): Nullable<Light>;
  10473. /**
  10474. * Serializes the current light into a Serialization object.
  10475. * @returns the serialized object.
  10476. */
  10477. serialize(): any;
  10478. /**
  10479. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10480. * This new light is named "name" and added to the passed scene.
  10481. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10482. * @param name The friendly name of the light
  10483. * @param scene The scene the new light will belong to
  10484. * @returns the constructor function
  10485. */
  10486. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10487. /**
  10488. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10489. * @param parsedLight The JSON representation of the light
  10490. * @param scene The scene to create the parsed light in
  10491. * @returns the created light after parsing
  10492. */
  10493. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10494. private _hookArrayForExcluded;
  10495. private _hookArrayForIncludedOnly;
  10496. private _resyncMeshes;
  10497. /**
  10498. * Forces the meshes to update their light related information in their rendering used effects
  10499. * @hidden Internal Use Only
  10500. */
  10501. _markMeshesAsLightDirty(): void;
  10502. /**
  10503. * Recomputes the cached photometric scale if needed.
  10504. */
  10505. private _computePhotometricScale;
  10506. /**
  10507. * Returns the Photometric Scale according to the light type and intensity mode.
  10508. */
  10509. private _getPhotometricScale;
  10510. /**
  10511. * Reorder the light in the scene according to their defined priority.
  10512. * @hidden Internal Use Only
  10513. */
  10514. _reorderLightsInScene(): void;
  10515. /**
  10516. * Prepares the list of defines specific to the light type.
  10517. * @param defines the list of defines
  10518. * @param lightIndex defines the index of the light for the effect
  10519. */
  10520. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10521. }
  10522. }
  10523. declare module "babylonjs/Actions/action" {
  10524. import { Observable } from "babylonjs/Misc/observable";
  10525. import { Condition } from "babylonjs/Actions/condition";
  10526. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10527. import { ActionManager } from "babylonjs/Actions/actionManager";
  10528. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10529. /**
  10530. * Interface used to define Action
  10531. */
  10532. export interface IAction {
  10533. /**
  10534. * Trigger for the action
  10535. */
  10536. trigger: number;
  10537. /** Options of the trigger */
  10538. triggerOptions: any;
  10539. /**
  10540. * Gets the trigger parameters
  10541. * @returns the trigger parameters
  10542. */
  10543. getTriggerParameter(): any;
  10544. /**
  10545. * Internal only - executes current action event
  10546. * @hidden
  10547. */
  10548. _executeCurrent(evt?: ActionEvent): void;
  10549. /**
  10550. * Serialize placeholder for child classes
  10551. * @param parent of child
  10552. * @returns the serialized object
  10553. */
  10554. serialize(parent: any): any;
  10555. /**
  10556. * Internal only
  10557. * @hidden
  10558. */
  10559. _prepare(): void;
  10560. /**
  10561. * Internal only - manager for action
  10562. * @hidden
  10563. */
  10564. _actionManager: AbstractActionManager;
  10565. /**
  10566. * Adds action to chain of actions, may be a DoNothingAction
  10567. * @param action defines the next action to execute
  10568. * @returns The action passed in
  10569. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10570. */
  10571. then(action: IAction): IAction;
  10572. }
  10573. /**
  10574. * The action to be carried out following a trigger
  10575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10576. */
  10577. export class Action implements IAction {
  10578. /** the trigger, with or without parameters, for the action */
  10579. triggerOptions: any;
  10580. /**
  10581. * Trigger for the action
  10582. */
  10583. trigger: number;
  10584. /**
  10585. * Internal only - manager for action
  10586. * @hidden
  10587. */
  10588. _actionManager: ActionManager;
  10589. private _nextActiveAction;
  10590. private _child;
  10591. private _condition?;
  10592. private _triggerParameter;
  10593. /**
  10594. * An event triggered prior to action being executed.
  10595. */
  10596. onBeforeExecuteObservable: Observable<Action>;
  10597. /**
  10598. * Creates a new Action
  10599. * @param triggerOptions the trigger, with or without parameters, for the action
  10600. * @param condition an optional determinant of action
  10601. */
  10602. constructor(
  10603. /** the trigger, with or without parameters, for the action */
  10604. triggerOptions: any, condition?: Condition);
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. _prepare(): void;
  10610. /**
  10611. * Gets the trigger parameters
  10612. * @returns the trigger parameters
  10613. */
  10614. getTriggerParameter(): any;
  10615. /**
  10616. * Internal only - executes current action event
  10617. * @hidden
  10618. */
  10619. _executeCurrent(evt?: ActionEvent): void;
  10620. /**
  10621. * Execute placeholder for child classes
  10622. * @param evt optional action event
  10623. */
  10624. execute(evt?: ActionEvent): void;
  10625. /**
  10626. * Skips to next active action
  10627. */
  10628. skipToNextActiveAction(): void;
  10629. /**
  10630. * Adds action to chain of actions, may be a DoNothingAction
  10631. * @param action defines the next action to execute
  10632. * @returns The action passed in
  10633. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10634. */
  10635. then(action: Action): Action;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. _getProperty(propertyPath: string): string;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. _getEffectiveTarget(target: any, propertyPath: string): any;
  10646. /**
  10647. * Serialize placeholder for child classes
  10648. * @param parent of child
  10649. * @returns the serialized object
  10650. */
  10651. serialize(parent: any): any;
  10652. /**
  10653. * Internal only called by serialize
  10654. * @hidden
  10655. */
  10656. protected _serialize(serializedAction: any, parent?: any): any;
  10657. /**
  10658. * Internal only
  10659. * @hidden
  10660. */
  10661. static _SerializeValueAsString: (value: any) => string;
  10662. /**
  10663. * Internal only
  10664. * @hidden
  10665. */
  10666. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10667. name: string;
  10668. targetType: string;
  10669. value: string;
  10670. };
  10671. }
  10672. }
  10673. declare module "babylonjs/Actions/condition" {
  10674. import { ActionManager } from "babylonjs/Actions/actionManager";
  10675. /**
  10676. * A Condition applied to an Action
  10677. */
  10678. export class Condition {
  10679. /**
  10680. * Internal only - manager for action
  10681. * @hidden
  10682. */
  10683. _actionManager: ActionManager;
  10684. /**
  10685. * Internal only
  10686. * @hidden
  10687. */
  10688. _evaluationId: number;
  10689. /**
  10690. * Internal only
  10691. * @hidden
  10692. */
  10693. _currentResult: boolean;
  10694. /**
  10695. * Creates a new Condition
  10696. * @param actionManager the manager of the action the condition is applied to
  10697. */
  10698. constructor(actionManager: ActionManager);
  10699. /**
  10700. * Check if the current condition is valid
  10701. * @returns a boolean
  10702. */
  10703. isValid(): boolean;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. _getProperty(propertyPath: string): string;
  10709. /**
  10710. * Internal only
  10711. * @hidden
  10712. */
  10713. _getEffectiveTarget(target: any, propertyPath: string): any;
  10714. /**
  10715. * Serialize placeholder for child classes
  10716. * @returns the serialized object
  10717. */
  10718. serialize(): any;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. protected _serialize(serializedCondition: any): any;
  10724. }
  10725. /**
  10726. * Defines specific conditional operators as extensions of Condition
  10727. */
  10728. export class ValueCondition extends Condition {
  10729. /** path to specify the property of the target the conditional operator uses */
  10730. propertyPath: string;
  10731. /** the value compared by the conditional operator against the current value of the property */
  10732. value: any;
  10733. /** the conditional operator, default ValueCondition.IsEqual */
  10734. operator: number;
  10735. /**
  10736. * Internal only
  10737. * @hidden
  10738. */
  10739. private static _IsEqual;
  10740. /**
  10741. * Internal only
  10742. * @hidden
  10743. */
  10744. private static _IsDifferent;
  10745. /**
  10746. * Internal only
  10747. * @hidden
  10748. */
  10749. private static _IsGreater;
  10750. /**
  10751. * Internal only
  10752. * @hidden
  10753. */
  10754. private static _IsLesser;
  10755. /**
  10756. * returns the number for IsEqual
  10757. */
  10758. static get IsEqual(): number;
  10759. /**
  10760. * Returns the number for IsDifferent
  10761. */
  10762. static get IsDifferent(): number;
  10763. /**
  10764. * Returns the number for IsGreater
  10765. */
  10766. static get IsGreater(): number;
  10767. /**
  10768. * Returns the number for IsLesser
  10769. */
  10770. static get IsLesser(): number;
  10771. /**
  10772. * Internal only The action manager for the condition
  10773. * @hidden
  10774. */
  10775. _actionManager: ActionManager;
  10776. /**
  10777. * Internal only
  10778. * @hidden
  10779. */
  10780. private _target;
  10781. /**
  10782. * Internal only
  10783. * @hidden
  10784. */
  10785. private _effectiveTarget;
  10786. /**
  10787. * Internal only
  10788. * @hidden
  10789. */
  10790. private _property;
  10791. /**
  10792. * Creates a new ValueCondition
  10793. * @param actionManager manager for the action the condition applies to
  10794. * @param target for the action
  10795. * @param propertyPath path to specify the property of the target the conditional operator uses
  10796. * @param value the value compared by the conditional operator against the current value of the property
  10797. * @param operator the conditional operator, default ValueCondition.IsEqual
  10798. */
  10799. constructor(actionManager: ActionManager, target: any,
  10800. /** path to specify the property of the target the conditional operator uses */
  10801. propertyPath: string,
  10802. /** the value compared by the conditional operator against the current value of the property */
  10803. value: any,
  10804. /** the conditional operator, default ValueCondition.IsEqual */
  10805. operator?: number);
  10806. /**
  10807. * Compares the given value with the property value for the specified conditional operator
  10808. * @returns the result of the comparison
  10809. */
  10810. isValid(): boolean;
  10811. /**
  10812. * Serialize the ValueCondition into a JSON compatible object
  10813. * @returns serialization object
  10814. */
  10815. serialize(): any;
  10816. /**
  10817. * Gets the name of the conditional operator for the ValueCondition
  10818. * @param operator the conditional operator
  10819. * @returns the name
  10820. */
  10821. static GetOperatorName(operator: number): string;
  10822. }
  10823. /**
  10824. * Defines a predicate condition as an extension of Condition
  10825. */
  10826. export class PredicateCondition extends Condition {
  10827. /** defines the predicate function used to validate the condition */
  10828. predicate: () => boolean;
  10829. /**
  10830. * Internal only - manager for action
  10831. * @hidden
  10832. */
  10833. _actionManager: ActionManager;
  10834. /**
  10835. * Creates a new PredicateCondition
  10836. * @param actionManager manager for the action the condition applies to
  10837. * @param predicate defines the predicate function used to validate the condition
  10838. */
  10839. constructor(actionManager: ActionManager,
  10840. /** defines the predicate function used to validate the condition */
  10841. predicate: () => boolean);
  10842. /**
  10843. * @returns the validity of the predicate condition
  10844. */
  10845. isValid(): boolean;
  10846. }
  10847. /**
  10848. * Defines a state condition as an extension of Condition
  10849. */
  10850. export class StateCondition extends Condition {
  10851. /** Value to compare with target state */
  10852. value: string;
  10853. /**
  10854. * Internal only - manager for action
  10855. * @hidden
  10856. */
  10857. _actionManager: ActionManager;
  10858. /**
  10859. * Internal only
  10860. * @hidden
  10861. */
  10862. private _target;
  10863. /**
  10864. * Creates a new StateCondition
  10865. * @param actionManager manager for the action the condition applies to
  10866. * @param target of the condition
  10867. * @param value to compare with target state
  10868. */
  10869. constructor(actionManager: ActionManager, target: any,
  10870. /** Value to compare with target state */
  10871. value: string);
  10872. /**
  10873. * Gets a boolean indicating if the current condition is met
  10874. * @returns the validity of the state
  10875. */
  10876. isValid(): boolean;
  10877. /**
  10878. * Serialize the StateCondition into a JSON compatible object
  10879. * @returns serialization object
  10880. */
  10881. serialize(): any;
  10882. }
  10883. }
  10884. declare module "babylonjs/Actions/directActions" {
  10885. import { Action } from "babylonjs/Actions/action";
  10886. import { Condition } from "babylonjs/Actions/condition";
  10887. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10888. /**
  10889. * This defines an action responsible to toggle a boolean once triggered.
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10891. */
  10892. export class SwitchBooleanAction extends Action {
  10893. /**
  10894. * The path to the boolean property in the target object
  10895. */
  10896. propertyPath: string;
  10897. private _target;
  10898. private _effectiveTarget;
  10899. private _property;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the object containing the boolean
  10904. * @param propertyPath defines the path to the boolean property in the target object
  10905. * @param condition defines the trigger related conditions
  10906. */
  10907. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10908. /** @hidden */
  10909. _prepare(): void;
  10910. /**
  10911. * Execute the action toggle the boolean value.
  10912. */
  10913. execute(): void;
  10914. /**
  10915. * Serializes the actions and its related information.
  10916. * @param parent defines the object to serialize in
  10917. * @returns the serialized object
  10918. */
  10919. serialize(parent: any): any;
  10920. }
  10921. /**
  10922. * This defines an action responsible to set a the state field of the target
  10923. * to a desired value once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class SetStateAction extends Action {
  10927. /**
  10928. * The value to store in the state field.
  10929. */
  10930. value: string;
  10931. private _target;
  10932. /**
  10933. * Instantiate the action
  10934. * @param triggerOptions defines the trigger options
  10935. * @param target defines the object containing the state property
  10936. * @param value defines the value to store in the state field
  10937. * @param condition defines the trigger related conditions
  10938. */
  10939. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10940. /**
  10941. * Execute the action and store the value on the target state property.
  10942. */
  10943. execute(): void;
  10944. /**
  10945. * Serializes the actions and its related information.
  10946. * @param parent defines the object to serialize in
  10947. * @returns the serialized object
  10948. */
  10949. serialize(parent: any): any;
  10950. }
  10951. /**
  10952. * This defines an action responsible to set a property of the target
  10953. * to a desired value once triggered.
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10955. */
  10956. export class SetValueAction extends Action {
  10957. /**
  10958. * The path of the property to set in the target.
  10959. */
  10960. propertyPath: string;
  10961. /**
  10962. * The value to set in the property
  10963. */
  10964. value: any;
  10965. private _target;
  10966. private _effectiveTarget;
  10967. private _property;
  10968. /**
  10969. * Instantiate the action
  10970. * @param triggerOptions defines the trigger options
  10971. * @param target defines the object containing the property
  10972. * @param propertyPath defines the path of the property to set in the target
  10973. * @param value defines the value to set in the property
  10974. * @param condition defines the trigger related conditions
  10975. */
  10976. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10977. /** @hidden */
  10978. _prepare(): void;
  10979. /**
  10980. * Execute the action and set the targetted property to the desired value.
  10981. */
  10982. execute(): void;
  10983. /**
  10984. * Serializes the actions and its related information.
  10985. * @param parent defines the object to serialize in
  10986. * @returns the serialized object
  10987. */
  10988. serialize(parent: any): any;
  10989. }
  10990. /**
  10991. * This defines an action responsible to increment the target value
  10992. * to a desired value once triggered.
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10994. */
  10995. export class IncrementValueAction extends Action {
  10996. /**
  10997. * The path of the property to increment in the target.
  10998. */
  10999. propertyPath: string;
  11000. /**
  11001. * The value we should increment the property by.
  11002. */
  11003. value: any;
  11004. private _target;
  11005. private _effectiveTarget;
  11006. private _property;
  11007. /**
  11008. * Instantiate the action
  11009. * @param triggerOptions defines the trigger options
  11010. * @param target defines the object containing the property
  11011. * @param propertyPath defines the path of the property to increment in the target
  11012. * @param value defines the value value we should increment the property by
  11013. * @param condition defines the trigger related conditions
  11014. */
  11015. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11016. /** @hidden */
  11017. _prepare(): void;
  11018. /**
  11019. * Execute the action and increment the target of the value amount.
  11020. */
  11021. execute(): void;
  11022. /**
  11023. * Serializes the actions and its related information.
  11024. * @param parent defines the object to serialize in
  11025. * @returns the serialized object
  11026. */
  11027. serialize(parent: any): any;
  11028. }
  11029. /**
  11030. * This defines an action responsible to start an animation once triggered.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class PlayAnimationAction extends Action {
  11034. /**
  11035. * Where the animation should start (animation frame)
  11036. */
  11037. from: number;
  11038. /**
  11039. * Where the animation should stop (animation frame)
  11040. */
  11041. to: number;
  11042. /**
  11043. * Define if the animation should loop or stop after the first play.
  11044. */
  11045. loop?: boolean;
  11046. private _target;
  11047. /**
  11048. * Instantiate the action
  11049. * @param triggerOptions defines the trigger options
  11050. * @param target defines the target animation or animation name
  11051. * @param from defines from where the animation should start (animation frame)
  11052. * @param end defines where the animation should stop (animation frame)
  11053. * @param loop defines if the animation should loop or stop after the first play
  11054. * @param condition defines the trigger related conditions
  11055. */
  11056. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11057. /** @hidden */
  11058. _prepare(): void;
  11059. /**
  11060. * Execute the action and play the animation.
  11061. */
  11062. execute(): void;
  11063. /**
  11064. * Serializes the actions and its related information.
  11065. * @param parent defines the object to serialize in
  11066. * @returns the serialized object
  11067. */
  11068. serialize(parent: any): any;
  11069. }
  11070. /**
  11071. * This defines an action responsible to stop an animation once triggered.
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11073. */
  11074. export class StopAnimationAction extends Action {
  11075. private _target;
  11076. /**
  11077. * Instantiate the action
  11078. * @param triggerOptions defines the trigger options
  11079. * @param target defines the target animation or animation name
  11080. * @param condition defines the trigger related conditions
  11081. */
  11082. constructor(triggerOptions: any, target: any, condition?: Condition);
  11083. /** @hidden */
  11084. _prepare(): void;
  11085. /**
  11086. * Execute the action and stop the animation.
  11087. */
  11088. execute(): void;
  11089. /**
  11090. * Serializes the actions and its related information.
  11091. * @param parent defines the object to serialize in
  11092. * @returns the serialized object
  11093. */
  11094. serialize(parent: any): any;
  11095. }
  11096. /**
  11097. * This defines an action responsible that does nothing once triggered.
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11099. */
  11100. export class DoNothingAction extends Action {
  11101. /**
  11102. * Instantiate the action
  11103. * @param triggerOptions defines the trigger options
  11104. * @param condition defines the trigger related conditions
  11105. */
  11106. constructor(triggerOptions?: any, condition?: Condition);
  11107. /**
  11108. * Execute the action and do nothing.
  11109. */
  11110. execute(): void;
  11111. /**
  11112. * Serializes the actions and its related information.
  11113. * @param parent defines the object to serialize in
  11114. * @returns the serialized object
  11115. */
  11116. serialize(parent: any): any;
  11117. }
  11118. /**
  11119. * This defines an action responsible to trigger several actions once triggered.
  11120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11121. */
  11122. export class CombineAction extends Action {
  11123. /**
  11124. * The list of aggregated animations to run.
  11125. */
  11126. children: Action[];
  11127. /**
  11128. * Instantiate the action
  11129. * @param triggerOptions defines the trigger options
  11130. * @param children defines the list of aggregated animations to run
  11131. * @param condition defines the trigger related conditions
  11132. */
  11133. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11134. /** @hidden */
  11135. _prepare(): void;
  11136. /**
  11137. * Execute the action and executes all the aggregated actions.
  11138. */
  11139. execute(evt: ActionEvent): void;
  11140. /**
  11141. * Serializes the actions and its related information.
  11142. * @param parent defines the object to serialize in
  11143. * @returns the serialized object
  11144. */
  11145. serialize(parent: any): any;
  11146. }
  11147. /**
  11148. * This defines an action responsible to run code (external event) once triggered.
  11149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11150. */
  11151. export class ExecuteCodeAction extends Action {
  11152. /**
  11153. * The callback function to run.
  11154. */
  11155. func: (evt: ActionEvent) => void;
  11156. /**
  11157. * Instantiate the action
  11158. * @param triggerOptions defines the trigger options
  11159. * @param func defines the callback function to run
  11160. * @param condition defines the trigger related conditions
  11161. */
  11162. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11163. /**
  11164. * Execute the action and run the attached code.
  11165. */
  11166. execute(evt: ActionEvent): void;
  11167. }
  11168. /**
  11169. * This defines an action responsible to set the parent property of the target once triggered.
  11170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11171. */
  11172. export class SetParentAction extends Action {
  11173. private _parent;
  11174. private _target;
  11175. /**
  11176. * Instantiate the action
  11177. * @param triggerOptions defines the trigger options
  11178. * @param target defines the target containing the parent property
  11179. * @param parent defines from where the animation should start (animation frame)
  11180. * @param condition defines the trigger related conditions
  11181. */
  11182. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11183. /** @hidden */
  11184. _prepare(): void;
  11185. /**
  11186. * Execute the action and set the parent property.
  11187. */
  11188. execute(): void;
  11189. /**
  11190. * Serializes the actions and its related information.
  11191. * @param parent defines the object to serialize in
  11192. * @returns the serialized object
  11193. */
  11194. serialize(parent: any): any;
  11195. }
  11196. }
  11197. declare module "babylonjs/Actions/actionManager" {
  11198. import { Nullable } from "babylonjs/types";
  11199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11200. import { Scene } from "babylonjs/scene";
  11201. import { IAction } from "babylonjs/Actions/action";
  11202. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11203. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11204. /**
  11205. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11206. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11208. */
  11209. export class ActionManager extends AbstractActionManager {
  11210. /**
  11211. * Nothing
  11212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11213. */
  11214. static readonly NothingTrigger: number;
  11215. /**
  11216. * On pick
  11217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11218. */
  11219. static readonly OnPickTrigger: number;
  11220. /**
  11221. * On left pick
  11222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11223. */
  11224. static readonly OnLeftPickTrigger: number;
  11225. /**
  11226. * On right pick
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnRightPickTrigger: number;
  11230. /**
  11231. * On center pick
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnCenterPickTrigger: number;
  11235. /**
  11236. * On pick down
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnPickDownTrigger: number;
  11240. /**
  11241. * On double pick
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11243. */
  11244. static readonly OnDoublePickTrigger: number;
  11245. /**
  11246. * On pick up
  11247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11248. */
  11249. static readonly OnPickUpTrigger: number;
  11250. /**
  11251. * On pick out.
  11252. * This trigger will only be raised if you also declared a OnPickDown
  11253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11254. */
  11255. static readonly OnPickOutTrigger: number;
  11256. /**
  11257. * On long press
  11258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11259. */
  11260. static readonly OnLongPressTrigger: number;
  11261. /**
  11262. * On pointer over
  11263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11264. */
  11265. static readonly OnPointerOverTrigger: number;
  11266. /**
  11267. * On pointer out
  11268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11269. */
  11270. static readonly OnPointerOutTrigger: number;
  11271. /**
  11272. * On every frame
  11273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11274. */
  11275. static readonly OnEveryFrameTrigger: number;
  11276. /**
  11277. * On intersection enter
  11278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11279. */
  11280. static readonly OnIntersectionEnterTrigger: number;
  11281. /**
  11282. * On intersection exit
  11283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11284. */
  11285. static readonly OnIntersectionExitTrigger: number;
  11286. /**
  11287. * On key down
  11288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11289. */
  11290. static readonly OnKeyDownTrigger: number;
  11291. /**
  11292. * On key up
  11293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11294. */
  11295. static readonly OnKeyUpTrigger: number;
  11296. private _scene;
  11297. /**
  11298. * Creates a new action manager
  11299. * @param scene defines the hosting scene
  11300. */
  11301. constructor(scene: Scene);
  11302. /**
  11303. * Releases all associated resources
  11304. */
  11305. dispose(): void;
  11306. /**
  11307. * Gets hosting scene
  11308. * @returns the hosting scene
  11309. */
  11310. getScene(): Scene;
  11311. /**
  11312. * Does this action manager handles actions of any of the given triggers
  11313. * @param triggers defines the triggers to be tested
  11314. * @return a boolean indicating whether one (or more) of the triggers is handled
  11315. */
  11316. hasSpecificTriggers(triggers: number[]): boolean;
  11317. /**
  11318. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11319. * speed.
  11320. * @param triggerA defines the trigger to be tested
  11321. * @param triggerB defines the trigger to be tested
  11322. * @return a boolean indicating whether one (or more) of the triggers is handled
  11323. */
  11324. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11325. /**
  11326. * Does this action manager handles actions of a given trigger
  11327. * @param trigger defines the trigger to be tested
  11328. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11329. * @return whether the trigger is handled
  11330. */
  11331. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11332. /**
  11333. * Does this action manager has pointer triggers
  11334. */
  11335. get hasPointerTriggers(): boolean;
  11336. /**
  11337. * Does this action manager has pick triggers
  11338. */
  11339. get hasPickTriggers(): boolean;
  11340. /**
  11341. * Registers an action to this action manager
  11342. * @param action defines the action to be registered
  11343. * @return the action amended (prepared) after registration
  11344. */
  11345. registerAction(action: IAction): Nullable<IAction>;
  11346. /**
  11347. * Unregisters an action to this action manager
  11348. * @param action defines the action to be unregistered
  11349. * @return a boolean indicating whether the action has been unregistered
  11350. */
  11351. unregisterAction(action: IAction): Boolean;
  11352. /**
  11353. * Process a specific trigger
  11354. * @param trigger defines the trigger to process
  11355. * @param evt defines the event details to be processed
  11356. */
  11357. processTrigger(trigger: number, evt?: IActionEvent): void;
  11358. /** @hidden */
  11359. _getEffectiveTarget(target: any, propertyPath: string): any;
  11360. /** @hidden */
  11361. _getProperty(propertyPath: string): string;
  11362. /**
  11363. * Serialize this manager to a JSON object
  11364. * @param name defines the property name to store this manager
  11365. * @returns a JSON representation of this manager
  11366. */
  11367. serialize(name: string): any;
  11368. /**
  11369. * Creates a new ActionManager from a JSON data
  11370. * @param parsedActions defines the JSON data to read from
  11371. * @param object defines the hosting mesh
  11372. * @param scene defines the hosting scene
  11373. */
  11374. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11375. /**
  11376. * Get a trigger name by index
  11377. * @param trigger defines the trigger index
  11378. * @returns a trigger name
  11379. */
  11380. static GetTriggerName(trigger: number): string;
  11381. }
  11382. }
  11383. declare module "babylonjs/Culling/ray" {
  11384. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11385. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11387. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11388. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11389. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11390. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11391. import { Plane } from "babylonjs/Maths/math.plane";
  11392. /**
  11393. * Class representing a ray with position and direction
  11394. */
  11395. export class Ray {
  11396. /** origin point */
  11397. origin: Vector3;
  11398. /** direction */
  11399. direction: Vector3;
  11400. /** length of the ray */
  11401. length: number;
  11402. private static readonly TmpVector3;
  11403. private _tmpRay;
  11404. /**
  11405. * Creates a new ray
  11406. * @param origin origin point
  11407. * @param direction direction
  11408. * @param length length of the ray
  11409. */
  11410. constructor(
  11411. /** origin point */
  11412. origin: Vector3,
  11413. /** direction */
  11414. direction: Vector3,
  11415. /** length of the ray */
  11416. length?: number);
  11417. /**
  11418. * Checks if the ray intersects a box
  11419. * @param minimum bound of the box
  11420. * @param maximum bound of the box
  11421. * @param intersectionTreshold extra extend to be added to the box in all direction
  11422. * @returns if the box was hit
  11423. */
  11424. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11425. /**
  11426. * Checks if the ray intersects a box
  11427. * @param box the bounding box to check
  11428. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11429. * @returns if the box was hit
  11430. */
  11431. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11432. /**
  11433. * If the ray hits a sphere
  11434. * @param sphere the bounding sphere to check
  11435. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11436. * @returns true if it hits the sphere
  11437. */
  11438. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11439. /**
  11440. * If the ray hits a triange
  11441. * @param vertex0 triangle vertex
  11442. * @param vertex1 triangle vertex
  11443. * @param vertex2 triangle vertex
  11444. * @returns intersection information if hit
  11445. */
  11446. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11447. /**
  11448. * Checks if ray intersects a plane
  11449. * @param plane the plane to check
  11450. * @returns the distance away it was hit
  11451. */
  11452. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11453. /**
  11454. * Calculate the intercept of a ray on a given axis
  11455. * @param axis to check 'x' | 'y' | 'z'
  11456. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11457. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11458. */
  11459. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11460. /**
  11461. * Checks if ray intersects a mesh
  11462. * @param mesh the mesh to check
  11463. * @param fastCheck if only the bounding box should checked
  11464. * @returns picking info of the intersecton
  11465. */
  11466. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11467. /**
  11468. * Checks if ray intersects a mesh
  11469. * @param meshes the meshes to check
  11470. * @param fastCheck if only the bounding box should checked
  11471. * @param results array to store result in
  11472. * @returns Array of picking infos
  11473. */
  11474. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11475. private _comparePickingInfo;
  11476. private static smallnum;
  11477. private static rayl;
  11478. /**
  11479. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11480. * @param sega the first point of the segment to test the intersection against
  11481. * @param segb the second point of the segment to test the intersection against
  11482. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11483. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11484. */
  11485. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11486. /**
  11487. * Update the ray from viewport position
  11488. * @param x position
  11489. * @param y y position
  11490. * @param viewportWidth viewport width
  11491. * @param viewportHeight viewport height
  11492. * @param world world matrix
  11493. * @param view view matrix
  11494. * @param projection projection matrix
  11495. * @returns this ray updated
  11496. */
  11497. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11498. /**
  11499. * Creates a ray with origin and direction of 0,0,0
  11500. * @returns the new ray
  11501. */
  11502. static Zero(): Ray;
  11503. /**
  11504. * Creates a new ray from screen space and viewport
  11505. * @param x position
  11506. * @param y y position
  11507. * @param viewportWidth viewport width
  11508. * @param viewportHeight viewport height
  11509. * @param world world matrix
  11510. * @param view view matrix
  11511. * @param projection projection matrix
  11512. * @returns new ray
  11513. */
  11514. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11515. /**
  11516. * 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
  11517. * transformed to the given world matrix.
  11518. * @param origin The origin point
  11519. * @param end The end point
  11520. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11521. * @returns the new ray
  11522. */
  11523. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11524. /**
  11525. * Transforms a ray by a matrix
  11526. * @param ray ray to transform
  11527. * @param matrix matrix to apply
  11528. * @returns the resulting new ray
  11529. */
  11530. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11531. /**
  11532. * Transforms a ray by a matrix
  11533. * @param ray ray to transform
  11534. * @param matrix matrix to apply
  11535. * @param result ray to store result in
  11536. */
  11537. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11538. /**
  11539. * Unproject a ray from screen space to object space
  11540. * @param sourceX defines the screen space x coordinate to use
  11541. * @param sourceY defines the screen space y coordinate to use
  11542. * @param viewportWidth defines the current width of the viewport
  11543. * @param viewportHeight defines the current height of the viewport
  11544. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11545. * @param view defines the view matrix to use
  11546. * @param projection defines the projection matrix to use
  11547. */
  11548. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11549. }
  11550. /**
  11551. * Type used to define predicate used to select faces when a mesh intersection is detected
  11552. */
  11553. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11554. module "babylonjs/scene" {
  11555. interface Scene {
  11556. /** @hidden */
  11557. _tempPickingRay: Nullable<Ray>;
  11558. /** @hidden */
  11559. _cachedRayForTransform: Ray;
  11560. /** @hidden */
  11561. _pickWithRayInverseMatrix: Matrix;
  11562. /** @hidden */
  11563. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11564. /** @hidden */
  11565. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11566. }
  11567. }
  11568. }
  11569. declare module "babylonjs/sceneComponent" {
  11570. import { Scene } from "babylonjs/scene";
  11571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11572. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11573. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11574. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11575. import { Nullable } from "babylonjs/types";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11578. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11579. import { AbstractScene } from "babylonjs/abstractScene";
  11580. import { Mesh } from "babylonjs/Meshes/mesh";
  11581. /**
  11582. * Groups all the scene component constants in one place to ease maintenance.
  11583. * @hidden
  11584. */
  11585. export class SceneComponentConstants {
  11586. static readonly NAME_EFFECTLAYER: string;
  11587. static readonly NAME_LAYER: string;
  11588. static readonly NAME_LENSFLARESYSTEM: string;
  11589. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11590. static readonly NAME_PARTICLESYSTEM: string;
  11591. static readonly NAME_GAMEPAD: string;
  11592. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11593. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11594. static readonly NAME_DEPTHRENDERER: string;
  11595. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11596. static readonly NAME_SPRITE: string;
  11597. static readonly NAME_OUTLINERENDERER: string;
  11598. static readonly NAME_PROCEDURALTEXTURE: string;
  11599. static readonly NAME_SHADOWGENERATOR: string;
  11600. static readonly NAME_OCTREE: string;
  11601. static readonly NAME_PHYSICSENGINE: string;
  11602. static readonly NAME_AUDIO: string;
  11603. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11604. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11605. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11606. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11607. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11608. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11609. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11610. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11611. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11612. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11613. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11614. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11615. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11616. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11617. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11618. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11619. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11620. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11621. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11622. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11623. static readonly STEP_AFTERRENDER_AUDIO: number;
  11624. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11625. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11626. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11627. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11628. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11629. static readonly STEP_POINTERMOVE_SPRITE: number;
  11630. static readonly STEP_POINTERDOWN_SPRITE: number;
  11631. static readonly STEP_POINTERUP_SPRITE: number;
  11632. }
  11633. /**
  11634. * This represents a scene component.
  11635. *
  11636. * This is used to decouple the dependency the scene is having on the different workloads like
  11637. * layers, post processes...
  11638. */
  11639. export interface ISceneComponent {
  11640. /**
  11641. * The name of the component. Each component must have a unique name.
  11642. */
  11643. name: string;
  11644. /**
  11645. * The scene the component belongs to.
  11646. */
  11647. scene: Scene;
  11648. /**
  11649. * Register the component to one instance of a scene.
  11650. */
  11651. register(): void;
  11652. /**
  11653. * Rebuilds the elements related to this component in case of
  11654. * context lost for instance.
  11655. */
  11656. rebuild(): void;
  11657. /**
  11658. * Disposes the component and the associated ressources.
  11659. */
  11660. dispose(): void;
  11661. }
  11662. /**
  11663. * This represents a SERIALIZABLE scene component.
  11664. *
  11665. * This extends Scene Component to add Serialization methods on top.
  11666. */
  11667. export interface ISceneSerializableComponent extends ISceneComponent {
  11668. /**
  11669. * Adds all the elements from the container to the scene
  11670. * @param container the container holding the elements
  11671. */
  11672. addFromContainer(container: AbstractScene): void;
  11673. /**
  11674. * Removes all the elements in the container from the scene
  11675. * @param container contains the elements to remove
  11676. * @param dispose if the removed element should be disposed (default: false)
  11677. */
  11678. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11679. /**
  11680. * Serializes the component data to the specified json object
  11681. * @param serializationObject The object to serialize to
  11682. */
  11683. serialize(serializationObject: any): void;
  11684. }
  11685. /**
  11686. * Strong typing of a Mesh related stage step action
  11687. */
  11688. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11689. /**
  11690. * Strong typing of a Evaluate Sub Mesh related stage step action
  11691. */
  11692. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11693. /**
  11694. * Strong typing of a Active Mesh related stage step action
  11695. */
  11696. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11697. /**
  11698. * Strong typing of a Camera related stage step action
  11699. */
  11700. export type CameraStageAction = (camera: Camera) => void;
  11701. /**
  11702. * Strong typing of a Camera Frame buffer related stage step action
  11703. */
  11704. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11705. /**
  11706. * Strong typing of a Render Target related stage step action
  11707. */
  11708. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11709. /**
  11710. * Strong typing of a RenderingGroup related stage step action
  11711. */
  11712. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11713. /**
  11714. * Strong typing of a Mesh Render related stage step action
  11715. */
  11716. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11717. /**
  11718. * Strong typing of a simple stage step action
  11719. */
  11720. export type SimpleStageAction = () => void;
  11721. /**
  11722. * Strong typing of a render target action.
  11723. */
  11724. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11725. /**
  11726. * Strong typing of a pointer move action.
  11727. */
  11728. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11729. /**
  11730. * Strong typing of a pointer up/down action.
  11731. */
  11732. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11733. /**
  11734. * Representation of a stage in the scene (Basically a list of ordered steps)
  11735. * @hidden
  11736. */
  11737. export class Stage<T extends Function> extends Array<{
  11738. index: number;
  11739. component: ISceneComponent;
  11740. action: T;
  11741. }> {
  11742. /**
  11743. * Hide ctor from the rest of the world.
  11744. * @param items The items to add.
  11745. */
  11746. private constructor();
  11747. /**
  11748. * Creates a new Stage.
  11749. * @returns A new instance of a Stage
  11750. */
  11751. static Create<T extends Function>(): Stage<T>;
  11752. /**
  11753. * Registers a step in an ordered way in the targeted stage.
  11754. * @param index Defines the position to register the step in
  11755. * @param component Defines the component attached to the step
  11756. * @param action Defines the action to launch during the step
  11757. */
  11758. registerStep(index: number, component: ISceneComponent, action: T): void;
  11759. /**
  11760. * Clears all the steps from the stage.
  11761. */
  11762. clear(): void;
  11763. }
  11764. }
  11765. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11766. import { Nullable } from "babylonjs/types";
  11767. import { Observable } from "babylonjs/Misc/observable";
  11768. import { Scene } from "babylonjs/scene";
  11769. import { Sprite } from "babylonjs/Sprites/sprite";
  11770. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11771. import { Ray } from "babylonjs/Culling/ray";
  11772. import { Camera } from "babylonjs/Cameras/camera";
  11773. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11774. import { ISceneComponent } from "babylonjs/sceneComponent";
  11775. module "babylonjs/scene" {
  11776. interface Scene {
  11777. /** @hidden */
  11778. _pointerOverSprite: Nullable<Sprite>;
  11779. /** @hidden */
  11780. _pickedDownSprite: Nullable<Sprite>;
  11781. /** @hidden */
  11782. _tempSpritePickingRay: Nullable<Ray>;
  11783. /**
  11784. * All of the sprite managers added to this scene
  11785. * @see http://doc.babylonjs.com/babylon101/sprites
  11786. */
  11787. spriteManagers: Array<ISpriteManager>;
  11788. /**
  11789. * An event triggered when sprites rendering is about to start
  11790. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11791. */
  11792. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11793. /**
  11794. * An event triggered when sprites rendering is done
  11795. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11796. */
  11797. onAfterSpritesRenderingObservable: Observable<Scene>;
  11798. /** @hidden */
  11799. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11800. /** Launch a ray to try to pick a sprite in the scene
  11801. * @param x position on screen
  11802. * @param y position on screen
  11803. * @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
  11804. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11805. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11806. * @returns a PickingInfo
  11807. */
  11808. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11809. /** Use the given ray to pick a sprite in the scene
  11810. * @param ray The ray (in world space) to use to pick meshes
  11811. * @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
  11812. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11813. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11814. * @returns a PickingInfo
  11815. */
  11816. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11817. /** @hidden */
  11818. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11819. /** Launch a ray to try to pick sprites in the scene
  11820. * @param x position on screen
  11821. * @param y position on screen
  11822. * @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
  11823. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11824. * @returns a PickingInfo array
  11825. */
  11826. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11827. /** Use the given ray to pick sprites in the scene
  11828. * @param ray The ray (in world space) to use to pick meshes
  11829. * @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
  11830. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11831. * @returns a PickingInfo array
  11832. */
  11833. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11834. /**
  11835. * Force the sprite under the pointer
  11836. * @param sprite defines the sprite to use
  11837. */
  11838. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11839. /**
  11840. * Gets the sprite under the pointer
  11841. * @returns a Sprite or null if no sprite is under the pointer
  11842. */
  11843. getPointerOverSprite(): Nullable<Sprite>;
  11844. }
  11845. }
  11846. /**
  11847. * Defines the sprite scene component responsible to manage sprites
  11848. * in a given scene.
  11849. */
  11850. export class SpriteSceneComponent implements ISceneComponent {
  11851. /**
  11852. * The component name helpfull to identify the component in the list of scene components.
  11853. */
  11854. readonly name: string;
  11855. /**
  11856. * The scene the component belongs to.
  11857. */
  11858. scene: Scene;
  11859. /** @hidden */
  11860. private _spritePredicate;
  11861. /**
  11862. * Creates a new instance of the component for the given scene
  11863. * @param scene Defines the scene to register the component in
  11864. */
  11865. constructor(scene: Scene);
  11866. /**
  11867. * Registers the component in a given scene
  11868. */
  11869. register(): void;
  11870. /**
  11871. * Rebuilds the elements related to this component in case of
  11872. * context lost for instance.
  11873. */
  11874. rebuild(): void;
  11875. /**
  11876. * Disposes the component and the associated ressources.
  11877. */
  11878. dispose(): void;
  11879. private _pickSpriteButKeepRay;
  11880. private _pointerMove;
  11881. private _pointerDown;
  11882. private _pointerUp;
  11883. }
  11884. }
  11885. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11886. /** @hidden */
  11887. export var fogFragmentDeclaration: {
  11888. name: string;
  11889. shader: string;
  11890. };
  11891. }
  11892. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11893. /** @hidden */
  11894. export var fogFragment: {
  11895. name: string;
  11896. shader: string;
  11897. };
  11898. }
  11899. declare module "babylonjs/Shaders/sprites.fragment" {
  11900. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11901. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11902. /** @hidden */
  11903. export var spritesPixelShader: {
  11904. name: string;
  11905. shader: string;
  11906. };
  11907. }
  11908. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11909. /** @hidden */
  11910. export var fogVertexDeclaration: {
  11911. name: string;
  11912. shader: string;
  11913. };
  11914. }
  11915. declare module "babylonjs/Shaders/sprites.vertex" {
  11916. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11917. /** @hidden */
  11918. export var spritesVertexShader: {
  11919. name: string;
  11920. shader: string;
  11921. };
  11922. }
  11923. declare module "babylonjs/Sprites/spriteManager" {
  11924. import { IDisposable, Scene } from "babylonjs/scene";
  11925. import { Nullable } from "babylonjs/types";
  11926. import { Observable } from "babylonjs/Misc/observable";
  11927. import { Sprite } from "babylonjs/Sprites/sprite";
  11928. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11929. import { Camera } from "babylonjs/Cameras/camera";
  11930. import { Texture } from "babylonjs/Materials/Textures/texture";
  11931. import "babylonjs/Shaders/sprites.fragment";
  11932. import "babylonjs/Shaders/sprites.vertex";
  11933. import { Ray } from "babylonjs/Culling/ray";
  11934. /**
  11935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11936. */
  11937. export interface ISpriteManager extends IDisposable {
  11938. /**
  11939. * Restricts the camera to viewing objects with the same layerMask.
  11940. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11941. */
  11942. layerMask: number;
  11943. /**
  11944. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11945. */
  11946. isPickable: boolean;
  11947. /**
  11948. * Specifies the rendering group id for this mesh (0 by default)
  11949. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11950. */
  11951. renderingGroupId: number;
  11952. /**
  11953. * Defines the list of sprites managed by the manager.
  11954. */
  11955. sprites: Array<Sprite>;
  11956. /**
  11957. * Tests the intersection of a sprite with a specific ray.
  11958. * @param ray The ray we are sending to test the collision
  11959. * @param camera The camera space we are sending rays in
  11960. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11961. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11962. * @returns picking info or null.
  11963. */
  11964. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11965. /**
  11966. * Intersects the sprites with a ray
  11967. * @param ray defines the ray to intersect with
  11968. * @param camera defines the current active camera
  11969. * @param predicate defines a predicate used to select candidate sprites
  11970. * @returns null if no hit or a PickingInfo array
  11971. */
  11972. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11973. /**
  11974. * Renders the list of sprites on screen.
  11975. */
  11976. render(): void;
  11977. }
  11978. /**
  11979. * Class used to manage multiple sprites on the same spritesheet
  11980. * @see http://doc.babylonjs.com/babylon101/sprites
  11981. */
  11982. export class SpriteManager implements ISpriteManager {
  11983. /** defines the manager's name */
  11984. name: string;
  11985. /** Gets the list of sprites */
  11986. sprites: Sprite[];
  11987. /** Gets or sets the rendering group id (0 by default) */
  11988. renderingGroupId: number;
  11989. /** Gets or sets camera layer mask */
  11990. layerMask: number;
  11991. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11992. fogEnabled: boolean;
  11993. /** Gets or sets a boolean indicating if the sprites are pickable */
  11994. isPickable: boolean;
  11995. /** Defines the default width of a cell in the spritesheet */
  11996. cellWidth: number;
  11997. /** Defines the default height of a cell in the spritesheet */
  11998. cellHeight: number;
  11999. /** Associative array from JSON sprite data file */
  12000. private _cellData;
  12001. /** Array of sprite names from JSON sprite data file */
  12002. private _spriteMap;
  12003. /** True when packed cell data from JSON file is ready*/
  12004. private _packedAndReady;
  12005. /**
  12006. * An event triggered when the manager is disposed.
  12007. */
  12008. onDisposeObservable: Observable<SpriteManager>;
  12009. private _onDisposeObserver;
  12010. /**
  12011. * Callback called when the manager is disposed
  12012. */
  12013. set onDispose(callback: () => void);
  12014. private _capacity;
  12015. private _fromPacked;
  12016. private _spriteTexture;
  12017. private _epsilon;
  12018. private _scene;
  12019. private _vertexData;
  12020. private _buffer;
  12021. private _vertexBuffers;
  12022. private _indexBuffer;
  12023. private _effectBase;
  12024. private _effectFog;
  12025. /**
  12026. * Gets or sets the spritesheet texture
  12027. */
  12028. get texture(): Texture;
  12029. set texture(value: Texture);
  12030. /**
  12031. * Creates a new sprite manager
  12032. * @param name defines the manager's name
  12033. * @param imgUrl defines the sprite sheet url
  12034. * @param capacity defines the maximum allowed number of sprites
  12035. * @param cellSize defines the size of a sprite cell
  12036. * @param scene defines the hosting scene
  12037. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12038. * @param samplingMode defines the smapling mode to use with spritesheet
  12039. * @param fromPacked set to false; do not alter
  12040. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  12041. */
  12042. constructor(
  12043. /** defines the manager's name */
  12044. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  12045. private _makePacked;
  12046. private _appendSpriteVertex;
  12047. /**
  12048. * Intersects the sprites with a ray
  12049. * @param ray defines the ray to intersect with
  12050. * @param camera defines the current active camera
  12051. * @param predicate defines a predicate used to select candidate sprites
  12052. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12053. * @returns null if no hit or a PickingInfo
  12054. */
  12055. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12056. /**
  12057. * Intersects the sprites with a ray
  12058. * @param ray defines the ray to intersect with
  12059. * @param camera defines the current active camera
  12060. * @param predicate defines a predicate used to select candidate sprites
  12061. * @returns null if no hit or a PickingInfo array
  12062. */
  12063. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12064. /**
  12065. * Render all child sprites
  12066. */
  12067. render(): void;
  12068. /**
  12069. * Release associated resources
  12070. */
  12071. dispose(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Sprites/sprite" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { Nullable } from "babylonjs/types";
  12077. import { ActionManager } from "babylonjs/Actions/actionManager";
  12078. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12079. import { Color4 } from "babylonjs/Maths/math.color";
  12080. /**
  12081. * Class used to represent a sprite
  12082. * @see http://doc.babylonjs.com/babylon101/sprites
  12083. */
  12084. export class Sprite {
  12085. /** defines the name */
  12086. name: string;
  12087. /** Gets or sets the current world position */
  12088. position: Vector3;
  12089. /** Gets or sets the main color */
  12090. color: Color4;
  12091. /** Gets or sets the width */
  12092. width: number;
  12093. /** Gets or sets the height */
  12094. height: number;
  12095. /** Gets or sets rotation angle */
  12096. angle: number;
  12097. /** Gets or sets the cell index in the sprite sheet */
  12098. cellIndex: number;
  12099. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12100. cellRef: string;
  12101. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12102. invertU: number;
  12103. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12104. invertV: number;
  12105. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12106. disposeWhenFinishedAnimating: boolean;
  12107. /** Gets the list of attached animations */
  12108. animations: Animation[];
  12109. /** Gets or sets a boolean indicating if the sprite can be picked */
  12110. isPickable: boolean;
  12111. /**
  12112. * Gets or sets the associated action manager
  12113. */
  12114. actionManager: Nullable<ActionManager>;
  12115. private _animationStarted;
  12116. private _loopAnimation;
  12117. private _fromIndex;
  12118. private _toIndex;
  12119. private _delay;
  12120. private _direction;
  12121. private _manager;
  12122. private _time;
  12123. private _onAnimationEnd;
  12124. /**
  12125. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12126. */
  12127. isVisible: boolean;
  12128. /**
  12129. * Gets or sets the sprite size
  12130. */
  12131. get size(): number;
  12132. set size(value: number);
  12133. /**
  12134. * Creates a new Sprite
  12135. * @param name defines the name
  12136. * @param manager defines the manager
  12137. */
  12138. constructor(
  12139. /** defines the name */
  12140. name: string, manager: ISpriteManager);
  12141. /**
  12142. * Starts an animation
  12143. * @param from defines the initial key
  12144. * @param to defines the end key
  12145. * @param loop defines if the animation must loop
  12146. * @param delay defines the start delay (in ms)
  12147. * @param onAnimationEnd defines a callback to call when animation ends
  12148. */
  12149. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12150. /** Stops current animation (if any) */
  12151. stopAnimation(): void;
  12152. /** @hidden */
  12153. _animate(deltaTime: number): void;
  12154. /** Release associated resources */
  12155. dispose(): void;
  12156. }
  12157. }
  12158. declare module "babylonjs/Collisions/pickingInfo" {
  12159. import { Nullable } from "babylonjs/types";
  12160. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12162. import { Sprite } from "babylonjs/Sprites/sprite";
  12163. import { Ray } from "babylonjs/Culling/ray";
  12164. /**
  12165. * Information about the result of picking within a scene
  12166. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12167. */
  12168. export class PickingInfo {
  12169. /** @hidden */
  12170. _pickingUnavailable: boolean;
  12171. /**
  12172. * If the pick collided with an object
  12173. */
  12174. hit: boolean;
  12175. /**
  12176. * Distance away where the pick collided
  12177. */
  12178. distance: number;
  12179. /**
  12180. * The location of pick collision
  12181. */
  12182. pickedPoint: Nullable<Vector3>;
  12183. /**
  12184. * The mesh corresponding the the pick collision
  12185. */
  12186. pickedMesh: Nullable<AbstractMesh>;
  12187. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12188. bu: number;
  12189. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12190. bv: number;
  12191. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12192. faceId: number;
  12193. /** Id of the the submesh that was picked */
  12194. subMeshId: number;
  12195. /** If a sprite was picked, this will be the sprite the pick collided with */
  12196. pickedSprite: Nullable<Sprite>;
  12197. /**
  12198. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12199. */
  12200. originMesh: Nullable<AbstractMesh>;
  12201. /**
  12202. * The ray that was used to perform the picking.
  12203. */
  12204. ray: Nullable<Ray>;
  12205. /**
  12206. * Gets the normal correspodning to the face the pick collided with
  12207. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12208. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12209. * @returns The normal correspodning to the face the pick collided with
  12210. */
  12211. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12212. /**
  12213. * Gets the texture coordinates of where the pick occured
  12214. * @returns the vector containing the coordnates of the texture
  12215. */
  12216. getTextureCoordinates(): Nullable<Vector2>;
  12217. }
  12218. }
  12219. declare module "babylonjs/Events/pointerEvents" {
  12220. import { Nullable } from "babylonjs/types";
  12221. import { Vector2 } from "babylonjs/Maths/math.vector";
  12222. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12223. import { Ray } from "babylonjs/Culling/ray";
  12224. /**
  12225. * Gather the list of pointer event types as constants.
  12226. */
  12227. export class PointerEventTypes {
  12228. /**
  12229. * 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.
  12230. */
  12231. static readonly POINTERDOWN: number;
  12232. /**
  12233. * The pointerup event is fired when a pointer is no longer active.
  12234. */
  12235. static readonly POINTERUP: number;
  12236. /**
  12237. * The pointermove event is fired when a pointer changes coordinates.
  12238. */
  12239. static readonly POINTERMOVE: number;
  12240. /**
  12241. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12242. */
  12243. static readonly POINTERWHEEL: number;
  12244. /**
  12245. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12246. */
  12247. static readonly POINTERPICK: number;
  12248. /**
  12249. * The pointertap event is fired when a the object has been touched and released without drag.
  12250. */
  12251. static readonly POINTERTAP: number;
  12252. /**
  12253. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12254. */
  12255. static readonly POINTERDOUBLETAP: number;
  12256. }
  12257. /**
  12258. * Base class of pointer info types.
  12259. */
  12260. export class PointerInfoBase {
  12261. /**
  12262. * Defines the type of event (PointerEventTypes)
  12263. */
  12264. type: number;
  12265. /**
  12266. * Defines the related dom event
  12267. */
  12268. event: PointerEvent | MouseWheelEvent;
  12269. /**
  12270. * Instantiates the base class of pointers info.
  12271. * @param type Defines the type of event (PointerEventTypes)
  12272. * @param event Defines the related dom event
  12273. */
  12274. constructor(
  12275. /**
  12276. * Defines the type of event (PointerEventTypes)
  12277. */
  12278. type: number,
  12279. /**
  12280. * Defines the related dom event
  12281. */
  12282. event: PointerEvent | MouseWheelEvent);
  12283. }
  12284. /**
  12285. * This class is used to store pointer related info for the onPrePointerObservable event.
  12286. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12287. */
  12288. export class PointerInfoPre extends PointerInfoBase {
  12289. /**
  12290. * Ray from a pointer if availible (eg. 6dof controller)
  12291. */
  12292. ray: Nullable<Ray>;
  12293. /**
  12294. * Defines the local position of the pointer on the canvas.
  12295. */
  12296. localPosition: Vector2;
  12297. /**
  12298. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12299. */
  12300. skipOnPointerObservable: boolean;
  12301. /**
  12302. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12303. * @param type Defines the type of event (PointerEventTypes)
  12304. * @param event Defines the related dom event
  12305. * @param localX Defines the local x coordinates of the pointer when the event occured
  12306. * @param localY Defines the local y coordinates of the pointer when the event occured
  12307. */
  12308. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12309. }
  12310. /**
  12311. * This type contains all the data related to a pointer event in Babylon.js.
  12312. * 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.
  12313. */
  12314. export class PointerInfo extends PointerInfoBase {
  12315. /**
  12316. * Defines the picking info associated to the info (if any)\
  12317. */
  12318. pickInfo: Nullable<PickingInfo>;
  12319. /**
  12320. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12321. * @param type Defines the type of event (PointerEventTypes)
  12322. * @param event Defines the related dom event
  12323. * @param pickInfo Defines the picking info associated to the info (if any)\
  12324. */
  12325. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12326. /**
  12327. * Defines the picking info associated to the info (if any)\
  12328. */
  12329. pickInfo: Nullable<PickingInfo>);
  12330. }
  12331. /**
  12332. * Data relating to a touch event on the screen.
  12333. */
  12334. export interface PointerTouch {
  12335. /**
  12336. * X coordinate of touch.
  12337. */
  12338. x: number;
  12339. /**
  12340. * Y coordinate of touch.
  12341. */
  12342. y: number;
  12343. /**
  12344. * Id of touch. Unique for each finger.
  12345. */
  12346. pointerId: number;
  12347. /**
  12348. * Event type passed from DOM.
  12349. */
  12350. type: any;
  12351. }
  12352. }
  12353. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12354. import { Observable } from "babylonjs/Misc/observable";
  12355. import { Nullable } from "babylonjs/types";
  12356. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12357. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12358. /**
  12359. * Manage the mouse inputs to control the movement of a free camera.
  12360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12361. */
  12362. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12363. /**
  12364. * Define if touch is enabled in the mouse input
  12365. */
  12366. touchEnabled: boolean;
  12367. /**
  12368. * Defines the camera the input is attached to.
  12369. */
  12370. camera: FreeCamera;
  12371. /**
  12372. * Defines the buttons associated with the input to handle camera move.
  12373. */
  12374. buttons: number[];
  12375. /**
  12376. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12377. */
  12378. angularSensibility: number;
  12379. private _pointerInput;
  12380. private _onMouseMove;
  12381. private _observer;
  12382. private previousPosition;
  12383. /**
  12384. * Observable for when a pointer move event occurs containing the move offset
  12385. */
  12386. onPointerMovedObservable: Observable<{
  12387. offsetX: number;
  12388. offsetY: number;
  12389. }>;
  12390. /**
  12391. * @hidden
  12392. * If the camera should be rotated automatically based on pointer movement
  12393. */
  12394. _allowCameraRotation: boolean;
  12395. /**
  12396. * Manage the mouse inputs to control the movement of a free camera.
  12397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12398. * @param touchEnabled Defines if touch is enabled or not
  12399. */
  12400. constructor(
  12401. /**
  12402. * Define if touch is enabled in the mouse input
  12403. */
  12404. touchEnabled?: boolean);
  12405. /**
  12406. * Attach the input controls to a specific dom element to get the input from.
  12407. * @param element Defines the element the controls should be listened from
  12408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12409. */
  12410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12411. /**
  12412. * Called on JS contextmenu event.
  12413. * Override this method to provide functionality.
  12414. */
  12415. protected onContextMenu(evt: PointerEvent): void;
  12416. /**
  12417. * Detach the current controls from the specified dom element.
  12418. * @param element Defines the element to stop listening the inputs from
  12419. */
  12420. detachControl(element: Nullable<HTMLElement>): void;
  12421. /**
  12422. * Gets the class name of the current intput.
  12423. * @returns the class name
  12424. */
  12425. getClassName(): string;
  12426. /**
  12427. * Get the friendly name associated with the input class.
  12428. * @returns the input friendly name
  12429. */
  12430. getSimpleName(): string;
  12431. }
  12432. }
  12433. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12434. import { Nullable } from "babylonjs/types";
  12435. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12436. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12437. /**
  12438. * Manage the touch inputs to control the movement of a free camera.
  12439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12440. */
  12441. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12442. /**
  12443. * Defines the camera the input is attached to.
  12444. */
  12445. camera: FreeCamera;
  12446. /**
  12447. * Defines the touch sensibility for rotation.
  12448. * The higher the faster.
  12449. */
  12450. touchAngularSensibility: number;
  12451. /**
  12452. * Defines the touch sensibility for move.
  12453. * The higher the faster.
  12454. */
  12455. touchMoveSensibility: number;
  12456. private _offsetX;
  12457. private _offsetY;
  12458. private _pointerPressed;
  12459. private _pointerInput;
  12460. private _observer;
  12461. private _onLostFocus;
  12462. /**
  12463. * Attach the input controls to a specific dom element to get the input from.
  12464. * @param element Defines the element the controls should be listened from
  12465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12466. */
  12467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12468. /**
  12469. * Detach the current controls from the specified dom element.
  12470. * @param element Defines the element to stop listening the inputs from
  12471. */
  12472. detachControl(element: Nullable<HTMLElement>): void;
  12473. /**
  12474. * Update the current camera state depending on the inputs that have been used this frame.
  12475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12476. */
  12477. checkInputs(): void;
  12478. /**
  12479. * Gets the class name of the current intput.
  12480. * @returns the class name
  12481. */
  12482. getClassName(): string;
  12483. /**
  12484. * Get the friendly name associated with the input class.
  12485. * @returns the input friendly name
  12486. */
  12487. getSimpleName(): string;
  12488. }
  12489. }
  12490. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12491. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12492. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12493. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12494. import { Nullable } from "babylonjs/types";
  12495. /**
  12496. * Default Inputs manager for the FreeCamera.
  12497. * It groups all the default supported inputs for ease of use.
  12498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12499. */
  12500. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12501. /**
  12502. * @hidden
  12503. */
  12504. _mouseInput: Nullable<FreeCameraMouseInput>;
  12505. /**
  12506. * Instantiates a new FreeCameraInputsManager.
  12507. * @param camera Defines the camera the inputs belong to
  12508. */
  12509. constructor(camera: FreeCamera);
  12510. /**
  12511. * Add keyboard input support to the input manager.
  12512. * @returns the current input manager
  12513. */
  12514. addKeyboard(): FreeCameraInputsManager;
  12515. /**
  12516. * Add mouse input support to the input manager.
  12517. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12518. * @returns the current input manager
  12519. */
  12520. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12521. /**
  12522. * Removes the mouse input support from the manager
  12523. * @returns the current input manager
  12524. */
  12525. removeMouse(): FreeCameraInputsManager;
  12526. /**
  12527. * Add touch input support to the input manager.
  12528. * @returns the current input manager
  12529. */
  12530. addTouch(): FreeCameraInputsManager;
  12531. /**
  12532. * Remove all attached input methods from a camera
  12533. */
  12534. clear(): void;
  12535. }
  12536. }
  12537. declare module "babylonjs/Cameras/freeCamera" {
  12538. import { Vector3 } from "babylonjs/Maths/math.vector";
  12539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12540. import { Scene } from "babylonjs/scene";
  12541. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12542. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12543. /**
  12544. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12545. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12546. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12547. */
  12548. export class FreeCamera extends TargetCamera {
  12549. /**
  12550. * Define the collision ellipsoid of the camera.
  12551. * This is helpful to simulate a camera body like the player body around the camera
  12552. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12553. */
  12554. ellipsoid: Vector3;
  12555. /**
  12556. * Define an offset for the position of the ellipsoid around the camera.
  12557. * This can be helpful to determine the center of the body near the gravity center of the body
  12558. * instead of its head.
  12559. */
  12560. ellipsoidOffset: Vector3;
  12561. /**
  12562. * Enable or disable collisions of the camera with the rest of the scene objects.
  12563. */
  12564. checkCollisions: boolean;
  12565. /**
  12566. * Enable or disable gravity on the camera.
  12567. */
  12568. applyGravity: boolean;
  12569. /**
  12570. * Define the input manager associated to the camera.
  12571. */
  12572. inputs: FreeCameraInputsManager;
  12573. /**
  12574. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12575. * Higher values reduce sensitivity.
  12576. */
  12577. get angularSensibility(): number;
  12578. /**
  12579. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12580. * Higher values reduce sensitivity.
  12581. */
  12582. set angularSensibility(value: number);
  12583. /**
  12584. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12585. */
  12586. get keysUp(): number[];
  12587. set keysUp(value: number[]);
  12588. /**
  12589. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12590. */
  12591. get keysDown(): number[];
  12592. set keysDown(value: number[]);
  12593. /**
  12594. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12595. */
  12596. get keysLeft(): number[];
  12597. set keysLeft(value: number[]);
  12598. /**
  12599. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12600. */
  12601. get keysRight(): number[];
  12602. set keysRight(value: number[]);
  12603. /**
  12604. * Event raised when the camera collide with a mesh in the scene.
  12605. */
  12606. onCollide: (collidedMesh: AbstractMesh) => void;
  12607. private _collider;
  12608. private _needMoveForGravity;
  12609. private _oldPosition;
  12610. private _diffPosition;
  12611. private _newPosition;
  12612. /** @hidden */
  12613. _localDirection: Vector3;
  12614. /** @hidden */
  12615. _transformedDirection: Vector3;
  12616. /**
  12617. * Instantiates a Free Camera.
  12618. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12619. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12620. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12621. * @param name Define the name of the camera in the scene
  12622. * @param position Define the start position of the camera in the scene
  12623. * @param scene Define the scene the camera belongs to
  12624. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12625. */
  12626. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12627. /**
  12628. * Attached controls to the current camera.
  12629. * @param element Defines the element the controls should be listened from
  12630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12631. */
  12632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12633. /**
  12634. * Detach the current controls from the camera.
  12635. * The camera will stop reacting to inputs.
  12636. * @param element Defines the element to stop listening the inputs from
  12637. */
  12638. detachControl(element: HTMLElement): void;
  12639. private _collisionMask;
  12640. /**
  12641. * Define a collision mask to limit the list of object the camera can collide with
  12642. */
  12643. get collisionMask(): number;
  12644. set collisionMask(mask: number);
  12645. /** @hidden */
  12646. _collideWithWorld(displacement: Vector3): void;
  12647. private _onCollisionPositionChange;
  12648. /** @hidden */
  12649. _checkInputs(): void;
  12650. /** @hidden */
  12651. _decideIfNeedsToMove(): boolean;
  12652. /** @hidden */
  12653. _updatePosition(): void;
  12654. /**
  12655. * Destroy the camera and release the current resources hold by it.
  12656. */
  12657. dispose(): void;
  12658. /**
  12659. * Gets the current object class name.
  12660. * @return the class name
  12661. */
  12662. getClassName(): string;
  12663. }
  12664. }
  12665. declare module "babylonjs/Gamepads/gamepad" {
  12666. import { Observable } from "babylonjs/Misc/observable";
  12667. /**
  12668. * Represents a gamepad control stick position
  12669. */
  12670. export class StickValues {
  12671. /**
  12672. * The x component of the control stick
  12673. */
  12674. x: number;
  12675. /**
  12676. * The y component of the control stick
  12677. */
  12678. y: number;
  12679. /**
  12680. * Initializes the gamepad x and y control stick values
  12681. * @param x The x component of the gamepad control stick value
  12682. * @param y The y component of the gamepad control stick value
  12683. */
  12684. constructor(
  12685. /**
  12686. * The x component of the control stick
  12687. */
  12688. x: number,
  12689. /**
  12690. * The y component of the control stick
  12691. */
  12692. y: number);
  12693. }
  12694. /**
  12695. * An interface which manages callbacks for gamepad button changes
  12696. */
  12697. export interface GamepadButtonChanges {
  12698. /**
  12699. * Called when a gamepad has been changed
  12700. */
  12701. changed: boolean;
  12702. /**
  12703. * Called when a gamepad press event has been triggered
  12704. */
  12705. pressChanged: boolean;
  12706. /**
  12707. * Called when a touch event has been triggered
  12708. */
  12709. touchChanged: boolean;
  12710. /**
  12711. * Called when a value has changed
  12712. */
  12713. valueChanged: boolean;
  12714. }
  12715. /**
  12716. * Represents a gamepad
  12717. */
  12718. export class Gamepad {
  12719. /**
  12720. * The id of the gamepad
  12721. */
  12722. id: string;
  12723. /**
  12724. * The index of the gamepad
  12725. */
  12726. index: number;
  12727. /**
  12728. * The browser gamepad
  12729. */
  12730. browserGamepad: any;
  12731. /**
  12732. * Specifies what type of gamepad this represents
  12733. */
  12734. type: number;
  12735. private _leftStick;
  12736. private _rightStick;
  12737. /** @hidden */
  12738. _isConnected: boolean;
  12739. private _leftStickAxisX;
  12740. private _leftStickAxisY;
  12741. private _rightStickAxisX;
  12742. private _rightStickAxisY;
  12743. /**
  12744. * Triggered when the left control stick has been changed
  12745. */
  12746. private _onleftstickchanged;
  12747. /**
  12748. * Triggered when the right control stick has been changed
  12749. */
  12750. private _onrightstickchanged;
  12751. /**
  12752. * Represents a gamepad controller
  12753. */
  12754. static GAMEPAD: number;
  12755. /**
  12756. * Represents a generic controller
  12757. */
  12758. static GENERIC: number;
  12759. /**
  12760. * Represents an XBox controller
  12761. */
  12762. static XBOX: number;
  12763. /**
  12764. * Represents a pose-enabled controller
  12765. */
  12766. static POSE_ENABLED: number;
  12767. /**
  12768. * Represents an Dual Shock controller
  12769. */
  12770. static DUALSHOCK: number;
  12771. /**
  12772. * Specifies whether the left control stick should be Y-inverted
  12773. */
  12774. protected _invertLeftStickY: boolean;
  12775. /**
  12776. * Specifies if the gamepad has been connected
  12777. */
  12778. get isConnected(): boolean;
  12779. /**
  12780. * Initializes the gamepad
  12781. * @param id The id of the gamepad
  12782. * @param index The index of the gamepad
  12783. * @param browserGamepad The browser gamepad
  12784. * @param leftStickX The x component of the left joystick
  12785. * @param leftStickY The y component of the left joystick
  12786. * @param rightStickX The x component of the right joystick
  12787. * @param rightStickY The y component of the right joystick
  12788. */
  12789. constructor(
  12790. /**
  12791. * The id of the gamepad
  12792. */
  12793. id: string,
  12794. /**
  12795. * The index of the gamepad
  12796. */
  12797. index: number,
  12798. /**
  12799. * The browser gamepad
  12800. */
  12801. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12802. /**
  12803. * Callback triggered when the left joystick has changed
  12804. * @param callback
  12805. */
  12806. onleftstickchanged(callback: (values: StickValues) => void): void;
  12807. /**
  12808. * Callback triggered when the right joystick has changed
  12809. * @param callback
  12810. */
  12811. onrightstickchanged(callback: (values: StickValues) => void): void;
  12812. /**
  12813. * Gets the left joystick
  12814. */
  12815. get leftStick(): StickValues;
  12816. /**
  12817. * Sets the left joystick values
  12818. */
  12819. set leftStick(newValues: StickValues);
  12820. /**
  12821. * Gets the right joystick
  12822. */
  12823. get rightStick(): StickValues;
  12824. /**
  12825. * Sets the right joystick value
  12826. */
  12827. set rightStick(newValues: StickValues);
  12828. /**
  12829. * Updates the gamepad joystick positions
  12830. */
  12831. update(): void;
  12832. /**
  12833. * Disposes the gamepad
  12834. */
  12835. dispose(): void;
  12836. }
  12837. /**
  12838. * Represents a generic gamepad
  12839. */
  12840. export class GenericPad extends Gamepad {
  12841. private _buttons;
  12842. private _onbuttondown;
  12843. private _onbuttonup;
  12844. /**
  12845. * Observable triggered when a button has been pressed
  12846. */
  12847. onButtonDownObservable: Observable<number>;
  12848. /**
  12849. * Observable triggered when a button has been released
  12850. */
  12851. onButtonUpObservable: Observable<number>;
  12852. /**
  12853. * Callback triggered when a button has been pressed
  12854. * @param callback Called when a button has been pressed
  12855. */
  12856. onbuttondown(callback: (buttonPressed: number) => void): void;
  12857. /**
  12858. * Callback triggered when a button has been released
  12859. * @param callback Called when a button has been released
  12860. */
  12861. onbuttonup(callback: (buttonReleased: number) => void): void;
  12862. /**
  12863. * Initializes the generic gamepad
  12864. * @param id The id of the generic gamepad
  12865. * @param index The index of the generic gamepad
  12866. * @param browserGamepad The browser gamepad
  12867. */
  12868. constructor(id: string, index: number, browserGamepad: any);
  12869. private _setButtonValue;
  12870. /**
  12871. * Updates the generic gamepad
  12872. */
  12873. update(): void;
  12874. /**
  12875. * Disposes the generic gamepad
  12876. */
  12877. dispose(): void;
  12878. }
  12879. }
  12880. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12881. import { Nullable } from "babylonjs/types";
  12882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12883. import { Scene } from "babylonjs/scene";
  12884. module "babylonjs/Engines/engine" {
  12885. interface Engine {
  12886. /**
  12887. * Creates a raw texture
  12888. * @param data defines the data to store in the texture
  12889. * @param width defines the width of the texture
  12890. * @param height defines the height of the texture
  12891. * @param format defines the format of the data
  12892. * @param generateMipMaps defines if the engine should generate the mip levels
  12893. * @param invertY defines if data must be stored with Y axis inverted
  12894. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12895. * @param compression defines the compression used (null by default)
  12896. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12897. * @returns the raw texture inside an InternalTexture
  12898. */
  12899. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12900. /**
  12901. * Update a raw texture
  12902. * @param texture defines the texture to update
  12903. * @param data defines the data to store in the texture
  12904. * @param format defines the format of the data
  12905. * @param invertY defines if data must be stored with Y axis inverted
  12906. */
  12907. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12908. /**
  12909. * Update a raw texture
  12910. * @param texture defines the texture to update
  12911. * @param data defines the data to store in the texture
  12912. * @param format defines the format of the data
  12913. * @param invertY defines if data must be stored with Y axis inverted
  12914. * @param compression defines the compression used (null by default)
  12915. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12916. */
  12917. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12918. /**
  12919. * Creates a new raw cube texture
  12920. * @param data defines the array of data to use to create each face
  12921. * @param size defines the size of the textures
  12922. * @param format defines the format of the data
  12923. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12924. * @param generateMipMaps defines if the engine should generate the mip levels
  12925. * @param invertY defines if data must be stored with Y axis inverted
  12926. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12927. * @param compression defines the compression used (null by default)
  12928. * @returns the cube texture as an InternalTexture
  12929. */
  12930. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12931. /**
  12932. * Update a raw cube texture
  12933. * @param texture defines the texture to udpdate
  12934. * @param data defines the data to store
  12935. * @param format defines the data format
  12936. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12937. * @param invertY defines if data must be stored with Y axis inverted
  12938. */
  12939. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12940. /**
  12941. * Update a raw cube texture
  12942. * @param texture defines the texture to udpdate
  12943. * @param data defines the data to store
  12944. * @param format defines the data format
  12945. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12946. * @param invertY defines if data must be stored with Y axis inverted
  12947. * @param compression defines the compression used (null by default)
  12948. */
  12949. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12950. /**
  12951. * Update a raw cube texture
  12952. * @param texture defines the texture to udpdate
  12953. * @param data defines the data to store
  12954. * @param format defines the data format
  12955. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12956. * @param invertY defines if data must be stored with Y axis inverted
  12957. * @param compression defines the compression used (null by default)
  12958. * @param level defines which level of the texture to update
  12959. */
  12960. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12961. /**
  12962. * Creates a new raw cube texture from a specified url
  12963. * @param url defines the url where the data is located
  12964. * @param scene defines the current scene
  12965. * @param size defines the size of the textures
  12966. * @param format defines the format of the data
  12967. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12968. * @param noMipmap defines if the engine should avoid generating the mip levels
  12969. * @param callback defines a callback used to extract texture data from loaded data
  12970. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12971. * @param onLoad defines a callback called when texture is loaded
  12972. * @param onError defines a callback called if there is an error
  12973. * @returns the cube texture as an InternalTexture
  12974. */
  12975. 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;
  12976. /**
  12977. * Creates a new raw cube texture from a specified url
  12978. * @param url defines the url where the data is located
  12979. * @param scene defines the current scene
  12980. * @param size defines the size of the textures
  12981. * @param format defines the format of the data
  12982. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12983. * @param noMipmap defines if the engine should avoid generating the mip levels
  12984. * @param callback defines a callback used to extract texture data from loaded data
  12985. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12986. * @param onLoad defines a callback called when texture is loaded
  12987. * @param onError defines a callback called if there is an error
  12988. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12989. * @param invertY defines if data must be stored with Y axis inverted
  12990. * @returns the cube texture as an InternalTexture
  12991. */
  12992. 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;
  12993. /**
  12994. * Creates a new raw 3D texture
  12995. * @param data defines the data used to create the texture
  12996. * @param width defines the width of the texture
  12997. * @param height defines the height of the texture
  12998. * @param depth defines the depth of the texture
  12999. * @param format defines the format of the texture
  13000. * @param generateMipMaps defines if the engine must generate mip levels
  13001. * @param invertY defines if data must be stored with Y axis inverted
  13002. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13003. * @param compression defines the compressed used (can be null)
  13004. * @param textureType defines the compressed used (can be null)
  13005. * @returns a new raw 3D texture (stored in an InternalTexture)
  13006. */
  13007. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13008. /**
  13009. * Update a raw 3D texture
  13010. * @param texture defines the texture to update
  13011. * @param data defines the data to store
  13012. * @param format defines the data format
  13013. * @param invertY defines if data must be stored with Y axis inverted
  13014. */
  13015. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13016. /**
  13017. * Update a raw 3D texture
  13018. * @param texture defines the texture to update
  13019. * @param data defines the data to store
  13020. * @param format defines the data format
  13021. * @param invertY defines if data must be stored with Y axis inverted
  13022. * @param compression defines the used compression (can be null)
  13023. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13024. */
  13025. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13026. /**
  13027. * Creates a new raw 2D array texture
  13028. * @param data defines the data used to create the texture
  13029. * @param width defines the width of the texture
  13030. * @param height defines the height of the texture
  13031. * @param depth defines the number of layers of the texture
  13032. * @param format defines the format of the texture
  13033. * @param generateMipMaps defines if the engine must generate mip levels
  13034. * @param invertY defines if data must be stored with Y axis inverted
  13035. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13036. * @param compression defines the compressed used (can be null)
  13037. * @param textureType defines the compressed used (can be null)
  13038. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13039. */
  13040. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13041. /**
  13042. * Update a raw 2D array texture
  13043. * @param texture defines the texture to update
  13044. * @param data defines the data to store
  13045. * @param format defines the data format
  13046. * @param invertY defines if data must be stored with Y axis inverted
  13047. */
  13048. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13049. /**
  13050. * Update a raw 2D array texture
  13051. * @param texture defines the texture to update
  13052. * @param data defines the data to store
  13053. * @param format defines the data format
  13054. * @param invertY defines if data must be stored with Y axis inverted
  13055. * @param compression defines the used compression (can be null)
  13056. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13057. */
  13058. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13059. }
  13060. }
  13061. }
  13062. declare module "babylonjs/Materials/Textures/rawTexture" {
  13063. import { Scene } from "babylonjs/scene";
  13064. import { Texture } from "babylonjs/Materials/Textures/texture";
  13065. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13066. /**
  13067. * Raw texture can help creating a texture directly from an array of data.
  13068. * This can be super useful if you either get the data from an uncompressed source or
  13069. * if you wish to create your texture pixel by pixel.
  13070. */
  13071. export class RawTexture extends Texture {
  13072. /**
  13073. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13074. */
  13075. format: number;
  13076. private _engine;
  13077. /**
  13078. * Instantiates a new RawTexture.
  13079. * Raw texture can help creating a texture directly from an array of data.
  13080. * This can be super useful if you either get the data from an uncompressed source or
  13081. * if you wish to create your texture pixel by pixel.
  13082. * @param data define the array of data to use to create the texture
  13083. * @param width define the width of the texture
  13084. * @param height define the height of the texture
  13085. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13086. * @param scene define the scene the texture belongs to
  13087. * @param generateMipMaps define whether mip maps should be generated or not
  13088. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13089. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13090. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13091. */
  13092. constructor(data: ArrayBufferView, width: number, height: number,
  13093. /**
  13094. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13095. */
  13096. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13097. /**
  13098. * Updates the texture underlying data.
  13099. * @param data Define the new data of the texture
  13100. */
  13101. update(data: ArrayBufferView): void;
  13102. /**
  13103. * Creates a luminance texture from some data.
  13104. * @param data Define the texture data
  13105. * @param width Define the width of the texture
  13106. * @param height Define the height of the texture
  13107. * @param scene Define the scene the texture belongs to
  13108. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13109. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13110. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13111. * @returns the luminance texture
  13112. */
  13113. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13114. /**
  13115. * Creates a luminance alpha texture from some data.
  13116. * @param data Define the texture data
  13117. * @param width Define the width of the texture
  13118. * @param height Define the height of the texture
  13119. * @param scene Define the scene the texture belongs to
  13120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13123. * @returns the luminance alpha texture
  13124. */
  13125. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13126. /**
  13127. * Creates an alpha texture from some data.
  13128. * @param data Define the texture data
  13129. * @param width Define the width of the texture
  13130. * @param height Define the height of the texture
  13131. * @param scene Define the scene the texture belongs to
  13132. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13133. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13134. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13135. * @returns the alpha texture
  13136. */
  13137. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13138. /**
  13139. * Creates a RGB texture from some data.
  13140. * @param data Define the texture data
  13141. * @param width Define the width of the texture
  13142. * @param height Define the height of the texture
  13143. * @param scene Define the scene the texture belongs to
  13144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13147. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13148. * @returns the RGB alpha texture
  13149. */
  13150. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13151. /**
  13152. * Creates a RGBA texture from some data.
  13153. * @param data Define the texture data
  13154. * @param width Define the width of the texture
  13155. * @param height Define the height of the texture
  13156. * @param scene Define the scene the texture belongs to
  13157. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13158. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13159. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13160. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13161. * @returns the RGBA texture
  13162. */
  13163. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13164. /**
  13165. * Creates a R texture from some data.
  13166. * @param data Define the texture data
  13167. * @param width Define the width of the texture
  13168. * @param height Define the height of the texture
  13169. * @param scene Define the scene the texture belongs to
  13170. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13171. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13172. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13173. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13174. * @returns the R texture
  13175. */
  13176. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13177. }
  13178. }
  13179. declare module "babylonjs/Maths/math.size" {
  13180. /**
  13181. * Interface for the size containing width and height
  13182. */
  13183. export interface ISize {
  13184. /**
  13185. * Width
  13186. */
  13187. width: number;
  13188. /**
  13189. * Heighht
  13190. */
  13191. height: number;
  13192. }
  13193. /**
  13194. * Size containing widht and height
  13195. */
  13196. export class Size implements ISize {
  13197. /**
  13198. * Width
  13199. */
  13200. width: number;
  13201. /**
  13202. * Height
  13203. */
  13204. height: number;
  13205. /**
  13206. * Creates a Size object from the given width and height (floats).
  13207. * @param width width of the new size
  13208. * @param height height of the new size
  13209. */
  13210. constructor(width: number, height: number);
  13211. /**
  13212. * Returns a string with the Size width and height
  13213. * @returns a string with the Size width and height
  13214. */
  13215. toString(): string;
  13216. /**
  13217. * "Size"
  13218. * @returns the string "Size"
  13219. */
  13220. getClassName(): string;
  13221. /**
  13222. * Returns the Size hash code.
  13223. * @returns a hash code for a unique width and height
  13224. */
  13225. getHashCode(): number;
  13226. /**
  13227. * Updates the current size from the given one.
  13228. * @param src the given size
  13229. */
  13230. copyFrom(src: Size): void;
  13231. /**
  13232. * Updates in place the current Size from the given floats.
  13233. * @param width width of the new size
  13234. * @param height height of the new size
  13235. * @returns the updated Size.
  13236. */
  13237. copyFromFloats(width: number, height: number): Size;
  13238. /**
  13239. * Updates in place the current Size from the given floats.
  13240. * @param width width to set
  13241. * @param height height to set
  13242. * @returns the updated Size.
  13243. */
  13244. set(width: number, height: number): Size;
  13245. /**
  13246. * Multiplies the width and height by numbers
  13247. * @param w factor to multiple the width by
  13248. * @param h factor to multiple the height by
  13249. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13250. */
  13251. multiplyByFloats(w: number, h: number): Size;
  13252. /**
  13253. * Clones the size
  13254. * @returns a new Size copied from the given one.
  13255. */
  13256. clone(): Size;
  13257. /**
  13258. * True if the current Size and the given one width and height are strictly equal.
  13259. * @param other the other size to compare against
  13260. * @returns True if the current Size and the given one width and height are strictly equal.
  13261. */
  13262. equals(other: Size): boolean;
  13263. /**
  13264. * The surface of the Size : width * height (float).
  13265. */
  13266. get surface(): number;
  13267. /**
  13268. * Create a new size of zero
  13269. * @returns a new Size set to (0.0, 0.0)
  13270. */
  13271. static Zero(): Size;
  13272. /**
  13273. * Sums the width and height of two sizes
  13274. * @param otherSize size to add to this size
  13275. * @returns a new Size set as the addition result of the current Size and the given one.
  13276. */
  13277. add(otherSize: Size): Size;
  13278. /**
  13279. * Subtracts the width and height of two
  13280. * @param otherSize size to subtract to this size
  13281. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13282. */
  13283. subtract(otherSize: Size): Size;
  13284. /**
  13285. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13286. * @param start starting size to lerp between
  13287. * @param end end size to lerp between
  13288. * @param amount amount to lerp between the start and end values
  13289. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13290. */
  13291. static Lerp(start: Size, end: Size, amount: number): Size;
  13292. }
  13293. }
  13294. declare module "babylonjs/Animations/runtimeAnimation" {
  13295. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13296. import { Animatable } from "babylonjs/Animations/animatable";
  13297. import { Scene } from "babylonjs/scene";
  13298. /**
  13299. * Defines a runtime animation
  13300. */
  13301. export class RuntimeAnimation {
  13302. private _events;
  13303. /**
  13304. * The current frame of the runtime animation
  13305. */
  13306. private _currentFrame;
  13307. /**
  13308. * The animation used by the runtime animation
  13309. */
  13310. private _animation;
  13311. /**
  13312. * The target of the runtime animation
  13313. */
  13314. private _target;
  13315. /**
  13316. * The initiating animatable
  13317. */
  13318. private _host;
  13319. /**
  13320. * The original value of the runtime animation
  13321. */
  13322. private _originalValue;
  13323. /**
  13324. * The original blend value of the runtime animation
  13325. */
  13326. private _originalBlendValue;
  13327. /**
  13328. * The offsets cache of the runtime animation
  13329. */
  13330. private _offsetsCache;
  13331. /**
  13332. * The high limits cache of the runtime animation
  13333. */
  13334. private _highLimitsCache;
  13335. /**
  13336. * Specifies if the runtime animation has been stopped
  13337. */
  13338. private _stopped;
  13339. /**
  13340. * The blending factor of the runtime animation
  13341. */
  13342. private _blendingFactor;
  13343. /**
  13344. * The BabylonJS scene
  13345. */
  13346. private _scene;
  13347. /**
  13348. * The current value of the runtime animation
  13349. */
  13350. private _currentValue;
  13351. /** @hidden */
  13352. _animationState: _IAnimationState;
  13353. /**
  13354. * The active target of the runtime animation
  13355. */
  13356. private _activeTargets;
  13357. private _currentActiveTarget;
  13358. private _directTarget;
  13359. /**
  13360. * The target path of the runtime animation
  13361. */
  13362. private _targetPath;
  13363. /**
  13364. * The weight of the runtime animation
  13365. */
  13366. private _weight;
  13367. /**
  13368. * The ratio offset of the runtime animation
  13369. */
  13370. private _ratioOffset;
  13371. /**
  13372. * The previous delay of the runtime animation
  13373. */
  13374. private _previousDelay;
  13375. /**
  13376. * The previous ratio of the runtime animation
  13377. */
  13378. private _previousRatio;
  13379. private _enableBlending;
  13380. private _keys;
  13381. private _minFrame;
  13382. private _maxFrame;
  13383. private _minValue;
  13384. private _maxValue;
  13385. private _targetIsArray;
  13386. /**
  13387. * Gets the current frame of the runtime animation
  13388. */
  13389. get currentFrame(): number;
  13390. /**
  13391. * Gets the weight of the runtime animation
  13392. */
  13393. get weight(): number;
  13394. /**
  13395. * Gets the current value of the runtime animation
  13396. */
  13397. get currentValue(): any;
  13398. /**
  13399. * Gets the target path of the runtime animation
  13400. */
  13401. get targetPath(): string;
  13402. /**
  13403. * Gets the actual target of the runtime animation
  13404. */
  13405. get target(): any;
  13406. /** @hidden */
  13407. _onLoop: () => void;
  13408. /**
  13409. * Create a new RuntimeAnimation object
  13410. * @param target defines the target of the animation
  13411. * @param animation defines the source animation object
  13412. * @param scene defines the hosting scene
  13413. * @param host defines the initiating Animatable
  13414. */
  13415. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13416. private _preparePath;
  13417. /**
  13418. * Gets the animation from the runtime animation
  13419. */
  13420. get animation(): Animation;
  13421. /**
  13422. * Resets the runtime animation to the beginning
  13423. * @param restoreOriginal defines whether to restore the target property to the original value
  13424. */
  13425. reset(restoreOriginal?: boolean): void;
  13426. /**
  13427. * Specifies if the runtime animation is stopped
  13428. * @returns Boolean specifying if the runtime animation is stopped
  13429. */
  13430. isStopped(): boolean;
  13431. /**
  13432. * Disposes of the runtime animation
  13433. */
  13434. dispose(): void;
  13435. /**
  13436. * Apply the interpolated value to the target
  13437. * @param currentValue defines the value computed by the animation
  13438. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13439. */
  13440. setValue(currentValue: any, weight: number): void;
  13441. private _getOriginalValues;
  13442. private _setValue;
  13443. /**
  13444. * Gets the loop pmode of the runtime animation
  13445. * @returns Loop Mode
  13446. */
  13447. private _getCorrectLoopMode;
  13448. /**
  13449. * Move the current animation to a given frame
  13450. * @param frame defines the frame to move to
  13451. */
  13452. goToFrame(frame: number): void;
  13453. /**
  13454. * @hidden Internal use only
  13455. */
  13456. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13457. /**
  13458. * Execute the current animation
  13459. * @param delay defines the delay to add to the current frame
  13460. * @param from defines the lower bound of the animation range
  13461. * @param to defines the upper bound of the animation range
  13462. * @param loop defines if the current animation must loop
  13463. * @param speedRatio defines the current speed ratio
  13464. * @param weight defines the weight of the animation (default is -1 so no weight)
  13465. * @param onLoop optional callback called when animation loops
  13466. * @returns a boolean indicating if the animation is running
  13467. */
  13468. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13469. }
  13470. }
  13471. declare module "babylonjs/Animations/animatable" {
  13472. import { Animation } from "babylonjs/Animations/animation";
  13473. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13474. import { Nullable } from "babylonjs/types";
  13475. import { Observable } from "babylonjs/Misc/observable";
  13476. import { Scene } from "babylonjs/scene";
  13477. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13478. import { Node } from "babylonjs/node";
  13479. /**
  13480. * Class used to store an actual running animation
  13481. */
  13482. export class Animatable {
  13483. /** defines the target object */
  13484. target: any;
  13485. /** defines the starting frame number (default is 0) */
  13486. fromFrame: number;
  13487. /** defines the ending frame number (default is 100) */
  13488. toFrame: number;
  13489. /** defines if the animation must loop (default is false) */
  13490. loopAnimation: boolean;
  13491. /** defines a callback to call when animation ends if it is not looping */
  13492. onAnimationEnd?: (() => void) | null | undefined;
  13493. /** defines a callback to call when animation loops */
  13494. onAnimationLoop?: (() => void) | null | undefined;
  13495. private _localDelayOffset;
  13496. private _pausedDelay;
  13497. private _runtimeAnimations;
  13498. private _paused;
  13499. private _scene;
  13500. private _speedRatio;
  13501. private _weight;
  13502. private _syncRoot;
  13503. /**
  13504. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13505. * This will only apply for non looping animation (default is true)
  13506. */
  13507. disposeOnEnd: boolean;
  13508. /**
  13509. * Gets a boolean indicating if the animation has started
  13510. */
  13511. animationStarted: boolean;
  13512. /**
  13513. * Observer raised when the animation ends
  13514. */
  13515. onAnimationEndObservable: Observable<Animatable>;
  13516. /**
  13517. * Observer raised when the animation loops
  13518. */
  13519. onAnimationLoopObservable: Observable<Animatable>;
  13520. /**
  13521. * Gets the root Animatable used to synchronize and normalize animations
  13522. */
  13523. get syncRoot(): Nullable<Animatable>;
  13524. /**
  13525. * Gets the current frame of the first RuntimeAnimation
  13526. * Used to synchronize Animatables
  13527. */
  13528. get masterFrame(): number;
  13529. /**
  13530. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13531. */
  13532. get weight(): number;
  13533. set weight(value: number);
  13534. /**
  13535. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13536. */
  13537. get speedRatio(): number;
  13538. set speedRatio(value: number);
  13539. /**
  13540. * Creates a new Animatable
  13541. * @param scene defines the hosting scene
  13542. * @param target defines the target object
  13543. * @param fromFrame defines the starting frame number (default is 0)
  13544. * @param toFrame defines the ending frame number (default is 100)
  13545. * @param loopAnimation defines if the animation must loop (default is false)
  13546. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13547. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13548. * @param animations defines a group of animation to add to the new Animatable
  13549. * @param onAnimationLoop defines a callback to call when animation loops
  13550. */
  13551. constructor(scene: Scene,
  13552. /** defines the target object */
  13553. target: any,
  13554. /** defines the starting frame number (default is 0) */
  13555. fromFrame?: number,
  13556. /** defines the ending frame number (default is 100) */
  13557. toFrame?: number,
  13558. /** defines if the animation must loop (default is false) */
  13559. loopAnimation?: boolean, speedRatio?: number,
  13560. /** defines a callback to call when animation ends if it is not looping */
  13561. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13562. /** defines a callback to call when animation loops */
  13563. onAnimationLoop?: (() => void) | null | undefined);
  13564. /**
  13565. * Synchronize and normalize current Animatable with a source Animatable
  13566. * This is useful when using animation weights and when animations are not of the same length
  13567. * @param root defines the root Animatable to synchronize with
  13568. * @returns the current Animatable
  13569. */
  13570. syncWith(root: Animatable): Animatable;
  13571. /**
  13572. * Gets the list of runtime animations
  13573. * @returns an array of RuntimeAnimation
  13574. */
  13575. getAnimations(): RuntimeAnimation[];
  13576. /**
  13577. * Adds more animations to the current animatable
  13578. * @param target defines the target of the animations
  13579. * @param animations defines the new animations to add
  13580. */
  13581. appendAnimations(target: any, animations: Animation[]): void;
  13582. /**
  13583. * Gets the source animation for a specific property
  13584. * @param property defines the propertyu to look for
  13585. * @returns null or the source animation for the given property
  13586. */
  13587. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13588. /**
  13589. * Gets the runtime animation for a specific property
  13590. * @param property defines the propertyu to look for
  13591. * @returns null or the runtime animation for the given property
  13592. */
  13593. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13594. /**
  13595. * Resets the animatable to its original state
  13596. */
  13597. reset(): void;
  13598. /**
  13599. * Allows the animatable to blend with current running animations
  13600. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13601. * @param blendingSpeed defines the blending speed to use
  13602. */
  13603. enableBlending(blendingSpeed: number): void;
  13604. /**
  13605. * Disable animation blending
  13606. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13607. */
  13608. disableBlending(): void;
  13609. /**
  13610. * Jump directly to a given frame
  13611. * @param frame defines the frame to jump to
  13612. */
  13613. goToFrame(frame: number): void;
  13614. /**
  13615. * Pause the animation
  13616. */
  13617. pause(): void;
  13618. /**
  13619. * Restart the animation
  13620. */
  13621. restart(): void;
  13622. private _raiseOnAnimationEnd;
  13623. /**
  13624. * Stop and delete the current animation
  13625. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13626. * @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)
  13627. */
  13628. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13629. /**
  13630. * Wait asynchronously for the animation to end
  13631. * @returns a promise which will be fullfilled when the animation ends
  13632. */
  13633. waitAsync(): Promise<Animatable>;
  13634. /** @hidden */
  13635. _animate(delay: number): boolean;
  13636. }
  13637. module "babylonjs/scene" {
  13638. interface Scene {
  13639. /** @hidden */
  13640. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13641. /** @hidden */
  13642. _processLateAnimationBindingsForMatrices(holder: {
  13643. totalWeight: number;
  13644. animations: RuntimeAnimation[];
  13645. originalValue: Matrix;
  13646. }): any;
  13647. /** @hidden */
  13648. _processLateAnimationBindingsForQuaternions(holder: {
  13649. totalWeight: number;
  13650. animations: RuntimeAnimation[];
  13651. originalValue: Quaternion;
  13652. }, refQuaternion: Quaternion): Quaternion;
  13653. /** @hidden */
  13654. _processLateAnimationBindings(): void;
  13655. /**
  13656. * Will start the animation sequence of a given target
  13657. * @param target defines the target
  13658. * @param from defines from which frame should animation start
  13659. * @param to defines until which frame should animation run.
  13660. * @param weight defines the weight to apply to the animation (1.0 by default)
  13661. * @param loop defines if the animation loops
  13662. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13663. * @param onAnimationEnd defines the function to be executed when the animation ends
  13664. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13665. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13666. * @param onAnimationLoop defines the callback to call when an animation loops
  13667. * @returns the animatable object created for this animation
  13668. */
  13669. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13670. /**
  13671. * Will start the animation sequence of a given target
  13672. * @param target defines the target
  13673. * @param from defines from which frame should animation start
  13674. * @param to defines until which frame should animation run.
  13675. * @param loop defines if the animation loops
  13676. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13677. * @param onAnimationEnd defines the function to be executed when the animation ends
  13678. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13679. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13680. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13681. * @param onAnimationLoop defines the callback to call when an animation loops
  13682. * @returns the animatable object created for this animation
  13683. */
  13684. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13685. /**
  13686. * Will start the animation sequence of a given target and its hierarchy
  13687. * @param target defines the target
  13688. * @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.
  13689. * @param from defines from which frame should animation start
  13690. * @param to defines until which frame should animation run.
  13691. * @param loop defines if the animation loops
  13692. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13693. * @param onAnimationEnd defines the function to be executed when the animation ends
  13694. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13695. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13696. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13697. * @param onAnimationLoop defines the callback to call when an animation loops
  13698. * @returns the list of created animatables
  13699. */
  13700. 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[];
  13701. /**
  13702. * Begin a new animation on a given node
  13703. * @param target defines the target where the animation will take place
  13704. * @param animations defines the list of animations to start
  13705. * @param from defines the initial value
  13706. * @param to defines the final value
  13707. * @param loop defines if you want animation to loop (off by default)
  13708. * @param speedRatio defines the speed ratio to apply to all animations
  13709. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13710. * @param onAnimationLoop defines the callback to call when an animation loops
  13711. * @returns the list of created animatables
  13712. */
  13713. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13714. /**
  13715. * Begin a new animation on a given node and its hierarchy
  13716. * @param target defines the root node where the animation will take place
  13717. * @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.
  13718. * @param animations defines the list of animations to start
  13719. * @param from defines the initial value
  13720. * @param to defines the final value
  13721. * @param loop defines if you want animation to loop (off by default)
  13722. * @param speedRatio defines the speed ratio to apply to all animations
  13723. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13724. * @param onAnimationLoop defines the callback to call when an animation loops
  13725. * @returns the list of animatables created for all nodes
  13726. */
  13727. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13728. /**
  13729. * Gets the animatable associated with a specific target
  13730. * @param target defines the target of the animatable
  13731. * @returns the required animatable if found
  13732. */
  13733. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13734. /**
  13735. * Gets all animatables associated with a given target
  13736. * @param target defines the target to look animatables for
  13737. * @returns an array of Animatables
  13738. */
  13739. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13740. /**
  13741. * Stops and removes all animations that have been applied to the scene
  13742. */
  13743. stopAllAnimations(): void;
  13744. /**
  13745. * Gets the current delta time used by animation engine
  13746. */
  13747. deltaTime: number;
  13748. }
  13749. }
  13750. module "babylonjs/Bones/bone" {
  13751. interface Bone {
  13752. /**
  13753. * Copy an animation range from another bone
  13754. * @param source defines the source bone
  13755. * @param rangeName defines the range name to copy
  13756. * @param frameOffset defines the frame offset
  13757. * @param rescaleAsRequired defines if rescaling must be applied if required
  13758. * @param skelDimensionsRatio defines the scaling ratio
  13759. * @returns true if operation was successful
  13760. */
  13761. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13762. }
  13763. }
  13764. }
  13765. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13766. /**
  13767. * Class used to override all child animations of a given target
  13768. */
  13769. export class AnimationPropertiesOverride {
  13770. /**
  13771. * Gets or sets a value indicating if animation blending must be used
  13772. */
  13773. enableBlending: boolean;
  13774. /**
  13775. * Gets or sets the blending speed to use when enableBlending is true
  13776. */
  13777. blendingSpeed: number;
  13778. /**
  13779. * Gets or sets the default loop mode to use
  13780. */
  13781. loopMode: number;
  13782. }
  13783. }
  13784. declare module "babylonjs/Bones/skeleton" {
  13785. import { Bone } from "babylonjs/Bones/bone";
  13786. import { Observable } from "babylonjs/Misc/observable";
  13787. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13788. import { Scene } from "babylonjs/scene";
  13789. import { Nullable } from "babylonjs/types";
  13790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13791. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13792. import { Animatable } from "babylonjs/Animations/animatable";
  13793. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13794. import { Animation } from "babylonjs/Animations/animation";
  13795. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13796. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13797. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13798. /**
  13799. * Class used to handle skinning animations
  13800. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13801. */
  13802. export class Skeleton implements IAnimatable {
  13803. /** defines the skeleton name */
  13804. name: string;
  13805. /** defines the skeleton Id */
  13806. id: string;
  13807. /**
  13808. * Defines the list of child bones
  13809. */
  13810. bones: Bone[];
  13811. /**
  13812. * Defines an estimate of the dimension of the skeleton at rest
  13813. */
  13814. dimensionsAtRest: Vector3;
  13815. /**
  13816. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13817. */
  13818. needInitialSkinMatrix: boolean;
  13819. /**
  13820. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13821. */
  13822. overrideMesh: Nullable<AbstractMesh>;
  13823. /**
  13824. * Gets the list of animations attached to this skeleton
  13825. */
  13826. animations: Array<Animation>;
  13827. private _scene;
  13828. private _isDirty;
  13829. private _transformMatrices;
  13830. private _transformMatrixTexture;
  13831. private _meshesWithPoseMatrix;
  13832. private _animatables;
  13833. private _identity;
  13834. private _synchronizedWithMesh;
  13835. private _ranges;
  13836. private _lastAbsoluteTransformsUpdateId;
  13837. private _canUseTextureForBones;
  13838. private _uniqueId;
  13839. /** @hidden */
  13840. _numBonesWithLinkedTransformNode: number;
  13841. /** @hidden */
  13842. _hasWaitingData: Nullable<boolean>;
  13843. /**
  13844. * Specifies if the skeleton should be serialized
  13845. */
  13846. doNotSerialize: boolean;
  13847. private _useTextureToStoreBoneMatrices;
  13848. /**
  13849. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13850. * Please note that this option is not available if the hardware does not support it
  13851. */
  13852. get useTextureToStoreBoneMatrices(): boolean;
  13853. set useTextureToStoreBoneMatrices(value: boolean);
  13854. private _animationPropertiesOverride;
  13855. /**
  13856. * Gets or sets the animation properties override
  13857. */
  13858. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13859. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13860. /**
  13861. * List of inspectable custom properties (used by the Inspector)
  13862. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13863. */
  13864. inspectableCustomProperties: IInspectable[];
  13865. /**
  13866. * An observable triggered before computing the skeleton's matrices
  13867. */
  13868. onBeforeComputeObservable: Observable<Skeleton>;
  13869. /**
  13870. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13871. */
  13872. get isUsingTextureForMatrices(): boolean;
  13873. /**
  13874. * Gets the unique ID of this skeleton
  13875. */
  13876. get uniqueId(): number;
  13877. /**
  13878. * Creates a new skeleton
  13879. * @param name defines the skeleton name
  13880. * @param id defines the skeleton Id
  13881. * @param scene defines the hosting scene
  13882. */
  13883. constructor(
  13884. /** defines the skeleton name */
  13885. name: string,
  13886. /** defines the skeleton Id */
  13887. id: string, scene: Scene);
  13888. /**
  13889. * Gets the current object class name.
  13890. * @return the class name
  13891. */
  13892. getClassName(): string;
  13893. /**
  13894. * Returns an array containing the root bones
  13895. * @returns an array containing the root bones
  13896. */
  13897. getChildren(): Array<Bone>;
  13898. /**
  13899. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13900. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13901. * @returns a Float32Array containing matrices data
  13902. */
  13903. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13904. /**
  13905. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13906. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13907. * @returns a raw texture containing the data
  13908. */
  13909. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13910. /**
  13911. * Gets the current hosting scene
  13912. * @returns a scene object
  13913. */
  13914. getScene(): Scene;
  13915. /**
  13916. * Gets a string representing the current skeleton data
  13917. * @param fullDetails defines a boolean indicating if we want a verbose version
  13918. * @returns a string representing the current skeleton data
  13919. */
  13920. toString(fullDetails?: boolean): string;
  13921. /**
  13922. * Get bone's index searching by name
  13923. * @param name defines bone's name to search for
  13924. * @return the indice of the bone. Returns -1 if not found
  13925. */
  13926. getBoneIndexByName(name: string): number;
  13927. /**
  13928. * Creater a new animation range
  13929. * @param name defines the name of the range
  13930. * @param from defines the start key
  13931. * @param to defines the end key
  13932. */
  13933. createAnimationRange(name: string, from: number, to: number): void;
  13934. /**
  13935. * Delete a specific animation range
  13936. * @param name defines the name of the range
  13937. * @param deleteFrames defines if frames must be removed as well
  13938. */
  13939. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13940. /**
  13941. * Gets a specific animation range
  13942. * @param name defines the name of the range to look for
  13943. * @returns the requested animation range or null if not found
  13944. */
  13945. getAnimationRange(name: string): Nullable<AnimationRange>;
  13946. /**
  13947. * Gets the list of all animation ranges defined on this skeleton
  13948. * @returns an array
  13949. */
  13950. getAnimationRanges(): Nullable<AnimationRange>[];
  13951. /**
  13952. * Copy animation range from a source skeleton.
  13953. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13954. * @param source defines the source skeleton
  13955. * @param name defines the name of the range to copy
  13956. * @param rescaleAsRequired defines if rescaling must be applied if required
  13957. * @returns true if operation was successful
  13958. */
  13959. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13960. /**
  13961. * Forces the skeleton to go to rest pose
  13962. */
  13963. returnToRest(): void;
  13964. private _getHighestAnimationFrame;
  13965. /**
  13966. * Begin a specific animation range
  13967. * @param name defines the name of the range to start
  13968. * @param loop defines if looping must be turned on (false by default)
  13969. * @param speedRatio defines the speed ratio to apply (1 by default)
  13970. * @param onAnimationEnd defines a callback which will be called when animation will end
  13971. * @returns a new animatable
  13972. */
  13973. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13974. /** @hidden */
  13975. _markAsDirty(): void;
  13976. /** @hidden */
  13977. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13978. /** @hidden */
  13979. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13980. private _computeTransformMatrices;
  13981. /**
  13982. * Build all resources required to render a skeleton
  13983. */
  13984. prepare(): void;
  13985. /**
  13986. * Gets the list of animatables currently running for this skeleton
  13987. * @returns an array of animatables
  13988. */
  13989. getAnimatables(): IAnimatable[];
  13990. /**
  13991. * Clone the current skeleton
  13992. * @param name defines the name of the new skeleton
  13993. * @param id defines the id of the new skeleton
  13994. * @returns the new skeleton
  13995. */
  13996. clone(name: string, id?: string): Skeleton;
  13997. /**
  13998. * Enable animation blending for this skeleton
  13999. * @param blendingSpeed defines the blending speed to apply
  14000. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14001. */
  14002. enableBlending(blendingSpeed?: number): void;
  14003. /**
  14004. * Releases all resources associated with the current skeleton
  14005. */
  14006. dispose(): void;
  14007. /**
  14008. * Serialize the skeleton in a JSON object
  14009. * @returns a JSON object
  14010. */
  14011. serialize(): any;
  14012. /**
  14013. * Creates a new skeleton from serialized data
  14014. * @param parsedSkeleton defines the serialized data
  14015. * @param scene defines the hosting scene
  14016. * @returns a new skeleton
  14017. */
  14018. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  14019. /**
  14020. * Compute all node absolute transforms
  14021. * @param forceUpdate defines if computation must be done even if cache is up to date
  14022. */
  14023. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  14024. /**
  14025. * Gets the root pose matrix
  14026. * @returns a matrix
  14027. */
  14028. getPoseMatrix(): Nullable<Matrix>;
  14029. /**
  14030. * Sorts bones per internal index
  14031. */
  14032. sortBones(): void;
  14033. private _sortBones;
  14034. }
  14035. }
  14036. declare module "babylonjs/Bones/bone" {
  14037. import { Skeleton } from "babylonjs/Bones/skeleton";
  14038. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14039. import { Nullable } from "babylonjs/types";
  14040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14042. import { Node } from "babylonjs/node";
  14043. import { Space } from "babylonjs/Maths/math.axis";
  14044. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14045. /**
  14046. * Class used to store bone information
  14047. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14048. */
  14049. export class Bone extends Node {
  14050. /**
  14051. * defines the bone name
  14052. */
  14053. name: string;
  14054. private static _tmpVecs;
  14055. private static _tmpQuat;
  14056. private static _tmpMats;
  14057. /**
  14058. * Gets the list of child bones
  14059. */
  14060. children: Bone[];
  14061. /** Gets the animations associated with this bone */
  14062. animations: import("babylonjs/Animations/animation").Animation[];
  14063. /**
  14064. * Gets or sets bone length
  14065. */
  14066. length: number;
  14067. /**
  14068. * @hidden Internal only
  14069. * Set this value to map this bone to a different index in the transform matrices
  14070. * Set this value to -1 to exclude the bone from the transform matrices
  14071. */
  14072. _index: Nullable<number>;
  14073. private _skeleton;
  14074. private _localMatrix;
  14075. private _restPose;
  14076. private _baseMatrix;
  14077. private _absoluteTransform;
  14078. private _invertedAbsoluteTransform;
  14079. private _parent;
  14080. private _scalingDeterminant;
  14081. private _worldTransform;
  14082. private _localScaling;
  14083. private _localRotation;
  14084. private _localPosition;
  14085. private _needToDecompose;
  14086. private _needToCompose;
  14087. /** @hidden */
  14088. _linkedTransformNode: Nullable<TransformNode>;
  14089. /** @hidden */
  14090. _waitingTransformNodeId: Nullable<string>;
  14091. /** @hidden */
  14092. get _matrix(): Matrix;
  14093. /** @hidden */
  14094. set _matrix(value: Matrix);
  14095. /**
  14096. * Create a new bone
  14097. * @param name defines the bone name
  14098. * @param skeleton defines the parent skeleton
  14099. * @param parentBone defines the parent (can be null if the bone is the root)
  14100. * @param localMatrix defines the local matrix
  14101. * @param restPose defines the rest pose matrix
  14102. * @param baseMatrix defines the base matrix
  14103. * @param index defines index of the bone in the hiearchy
  14104. */
  14105. constructor(
  14106. /**
  14107. * defines the bone name
  14108. */
  14109. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14110. /**
  14111. * Gets the current object class name.
  14112. * @return the class name
  14113. */
  14114. getClassName(): string;
  14115. /**
  14116. * Gets the parent skeleton
  14117. * @returns a skeleton
  14118. */
  14119. getSkeleton(): Skeleton;
  14120. /**
  14121. * Gets parent bone
  14122. * @returns a bone or null if the bone is the root of the bone hierarchy
  14123. */
  14124. getParent(): Nullable<Bone>;
  14125. /**
  14126. * Returns an array containing the root bones
  14127. * @returns an array containing the root bones
  14128. */
  14129. getChildren(): Array<Bone>;
  14130. /**
  14131. * Gets the node index in matrix array generated for rendering
  14132. * @returns the node index
  14133. */
  14134. getIndex(): number;
  14135. /**
  14136. * Sets the parent bone
  14137. * @param parent defines the parent (can be null if the bone is the root)
  14138. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14139. */
  14140. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14141. /**
  14142. * Gets the local matrix
  14143. * @returns a matrix
  14144. */
  14145. getLocalMatrix(): Matrix;
  14146. /**
  14147. * Gets the base matrix (initial matrix which remains unchanged)
  14148. * @returns a matrix
  14149. */
  14150. getBaseMatrix(): Matrix;
  14151. /**
  14152. * Gets the rest pose matrix
  14153. * @returns a matrix
  14154. */
  14155. getRestPose(): Matrix;
  14156. /**
  14157. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14158. */
  14159. getWorldMatrix(): Matrix;
  14160. /**
  14161. * Sets the local matrix to rest pose matrix
  14162. */
  14163. returnToRest(): void;
  14164. /**
  14165. * Gets the inverse of the absolute transform matrix.
  14166. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14167. * @returns a matrix
  14168. */
  14169. getInvertedAbsoluteTransform(): Matrix;
  14170. /**
  14171. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14172. * @returns a matrix
  14173. */
  14174. getAbsoluteTransform(): Matrix;
  14175. /**
  14176. * Links with the given transform node.
  14177. * The local matrix of this bone is copied from the transform node every frame.
  14178. * @param transformNode defines the transform node to link to
  14179. */
  14180. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14181. /**
  14182. * Gets the node used to drive the bone's transformation
  14183. * @returns a transform node or null
  14184. */
  14185. getTransformNode(): Nullable<TransformNode>;
  14186. /** Gets or sets current position (in local space) */
  14187. get position(): Vector3;
  14188. set position(newPosition: Vector3);
  14189. /** Gets or sets current rotation (in local space) */
  14190. get rotation(): Vector3;
  14191. set rotation(newRotation: Vector3);
  14192. /** Gets or sets current rotation quaternion (in local space) */
  14193. get rotationQuaternion(): Quaternion;
  14194. set rotationQuaternion(newRotation: Quaternion);
  14195. /** Gets or sets current scaling (in local space) */
  14196. get scaling(): Vector3;
  14197. set scaling(newScaling: Vector3);
  14198. /**
  14199. * Gets the animation properties override
  14200. */
  14201. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14202. private _decompose;
  14203. private _compose;
  14204. /**
  14205. * Update the base and local matrices
  14206. * @param matrix defines the new base or local matrix
  14207. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14208. * @param updateLocalMatrix defines if the local matrix should be updated
  14209. */
  14210. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14211. /** @hidden */
  14212. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14213. /**
  14214. * Flag the bone as dirty (Forcing it to update everything)
  14215. */
  14216. markAsDirty(): void;
  14217. /** @hidden */
  14218. _markAsDirtyAndCompose(): void;
  14219. private _markAsDirtyAndDecompose;
  14220. /**
  14221. * Translate the bone in local or world space
  14222. * @param vec The amount to translate the bone
  14223. * @param space The space that the translation is in
  14224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14225. */
  14226. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14227. /**
  14228. * Set the postion of the bone in local or world space
  14229. * @param position The position to set the bone
  14230. * @param space The space that the position is in
  14231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14232. */
  14233. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14234. /**
  14235. * Set the absolute position of the bone (world space)
  14236. * @param position The position to set the bone
  14237. * @param mesh The mesh that this bone is attached to
  14238. */
  14239. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14240. /**
  14241. * Scale the bone on the x, y and z axes (in local space)
  14242. * @param x The amount to scale the bone on the x axis
  14243. * @param y The amount to scale the bone on the y axis
  14244. * @param z The amount to scale the bone on the z axis
  14245. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14246. */
  14247. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14248. /**
  14249. * Set the bone scaling in local space
  14250. * @param scale defines the scaling vector
  14251. */
  14252. setScale(scale: Vector3): void;
  14253. /**
  14254. * Gets the current scaling in local space
  14255. * @returns the current scaling vector
  14256. */
  14257. getScale(): Vector3;
  14258. /**
  14259. * Gets the current scaling in local space and stores it in a target vector
  14260. * @param result defines the target vector
  14261. */
  14262. getScaleToRef(result: Vector3): void;
  14263. /**
  14264. * Set the yaw, pitch, and roll of the bone in local or world space
  14265. * @param yaw The rotation of the bone on the y axis
  14266. * @param pitch The rotation of the bone on the x axis
  14267. * @param roll The rotation of the bone on the z axis
  14268. * @param space The space that the axes of rotation are in
  14269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14270. */
  14271. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14272. /**
  14273. * Add a rotation to the bone on an axis in local or world space
  14274. * @param axis The axis to rotate the bone on
  14275. * @param amount The amount to rotate the bone
  14276. * @param space The space that the axis is in
  14277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14278. */
  14279. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14280. /**
  14281. * Set the rotation of the bone to a particular axis angle in local or world space
  14282. * @param axis The axis to rotate the bone on
  14283. * @param angle The angle that the bone should be rotated to
  14284. * @param space The space that the axis is in
  14285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14286. */
  14287. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14288. /**
  14289. * Set the euler rotation of the bone in local of world space
  14290. * @param rotation The euler rotation that the bone should be set to
  14291. * @param space The space that the rotation is in
  14292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14293. */
  14294. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14295. /**
  14296. * Set the quaternion rotation of the bone in local of world space
  14297. * @param quat The quaternion rotation that the bone should be set to
  14298. * @param space The space that the rotation is in
  14299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14300. */
  14301. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14302. /**
  14303. * Set the rotation matrix of the bone in local of world space
  14304. * @param rotMat The rotation matrix that the bone should be set to
  14305. * @param space The space that the rotation is in
  14306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14307. */
  14308. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14309. private _rotateWithMatrix;
  14310. private _getNegativeRotationToRef;
  14311. /**
  14312. * Get the position of the bone in local or world space
  14313. * @param space The space that the returned position is in
  14314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14315. * @returns The position of the bone
  14316. */
  14317. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14318. /**
  14319. * Copy the position of the bone to a vector3 in local or world space
  14320. * @param space The space that the returned position is in
  14321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14322. * @param result The vector3 to copy the position to
  14323. */
  14324. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14325. /**
  14326. * Get the absolute position of the bone (world space)
  14327. * @param mesh The mesh that this bone is attached to
  14328. * @returns The absolute position of the bone
  14329. */
  14330. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14331. /**
  14332. * Copy the absolute position of the bone (world space) to the result param
  14333. * @param mesh The mesh that this bone is attached to
  14334. * @param result The vector3 to copy the absolute position to
  14335. */
  14336. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14337. /**
  14338. * Compute the absolute transforms of this bone and its children
  14339. */
  14340. computeAbsoluteTransforms(): void;
  14341. /**
  14342. * Get the world direction from an axis that is in the local space of the bone
  14343. * @param localAxis The local direction that is used to compute the world direction
  14344. * @param mesh The mesh that this bone is attached to
  14345. * @returns The world direction
  14346. */
  14347. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14348. /**
  14349. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14350. * @param localAxis The local direction that is used to compute the world direction
  14351. * @param mesh The mesh that this bone is attached to
  14352. * @param result The vector3 that the world direction will be copied to
  14353. */
  14354. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14355. /**
  14356. * Get the euler rotation of the bone in local or world space
  14357. * @param space The space that the rotation should be in
  14358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14359. * @returns The euler rotation
  14360. */
  14361. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14362. /**
  14363. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14364. * @param space The space that the rotation should be in
  14365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14366. * @param result The vector3 that the rotation should be copied to
  14367. */
  14368. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14369. /**
  14370. * Get the quaternion rotation of the bone in either local or world space
  14371. * @param space The space that the rotation should be in
  14372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14373. * @returns The quaternion rotation
  14374. */
  14375. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14376. /**
  14377. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14378. * @param space The space that the rotation should be in
  14379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14380. * @param result The quaternion that the rotation should be copied to
  14381. */
  14382. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14383. /**
  14384. * Get the rotation matrix of the bone in local or world space
  14385. * @param space The space that the rotation should be in
  14386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14387. * @returns The rotation matrix
  14388. */
  14389. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14390. /**
  14391. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14392. * @param space The space that the rotation should be in
  14393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14394. * @param result The quaternion that the rotation should be copied to
  14395. */
  14396. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14397. /**
  14398. * Get the world position of a point that is in the local space of the bone
  14399. * @param position The local position
  14400. * @param mesh The mesh that this bone is attached to
  14401. * @returns The world position
  14402. */
  14403. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14404. /**
  14405. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14406. * @param position The local position
  14407. * @param mesh The mesh that this bone is attached to
  14408. * @param result The vector3 that the world position should be copied to
  14409. */
  14410. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14411. /**
  14412. * Get the local position of a point that is in world space
  14413. * @param position The world position
  14414. * @param mesh The mesh that this bone is attached to
  14415. * @returns The local position
  14416. */
  14417. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14418. /**
  14419. * Get the local position of a point that is in world space and copy it to the result param
  14420. * @param position The world position
  14421. * @param mesh The mesh that this bone is attached to
  14422. * @param result The vector3 that the local position should be copied to
  14423. */
  14424. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14425. }
  14426. }
  14427. declare module "babylonjs/Meshes/transformNode" {
  14428. import { DeepImmutable } from "babylonjs/types";
  14429. import { Observable } from "babylonjs/Misc/observable";
  14430. import { Nullable } from "babylonjs/types";
  14431. import { Camera } from "babylonjs/Cameras/camera";
  14432. import { Scene } from "babylonjs/scene";
  14433. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14434. import { Node } from "babylonjs/node";
  14435. import { Bone } from "babylonjs/Bones/bone";
  14436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14437. import { Space } from "babylonjs/Maths/math.axis";
  14438. /**
  14439. * 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.
  14440. * @see https://doc.babylonjs.com/how_to/transformnode
  14441. */
  14442. export class TransformNode extends Node {
  14443. /**
  14444. * Object will not rotate to face the camera
  14445. */
  14446. static BILLBOARDMODE_NONE: number;
  14447. /**
  14448. * Object will rotate to face the camera but only on the x axis
  14449. */
  14450. static BILLBOARDMODE_X: number;
  14451. /**
  14452. * Object will rotate to face the camera but only on the y axis
  14453. */
  14454. static BILLBOARDMODE_Y: number;
  14455. /**
  14456. * Object will rotate to face the camera but only on the z axis
  14457. */
  14458. static BILLBOARDMODE_Z: number;
  14459. /**
  14460. * Object will rotate to face the camera
  14461. */
  14462. static BILLBOARDMODE_ALL: number;
  14463. /**
  14464. * Object will rotate to face the camera's position instead of orientation
  14465. */
  14466. static BILLBOARDMODE_USE_POSITION: number;
  14467. private _forward;
  14468. private _forwardInverted;
  14469. private _up;
  14470. private _right;
  14471. private _rightInverted;
  14472. private _position;
  14473. private _rotation;
  14474. private _rotationQuaternion;
  14475. protected _scaling: Vector3;
  14476. protected _isDirty: boolean;
  14477. private _transformToBoneReferal;
  14478. private _isAbsoluteSynced;
  14479. private _billboardMode;
  14480. /**
  14481. * Gets or sets the billboard mode. Default is 0.
  14482. *
  14483. * | Value | Type | Description |
  14484. * | --- | --- | --- |
  14485. * | 0 | BILLBOARDMODE_NONE | |
  14486. * | 1 | BILLBOARDMODE_X | |
  14487. * | 2 | BILLBOARDMODE_Y | |
  14488. * | 4 | BILLBOARDMODE_Z | |
  14489. * | 7 | BILLBOARDMODE_ALL | |
  14490. *
  14491. */
  14492. get billboardMode(): number;
  14493. set billboardMode(value: number);
  14494. private _preserveParentRotationForBillboard;
  14495. /**
  14496. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14497. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14498. */
  14499. get preserveParentRotationForBillboard(): boolean;
  14500. set preserveParentRotationForBillboard(value: boolean);
  14501. /**
  14502. * 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
  14503. */
  14504. scalingDeterminant: number;
  14505. private _infiniteDistance;
  14506. /**
  14507. * Gets or sets the distance of the object to max, often used by skybox
  14508. */
  14509. get infiniteDistance(): boolean;
  14510. set infiniteDistance(value: boolean);
  14511. /**
  14512. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14513. * By default the system will update normals to compensate
  14514. */
  14515. ignoreNonUniformScaling: boolean;
  14516. /**
  14517. * 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
  14518. */
  14519. reIntegrateRotationIntoRotationQuaternion: boolean;
  14520. /** @hidden */
  14521. _poseMatrix: Nullable<Matrix>;
  14522. /** @hidden */
  14523. _localMatrix: Matrix;
  14524. private _usePivotMatrix;
  14525. private _absolutePosition;
  14526. private _absoluteScaling;
  14527. private _absoluteRotationQuaternion;
  14528. private _pivotMatrix;
  14529. private _pivotMatrixInverse;
  14530. protected _postMultiplyPivotMatrix: boolean;
  14531. protected _isWorldMatrixFrozen: boolean;
  14532. /** @hidden */
  14533. _indexInSceneTransformNodesArray: number;
  14534. /**
  14535. * An event triggered after the world matrix is updated
  14536. */
  14537. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14538. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14539. /**
  14540. * Gets a string identifying the name of the class
  14541. * @returns "TransformNode" string
  14542. */
  14543. getClassName(): string;
  14544. /**
  14545. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14546. */
  14547. get position(): Vector3;
  14548. set position(newPosition: Vector3);
  14549. /**
  14550. * 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)).
  14551. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14552. */
  14553. get rotation(): Vector3;
  14554. set rotation(newRotation: Vector3);
  14555. /**
  14556. * 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)).
  14557. */
  14558. get scaling(): Vector3;
  14559. set scaling(newScaling: Vector3);
  14560. /**
  14561. * 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).
  14562. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14563. */
  14564. get rotationQuaternion(): Nullable<Quaternion>;
  14565. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14566. /**
  14567. * The forward direction of that transform in world space.
  14568. */
  14569. get forward(): Vector3;
  14570. /**
  14571. * The up direction of that transform in world space.
  14572. */
  14573. get up(): Vector3;
  14574. /**
  14575. * The right direction of that transform in world space.
  14576. */
  14577. get right(): Vector3;
  14578. /**
  14579. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14580. * @param matrix the matrix to copy the pose from
  14581. * @returns this TransformNode.
  14582. */
  14583. updatePoseMatrix(matrix: Matrix): TransformNode;
  14584. /**
  14585. * Returns the mesh Pose matrix.
  14586. * @returns the pose matrix
  14587. */
  14588. getPoseMatrix(): Matrix;
  14589. /** @hidden */
  14590. _isSynchronized(): boolean;
  14591. /** @hidden */
  14592. _initCache(): void;
  14593. /**
  14594. * Flag the transform node as dirty (Forcing it to update everything)
  14595. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14596. * @returns this transform node
  14597. */
  14598. markAsDirty(property: string): TransformNode;
  14599. /**
  14600. * Returns the current mesh absolute position.
  14601. * Returns a Vector3.
  14602. */
  14603. get absolutePosition(): Vector3;
  14604. /**
  14605. * Returns the current mesh absolute scaling.
  14606. * Returns a Vector3.
  14607. */
  14608. get absoluteScaling(): Vector3;
  14609. /**
  14610. * Returns the current mesh absolute rotation.
  14611. * Returns a Quaternion.
  14612. */
  14613. get absoluteRotationQuaternion(): Quaternion;
  14614. /**
  14615. * Sets a new matrix to apply before all other transformation
  14616. * @param matrix defines the transform matrix
  14617. * @returns the current TransformNode
  14618. */
  14619. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14620. /**
  14621. * Sets a new pivot matrix to the current node
  14622. * @param matrix defines the new pivot matrix to use
  14623. * @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
  14624. * @returns the current TransformNode
  14625. */
  14626. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14627. /**
  14628. * Returns the mesh pivot matrix.
  14629. * Default : Identity.
  14630. * @returns the matrix
  14631. */
  14632. getPivotMatrix(): Matrix;
  14633. /**
  14634. * Instantiate (when possible) or clone that node with its hierarchy
  14635. * @param newParent defines the new parent to use for the instance (or clone)
  14636. * @param options defines options to configure how copy is done
  14637. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14638. * @returns an instance (or a clone) of the current node with its hiearchy
  14639. */
  14640. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14641. doNotInstantiate: boolean;
  14642. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14643. /**
  14644. * Prevents the World matrix to be computed any longer
  14645. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14646. * @returns the TransformNode.
  14647. */
  14648. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14649. /**
  14650. * Allows back the World matrix computation.
  14651. * @returns the TransformNode.
  14652. */
  14653. unfreezeWorldMatrix(): this;
  14654. /**
  14655. * True if the World matrix has been frozen.
  14656. */
  14657. get isWorldMatrixFrozen(): boolean;
  14658. /**
  14659. * Retuns the mesh absolute position in the World.
  14660. * @returns a Vector3.
  14661. */
  14662. getAbsolutePosition(): Vector3;
  14663. /**
  14664. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14665. * @param absolutePosition the absolute position to set
  14666. * @returns the TransformNode.
  14667. */
  14668. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14669. /**
  14670. * Sets the mesh position in its local space.
  14671. * @param vector3 the position to set in localspace
  14672. * @returns the TransformNode.
  14673. */
  14674. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14675. /**
  14676. * Returns the mesh position in the local space from the current World matrix values.
  14677. * @returns a new Vector3.
  14678. */
  14679. getPositionExpressedInLocalSpace(): Vector3;
  14680. /**
  14681. * Translates the mesh along the passed Vector3 in its local space.
  14682. * @param vector3 the distance to translate in localspace
  14683. * @returns the TransformNode.
  14684. */
  14685. locallyTranslate(vector3: Vector3): TransformNode;
  14686. private static _lookAtVectorCache;
  14687. /**
  14688. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14689. * @param targetPoint the position (must be in same space as current mesh) to look at
  14690. * @param yawCor optional yaw (y-axis) correction in radians
  14691. * @param pitchCor optional pitch (x-axis) correction in radians
  14692. * @param rollCor optional roll (z-axis) correction in radians
  14693. * @param space the choosen space of the target
  14694. * @returns the TransformNode.
  14695. */
  14696. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14697. /**
  14698. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14699. * This Vector3 is expressed in the World space.
  14700. * @param localAxis axis to rotate
  14701. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14702. */
  14703. getDirection(localAxis: Vector3): Vector3;
  14704. /**
  14705. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14706. * localAxis is expressed in the mesh local space.
  14707. * result is computed in the Wordl space from the mesh World matrix.
  14708. * @param localAxis axis to rotate
  14709. * @param result the resulting transformnode
  14710. * @returns this TransformNode.
  14711. */
  14712. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14713. /**
  14714. * Sets this transform node rotation to the given local axis.
  14715. * @param localAxis the axis in local space
  14716. * @param yawCor optional yaw (y-axis) correction in radians
  14717. * @param pitchCor optional pitch (x-axis) correction in radians
  14718. * @param rollCor optional roll (z-axis) correction in radians
  14719. * @returns this TransformNode
  14720. */
  14721. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14722. /**
  14723. * Sets a new pivot point to the current node
  14724. * @param point defines the new pivot point to use
  14725. * @param space defines if the point is in world or local space (local by default)
  14726. * @returns the current TransformNode
  14727. */
  14728. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14729. /**
  14730. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14731. * @returns the pivot point
  14732. */
  14733. getPivotPoint(): Vector3;
  14734. /**
  14735. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14736. * @param result the vector3 to store the result
  14737. * @returns this TransformNode.
  14738. */
  14739. getPivotPointToRef(result: Vector3): TransformNode;
  14740. /**
  14741. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14742. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14743. */
  14744. getAbsolutePivotPoint(): Vector3;
  14745. /**
  14746. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14747. * @param result vector3 to store the result
  14748. * @returns this TransformNode.
  14749. */
  14750. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14751. /**
  14752. * Defines the passed node as the parent of the current node.
  14753. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14754. * @see https://doc.babylonjs.com/how_to/parenting
  14755. * @param node the node ot set as the parent
  14756. * @returns this TransformNode.
  14757. */
  14758. setParent(node: Nullable<Node>): TransformNode;
  14759. private _nonUniformScaling;
  14760. /**
  14761. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14762. */
  14763. get nonUniformScaling(): boolean;
  14764. /** @hidden */
  14765. _updateNonUniformScalingState(value: boolean): boolean;
  14766. /**
  14767. * Attach the current TransformNode to another TransformNode associated with a bone
  14768. * @param bone Bone affecting the TransformNode
  14769. * @param affectedTransformNode TransformNode associated with the bone
  14770. * @returns this object
  14771. */
  14772. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14773. /**
  14774. * Detach the transform node if its associated with a bone
  14775. * @returns this object
  14776. */
  14777. detachFromBone(): TransformNode;
  14778. private static _rotationAxisCache;
  14779. /**
  14780. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14781. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14782. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14783. * The passed axis is also normalized.
  14784. * @param axis the axis to rotate around
  14785. * @param amount the amount to rotate in radians
  14786. * @param space Space to rotate in (Default: local)
  14787. * @returns the TransformNode.
  14788. */
  14789. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14790. /**
  14791. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14792. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14793. * The passed axis is also normalized. .
  14794. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14795. * @param point the point to rotate around
  14796. * @param axis the axis to rotate around
  14797. * @param amount the amount to rotate in radians
  14798. * @returns the TransformNode
  14799. */
  14800. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14801. /**
  14802. * Translates the mesh along the axis vector for the passed distance in the given space.
  14803. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14804. * @param axis the axis to translate in
  14805. * @param distance the distance to translate
  14806. * @param space Space to rotate in (Default: local)
  14807. * @returns the TransformNode.
  14808. */
  14809. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14810. /**
  14811. * Adds a rotation step to the mesh current rotation.
  14812. * x, y, z are Euler angles expressed in radians.
  14813. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14814. * This means this rotation is made in the mesh local space only.
  14815. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14816. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14817. * ```javascript
  14818. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14819. * ```
  14820. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14821. * 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.
  14822. * @param x Rotation to add
  14823. * @param y Rotation to add
  14824. * @param z Rotation to add
  14825. * @returns the TransformNode.
  14826. */
  14827. addRotation(x: number, y: number, z: number): TransformNode;
  14828. /**
  14829. * @hidden
  14830. */
  14831. protected _getEffectiveParent(): Nullable<Node>;
  14832. /**
  14833. * Computes the world matrix of the node
  14834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14835. * @returns the world matrix
  14836. */
  14837. computeWorldMatrix(force?: boolean): Matrix;
  14838. /**
  14839. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14840. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14841. */
  14842. resetLocalMatrix(independentOfChildren?: boolean): void;
  14843. protected _afterComputeWorldMatrix(): void;
  14844. /**
  14845. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14846. * @param func callback function to add
  14847. *
  14848. * @returns the TransformNode.
  14849. */
  14850. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14851. /**
  14852. * Removes a registered callback function.
  14853. * @param func callback function to remove
  14854. * @returns the TransformNode.
  14855. */
  14856. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14857. /**
  14858. * Gets the position of the current mesh in camera space
  14859. * @param camera defines the camera to use
  14860. * @returns a position
  14861. */
  14862. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14863. /**
  14864. * Returns the distance from the mesh to the active camera
  14865. * @param camera defines the camera to use
  14866. * @returns the distance
  14867. */
  14868. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14869. /**
  14870. * Clone the current transform node
  14871. * @param name Name of the new clone
  14872. * @param newParent New parent for the clone
  14873. * @param doNotCloneChildren Do not clone children hierarchy
  14874. * @returns the new transform node
  14875. */
  14876. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14877. /**
  14878. * Serializes the objects information.
  14879. * @param currentSerializationObject defines the object to serialize in
  14880. * @returns the serialized object
  14881. */
  14882. serialize(currentSerializationObject?: any): any;
  14883. /**
  14884. * Returns a new TransformNode object parsed from the source provided.
  14885. * @param parsedTransformNode is the source.
  14886. * @param scene the scne the object belongs to
  14887. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14888. * @returns a new TransformNode object parsed from the source provided.
  14889. */
  14890. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14891. /**
  14892. * Get all child-transformNodes of this node
  14893. * @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
  14894. * @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
  14895. * @returns an array of TransformNode
  14896. */
  14897. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14898. /**
  14899. * Releases resources associated with this transform node.
  14900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14902. */
  14903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14904. /**
  14905. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14906. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14907. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14908. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14909. * @returns the current mesh
  14910. */
  14911. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14912. private _syncAbsoluteScalingAndRotation;
  14913. }
  14914. }
  14915. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14916. import { Observable } from "babylonjs/Misc/observable";
  14917. import { Nullable } from "babylonjs/types";
  14918. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14919. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14921. import { Ray } from "babylonjs/Culling/ray";
  14922. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14923. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14924. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14925. /**
  14926. * Defines the types of pose enabled controllers that are supported
  14927. */
  14928. export enum PoseEnabledControllerType {
  14929. /**
  14930. * HTC Vive
  14931. */
  14932. VIVE = 0,
  14933. /**
  14934. * Oculus Rift
  14935. */
  14936. OCULUS = 1,
  14937. /**
  14938. * Windows mixed reality
  14939. */
  14940. WINDOWS = 2,
  14941. /**
  14942. * Samsung gear VR
  14943. */
  14944. GEAR_VR = 3,
  14945. /**
  14946. * Google Daydream
  14947. */
  14948. DAYDREAM = 4,
  14949. /**
  14950. * Generic
  14951. */
  14952. GENERIC = 5
  14953. }
  14954. /**
  14955. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14956. */
  14957. export interface MutableGamepadButton {
  14958. /**
  14959. * Value of the button/trigger
  14960. */
  14961. value: number;
  14962. /**
  14963. * If the button/trigger is currently touched
  14964. */
  14965. touched: boolean;
  14966. /**
  14967. * If the button/trigger is currently pressed
  14968. */
  14969. pressed: boolean;
  14970. }
  14971. /**
  14972. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14973. * @hidden
  14974. */
  14975. export interface ExtendedGamepadButton extends GamepadButton {
  14976. /**
  14977. * If the button/trigger is currently pressed
  14978. */
  14979. readonly pressed: boolean;
  14980. /**
  14981. * If the button/trigger is currently touched
  14982. */
  14983. readonly touched: boolean;
  14984. /**
  14985. * Value of the button/trigger
  14986. */
  14987. readonly value: number;
  14988. }
  14989. /** @hidden */
  14990. export interface _GamePadFactory {
  14991. /**
  14992. * Returns whether or not the current gamepad can be created for this type of controller.
  14993. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  14994. * @returns true if it can be created, otherwise false
  14995. */
  14996. canCreate(gamepadInfo: any): boolean;
  14997. /**
  14998. * Creates a new instance of the Gamepad.
  14999. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  15000. * @returns the new gamepad instance
  15001. */
  15002. create(gamepadInfo: any): Gamepad;
  15003. }
  15004. /**
  15005. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  15006. */
  15007. export class PoseEnabledControllerHelper {
  15008. /** @hidden */
  15009. static _ControllerFactories: _GamePadFactory[];
  15010. /** @hidden */
  15011. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  15012. /**
  15013. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  15014. * @param vrGamepad the gamepad to initialized
  15015. * @returns a vr controller of the type the gamepad identified as
  15016. */
  15017. static InitiateController(vrGamepad: any): Gamepad;
  15018. }
  15019. /**
  15020. * Defines the PoseEnabledController object that contains state of a vr capable controller
  15021. */
  15022. export class PoseEnabledController extends Gamepad implements PoseControlled {
  15023. /**
  15024. * If the controller is used in a webXR session
  15025. */
  15026. isXR: boolean;
  15027. private _deviceRoomPosition;
  15028. private _deviceRoomRotationQuaternion;
  15029. /**
  15030. * The device position in babylon space
  15031. */
  15032. devicePosition: Vector3;
  15033. /**
  15034. * The device rotation in babylon space
  15035. */
  15036. deviceRotationQuaternion: Quaternion;
  15037. /**
  15038. * The scale factor of the device in babylon space
  15039. */
  15040. deviceScaleFactor: number;
  15041. /**
  15042. * (Likely devicePosition should be used instead) The device position in its room space
  15043. */
  15044. position: Vector3;
  15045. /**
  15046. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  15047. */
  15048. rotationQuaternion: Quaternion;
  15049. /**
  15050. * The type of controller (Eg. Windows mixed reality)
  15051. */
  15052. controllerType: PoseEnabledControllerType;
  15053. protected _calculatedPosition: Vector3;
  15054. private _calculatedRotation;
  15055. /**
  15056. * The raw pose from the device
  15057. */
  15058. rawPose: DevicePose;
  15059. private _trackPosition;
  15060. private _maxRotationDistFromHeadset;
  15061. private _draggedRoomRotation;
  15062. /**
  15063. * @hidden
  15064. */
  15065. _disableTrackPosition(fixedPosition: Vector3): void;
  15066. /**
  15067. * Internal, the mesh attached to the controller
  15068. * @hidden
  15069. */
  15070. _mesh: Nullable<AbstractMesh>;
  15071. private _poseControlledCamera;
  15072. private _leftHandSystemQuaternion;
  15073. /**
  15074. * Internal, matrix used to convert room space to babylon space
  15075. * @hidden
  15076. */
  15077. _deviceToWorld: Matrix;
  15078. /**
  15079. * Node to be used when casting a ray from the controller
  15080. * @hidden
  15081. */
  15082. _pointingPoseNode: Nullable<TransformNode>;
  15083. /**
  15084. * Name of the child mesh that can be used to cast a ray from the controller
  15085. */
  15086. static readonly POINTING_POSE: string;
  15087. /**
  15088. * Creates a new PoseEnabledController from a gamepad
  15089. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15090. */
  15091. constructor(browserGamepad: any);
  15092. private _workingMatrix;
  15093. /**
  15094. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15095. */
  15096. update(): void;
  15097. /**
  15098. * Updates only the pose device and mesh without doing any button event checking
  15099. */
  15100. protected _updatePoseAndMesh(): void;
  15101. /**
  15102. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15103. * @param poseData raw pose fromthe device
  15104. */
  15105. updateFromDevice(poseData: DevicePose): void;
  15106. /**
  15107. * @hidden
  15108. */
  15109. _meshAttachedObservable: Observable<AbstractMesh>;
  15110. /**
  15111. * Attaches a mesh to the controller
  15112. * @param mesh the mesh to be attached
  15113. */
  15114. attachToMesh(mesh: AbstractMesh): void;
  15115. /**
  15116. * Attaches the controllers mesh to a camera
  15117. * @param camera the camera the mesh should be attached to
  15118. */
  15119. attachToPoseControlledCamera(camera: TargetCamera): void;
  15120. /**
  15121. * Disposes of the controller
  15122. */
  15123. dispose(): void;
  15124. /**
  15125. * The mesh that is attached to the controller
  15126. */
  15127. get mesh(): Nullable<AbstractMesh>;
  15128. /**
  15129. * Gets the ray of the controller in the direction the controller is pointing
  15130. * @param length the length the resulting ray should be
  15131. * @returns a ray in the direction the controller is pointing
  15132. */
  15133. getForwardRay(length?: number): Ray;
  15134. }
  15135. }
  15136. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15137. import { Observable } from "babylonjs/Misc/observable";
  15138. import { Scene } from "babylonjs/scene";
  15139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15140. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15141. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15142. import { Nullable } from "babylonjs/types";
  15143. /**
  15144. * Defines the WebVRController object that represents controllers tracked in 3D space
  15145. */
  15146. export abstract class WebVRController extends PoseEnabledController {
  15147. /**
  15148. * Internal, the default controller model for the controller
  15149. */
  15150. protected _defaultModel: Nullable<AbstractMesh>;
  15151. /**
  15152. * Fired when the trigger state has changed
  15153. */
  15154. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15155. /**
  15156. * Fired when the main button state has changed
  15157. */
  15158. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15159. /**
  15160. * Fired when the secondary button state has changed
  15161. */
  15162. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15163. /**
  15164. * Fired when the pad state has changed
  15165. */
  15166. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15167. /**
  15168. * Fired when controllers stick values have changed
  15169. */
  15170. onPadValuesChangedObservable: Observable<StickValues>;
  15171. /**
  15172. * Array of button availible on the controller
  15173. */
  15174. protected _buttons: Array<MutableGamepadButton>;
  15175. private _onButtonStateChange;
  15176. /**
  15177. * Fired when a controller button's state has changed
  15178. * @param callback the callback containing the button that was modified
  15179. */
  15180. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15181. /**
  15182. * X and Y axis corresponding to the controllers joystick
  15183. */
  15184. pad: StickValues;
  15185. /**
  15186. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15187. */
  15188. hand: string;
  15189. /**
  15190. * The default controller model for the controller
  15191. */
  15192. get defaultModel(): Nullable<AbstractMesh>;
  15193. /**
  15194. * Creates a new WebVRController from a gamepad
  15195. * @param vrGamepad the gamepad that the WebVRController should be created from
  15196. */
  15197. constructor(vrGamepad: any);
  15198. /**
  15199. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15200. */
  15201. update(): void;
  15202. /**
  15203. * Function to be called when a button is modified
  15204. */
  15205. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15206. /**
  15207. * Loads a mesh and attaches it to the controller
  15208. * @param scene the scene the mesh should be added to
  15209. * @param meshLoaded callback for when the mesh has been loaded
  15210. */
  15211. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15212. private _setButtonValue;
  15213. private _changes;
  15214. private _checkChanges;
  15215. /**
  15216. * Disposes of th webVRCOntroller
  15217. */
  15218. dispose(): void;
  15219. }
  15220. }
  15221. declare module "babylonjs/Lights/hemisphericLight" {
  15222. import { Nullable } from "babylonjs/types";
  15223. import { Scene } from "babylonjs/scene";
  15224. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15225. import { Color3 } from "babylonjs/Maths/math.color";
  15226. import { Effect } from "babylonjs/Materials/effect";
  15227. import { Light } from "babylonjs/Lights/light";
  15228. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15229. /**
  15230. * The HemisphericLight simulates the ambient environment light,
  15231. * so the passed direction is the light reflection direction, not the incoming direction.
  15232. */
  15233. export class HemisphericLight extends Light {
  15234. /**
  15235. * The groundColor is the light in the opposite direction to the one specified during creation.
  15236. * 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.
  15237. */
  15238. groundColor: Color3;
  15239. /**
  15240. * The light reflection direction, not the incoming direction.
  15241. */
  15242. direction: Vector3;
  15243. /**
  15244. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15245. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15246. * The HemisphericLight can't cast shadows.
  15247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15248. * @param name The friendly name of the light
  15249. * @param direction The direction of the light reflection
  15250. * @param scene The scene the light belongs to
  15251. */
  15252. constructor(name: string, direction: Vector3, scene: Scene);
  15253. protected _buildUniformLayout(): void;
  15254. /**
  15255. * Returns the string "HemisphericLight".
  15256. * @return The class name
  15257. */
  15258. getClassName(): string;
  15259. /**
  15260. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15261. * Returns the updated direction.
  15262. * @param target The target the direction should point to
  15263. * @return The computed direction
  15264. */
  15265. setDirectionToTarget(target: Vector3): Vector3;
  15266. /**
  15267. * Returns the shadow generator associated to the light.
  15268. * @returns Always null for hemispheric lights because it does not support shadows.
  15269. */
  15270. getShadowGenerator(): Nullable<IShadowGenerator>;
  15271. /**
  15272. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15273. * @param effect The effect to update
  15274. * @param lightIndex The index of the light in the effect to update
  15275. * @returns The hemispheric light
  15276. */
  15277. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15278. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15279. /**
  15280. * Computes the world matrix of the node
  15281. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15282. * @param useWasUpdatedFlag defines a reserved property
  15283. * @returns the world matrix
  15284. */
  15285. computeWorldMatrix(): Matrix;
  15286. /**
  15287. * Returns the integer 3.
  15288. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15289. */
  15290. getTypeID(): number;
  15291. /**
  15292. * Prepares the list of defines specific to the light type.
  15293. * @param defines the list of defines
  15294. * @param lightIndex defines the index of the light for the effect
  15295. */
  15296. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15297. }
  15298. }
  15299. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15300. /** @hidden */
  15301. export var vrMultiviewToSingleviewPixelShader: {
  15302. name: string;
  15303. shader: string;
  15304. };
  15305. }
  15306. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15307. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15308. import { Scene } from "babylonjs/scene";
  15309. /**
  15310. * Renders to multiple views with a single draw call
  15311. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15312. */
  15313. export class MultiviewRenderTarget extends RenderTargetTexture {
  15314. /**
  15315. * Creates a multiview render target
  15316. * @param scene scene used with the render target
  15317. * @param size the size of the render target (used for each view)
  15318. */
  15319. constructor(scene: Scene, size?: number | {
  15320. width: number;
  15321. height: number;
  15322. } | {
  15323. ratio: number;
  15324. });
  15325. /**
  15326. * @hidden
  15327. * @param faceIndex the face index, if its a cube texture
  15328. */
  15329. _bindFrameBuffer(faceIndex?: number): void;
  15330. /**
  15331. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15332. * @returns the view count
  15333. */
  15334. getViewCount(): number;
  15335. }
  15336. }
  15337. declare module "babylonjs/Maths/math.frustum" {
  15338. import { Matrix } from "babylonjs/Maths/math.vector";
  15339. import { DeepImmutable } from "babylonjs/types";
  15340. import { Plane } from "babylonjs/Maths/math.plane";
  15341. /**
  15342. * Represents a camera frustum
  15343. */
  15344. export class Frustum {
  15345. /**
  15346. * Gets the planes representing the frustum
  15347. * @param transform matrix to be applied to the returned planes
  15348. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15349. */
  15350. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15351. /**
  15352. * Gets the near frustum plane transformed by the transform matrix
  15353. * @param transform transformation matrix to be applied to the resulting frustum plane
  15354. * @param frustumPlane the resuling frustum plane
  15355. */
  15356. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15357. /**
  15358. * Gets the far frustum plane transformed by the transform matrix
  15359. * @param transform transformation matrix to be applied to the resulting frustum plane
  15360. * @param frustumPlane the resuling frustum plane
  15361. */
  15362. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15363. /**
  15364. * Gets the left frustum plane transformed by the transform matrix
  15365. * @param transform transformation matrix to be applied to the resulting frustum plane
  15366. * @param frustumPlane the resuling frustum plane
  15367. */
  15368. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15369. /**
  15370. * Gets the right frustum plane transformed by the transform matrix
  15371. * @param transform transformation matrix to be applied to the resulting frustum plane
  15372. * @param frustumPlane the resuling frustum plane
  15373. */
  15374. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15375. /**
  15376. * Gets the top frustum plane transformed by the transform matrix
  15377. * @param transform transformation matrix to be applied to the resulting frustum plane
  15378. * @param frustumPlane the resuling frustum plane
  15379. */
  15380. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15381. /**
  15382. * Gets the bottom frustum plane transformed by the transform matrix
  15383. * @param transform transformation matrix to be applied to the resulting frustum plane
  15384. * @param frustumPlane the resuling frustum plane
  15385. */
  15386. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15387. /**
  15388. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15389. * @param transform transformation matrix to be applied to the resulting frustum planes
  15390. * @param frustumPlanes the resuling frustum planes
  15391. */
  15392. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15393. }
  15394. }
  15395. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15396. import { Camera } from "babylonjs/Cameras/camera";
  15397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15398. import { Nullable } from "babylonjs/types";
  15399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15400. import { Matrix } from "babylonjs/Maths/math.vector";
  15401. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15402. module "babylonjs/Engines/engine" {
  15403. interface Engine {
  15404. /**
  15405. * Creates a new multiview render target
  15406. * @param width defines the width of the texture
  15407. * @param height defines the height of the texture
  15408. * @returns the created multiview texture
  15409. */
  15410. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15411. /**
  15412. * Binds a multiview framebuffer to be drawn to
  15413. * @param multiviewTexture texture to bind
  15414. */
  15415. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15416. }
  15417. }
  15418. module "babylonjs/Cameras/camera" {
  15419. interface Camera {
  15420. /**
  15421. * @hidden
  15422. * 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)
  15423. */
  15424. _useMultiviewToSingleView: boolean;
  15425. /**
  15426. * @hidden
  15427. * 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)
  15428. */
  15429. _multiviewTexture: Nullable<RenderTargetTexture>;
  15430. /**
  15431. * @hidden
  15432. * ensures the multiview texture of the camera exists and has the specified width/height
  15433. * @param width height to set on the multiview texture
  15434. * @param height width to set on the multiview texture
  15435. */
  15436. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15437. }
  15438. }
  15439. module "babylonjs/scene" {
  15440. interface Scene {
  15441. /** @hidden */
  15442. _transformMatrixR: Matrix;
  15443. /** @hidden */
  15444. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15445. /** @hidden */
  15446. _createMultiviewUbo(): void;
  15447. /** @hidden */
  15448. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15449. /** @hidden */
  15450. _renderMultiviewToSingleView(camera: Camera): void;
  15451. }
  15452. }
  15453. }
  15454. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15455. import { Camera } from "babylonjs/Cameras/camera";
  15456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15457. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15458. import "babylonjs/Engines/Extensions/engine.multiview";
  15459. /**
  15460. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15461. * This will not be used for webXR as it supports displaying texture arrays directly
  15462. */
  15463. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15464. /**
  15465. * Initializes a VRMultiviewToSingleview
  15466. * @param name name of the post process
  15467. * @param camera camera to be applied to
  15468. * @param scaleFactor scaling factor to the size of the output texture
  15469. */
  15470. constructor(name: string, camera: Camera, scaleFactor: number);
  15471. }
  15472. }
  15473. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15474. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15475. import { Nullable } from "babylonjs/types";
  15476. import { Size } from "babylonjs/Maths/math.size";
  15477. import { Observable } from "babylonjs/Misc/observable";
  15478. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15479. /**
  15480. * Interface used to define additional presentation attributes
  15481. */
  15482. export interface IVRPresentationAttributes {
  15483. /**
  15484. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15485. */
  15486. highRefreshRate: boolean;
  15487. /**
  15488. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15489. */
  15490. foveationLevel: number;
  15491. }
  15492. module "babylonjs/Engines/engine" {
  15493. interface Engine {
  15494. /** @hidden */
  15495. _vrDisplay: any;
  15496. /** @hidden */
  15497. _vrSupported: boolean;
  15498. /** @hidden */
  15499. _oldSize: Size;
  15500. /** @hidden */
  15501. _oldHardwareScaleFactor: number;
  15502. /** @hidden */
  15503. _vrExclusivePointerMode: boolean;
  15504. /** @hidden */
  15505. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15506. /** @hidden */
  15507. _onVRDisplayPointerRestricted: () => void;
  15508. /** @hidden */
  15509. _onVRDisplayPointerUnrestricted: () => void;
  15510. /** @hidden */
  15511. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15512. /** @hidden */
  15513. _onVrDisplayDisconnect: Nullable<() => void>;
  15514. /** @hidden */
  15515. _onVrDisplayPresentChange: Nullable<() => void>;
  15516. /**
  15517. * Observable signaled when VR display mode changes
  15518. */
  15519. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15520. /**
  15521. * Observable signaled when VR request present is complete
  15522. */
  15523. onVRRequestPresentComplete: Observable<boolean>;
  15524. /**
  15525. * Observable signaled when VR request present starts
  15526. */
  15527. onVRRequestPresentStart: Observable<Engine>;
  15528. /**
  15529. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15530. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15531. */
  15532. isInVRExclusivePointerMode: boolean;
  15533. /**
  15534. * Gets a boolean indicating if a webVR device was detected
  15535. * @returns true if a webVR device was detected
  15536. */
  15537. isVRDevicePresent(): boolean;
  15538. /**
  15539. * Gets the current webVR device
  15540. * @returns the current webVR device (or null)
  15541. */
  15542. getVRDevice(): any;
  15543. /**
  15544. * Initializes a webVR display and starts listening to display change events
  15545. * The onVRDisplayChangedObservable will be notified upon these changes
  15546. * @returns A promise containing a VRDisplay and if vr is supported
  15547. */
  15548. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15549. /** @hidden */
  15550. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15551. /**
  15552. * Gets or sets the presentation attributes used to configure VR rendering
  15553. */
  15554. vrPresentationAttributes?: IVRPresentationAttributes;
  15555. /**
  15556. * Call this function to switch to webVR mode
  15557. * Will do nothing if webVR is not supported or if there is no webVR device
  15558. * @param options the webvr options provided to the camera. mainly used for multiview
  15559. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15560. */
  15561. enableVR(options: WebVROptions): void;
  15562. /** @hidden */
  15563. _onVRFullScreenTriggered(): void;
  15564. }
  15565. }
  15566. }
  15567. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15568. import { Nullable } from "babylonjs/types";
  15569. import { Observable } from "babylonjs/Misc/observable";
  15570. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15571. import { Scene } from "babylonjs/scene";
  15572. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15573. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15574. import { Node } from "babylonjs/node";
  15575. import { Ray } from "babylonjs/Culling/ray";
  15576. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15577. import "babylonjs/Engines/Extensions/engine.webVR";
  15578. /**
  15579. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15580. * IMPORTANT!! The data is right-hand data.
  15581. * @export
  15582. * @interface DevicePose
  15583. */
  15584. export interface DevicePose {
  15585. /**
  15586. * The position of the device, values in array are [x,y,z].
  15587. */
  15588. readonly position: Nullable<Float32Array>;
  15589. /**
  15590. * The linearVelocity of the device, values in array are [x,y,z].
  15591. */
  15592. readonly linearVelocity: Nullable<Float32Array>;
  15593. /**
  15594. * The linearAcceleration of the device, values in array are [x,y,z].
  15595. */
  15596. readonly linearAcceleration: Nullable<Float32Array>;
  15597. /**
  15598. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15599. */
  15600. readonly orientation: Nullable<Float32Array>;
  15601. /**
  15602. * The angularVelocity of the device, values in array are [x,y,z].
  15603. */
  15604. readonly angularVelocity: Nullable<Float32Array>;
  15605. /**
  15606. * The angularAcceleration of the device, values in array are [x,y,z].
  15607. */
  15608. readonly angularAcceleration: Nullable<Float32Array>;
  15609. }
  15610. /**
  15611. * Interface representing a pose controlled object in Babylon.
  15612. * A pose controlled object has both regular pose values as well as pose values
  15613. * from an external device such as a VR head mounted display
  15614. */
  15615. export interface PoseControlled {
  15616. /**
  15617. * The position of the object in babylon space.
  15618. */
  15619. position: Vector3;
  15620. /**
  15621. * The rotation quaternion of the object in babylon space.
  15622. */
  15623. rotationQuaternion: Quaternion;
  15624. /**
  15625. * The position of the device in babylon space.
  15626. */
  15627. devicePosition?: Vector3;
  15628. /**
  15629. * The rotation quaternion of the device in babylon space.
  15630. */
  15631. deviceRotationQuaternion: Quaternion;
  15632. /**
  15633. * The raw pose coming from the device.
  15634. */
  15635. rawPose: Nullable<DevicePose>;
  15636. /**
  15637. * The scale of the device to be used when translating from device space to babylon space.
  15638. */
  15639. deviceScaleFactor: number;
  15640. /**
  15641. * Updates the poseControlled values based on the input device pose.
  15642. * @param poseData the pose data to update the object with
  15643. */
  15644. updateFromDevice(poseData: DevicePose): void;
  15645. }
  15646. /**
  15647. * Set of options to customize the webVRCamera
  15648. */
  15649. export interface WebVROptions {
  15650. /**
  15651. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15652. */
  15653. trackPosition?: boolean;
  15654. /**
  15655. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15656. */
  15657. positionScale?: number;
  15658. /**
  15659. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15660. */
  15661. displayName?: string;
  15662. /**
  15663. * Should the native controller meshes be initialized. (default: true)
  15664. */
  15665. controllerMeshes?: boolean;
  15666. /**
  15667. * Creating a default HemiLight only on controllers. (default: true)
  15668. */
  15669. defaultLightingOnControllers?: boolean;
  15670. /**
  15671. * If you don't want to use the default VR button of the helper. (default: false)
  15672. */
  15673. useCustomVRButton?: boolean;
  15674. /**
  15675. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15676. */
  15677. customVRButton?: HTMLButtonElement;
  15678. /**
  15679. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15680. */
  15681. rayLength?: number;
  15682. /**
  15683. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15684. */
  15685. defaultHeight?: number;
  15686. /**
  15687. * If multiview should be used if availible (default: false)
  15688. */
  15689. useMultiview?: boolean;
  15690. }
  15691. /**
  15692. * This represents a WebVR camera.
  15693. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15694. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15695. */
  15696. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15697. private webVROptions;
  15698. /**
  15699. * @hidden
  15700. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15701. */
  15702. _vrDevice: any;
  15703. /**
  15704. * The rawPose of the vrDevice.
  15705. */
  15706. rawPose: Nullable<DevicePose>;
  15707. private _onVREnabled;
  15708. private _specsVersion;
  15709. private _attached;
  15710. private _frameData;
  15711. protected _descendants: Array<Node>;
  15712. private _deviceRoomPosition;
  15713. /** @hidden */
  15714. _deviceRoomRotationQuaternion: Quaternion;
  15715. private _standingMatrix;
  15716. /**
  15717. * Represents device position in babylon space.
  15718. */
  15719. devicePosition: Vector3;
  15720. /**
  15721. * Represents device rotation in babylon space.
  15722. */
  15723. deviceRotationQuaternion: Quaternion;
  15724. /**
  15725. * The scale of the device to be used when translating from device space to babylon space.
  15726. */
  15727. deviceScaleFactor: number;
  15728. private _deviceToWorld;
  15729. private _worldToDevice;
  15730. /**
  15731. * References to the webVR controllers for the vrDevice.
  15732. */
  15733. controllers: Array<WebVRController>;
  15734. /**
  15735. * Emits an event when a controller is attached.
  15736. */
  15737. onControllersAttachedObservable: Observable<WebVRController[]>;
  15738. /**
  15739. * Emits an event when a controller's mesh has been loaded;
  15740. */
  15741. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15742. /**
  15743. * Emits an event when the HMD's pose has been updated.
  15744. */
  15745. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15746. private _poseSet;
  15747. /**
  15748. * If the rig cameras be used as parent instead of this camera.
  15749. */
  15750. rigParenting: boolean;
  15751. private _lightOnControllers;
  15752. private _defaultHeight?;
  15753. /**
  15754. * Instantiates a WebVRFreeCamera.
  15755. * @param name The name of the WebVRFreeCamera
  15756. * @param position The starting anchor position for the camera
  15757. * @param scene The scene the camera belongs to
  15758. * @param webVROptions a set of customizable options for the webVRCamera
  15759. */
  15760. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15761. /**
  15762. * Gets the device distance from the ground in meters.
  15763. * @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.
  15764. */
  15765. deviceDistanceToRoomGround(): number;
  15766. /**
  15767. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15768. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15769. */
  15770. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15771. /**
  15772. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15773. * @returns A promise with a boolean set to if the standing matrix is supported.
  15774. */
  15775. useStandingMatrixAsync(): Promise<boolean>;
  15776. /**
  15777. * Disposes the camera
  15778. */
  15779. dispose(): void;
  15780. /**
  15781. * Gets a vrController by name.
  15782. * @param name The name of the controller to retreive
  15783. * @returns the controller matching the name specified or null if not found
  15784. */
  15785. getControllerByName(name: string): Nullable<WebVRController>;
  15786. private _leftController;
  15787. /**
  15788. * The controller corresponding to the users left hand.
  15789. */
  15790. get leftController(): Nullable<WebVRController>;
  15791. private _rightController;
  15792. /**
  15793. * The controller corresponding to the users right hand.
  15794. */
  15795. get rightController(): Nullable<WebVRController>;
  15796. /**
  15797. * Casts a ray forward from the vrCamera's gaze.
  15798. * @param length Length of the ray (default: 100)
  15799. * @returns the ray corresponding to the gaze
  15800. */
  15801. getForwardRay(length?: number): Ray;
  15802. /**
  15803. * @hidden
  15804. * Updates the camera based on device's frame data
  15805. */
  15806. _checkInputs(): void;
  15807. /**
  15808. * Updates the poseControlled values based on the input device pose.
  15809. * @param poseData Pose coming from the device
  15810. */
  15811. updateFromDevice(poseData: DevicePose): void;
  15812. private _htmlElementAttached;
  15813. private _detachIfAttached;
  15814. /**
  15815. * WebVR's attach control will start broadcasting frames to the device.
  15816. * Note that in certain browsers (chrome for example) this function must be called
  15817. * within a user-interaction callback. Example:
  15818. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15819. *
  15820. * @param element html element to attach the vrDevice to
  15821. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15822. */
  15823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15824. /**
  15825. * Detaches the camera from the html element and disables VR
  15826. *
  15827. * @param element html element to detach from
  15828. */
  15829. detachControl(element: HTMLElement): void;
  15830. /**
  15831. * @returns the name of this class
  15832. */
  15833. getClassName(): string;
  15834. /**
  15835. * Calls resetPose on the vrDisplay
  15836. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15837. */
  15838. resetToCurrentRotation(): void;
  15839. /**
  15840. * @hidden
  15841. * Updates the rig cameras (left and right eye)
  15842. */
  15843. _updateRigCameras(): void;
  15844. private _workingVector;
  15845. private _oneVector;
  15846. private _workingMatrix;
  15847. private updateCacheCalled;
  15848. private _correctPositionIfNotTrackPosition;
  15849. /**
  15850. * @hidden
  15851. * Updates the cached values of the camera
  15852. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15853. */
  15854. _updateCache(ignoreParentClass?: boolean): void;
  15855. /**
  15856. * @hidden
  15857. * Get current device position in babylon world
  15858. */
  15859. _computeDevicePosition(): void;
  15860. /**
  15861. * Updates the current device position and rotation in the babylon world
  15862. */
  15863. update(): void;
  15864. /**
  15865. * @hidden
  15866. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15867. * @returns an identity matrix
  15868. */
  15869. _getViewMatrix(): Matrix;
  15870. private _tmpMatrix;
  15871. /**
  15872. * This function is called by the two RIG cameras.
  15873. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15874. * @hidden
  15875. */
  15876. _getWebVRViewMatrix(): Matrix;
  15877. /** @hidden */
  15878. _getWebVRProjectionMatrix(): Matrix;
  15879. private _onGamepadConnectedObserver;
  15880. private _onGamepadDisconnectedObserver;
  15881. private _updateCacheWhenTrackingDisabledObserver;
  15882. /**
  15883. * Initializes the controllers and their meshes
  15884. */
  15885. initControllers(): void;
  15886. }
  15887. }
  15888. declare module "babylonjs/PostProcesses/postProcess" {
  15889. import { Nullable } from "babylonjs/types";
  15890. import { SmartArray } from "babylonjs/Misc/smartArray";
  15891. import { Observable } from "babylonjs/Misc/observable";
  15892. import { Vector2 } from "babylonjs/Maths/math.vector";
  15893. import { Camera } from "babylonjs/Cameras/camera";
  15894. import { Effect } from "babylonjs/Materials/effect";
  15895. import "babylonjs/Shaders/postprocess.vertex";
  15896. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15897. import { Engine } from "babylonjs/Engines/engine";
  15898. import { Color4 } from "babylonjs/Maths/math.color";
  15899. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15900. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15901. /**
  15902. * Size options for a post process
  15903. */
  15904. export type PostProcessOptions = {
  15905. width: number;
  15906. height: number;
  15907. };
  15908. /**
  15909. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15910. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15911. */
  15912. export class PostProcess {
  15913. /** Name of the PostProcess. */
  15914. name: string;
  15915. /**
  15916. * Gets or sets the unique id of the post process
  15917. */
  15918. uniqueId: number;
  15919. /**
  15920. * Width of the texture to apply the post process on
  15921. */
  15922. width: number;
  15923. /**
  15924. * Height of the texture to apply the post process on
  15925. */
  15926. height: number;
  15927. /**
  15928. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15929. * @hidden
  15930. */
  15931. _outputTexture: Nullable<InternalTexture>;
  15932. /**
  15933. * Sampling mode used by the shader
  15934. * See https://doc.babylonjs.com/classes/3.1/texture
  15935. */
  15936. renderTargetSamplingMode: number;
  15937. /**
  15938. * Clear color to use when screen clearing
  15939. */
  15940. clearColor: Color4;
  15941. /**
  15942. * If the buffer needs to be cleared before applying the post process. (default: true)
  15943. * Should be set to false if shader will overwrite all previous pixels.
  15944. */
  15945. autoClear: boolean;
  15946. /**
  15947. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15948. */
  15949. alphaMode: number;
  15950. /**
  15951. * Sets the setAlphaBlendConstants of the babylon engine
  15952. */
  15953. alphaConstants: Color4;
  15954. /**
  15955. * Animations to be used for the post processing
  15956. */
  15957. animations: import("babylonjs/Animations/animation").Animation[];
  15958. /**
  15959. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15960. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15961. */
  15962. enablePixelPerfectMode: boolean;
  15963. /**
  15964. * Force the postprocess to be applied without taking in account viewport
  15965. */
  15966. forceFullscreenViewport: boolean;
  15967. /**
  15968. * List of inspectable custom properties (used by the Inspector)
  15969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15970. */
  15971. inspectableCustomProperties: IInspectable[];
  15972. /**
  15973. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15974. *
  15975. * | Value | Type | Description |
  15976. * | ----- | ----------------------------------- | ----------- |
  15977. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15978. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15979. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15980. *
  15981. */
  15982. scaleMode: number;
  15983. /**
  15984. * Force textures to be a power of two (default: false)
  15985. */
  15986. alwaysForcePOT: boolean;
  15987. private _samples;
  15988. /**
  15989. * Number of sample textures (default: 1)
  15990. */
  15991. get samples(): number;
  15992. set samples(n: number);
  15993. /**
  15994. * Modify the scale of the post process to be the same as the viewport (default: false)
  15995. */
  15996. adaptScaleToCurrentViewport: boolean;
  15997. private _camera;
  15998. private _scene;
  15999. private _engine;
  16000. private _options;
  16001. private _reusable;
  16002. private _textureType;
  16003. private _textureFormat;
  16004. /**
  16005. * Smart array of input and output textures for the post process.
  16006. * @hidden
  16007. */
  16008. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  16009. /**
  16010. * The index in _textures that corresponds to the output texture.
  16011. * @hidden
  16012. */
  16013. _currentRenderTextureInd: number;
  16014. private _effect;
  16015. private _samplers;
  16016. private _fragmentUrl;
  16017. private _vertexUrl;
  16018. private _parameters;
  16019. private _scaleRatio;
  16020. protected _indexParameters: any;
  16021. private _shareOutputWithPostProcess;
  16022. private _texelSize;
  16023. private _forcedOutputTexture;
  16024. /**
  16025. * Returns the fragment url or shader name used in the post process.
  16026. * @returns the fragment url or name in the shader store.
  16027. */
  16028. getEffectName(): string;
  16029. /**
  16030. * An event triggered when the postprocess is activated.
  16031. */
  16032. onActivateObservable: Observable<Camera>;
  16033. private _onActivateObserver;
  16034. /**
  16035. * A function that is added to the onActivateObservable
  16036. */
  16037. set onActivate(callback: Nullable<(camera: Camera) => void>);
  16038. /**
  16039. * An event triggered when the postprocess changes its size.
  16040. */
  16041. onSizeChangedObservable: Observable<PostProcess>;
  16042. private _onSizeChangedObserver;
  16043. /**
  16044. * A function that is added to the onSizeChangedObservable
  16045. */
  16046. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  16047. /**
  16048. * An event triggered when the postprocess applies its effect.
  16049. */
  16050. onApplyObservable: Observable<Effect>;
  16051. private _onApplyObserver;
  16052. /**
  16053. * A function that is added to the onApplyObservable
  16054. */
  16055. set onApply(callback: (effect: Effect) => void);
  16056. /**
  16057. * An event triggered before rendering the postprocess
  16058. */
  16059. onBeforeRenderObservable: Observable<Effect>;
  16060. private _onBeforeRenderObserver;
  16061. /**
  16062. * A function that is added to the onBeforeRenderObservable
  16063. */
  16064. set onBeforeRender(callback: (effect: Effect) => void);
  16065. /**
  16066. * An event triggered after rendering the postprocess
  16067. */
  16068. onAfterRenderObservable: Observable<Effect>;
  16069. private _onAfterRenderObserver;
  16070. /**
  16071. * A function that is added to the onAfterRenderObservable
  16072. */
  16073. set onAfterRender(callback: (efect: Effect) => void);
  16074. /**
  16075. * 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
  16076. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16077. */
  16078. get inputTexture(): InternalTexture;
  16079. set inputTexture(value: InternalTexture);
  16080. /**
  16081. * Gets the camera which post process is applied to.
  16082. * @returns The camera the post process is applied to.
  16083. */
  16084. getCamera(): Camera;
  16085. /**
  16086. * Gets the texel size of the postprocess.
  16087. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16088. */
  16089. get texelSize(): Vector2;
  16090. /**
  16091. * Creates a new instance PostProcess
  16092. * @param name The name of the PostProcess.
  16093. * @param fragmentUrl The url of the fragment shader to be used.
  16094. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16095. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16096. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16097. * @param camera The camera to apply the render pass to.
  16098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16099. * @param engine The engine which the post process will be applied. (default: current engine)
  16100. * @param reusable If the post process can be reused on the same frame. (default: false)
  16101. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16102. * @param textureType Type of textures used when performing the post process. (default: 0)
  16103. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16104. * @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
  16105. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16106. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  16107. */
  16108. constructor(
  16109. /** Name of the PostProcess. */
  16110. 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);
  16111. /**
  16112. * Gets a string idenfifying the name of the class
  16113. * @returns "PostProcess" string
  16114. */
  16115. getClassName(): string;
  16116. /**
  16117. * Gets the engine which this post process belongs to.
  16118. * @returns The engine the post process was enabled with.
  16119. */
  16120. getEngine(): Engine;
  16121. /**
  16122. * The effect that is created when initializing the post process.
  16123. * @returns The created effect corresponding the the postprocess.
  16124. */
  16125. getEffect(): Effect;
  16126. /**
  16127. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16128. * @param postProcess The post process to share the output with.
  16129. * @returns This post process.
  16130. */
  16131. shareOutputWith(postProcess: PostProcess): PostProcess;
  16132. /**
  16133. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16134. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16135. */
  16136. useOwnOutput(): void;
  16137. /**
  16138. * Updates the effect with the current post process compile time values and recompiles the shader.
  16139. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16140. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16141. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16142. * @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
  16143. * @param onCompiled Called when the shader has been compiled.
  16144. * @param onError Called if there is an error when compiling a shader.
  16145. */
  16146. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16147. /**
  16148. * The post process is reusable if it can be used multiple times within one frame.
  16149. * @returns If the post process is reusable
  16150. */
  16151. isReusable(): boolean;
  16152. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16153. markTextureDirty(): void;
  16154. /**
  16155. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16156. * 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.
  16157. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16158. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16159. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16160. * @returns The target texture that was bound to be written to.
  16161. */
  16162. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16163. /**
  16164. * If the post process is supported.
  16165. */
  16166. get isSupported(): boolean;
  16167. /**
  16168. * The aspect ratio of the output texture.
  16169. */
  16170. get aspectRatio(): number;
  16171. /**
  16172. * Get a value indicating if the post-process is ready to be used
  16173. * @returns true if the post-process is ready (shader is compiled)
  16174. */
  16175. isReady(): boolean;
  16176. /**
  16177. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16178. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16179. */
  16180. apply(): Nullable<Effect>;
  16181. private _disposeTextures;
  16182. /**
  16183. * Disposes the post process.
  16184. * @param camera The camera to dispose the post process on.
  16185. */
  16186. dispose(camera?: Camera): void;
  16187. }
  16188. }
  16189. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16190. /** @hidden */
  16191. export var kernelBlurVaryingDeclaration: {
  16192. name: string;
  16193. shader: string;
  16194. };
  16195. }
  16196. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16197. /** @hidden */
  16198. export var kernelBlurFragment: {
  16199. name: string;
  16200. shader: string;
  16201. };
  16202. }
  16203. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16204. /** @hidden */
  16205. export var kernelBlurFragment2: {
  16206. name: string;
  16207. shader: string;
  16208. };
  16209. }
  16210. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16211. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16212. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16213. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16214. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16215. /** @hidden */
  16216. export var kernelBlurPixelShader: {
  16217. name: string;
  16218. shader: string;
  16219. };
  16220. }
  16221. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16222. /** @hidden */
  16223. export var kernelBlurVertex: {
  16224. name: string;
  16225. shader: string;
  16226. };
  16227. }
  16228. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16229. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16230. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16231. /** @hidden */
  16232. export var kernelBlurVertexShader: {
  16233. name: string;
  16234. shader: string;
  16235. };
  16236. }
  16237. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16238. import { Vector2 } from "babylonjs/Maths/math.vector";
  16239. import { Nullable } from "babylonjs/types";
  16240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16241. import { Camera } from "babylonjs/Cameras/camera";
  16242. import { Effect } from "babylonjs/Materials/effect";
  16243. import { Engine } from "babylonjs/Engines/engine";
  16244. import "babylonjs/Shaders/kernelBlur.fragment";
  16245. import "babylonjs/Shaders/kernelBlur.vertex";
  16246. /**
  16247. * The Blur Post Process which blurs an image based on a kernel and direction.
  16248. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16249. */
  16250. export class BlurPostProcess extends PostProcess {
  16251. /** The direction in which to blur the image. */
  16252. direction: Vector2;
  16253. private blockCompilation;
  16254. protected _kernel: number;
  16255. protected _idealKernel: number;
  16256. protected _packedFloat: boolean;
  16257. private _staticDefines;
  16258. /**
  16259. * Sets the length in pixels of the blur sample region
  16260. */
  16261. set kernel(v: number);
  16262. /**
  16263. * Gets the length in pixels of the blur sample region
  16264. */
  16265. get kernel(): number;
  16266. /**
  16267. * Sets wether or not the blur needs to unpack/repack floats
  16268. */
  16269. set packedFloat(v: boolean);
  16270. /**
  16271. * Gets wether or not the blur is unpacking/repacking floats
  16272. */
  16273. get packedFloat(): boolean;
  16274. /**
  16275. * Creates a new instance BlurPostProcess
  16276. * @param name The name of the effect.
  16277. * @param direction The direction in which to blur the image.
  16278. * @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.
  16279. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16280. * @param camera The camera to apply the render pass to.
  16281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16282. * @param engine The engine which the post process will be applied. (default: current engine)
  16283. * @param reusable If the post process can be reused on the same frame. (default: false)
  16284. * @param textureType Type of textures used when performing the post process. (default: 0)
  16285. * @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)
  16286. */
  16287. constructor(name: string,
  16288. /** The direction in which to blur the image. */
  16289. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16290. /**
  16291. * Updates the effect with the current post process compile time values and recompiles the shader.
  16292. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16293. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16294. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16295. * @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
  16296. * @param onCompiled Called when the shader has been compiled.
  16297. * @param onError Called if there is an error when compiling a shader.
  16298. */
  16299. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16300. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16301. /**
  16302. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16303. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16304. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16305. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16306. * The gaps between physical kernels are compensated for in the weighting of the samples
  16307. * @param idealKernel Ideal blur kernel.
  16308. * @return Nearest best kernel.
  16309. */
  16310. protected _nearestBestKernel(idealKernel: number): number;
  16311. /**
  16312. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16313. * @param x The point on the Gaussian distribution to sample.
  16314. * @return the value of the Gaussian function at x.
  16315. */
  16316. protected _gaussianWeight(x: number): number;
  16317. /**
  16318. * Generates a string that can be used as a floating point number in GLSL.
  16319. * @param x Value to print.
  16320. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16321. * @return GLSL float string.
  16322. */
  16323. protected _glslFloat(x: number, decimalFigures?: number): string;
  16324. }
  16325. }
  16326. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16327. import { Scene } from "babylonjs/scene";
  16328. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16329. import { Plane } from "babylonjs/Maths/math.plane";
  16330. /**
  16331. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16332. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16333. * You can then easily use it as a reflectionTexture on a flat surface.
  16334. * In case the surface is not a plane, please consider relying on reflection probes.
  16335. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16336. */
  16337. export class MirrorTexture extends RenderTargetTexture {
  16338. private scene;
  16339. /**
  16340. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16341. * 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.
  16342. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16343. */
  16344. mirrorPlane: Plane;
  16345. /**
  16346. * Define the blur ratio used to blur the reflection if needed.
  16347. */
  16348. set blurRatio(value: number);
  16349. get blurRatio(): number;
  16350. /**
  16351. * Define the adaptive blur kernel used to blur the reflection if needed.
  16352. * This will autocompute the closest best match for the `blurKernel`
  16353. */
  16354. set adaptiveBlurKernel(value: number);
  16355. /**
  16356. * Define the blur kernel used to blur the reflection if needed.
  16357. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16358. */
  16359. set blurKernel(value: number);
  16360. /**
  16361. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16362. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16363. */
  16364. set blurKernelX(value: number);
  16365. get blurKernelX(): number;
  16366. /**
  16367. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16368. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16369. */
  16370. set blurKernelY(value: number);
  16371. get blurKernelY(): number;
  16372. private _autoComputeBlurKernel;
  16373. protected _onRatioRescale(): void;
  16374. private _updateGammaSpace;
  16375. private _imageProcessingConfigChangeObserver;
  16376. private _transformMatrix;
  16377. private _mirrorMatrix;
  16378. private _savedViewMatrix;
  16379. private _blurX;
  16380. private _blurY;
  16381. private _adaptiveBlurKernel;
  16382. private _blurKernelX;
  16383. private _blurKernelY;
  16384. private _blurRatio;
  16385. /**
  16386. * Instantiates a Mirror Texture.
  16387. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16388. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16389. * You can then easily use it as a reflectionTexture on a flat surface.
  16390. * In case the surface is not a plane, please consider relying on reflection probes.
  16391. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16392. * @param name
  16393. * @param size
  16394. * @param scene
  16395. * @param generateMipMaps
  16396. * @param type
  16397. * @param samplingMode
  16398. * @param generateDepthBuffer
  16399. */
  16400. constructor(name: string, size: number | {
  16401. width: number;
  16402. height: number;
  16403. } | {
  16404. ratio: number;
  16405. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16406. private _preparePostProcesses;
  16407. /**
  16408. * Clone the mirror texture.
  16409. * @returns the cloned texture
  16410. */
  16411. clone(): MirrorTexture;
  16412. /**
  16413. * Serialize the texture to a JSON representation you could use in Parse later on
  16414. * @returns the serialized JSON representation
  16415. */
  16416. serialize(): any;
  16417. /**
  16418. * Dispose the texture and release its associated resources.
  16419. */
  16420. dispose(): void;
  16421. }
  16422. }
  16423. declare module "babylonjs/Materials/Textures/texture" {
  16424. import { Observable } from "babylonjs/Misc/observable";
  16425. import { Nullable } from "babylonjs/types";
  16426. import { Matrix } from "babylonjs/Maths/math.vector";
  16427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16428. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16429. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16430. import { Scene } from "babylonjs/scene";
  16431. /**
  16432. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16433. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16434. */
  16435. export class Texture extends BaseTexture {
  16436. /**
  16437. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16438. */
  16439. static SerializeBuffers: boolean;
  16440. /** @hidden */
  16441. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16442. /** @hidden */
  16443. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16444. /** @hidden */
  16445. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16446. /** nearest is mag = nearest and min = nearest and mip = linear */
  16447. static readonly NEAREST_SAMPLINGMODE: number;
  16448. /** nearest is mag = nearest and min = nearest and mip = linear */
  16449. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16450. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16451. static readonly BILINEAR_SAMPLINGMODE: number;
  16452. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16453. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16454. /** Trilinear is mag = linear and min = linear and mip = linear */
  16455. static readonly TRILINEAR_SAMPLINGMODE: number;
  16456. /** Trilinear is mag = linear and min = linear and mip = linear */
  16457. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16458. /** mag = nearest and min = nearest and mip = nearest */
  16459. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16460. /** mag = nearest and min = linear and mip = nearest */
  16461. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16462. /** mag = nearest and min = linear and mip = linear */
  16463. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16464. /** mag = nearest and min = linear and mip = none */
  16465. static readonly NEAREST_LINEAR: number;
  16466. /** mag = nearest and min = nearest and mip = none */
  16467. static readonly NEAREST_NEAREST: number;
  16468. /** mag = linear and min = nearest and mip = nearest */
  16469. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16470. /** mag = linear and min = nearest and mip = linear */
  16471. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16472. /** mag = linear and min = linear and mip = none */
  16473. static readonly LINEAR_LINEAR: number;
  16474. /** mag = linear and min = nearest and mip = none */
  16475. static readonly LINEAR_NEAREST: number;
  16476. /** Explicit coordinates mode */
  16477. static readonly EXPLICIT_MODE: number;
  16478. /** Spherical coordinates mode */
  16479. static readonly SPHERICAL_MODE: number;
  16480. /** Planar coordinates mode */
  16481. static readonly PLANAR_MODE: number;
  16482. /** Cubic coordinates mode */
  16483. static readonly CUBIC_MODE: number;
  16484. /** Projection coordinates mode */
  16485. static readonly PROJECTION_MODE: number;
  16486. /** Inverse Cubic coordinates mode */
  16487. static readonly SKYBOX_MODE: number;
  16488. /** Inverse Cubic coordinates mode */
  16489. static readonly INVCUBIC_MODE: number;
  16490. /** Equirectangular coordinates mode */
  16491. static readonly EQUIRECTANGULAR_MODE: number;
  16492. /** Equirectangular Fixed coordinates mode */
  16493. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16494. /** Equirectangular Fixed Mirrored coordinates mode */
  16495. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16496. /** Texture is not repeating outside of 0..1 UVs */
  16497. static readonly CLAMP_ADDRESSMODE: number;
  16498. /** Texture is repeating outside of 0..1 UVs */
  16499. static readonly WRAP_ADDRESSMODE: number;
  16500. /** Texture is repeating and mirrored */
  16501. static readonly MIRROR_ADDRESSMODE: number;
  16502. /**
  16503. * 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
  16504. */
  16505. static UseSerializedUrlIfAny: boolean;
  16506. /**
  16507. * Define the url of the texture.
  16508. */
  16509. url: Nullable<string>;
  16510. /**
  16511. * Define an offset on the texture to offset the u coordinates of the UVs
  16512. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16513. */
  16514. uOffset: number;
  16515. /**
  16516. * Define an offset on the texture to offset the v coordinates of the UVs
  16517. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16518. */
  16519. vOffset: number;
  16520. /**
  16521. * Define an offset on the texture to scale the u coordinates of the UVs
  16522. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16523. */
  16524. uScale: number;
  16525. /**
  16526. * Define an offset on the texture to scale the v coordinates of the UVs
  16527. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16528. */
  16529. vScale: number;
  16530. /**
  16531. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16532. * @see http://doc.babylonjs.com/how_to/more_materials
  16533. */
  16534. uAng: number;
  16535. /**
  16536. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16537. * @see http://doc.babylonjs.com/how_to/more_materials
  16538. */
  16539. vAng: number;
  16540. /**
  16541. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16542. * @see http://doc.babylonjs.com/how_to/more_materials
  16543. */
  16544. wAng: number;
  16545. /**
  16546. * Defines the center of rotation (U)
  16547. */
  16548. uRotationCenter: number;
  16549. /**
  16550. * Defines the center of rotation (V)
  16551. */
  16552. vRotationCenter: number;
  16553. /**
  16554. * Defines the center of rotation (W)
  16555. */
  16556. wRotationCenter: number;
  16557. /**
  16558. * Are mip maps generated for this texture or not.
  16559. */
  16560. get noMipmap(): boolean;
  16561. /**
  16562. * List of inspectable custom properties (used by the Inspector)
  16563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16564. */
  16565. inspectableCustomProperties: Nullable<IInspectable[]>;
  16566. private _noMipmap;
  16567. /** @hidden */
  16568. _invertY: boolean;
  16569. private _rowGenerationMatrix;
  16570. private _cachedTextureMatrix;
  16571. private _projectionModeMatrix;
  16572. private _t0;
  16573. private _t1;
  16574. private _t2;
  16575. private _cachedUOffset;
  16576. private _cachedVOffset;
  16577. private _cachedUScale;
  16578. private _cachedVScale;
  16579. private _cachedUAng;
  16580. private _cachedVAng;
  16581. private _cachedWAng;
  16582. private _cachedProjectionMatrixId;
  16583. private _cachedCoordinatesMode;
  16584. /** @hidden */
  16585. protected _initialSamplingMode: number;
  16586. /** @hidden */
  16587. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16588. private _deleteBuffer;
  16589. protected _format: Nullable<number>;
  16590. private _delayedOnLoad;
  16591. private _delayedOnError;
  16592. private _mimeType?;
  16593. /**
  16594. * Observable triggered once the texture has been loaded.
  16595. */
  16596. onLoadObservable: Observable<Texture>;
  16597. protected _isBlocking: boolean;
  16598. /**
  16599. * Is the texture preventing material to render while loading.
  16600. * If false, a default texture will be used instead of the loading one during the preparation step.
  16601. */
  16602. set isBlocking(value: boolean);
  16603. get isBlocking(): boolean;
  16604. /**
  16605. * Get the current sampling mode associated with the texture.
  16606. */
  16607. get samplingMode(): number;
  16608. /**
  16609. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16610. */
  16611. get invertY(): boolean;
  16612. /**
  16613. * Instantiates a new texture.
  16614. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16615. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16616. * @param url defines the url of the picture to load as a texture
  16617. * @param scene defines the scene or engine the texture will belong to
  16618. * @param noMipmap defines if the texture will require mip maps or not
  16619. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16620. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16621. * @param onLoad defines a callback triggered when the texture has been loaded
  16622. * @param onError defines a callback triggered when an error occurred during the loading session
  16623. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16624. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16625. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16626. * @param mimeType defines an optional mime type information
  16627. */
  16628. 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);
  16629. /**
  16630. * Update the url (and optional buffer) of this texture if url was null during construction.
  16631. * @param url the url of the texture
  16632. * @param buffer the buffer of the texture (defaults to null)
  16633. * @param onLoad callback called when the texture is loaded (defaults to null)
  16634. */
  16635. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16636. /**
  16637. * Finish the loading sequence of a texture flagged as delayed load.
  16638. * @hidden
  16639. */
  16640. delayLoad(): void;
  16641. private _prepareRowForTextureGeneration;
  16642. /**
  16643. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16644. * @returns the transform matrix of the texture.
  16645. */
  16646. getTextureMatrix(uBase?: number): Matrix;
  16647. /**
  16648. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16649. * @returns The reflection texture transform
  16650. */
  16651. getReflectionTextureMatrix(): Matrix;
  16652. /**
  16653. * Clones the texture.
  16654. * @returns the cloned texture
  16655. */
  16656. clone(): Texture;
  16657. /**
  16658. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16659. * @returns The JSON representation of the texture
  16660. */
  16661. serialize(): any;
  16662. /**
  16663. * Get the current class name of the texture useful for serialization or dynamic coding.
  16664. * @returns "Texture"
  16665. */
  16666. getClassName(): string;
  16667. /**
  16668. * Dispose the texture and release its associated resources.
  16669. */
  16670. dispose(): void;
  16671. /**
  16672. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16673. * @param parsedTexture Define the JSON representation of the texture
  16674. * @param scene Define the scene the parsed texture should be instantiated in
  16675. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16676. * @returns The parsed texture if successful
  16677. */
  16678. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16679. /**
  16680. * Creates a texture from its base 64 representation.
  16681. * @param data Define the base64 payload without the data: prefix
  16682. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16683. * @param scene Define the scene the texture should belong to
  16684. * @param noMipmap Forces the texture to not create mip map information if true
  16685. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16686. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16687. * @param onLoad define a callback triggered when the texture has been loaded
  16688. * @param onError define a callback triggered when an error occurred during the loading session
  16689. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16690. * @returns the created texture
  16691. */
  16692. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16693. /**
  16694. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16695. * @param data Define the base64 payload without the data: prefix
  16696. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16697. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16698. * @param scene Define the scene the texture should belong to
  16699. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16700. * @param noMipmap Forces the texture to not create mip map information if true
  16701. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16702. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16703. * @param onLoad define a callback triggered when the texture has been loaded
  16704. * @param onError define a callback triggered when an error occurred during the loading session
  16705. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16706. * @returns the created texture
  16707. */
  16708. 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;
  16709. }
  16710. }
  16711. declare module "babylonjs/PostProcesses/postProcessManager" {
  16712. import { Nullable } from "babylonjs/types";
  16713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16714. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16715. import { Scene } from "babylonjs/scene";
  16716. /**
  16717. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16718. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16719. */
  16720. export class PostProcessManager {
  16721. private _scene;
  16722. private _indexBuffer;
  16723. private _vertexBuffers;
  16724. /**
  16725. * Creates a new instance PostProcess
  16726. * @param scene The scene that the post process is associated with.
  16727. */
  16728. constructor(scene: Scene);
  16729. private _prepareBuffers;
  16730. private _buildIndexBuffer;
  16731. /**
  16732. * Rebuilds the vertex buffers of the manager.
  16733. * @hidden
  16734. */
  16735. _rebuild(): void;
  16736. /**
  16737. * Prepares a frame to be run through a post process.
  16738. * @param sourceTexture The input texture to the post procesess. (default: null)
  16739. * @param postProcesses An array of post processes to be run. (default: null)
  16740. * @returns True if the post processes were able to be run.
  16741. * @hidden
  16742. */
  16743. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16744. /**
  16745. * Manually render a set of post processes to a texture.
  16746. * @param postProcesses An array of post processes to be run.
  16747. * @param targetTexture The target texture to render to.
  16748. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16749. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16750. * @param lodLevel defines which lod of the texture to render to
  16751. */
  16752. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16753. /**
  16754. * Finalize the result of the output of the postprocesses.
  16755. * @param doNotPresent If true the result will not be displayed to the screen.
  16756. * @param targetTexture The target texture to render to.
  16757. * @param faceIndex The index of the face to bind the target texture to.
  16758. * @param postProcesses The array of post processes to render.
  16759. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16760. * @hidden
  16761. */
  16762. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16763. /**
  16764. * Disposes of the post process manager.
  16765. */
  16766. dispose(): void;
  16767. }
  16768. }
  16769. declare module "babylonjs/Misc/gradients" {
  16770. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16771. /** Interface used by value gradients (color, factor, ...) */
  16772. export interface IValueGradient {
  16773. /**
  16774. * Gets or sets the gradient value (between 0 and 1)
  16775. */
  16776. gradient: number;
  16777. }
  16778. /** Class used to store color4 gradient */
  16779. export class ColorGradient implements IValueGradient {
  16780. /**
  16781. * Gets or sets the gradient value (between 0 and 1)
  16782. */
  16783. gradient: number;
  16784. /**
  16785. * Gets or sets first associated color
  16786. */
  16787. color1: Color4;
  16788. /**
  16789. * Gets or sets second associated color
  16790. */
  16791. color2?: Color4;
  16792. /**
  16793. * Will get a color picked randomly between color1 and color2.
  16794. * If color2 is undefined then color1 will be used
  16795. * @param result defines the target Color4 to store the result in
  16796. */
  16797. getColorToRef(result: Color4): void;
  16798. }
  16799. /** Class used to store color 3 gradient */
  16800. export class Color3Gradient implements IValueGradient {
  16801. /**
  16802. * Gets or sets the gradient value (between 0 and 1)
  16803. */
  16804. gradient: number;
  16805. /**
  16806. * Gets or sets the associated color
  16807. */
  16808. color: Color3;
  16809. }
  16810. /** Class used to store factor gradient */
  16811. export class FactorGradient implements IValueGradient {
  16812. /**
  16813. * Gets or sets the gradient value (between 0 and 1)
  16814. */
  16815. gradient: number;
  16816. /**
  16817. * Gets or sets first associated factor
  16818. */
  16819. factor1: number;
  16820. /**
  16821. * Gets or sets second associated factor
  16822. */
  16823. factor2?: number;
  16824. /**
  16825. * Will get a number picked randomly between factor1 and factor2.
  16826. * If factor2 is undefined then factor1 will be used
  16827. * @returns the picked number
  16828. */
  16829. getFactor(): number;
  16830. }
  16831. /**
  16832. * Helper used to simplify some generic gradient tasks
  16833. */
  16834. export class GradientHelper {
  16835. /**
  16836. * Gets the current gradient from an array of IValueGradient
  16837. * @param ratio defines the current ratio to get
  16838. * @param gradients defines the array of IValueGradient
  16839. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16840. */
  16841. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16842. }
  16843. }
  16844. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16845. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16846. import { Nullable } from "babylonjs/types";
  16847. module "babylonjs/Engines/thinEngine" {
  16848. interface ThinEngine {
  16849. /**
  16850. * Creates a dynamic texture
  16851. * @param width defines the width of the texture
  16852. * @param height defines the height of the texture
  16853. * @param generateMipMaps defines if the engine should generate the mip levels
  16854. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16855. * @returns the dynamic texture inside an InternalTexture
  16856. */
  16857. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16858. /**
  16859. * Update the content of a dynamic texture
  16860. * @param texture defines the texture to update
  16861. * @param canvas defines the canvas containing the source
  16862. * @param invertY defines if data must be stored with Y axis inverted
  16863. * @param premulAlpha defines if alpha is stored as premultiplied
  16864. * @param format defines the format of the data
  16865. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16866. */
  16867. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16868. }
  16869. }
  16870. }
  16871. declare module "babylonjs/Misc/canvasGenerator" {
  16872. /**
  16873. * Helper class used to generate a canvas to manipulate images
  16874. */
  16875. export class CanvasGenerator {
  16876. /**
  16877. * Create a new canvas (or offscreen canvas depending on the context)
  16878. * @param width defines the expected width
  16879. * @param height defines the expected height
  16880. * @return a new canvas or offscreen canvas
  16881. */
  16882. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16883. }
  16884. }
  16885. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16886. import { Scene } from "babylonjs/scene";
  16887. import { Texture } from "babylonjs/Materials/Textures/texture";
  16888. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16889. /**
  16890. * A class extending Texture allowing drawing on a texture
  16891. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16892. */
  16893. export class DynamicTexture extends Texture {
  16894. private _generateMipMaps;
  16895. private _canvas;
  16896. private _context;
  16897. private _engine;
  16898. /**
  16899. * Creates a DynamicTexture
  16900. * @param name defines the name of the texture
  16901. * @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
  16902. * @param scene defines the scene where you want the texture
  16903. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16904. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16905. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16906. */
  16907. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16908. /**
  16909. * Get the current class name of the texture useful for serialization or dynamic coding.
  16910. * @returns "DynamicTexture"
  16911. */
  16912. getClassName(): string;
  16913. /**
  16914. * Gets the current state of canRescale
  16915. */
  16916. get canRescale(): boolean;
  16917. private _recreate;
  16918. /**
  16919. * Scales the texture
  16920. * @param ratio the scale factor to apply to both width and height
  16921. */
  16922. scale(ratio: number): void;
  16923. /**
  16924. * Resizes the texture
  16925. * @param width the new width
  16926. * @param height the new height
  16927. */
  16928. scaleTo(width: number, height: number): void;
  16929. /**
  16930. * Gets the context of the canvas used by the texture
  16931. * @returns the canvas context of the dynamic texture
  16932. */
  16933. getContext(): CanvasRenderingContext2D;
  16934. /**
  16935. * Clears the texture
  16936. */
  16937. clear(): void;
  16938. /**
  16939. * Updates the texture
  16940. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16941. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16942. */
  16943. update(invertY?: boolean, premulAlpha?: boolean): void;
  16944. /**
  16945. * Draws text onto the texture
  16946. * @param text defines the text to be drawn
  16947. * @param x defines the placement of the text from the left
  16948. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16949. * @param font defines the font to be used with font-style, font-size, font-name
  16950. * @param color defines the color used for the text
  16951. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16953. * @param update defines whether texture is immediately update (default is true)
  16954. */
  16955. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16956. /**
  16957. * Clones the texture
  16958. * @returns the clone of the texture.
  16959. */
  16960. clone(): DynamicTexture;
  16961. /**
  16962. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16963. * @returns a serialized dynamic texture object
  16964. */
  16965. serialize(): any;
  16966. /** @hidden */
  16967. _rebuild(): void;
  16968. }
  16969. }
  16970. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16971. import { Scene } from "babylonjs/scene";
  16972. import { ISceneComponent } from "babylonjs/sceneComponent";
  16973. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16974. module "babylonjs/abstractScene" {
  16975. interface AbstractScene {
  16976. /**
  16977. * The list of procedural textures added to the scene
  16978. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16979. */
  16980. proceduralTextures: Array<ProceduralTexture>;
  16981. }
  16982. }
  16983. /**
  16984. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16985. * in a given scene.
  16986. */
  16987. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16988. /**
  16989. * The component name helpfull to identify the component in the list of scene components.
  16990. */
  16991. readonly name: string;
  16992. /**
  16993. * The scene the component belongs to.
  16994. */
  16995. scene: Scene;
  16996. /**
  16997. * Creates a new instance of the component for the given scene
  16998. * @param scene Defines the scene to register the component in
  16999. */
  17000. constructor(scene: Scene);
  17001. /**
  17002. * Registers the component in a given scene
  17003. */
  17004. register(): void;
  17005. /**
  17006. * Rebuilds the elements related to this component in case of
  17007. * context lost for instance.
  17008. */
  17009. rebuild(): void;
  17010. /**
  17011. * Disposes the component and the associated ressources.
  17012. */
  17013. dispose(): void;
  17014. private _beforeClear;
  17015. }
  17016. }
  17017. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  17018. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17019. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17020. module "babylonjs/Engines/thinEngine" {
  17021. interface ThinEngine {
  17022. /**
  17023. * Creates a new render target cube texture
  17024. * @param size defines the size of the texture
  17025. * @param options defines the options used to create the texture
  17026. * @returns a new render target cube texture stored in an InternalTexture
  17027. */
  17028. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  17029. }
  17030. }
  17031. }
  17032. declare module "babylonjs/Shaders/procedural.vertex" {
  17033. /** @hidden */
  17034. export var proceduralVertexShader: {
  17035. name: string;
  17036. shader: string;
  17037. };
  17038. }
  17039. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  17040. import { Observable } from "babylonjs/Misc/observable";
  17041. import { Nullable } from "babylonjs/types";
  17042. import { Scene } from "babylonjs/scene";
  17043. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  17044. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17045. import { Effect } from "babylonjs/Materials/effect";
  17046. import { Texture } from "babylonjs/Materials/Textures/texture";
  17047. import "babylonjs/Engines/Extensions/engine.renderTarget";
  17048. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  17049. import "babylonjs/Shaders/procedural.vertex";
  17050. /**
  17051. * 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.
  17052. * This is the base class of any Procedural texture and contains most of the shareable code.
  17053. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17054. */
  17055. export class ProceduralTexture extends Texture {
  17056. isCube: boolean;
  17057. /**
  17058. * Define if the texture is enabled or not (disabled texture will not render)
  17059. */
  17060. isEnabled: boolean;
  17061. /**
  17062. * Define if the texture must be cleared before rendering (default is true)
  17063. */
  17064. autoClear: boolean;
  17065. /**
  17066. * Callback called when the texture is generated
  17067. */
  17068. onGenerated: () => void;
  17069. /**
  17070. * Event raised when the texture is generated
  17071. */
  17072. onGeneratedObservable: Observable<ProceduralTexture>;
  17073. /** @hidden */
  17074. _generateMipMaps: boolean;
  17075. /** @hidden **/
  17076. _effect: Effect;
  17077. /** @hidden */
  17078. _textures: {
  17079. [key: string]: Texture;
  17080. };
  17081. private _size;
  17082. private _currentRefreshId;
  17083. private _frameId;
  17084. private _refreshRate;
  17085. private _vertexBuffers;
  17086. private _indexBuffer;
  17087. private _uniforms;
  17088. private _samplers;
  17089. private _fragment;
  17090. private _floats;
  17091. private _ints;
  17092. private _floatsArrays;
  17093. private _colors3;
  17094. private _colors4;
  17095. private _vectors2;
  17096. private _vectors3;
  17097. private _matrices;
  17098. private _fallbackTexture;
  17099. private _fallbackTextureUsed;
  17100. private _engine;
  17101. private _cachedDefines;
  17102. private _contentUpdateId;
  17103. private _contentData;
  17104. /**
  17105. * Instantiates a new procedural texture.
  17106. * 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.
  17107. * This is the base class of any Procedural texture and contains most of the shareable code.
  17108. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17109. * @param name Define the name of the texture
  17110. * @param size Define the size of the texture to create
  17111. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17112. * @param scene Define the scene the texture belongs to
  17113. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17114. * @param generateMipMaps Define if the texture should creates mip maps or not
  17115. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17116. */
  17117. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17118. /**
  17119. * The effect that is created when initializing the post process.
  17120. * @returns The created effect corresponding the the postprocess.
  17121. */
  17122. getEffect(): Effect;
  17123. /**
  17124. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17125. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17126. */
  17127. getContent(): Nullable<ArrayBufferView>;
  17128. private _createIndexBuffer;
  17129. /** @hidden */
  17130. _rebuild(): void;
  17131. /**
  17132. * Resets the texture in order to recreate its associated resources.
  17133. * This can be called in case of context loss
  17134. */
  17135. reset(): void;
  17136. protected _getDefines(): string;
  17137. /**
  17138. * Is the texture ready to be used ? (rendered at least once)
  17139. * @returns true if ready, otherwise, false.
  17140. */
  17141. isReady(): boolean;
  17142. /**
  17143. * Resets the refresh counter of the texture and start bak from scratch.
  17144. * Could be useful to regenerate the texture if it is setup to render only once.
  17145. */
  17146. resetRefreshCounter(): void;
  17147. /**
  17148. * Set the fragment shader to use in order to render the texture.
  17149. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17150. */
  17151. setFragment(fragment: any): void;
  17152. /**
  17153. * Define the refresh rate of the texture or the rendering frequency.
  17154. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17155. */
  17156. get refreshRate(): number;
  17157. set refreshRate(value: number);
  17158. /** @hidden */
  17159. _shouldRender(): boolean;
  17160. /**
  17161. * Get the size the texture is rendering at.
  17162. * @returns the size (texture is always squared)
  17163. */
  17164. getRenderSize(): number;
  17165. /**
  17166. * Resize the texture to new value.
  17167. * @param size Define the new size the texture should have
  17168. * @param generateMipMaps Define whether the new texture should create mip maps
  17169. */
  17170. resize(size: number, generateMipMaps: boolean): void;
  17171. private _checkUniform;
  17172. /**
  17173. * Set a texture in the shader program used to render.
  17174. * @param name Define the name of the uniform samplers as defined in the shader
  17175. * @param texture Define the texture to bind to this sampler
  17176. * @return the texture itself allowing "fluent" like uniform updates
  17177. */
  17178. setTexture(name: string, texture: Texture): ProceduralTexture;
  17179. /**
  17180. * Set a float in the shader.
  17181. * @param name Define the name of the uniform as defined in the shader
  17182. * @param value Define the value to give to the uniform
  17183. * @return the texture itself allowing "fluent" like uniform updates
  17184. */
  17185. setFloat(name: string, value: number): ProceduralTexture;
  17186. /**
  17187. * Set a int in the shader.
  17188. * @param name Define the name of the uniform as defined in the shader
  17189. * @param value Define the value to give to the uniform
  17190. * @return the texture itself allowing "fluent" like uniform updates
  17191. */
  17192. setInt(name: string, value: number): ProceduralTexture;
  17193. /**
  17194. * Set an array of floats in the shader.
  17195. * @param name Define the name of the uniform as defined in the shader
  17196. * @param value Define the value to give to the uniform
  17197. * @return the texture itself allowing "fluent" like uniform updates
  17198. */
  17199. setFloats(name: string, value: number[]): ProceduralTexture;
  17200. /**
  17201. * Set a vec3 in the shader from a Color3.
  17202. * @param name Define the name of the uniform as defined in the shader
  17203. * @param value Define the value to give to the uniform
  17204. * @return the texture itself allowing "fluent" like uniform updates
  17205. */
  17206. setColor3(name: string, value: Color3): ProceduralTexture;
  17207. /**
  17208. * Set a vec4 in the shader from a Color4.
  17209. * @param name Define the name of the uniform as defined in the shader
  17210. * @param value Define the value to give to the uniform
  17211. * @return the texture itself allowing "fluent" like uniform updates
  17212. */
  17213. setColor4(name: string, value: Color4): ProceduralTexture;
  17214. /**
  17215. * Set a vec2 in the shader from a Vector2.
  17216. * @param name Define the name of the uniform as defined in the shader
  17217. * @param value Define the value to give to the uniform
  17218. * @return the texture itself allowing "fluent" like uniform updates
  17219. */
  17220. setVector2(name: string, value: Vector2): ProceduralTexture;
  17221. /**
  17222. * Set a vec3 in the shader from a Vector3.
  17223. * @param name Define the name of the uniform as defined in the shader
  17224. * @param value Define the value to give to the uniform
  17225. * @return the texture itself allowing "fluent" like uniform updates
  17226. */
  17227. setVector3(name: string, value: Vector3): ProceduralTexture;
  17228. /**
  17229. * Set a mat4 in the shader from a MAtrix.
  17230. * @param name Define the name of the uniform as defined in the shader
  17231. * @param value Define the value to give to the uniform
  17232. * @return the texture itself allowing "fluent" like uniform updates
  17233. */
  17234. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17235. /**
  17236. * Render the texture to its associated render target.
  17237. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17238. */
  17239. render(useCameraPostProcess?: boolean): void;
  17240. /**
  17241. * Clone the texture.
  17242. * @returns the cloned texture
  17243. */
  17244. clone(): ProceduralTexture;
  17245. /**
  17246. * Dispose the texture and release its asoociated resources.
  17247. */
  17248. dispose(): void;
  17249. }
  17250. }
  17251. declare module "babylonjs/Particles/baseParticleSystem" {
  17252. import { Nullable } from "babylonjs/types";
  17253. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17255. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17256. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17257. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17258. import { Scene } from "babylonjs/scene";
  17259. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17260. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17261. import { Texture } from "babylonjs/Materials/Textures/texture";
  17262. import { Color4 } from "babylonjs/Maths/math.color";
  17263. import { Animation } from "babylonjs/Animations/animation";
  17264. /**
  17265. * This represents the base class for particle system in Babylon.
  17266. * 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.
  17267. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17268. * @example https://doc.babylonjs.com/babylon101/particles
  17269. */
  17270. export class BaseParticleSystem {
  17271. /**
  17272. * Source color is added to the destination color without alpha affecting the result
  17273. */
  17274. static BLENDMODE_ONEONE: number;
  17275. /**
  17276. * Blend current color and particle color using particle’s alpha
  17277. */
  17278. static BLENDMODE_STANDARD: number;
  17279. /**
  17280. * Add current color and particle color multiplied by particle’s alpha
  17281. */
  17282. static BLENDMODE_ADD: number;
  17283. /**
  17284. * Multiply current color with particle color
  17285. */
  17286. static BLENDMODE_MULTIPLY: number;
  17287. /**
  17288. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17289. */
  17290. static BLENDMODE_MULTIPLYADD: number;
  17291. /**
  17292. * List of animations used by the particle system.
  17293. */
  17294. animations: Animation[];
  17295. /**
  17296. * The id of the Particle system.
  17297. */
  17298. id: string;
  17299. /**
  17300. * The friendly name of the Particle system.
  17301. */
  17302. name: string;
  17303. /**
  17304. * The rendering group used by the Particle system to chose when to render.
  17305. */
  17306. renderingGroupId: number;
  17307. /**
  17308. * The emitter represents the Mesh or position we are attaching the particle system to.
  17309. */
  17310. emitter: Nullable<AbstractMesh | Vector3>;
  17311. /**
  17312. * The maximum number of particles to emit per frame
  17313. */
  17314. emitRate: number;
  17315. /**
  17316. * If you want to launch only a few particles at once, that can be done, as well.
  17317. */
  17318. manualEmitCount: number;
  17319. /**
  17320. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17321. */
  17322. updateSpeed: number;
  17323. /**
  17324. * The amount of time the particle system is running (depends of the overall update speed).
  17325. */
  17326. targetStopDuration: number;
  17327. /**
  17328. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17329. */
  17330. disposeOnStop: boolean;
  17331. /**
  17332. * Minimum power of emitting particles.
  17333. */
  17334. minEmitPower: number;
  17335. /**
  17336. * Maximum power of emitting particles.
  17337. */
  17338. maxEmitPower: number;
  17339. /**
  17340. * Minimum life time of emitting particles.
  17341. */
  17342. minLifeTime: number;
  17343. /**
  17344. * Maximum life time of emitting particles.
  17345. */
  17346. maxLifeTime: number;
  17347. /**
  17348. * Minimum Size of emitting particles.
  17349. */
  17350. minSize: number;
  17351. /**
  17352. * Maximum Size of emitting particles.
  17353. */
  17354. maxSize: number;
  17355. /**
  17356. * Minimum scale of emitting particles on X axis.
  17357. */
  17358. minScaleX: number;
  17359. /**
  17360. * Maximum scale of emitting particles on X axis.
  17361. */
  17362. maxScaleX: number;
  17363. /**
  17364. * Minimum scale of emitting particles on Y axis.
  17365. */
  17366. minScaleY: number;
  17367. /**
  17368. * Maximum scale of emitting particles on Y axis.
  17369. */
  17370. maxScaleY: number;
  17371. /**
  17372. * Gets or sets the minimal initial rotation in radians.
  17373. */
  17374. minInitialRotation: number;
  17375. /**
  17376. * Gets or sets the maximal initial rotation in radians.
  17377. */
  17378. maxInitialRotation: number;
  17379. /**
  17380. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17381. */
  17382. minAngularSpeed: number;
  17383. /**
  17384. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17385. */
  17386. maxAngularSpeed: number;
  17387. /**
  17388. * The texture used to render each particle. (this can be a spritesheet)
  17389. */
  17390. particleTexture: Nullable<Texture>;
  17391. /**
  17392. * The layer mask we are rendering the particles through.
  17393. */
  17394. layerMask: number;
  17395. /**
  17396. * This can help using your own shader to render the particle system.
  17397. * The according effect will be created
  17398. */
  17399. customShader: any;
  17400. /**
  17401. * By default particle system starts as soon as they are created. This prevents the
  17402. * automatic start to happen and let you decide when to start emitting particles.
  17403. */
  17404. preventAutoStart: boolean;
  17405. private _noiseTexture;
  17406. /**
  17407. * Gets or sets a texture used to add random noise to particle positions
  17408. */
  17409. get noiseTexture(): Nullable<ProceduralTexture>;
  17410. set noiseTexture(value: Nullable<ProceduralTexture>);
  17411. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17412. noiseStrength: Vector3;
  17413. /**
  17414. * Callback triggered when the particle animation is ending.
  17415. */
  17416. onAnimationEnd: Nullable<() => void>;
  17417. /**
  17418. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17419. */
  17420. blendMode: number;
  17421. /**
  17422. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17423. * to override the particles.
  17424. */
  17425. forceDepthWrite: boolean;
  17426. /** 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 */
  17427. preWarmCycles: number;
  17428. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17429. preWarmStepOffset: number;
  17430. /**
  17431. * 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)
  17432. */
  17433. spriteCellChangeSpeed: number;
  17434. /**
  17435. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17436. */
  17437. startSpriteCellID: number;
  17438. /**
  17439. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17440. */
  17441. endSpriteCellID: number;
  17442. /**
  17443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17444. */
  17445. spriteCellWidth: number;
  17446. /**
  17447. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17448. */
  17449. spriteCellHeight: number;
  17450. /**
  17451. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17452. */
  17453. spriteRandomStartCell: boolean;
  17454. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17455. translationPivot: Vector2;
  17456. /** @hidden */
  17457. protected _isAnimationSheetEnabled: boolean;
  17458. /**
  17459. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17460. */
  17461. beginAnimationOnStart: boolean;
  17462. /**
  17463. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17464. */
  17465. beginAnimationFrom: number;
  17466. /**
  17467. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17468. */
  17469. beginAnimationTo: number;
  17470. /**
  17471. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17472. */
  17473. beginAnimationLoop: boolean;
  17474. /**
  17475. * Gets or sets a world offset applied to all particles
  17476. */
  17477. worldOffset: Vector3;
  17478. /**
  17479. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17480. */
  17481. get isAnimationSheetEnabled(): boolean;
  17482. set isAnimationSheetEnabled(value: boolean);
  17483. /**
  17484. * Get hosting scene
  17485. * @returns the scene
  17486. */
  17487. getScene(): Scene;
  17488. /**
  17489. * You can use gravity if you want to give an orientation to your particles.
  17490. */
  17491. gravity: Vector3;
  17492. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17493. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17494. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17495. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17496. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17497. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17498. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17499. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17500. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17501. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17502. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17503. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17504. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17505. /**
  17506. * Defines the delay in milliseconds before starting the system (0 by default)
  17507. */
  17508. startDelay: number;
  17509. /**
  17510. * Gets the current list of drag gradients.
  17511. * You must use addDragGradient and removeDragGradient to udpate this list
  17512. * @returns the list of drag gradients
  17513. */
  17514. getDragGradients(): Nullable<Array<FactorGradient>>;
  17515. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17516. limitVelocityDamping: number;
  17517. /**
  17518. * Gets the current list of limit velocity gradients.
  17519. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17520. * @returns the list of limit velocity gradients
  17521. */
  17522. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17523. /**
  17524. * Gets the current list of color gradients.
  17525. * You must use addColorGradient and removeColorGradient to udpate this list
  17526. * @returns the list of color gradients
  17527. */
  17528. getColorGradients(): Nullable<Array<ColorGradient>>;
  17529. /**
  17530. * Gets the current list of size gradients.
  17531. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17532. * @returns the list of size gradients
  17533. */
  17534. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17535. /**
  17536. * Gets the current list of color remap gradients.
  17537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17538. * @returns the list of color remap gradients
  17539. */
  17540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17541. /**
  17542. * Gets the current list of alpha remap gradients.
  17543. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17544. * @returns the list of alpha remap gradients
  17545. */
  17546. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17547. /**
  17548. * Gets the current list of life time gradients.
  17549. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17550. * @returns the list of life time gradients
  17551. */
  17552. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17553. /**
  17554. * Gets the current list of angular speed gradients.
  17555. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17556. * @returns the list of angular speed gradients
  17557. */
  17558. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17559. /**
  17560. * Gets the current list of velocity gradients.
  17561. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17562. * @returns the list of velocity gradients
  17563. */
  17564. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17565. /**
  17566. * Gets the current list of start size gradients.
  17567. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17568. * @returns the list of start size gradients
  17569. */
  17570. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17571. /**
  17572. * Gets the current list of emit rate gradients.
  17573. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17574. * @returns the list of emit rate gradients
  17575. */
  17576. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17577. /**
  17578. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17580. */
  17581. get direction1(): Vector3;
  17582. set direction1(value: Vector3);
  17583. /**
  17584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17586. */
  17587. get direction2(): Vector3;
  17588. set direction2(value: Vector3);
  17589. /**
  17590. * 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.
  17591. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17592. */
  17593. get minEmitBox(): Vector3;
  17594. set minEmitBox(value: Vector3);
  17595. /**
  17596. * 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.
  17597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17598. */
  17599. get maxEmitBox(): Vector3;
  17600. set maxEmitBox(value: Vector3);
  17601. /**
  17602. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17603. */
  17604. color1: Color4;
  17605. /**
  17606. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17607. */
  17608. color2: Color4;
  17609. /**
  17610. * Color the particle will have at the end of its lifetime
  17611. */
  17612. colorDead: Color4;
  17613. /**
  17614. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17615. */
  17616. textureMask: Color4;
  17617. /**
  17618. * The particle emitter type defines the emitter used by the particle system.
  17619. * It can be for example box, sphere, or cone...
  17620. */
  17621. particleEmitterType: IParticleEmitterType;
  17622. /** @hidden */
  17623. _isSubEmitter: boolean;
  17624. /**
  17625. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17626. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17627. */
  17628. billboardMode: number;
  17629. protected _isBillboardBased: boolean;
  17630. /**
  17631. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17632. */
  17633. get isBillboardBased(): boolean;
  17634. set isBillboardBased(value: boolean);
  17635. /**
  17636. * The scene the particle system belongs to.
  17637. */
  17638. protected _scene: Scene;
  17639. /**
  17640. * Local cache of defines for image processing.
  17641. */
  17642. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17643. /**
  17644. * Default configuration related to image processing available in the standard Material.
  17645. */
  17646. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17647. /**
  17648. * Gets the image processing configuration used either in this material.
  17649. */
  17650. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17651. /**
  17652. * Sets the Default image processing configuration used either in the this material.
  17653. *
  17654. * If sets to null, the scene one is in use.
  17655. */
  17656. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17657. /**
  17658. * Attaches a new image processing configuration to the Standard Material.
  17659. * @param configuration
  17660. */
  17661. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17662. /** @hidden */
  17663. protected _reset(): void;
  17664. /** @hidden */
  17665. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17666. /**
  17667. * Instantiates a particle system.
  17668. * 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.
  17669. * @param name The name of the particle system
  17670. */
  17671. constructor(name: string);
  17672. /**
  17673. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17676. * @returns the emitter
  17677. */
  17678. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17679. /**
  17680. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17681. * @param radius The radius of the hemisphere to emit from
  17682. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17683. * @returns the emitter
  17684. */
  17685. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17686. /**
  17687. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17688. * @param radius The radius of the sphere to emit from
  17689. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17690. * @returns the emitter
  17691. */
  17692. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17693. /**
  17694. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17695. * @param radius The radius of the sphere to emit from
  17696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17698. * @returns the emitter
  17699. */
  17700. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17701. /**
  17702. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17703. * @param radius The radius of the emission cylinder
  17704. * @param height The height of the emission cylinder
  17705. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17706. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17707. * @returns the emitter
  17708. */
  17709. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17710. /**
  17711. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17712. * @param radius The radius of the cylinder to emit from
  17713. * @param height The height of the emission cylinder
  17714. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17717. * @returns the emitter
  17718. */
  17719. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17720. /**
  17721. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17722. * @param radius The radius of the cone to emit from
  17723. * @param angle The base angle of the cone
  17724. * @returns the emitter
  17725. */
  17726. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17727. /**
  17728. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17731. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17732. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17733. * @returns the emitter
  17734. */
  17735. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17736. }
  17737. }
  17738. declare module "babylonjs/Particles/subEmitter" {
  17739. import { Scene } from "babylonjs/scene";
  17740. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17741. /**
  17742. * Type of sub emitter
  17743. */
  17744. export enum SubEmitterType {
  17745. /**
  17746. * Attached to the particle over it's lifetime
  17747. */
  17748. ATTACHED = 0,
  17749. /**
  17750. * Created when the particle dies
  17751. */
  17752. END = 1
  17753. }
  17754. /**
  17755. * Sub emitter class used to emit particles from an existing particle
  17756. */
  17757. export class SubEmitter {
  17758. /**
  17759. * the particle system to be used by the sub emitter
  17760. */
  17761. particleSystem: ParticleSystem;
  17762. /**
  17763. * Type of the submitter (Default: END)
  17764. */
  17765. type: SubEmitterType;
  17766. /**
  17767. * 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)
  17768. * Note: This only is supported when using an emitter of type Mesh
  17769. */
  17770. inheritDirection: boolean;
  17771. /**
  17772. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17773. */
  17774. inheritedVelocityAmount: number;
  17775. /**
  17776. * Creates a sub emitter
  17777. * @param particleSystem the particle system to be used by the sub emitter
  17778. */
  17779. constructor(
  17780. /**
  17781. * the particle system to be used by the sub emitter
  17782. */
  17783. particleSystem: ParticleSystem);
  17784. /**
  17785. * Clones the sub emitter
  17786. * @returns the cloned sub emitter
  17787. */
  17788. clone(): SubEmitter;
  17789. /**
  17790. * Serialize current object to a JSON object
  17791. * @returns the serialized object
  17792. */
  17793. serialize(): any;
  17794. /** @hidden */
  17795. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17796. /**
  17797. * Creates a new SubEmitter from a serialized JSON version
  17798. * @param serializationObject defines the JSON object to read from
  17799. * @param scene defines the hosting scene
  17800. * @param rootUrl defines the rootUrl for data loading
  17801. * @returns a new SubEmitter
  17802. */
  17803. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17804. /** Release associated resources */
  17805. dispose(): void;
  17806. }
  17807. }
  17808. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17809. /** @hidden */
  17810. export var imageProcessingDeclaration: {
  17811. name: string;
  17812. shader: string;
  17813. };
  17814. }
  17815. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17816. /** @hidden */
  17817. export var imageProcessingFunctions: {
  17818. name: string;
  17819. shader: string;
  17820. };
  17821. }
  17822. declare module "babylonjs/Shaders/particles.fragment" {
  17823. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17824. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17825. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17826. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17827. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17828. /** @hidden */
  17829. export var particlesPixelShader: {
  17830. name: string;
  17831. shader: string;
  17832. };
  17833. }
  17834. declare module "babylonjs/Shaders/particles.vertex" {
  17835. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17836. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17837. /** @hidden */
  17838. export var particlesVertexShader: {
  17839. name: string;
  17840. shader: string;
  17841. };
  17842. }
  17843. declare module "babylonjs/Particles/particleSystem" {
  17844. import { Nullable } from "babylonjs/types";
  17845. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17846. import { Observable } from "babylonjs/Misc/observable";
  17847. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17848. import { Effect } from "babylonjs/Materials/effect";
  17849. import { Scene, IDisposable } from "babylonjs/scene";
  17850. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17851. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17852. import { Particle } from "babylonjs/Particles/particle";
  17853. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17854. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17855. import "babylonjs/Shaders/particles.fragment";
  17856. import "babylonjs/Shaders/particles.vertex";
  17857. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17858. /**
  17859. * This represents a particle system in Babylon.
  17860. * 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.
  17861. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17862. * @example https://doc.babylonjs.com/babylon101/particles
  17863. */
  17864. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17865. /**
  17866. * Billboard mode will only apply to Y axis
  17867. */
  17868. static readonly BILLBOARDMODE_Y: number;
  17869. /**
  17870. * Billboard mode will apply to all axes
  17871. */
  17872. static readonly BILLBOARDMODE_ALL: number;
  17873. /**
  17874. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17875. */
  17876. static readonly BILLBOARDMODE_STRETCHED: number;
  17877. /**
  17878. * This function can be defined to provide custom update for active particles.
  17879. * This function will be called instead of regular update (age, position, color, etc.).
  17880. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17881. */
  17882. updateFunction: (particles: Particle[]) => void;
  17883. private _emitterWorldMatrix;
  17884. /**
  17885. * This function can be defined to specify initial direction for every new particle.
  17886. * It by default use the emitterType defined function
  17887. */
  17888. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17889. /**
  17890. * This function can be defined to specify initial position for every new particle.
  17891. * It by default use the emitterType defined function
  17892. */
  17893. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17894. /**
  17895. * @hidden
  17896. */
  17897. _inheritedVelocityOffset: Vector3;
  17898. /**
  17899. * An event triggered when the system is disposed
  17900. */
  17901. onDisposeObservable: Observable<ParticleSystem>;
  17902. private _onDisposeObserver;
  17903. /**
  17904. * Sets a callback that will be triggered when the system is disposed
  17905. */
  17906. set onDispose(callback: () => void);
  17907. private _particles;
  17908. private _epsilon;
  17909. private _capacity;
  17910. private _stockParticles;
  17911. private _newPartsExcess;
  17912. private _vertexData;
  17913. private _vertexBuffer;
  17914. private _vertexBuffers;
  17915. private _spriteBuffer;
  17916. private _indexBuffer;
  17917. private _effect;
  17918. private _customEffect;
  17919. private _cachedDefines;
  17920. private _scaledColorStep;
  17921. private _colorDiff;
  17922. private _scaledDirection;
  17923. private _scaledGravity;
  17924. private _currentRenderId;
  17925. private _alive;
  17926. private _useInstancing;
  17927. private _started;
  17928. private _stopped;
  17929. private _actualFrame;
  17930. private _scaledUpdateSpeed;
  17931. private _vertexBufferSize;
  17932. /** @hidden */
  17933. _currentEmitRateGradient: Nullable<FactorGradient>;
  17934. /** @hidden */
  17935. _currentEmitRate1: number;
  17936. /** @hidden */
  17937. _currentEmitRate2: number;
  17938. /** @hidden */
  17939. _currentStartSizeGradient: Nullable<FactorGradient>;
  17940. /** @hidden */
  17941. _currentStartSize1: number;
  17942. /** @hidden */
  17943. _currentStartSize2: number;
  17944. private readonly _rawTextureWidth;
  17945. private _rampGradientsTexture;
  17946. private _useRampGradients;
  17947. /** Gets or sets a boolean indicating that ramp gradients must be used
  17948. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17949. */
  17950. get useRampGradients(): boolean;
  17951. set useRampGradients(value: boolean);
  17952. /**
  17953. * 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.
  17954. * 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: [])
  17955. */
  17956. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17957. private _subEmitters;
  17958. /**
  17959. * @hidden
  17960. * If the particle systems emitter should be disposed when the particle system is disposed
  17961. */
  17962. _disposeEmitterOnDispose: boolean;
  17963. /**
  17964. * The current active Sub-systems, this property is used by the root particle system only.
  17965. */
  17966. activeSubSystems: Array<ParticleSystem>;
  17967. private _rootParticleSystem;
  17968. /**
  17969. * Gets the current list of active particles
  17970. */
  17971. get particles(): Particle[];
  17972. /**
  17973. * Returns the string "ParticleSystem"
  17974. * @returns a string containing the class name
  17975. */
  17976. getClassName(): string;
  17977. /**
  17978. * Instantiates a particle system.
  17979. * 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.
  17980. * @param name The name of the particle system
  17981. * @param capacity The max number of particles alive at the same time
  17982. * @param scene The scene the particle system belongs to
  17983. * @param customEffect a custom effect used to change the way particles are rendered by default
  17984. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17985. * @param epsilon Offset used to render the particles
  17986. */
  17987. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17988. private _addFactorGradient;
  17989. private _removeFactorGradient;
  17990. /**
  17991. * Adds a new life time gradient
  17992. * @param gradient defines the gradient to use (between 0 and 1)
  17993. * @param factor defines the life time factor to affect to the specified gradient
  17994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17995. * @returns the current particle system
  17996. */
  17997. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17998. /**
  17999. * Remove a specific life time gradient
  18000. * @param gradient defines the gradient to remove
  18001. * @returns the current particle system
  18002. */
  18003. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18004. /**
  18005. * Adds a new size gradient
  18006. * @param gradient defines the gradient to use (between 0 and 1)
  18007. * @param factor defines the size factor to affect to the specified gradient
  18008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18009. * @returns the current particle system
  18010. */
  18011. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18012. /**
  18013. * Remove a specific size gradient
  18014. * @param gradient defines the gradient to remove
  18015. * @returns the current particle system
  18016. */
  18017. removeSizeGradient(gradient: number): IParticleSystem;
  18018. /**
  18019. * Adds a new color remap gradient
  18020. * @param gradient defines the gradient to use (between 0 and 1)
  18021. * @param min defines the color remap minimal range
  18022. * @param max defines the color remap maximal range
  18023. * @returns the current particle system
  18024. */
  18025. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18026. /**
  18027. * Remove a specific color remap gradient
  18028. * @param gradient defines the gradient to remove
  18029. * @returns the current particle system
  18030. */
  18031. removeColorRemapGradient(gradient: number): IParticleSystem;
  18032. /**
  18033. * Adds a new alpha remap gradient
  18034. * @param gradient defines the gradient to use (between 0 and 1)
  18035. * @param min defines the alpha remap minimal range
  18036. * @param max defines the alpha remap maximal range
  18037. * @returns the current particle system
  18038. */
  18039. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18040. /**
  18041. * Remove a specific alpha remap gradient
  18042. * @param gradient defines the gradient to remove
  18043. * @returns the current particle system
  18044. */
  18045. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18046. /**
  18047. * Adds a new angular speed gradient
  18048. * @param gradient defines the gradient to use (between 0 and 1)
  18049. * @param factor defines the angular speed to affect to the specified gradient
  18050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18051. * @returns the current particle system
  18052. */
  18053. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18054. /**
  18055. * Remove a specific angular speed gradient
  18056. * @param gradient defines the gradient to remove
  18057. * @returns the current particle system
  18058. */
  18059. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18060. /**
  18061. * Adds a new velocity gradient
  18062. * @param gradient defines the gradient to use (between 0 and 1)
  18063. * @param factor defines the velocity to affect to the specified gradient
  18064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18065. * @returns the current particle system
  18066. */
  18067. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18068. /**
  18069. * Remove a specific velocity gradient
  18070. * @param gradient defines the gradient to remove
  18071. * @returns the current particle system
  18072. */
  18073. removeVelocityGradient(gradient: number): IParticleSystem;
  18074. /**
  18075. * Adds a new limit velocity gradient
  18076. * @param gradient defines the gradient to use (between 0 and 1)
  18077. * @param factor defines the limit velocity value to affect to the specified gradient
  18078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18079. * @returns the current particle system
  18080. */
  18081. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18082. /**
  18083. * Remove a specific limit velocity gradient
  18084. * @param gradient defines the gradient to remove
  18085. * @returns the current particle system
  18086. */
  18087. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18088. /**
  18089. * Adds a new drag gradient
  18090. * @param gradient defines the gradient to use (between 0 and 1)
  18091. * @param factor defines the drag value to affect to the specified gradient
  18092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18093. * @returns the current particle system
  18094. */
  18095. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18096. /**
  18097. * Remove a specific drag gradient
  18098. * @param gradient defines the gradient to remove
  18099. * @returns the current particle system
  18100. */
  18101. removeDragGradient(gradient: number): IParticleSystem;
  18102. /**
  18103. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18104. * @param gradient defines the gradient to use (between 0 and 1)
  18105. * @param factor defines the emit rate value to affect to the specified gradient
  18106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18107. * @returns the current particle system
  18108. */
  18109. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18110. /**
  18111. * Remove a specific emit rate gradient
  18112. * @param gradient defines the gradient to remove
  18113. * @returns the current particle system
  18114. */
  18115. removeEmitRateGradient(gradient: number): IParticleSystem;
  18116. /**
  18117. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18118. * @param gradient defines the gradient to use (between 0 and 1)
  18119. * @param factor defines the start size value to affect to the specified gradient
  18120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18121. * @returns the current particle system
  18122. */
  18123. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18124. /**
  18125. * Remove a specific start size gradient
  18126. * @param gradient defines the gradient to remove
  18127. * @returns the current particle system
  18128. */
  18129. removeStartSizeGradient(gradient: number): IParticleSystem;
  18130. private _createRampGradientTexture;
  18131. /**
  18132. * Gets the current list of ramp gradients.
  18133. * You must use addRampGradient and removeRampGradient to udpate this list
  18134. * @returns the list of ramp gradients
  18135. */
  18136. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18137. /**
  18138. * Adds a new ramp gradient used to remap particle colors
  18139. * @param gradient defines the gradient to use (between 0 and 1)
  18140. * @param color defines the color to affect to the specified gradient
  18141. * @returns the current particle system
  18142. */
  18143. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18144. /**
  18145. * Remove a specific ramp gradient
  18146. * @param gradient defines the gradient to remove
  18147. * @returns the current particle system
  18148. */
  18149. removeRampGradient(gradient: number): ParticleSystem;
  18150. /**
  18151. * Adds a new color gradient
  18152. * @param gradient defines the gradient to use (between 0 and 1)
  18153. * @param color1 defines the color to affect to the specified gradient
  18154. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18155. * @returns this particle system
  18156. */
  18157. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18158. /**
  18159. * Remove a specific color gradient
  18160. * @param gradient defines the gradient to remove
  18161. * @returns this particle system
  18162. */
  18163. removeColorGradient(gradient: number): IParticleSystem;
  18164. private _fetchR;
  18165. protected _reset(): void;
  18166. private _resetEffect;
  18167. private _createVertexBuffers;
  18168. private _createIndexBuffer;
  18169. /**
  18170. * Gets the maximum number of particles active at the same time.
  18171. * @returns The max number of active particles.
  18172. */
  18173. getCapacity(): number;
  18174. /**
  18175. * Gets whether there are still active particles in the system.
  18176. * @returns True if it is alive, otherwise false.
  18177. */
  18178. isAlive(): boolean;
  18179. /**
  18180. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18181. * @returns True if it has been started, otherwise false.
  18182. */
  18183. isStarted(): boolean;
  18184. private _prepareSubEmitterInternalArray;
  18185. /**
  18186. * Starts the particle system and begins to emit
  18187. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18188. */
  18189. start(delay?: number): void;
  18190. /**
  18191. * Stops the particle system.
  18192. * @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.
  18193. */
  18194. stop(stopSubEmitters?: boolean): void;
  18195. /**
  18196. * Remove all active particles
  18197. */
  18198. reset(): void;
  18199. /**
  18200. * @hidden (for internal use only)
  18201. */
  18202. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18203. /**
  18204. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18205. * Its lifetime will start back at 0.
  18206. */
  18207. recycleParticle: (particle: Particle) => void;
  18208. private _stopSubEmitters;
  18209. private _createParticle;
  18210. private _removeFromRoot;
  18211. private _emitFromParticle;
  18212. private _update;
  18213. /** @hidden */
  18214. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18215. /** @hidden */
  18216. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18217. /** @hidden */
  18218. private _getEffect;
  18219. /**
  18220. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18221. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18222. */
  18223. animate(preWarmOnly?: boolean): void;
  18224. private _appendParticleVertices;
  18225. /**
  18226. * Rebuilds the particle system.
  18227. */
  18228. rebuild(): void;
  18229. /**
  18230. * Is this system ready to be used/rendered
  18231. * @return true if the system is ready
  18232. */
  18233. isReady(): boolean;
  18234. private _render;
  18235. /**
  18236. * Renders the particle system in its current state.
  18237. * @returns the current number of particles
  18238. */
  18239. render(): number;
  18240. /**
  18241. * Disposes the particle system and free the associated resources
  18242. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18243. */
  18244. dispose(disposeTexture?: boolean): void;
  18245. /**
  18246. * Clones the particle system.
  18247. * @param name The name of the cloned object
  18248. * @param newEmitter The new emitter to use
  18249. * @returns the cloned particle system
  18250. */
  18251. clone(name: string, newEmitter: any): ParticleSystem;
  18252. /**
  18253. * Serializes the particle system to a JSON object.
  18254. * @returns the JSON object
  18255. */
  18256. serialize(): any;
  18257. /** @hidden */
  18258. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18259. /** @hidden */
  18260. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18261. /**
  18262. * Parses a JSON object to create a particle system.
  18263. * @param parsedParticleSystem The JSON object to parse
  18264. * @param scene The scene to create the particle system in
  18265. * @param rootUrl The root url to use to load external dependencies like texture
  18266. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18267. * @returns the Parsed particle system
  18268. */
  18269. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18270. }
  18271. }
  18272. declare module "babylonjs/Particles/particle" {
  18273. import { Nullable } from "babylonjs/types";
  18274. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18275. import { Color4 } from "babylonjs/Maths/math.color";
  18276. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18277. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18278. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18279. /**
  18280. * A particle represents one of the element emitted by a particle system.
  18281. * This is mainly define by its coordinates, direction, velocity and age.
  18282. */
  18283. export class Particle {
  18284. /**
  18285. * The particle system the particle belongs to.
  18286. */
  18287. particleSystem: ParticleSystem;
  18288. private static _Count;
  18289. /**
  18290. * Unique ID of the particle
  18291. */
  18292. id: number;
  18293. /**
  18294. * The world position of the particle in the scene.
  18295. */
  18296. position: Vector3;
  18297. /**
  18298. * The world direction of the particle in the scene.
  18299. */
  18300. direction: Vector3;
  18301. /**
  18302. * The color of the particle.
  18303. */
  18304. color: Color4;
  18305. /**
  18306. * The color change of the particle per step.
  18307. */
  18308. colorStep: Color4;
  18309. /**
  18310. * Defines how long will the life of the particle be.
  18311. */
  18312. lifeTime: number;
  18313. /**
  18314. * The current age of the particle.
  18315. */
  18316. age: number;
  18317. /**
  18318. * The current size of the particle.
  18319. */
  18320. size: number;
  18321. /**
  18322. * The current scale of the particle.
  18323. */
  18324. scale: Vector2;
  18325. /**
  18326. * The current angle of the particle.
  18327. */
  18328. angle: number;
  18329. /**
  18330. * Defines how fast is the angle changing.
  18331. */
  18332. angularSpeed: number;
  18333. /**
  18334. * Defines the cell index used by the particle to be rendered from a sprite.
  18335. */
  18336. cellIndex: number;
  18337. /**
  18338. * The information required to support color remapping
  18339. */
  18340. remapData: Vector4;
  18341. /** @hidden */
  18342. _randomCellOffset?: number;
  18343. /** @hidden */
  18344. _initialDirection: Nullable<Vector3>;
  18345. /** @hidden */
  18346. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18347. /** @hidden */
  18348. _initialStartSpriteCellID: number;
  18349. /** @hidden */
  18350. _initialEndSpriteCellID: number;
  18351. /** @hidden */
  18352. _currentColorGradient: Nullable<ColorGradient>;
  18353. /** @hidden */
  18354. _currentColor1: Color4;
  18355. /** @hidden */
  18356. _currentColor2: Color4;
  18357. /** @hidden */
  18358. _currentSizeGradient: Nullable<FactorGradient>;
  18359. /** @hidden */
  18360. _currentSize1: number;
  18361. /** @hidden */
  18362. _currentSize2: number;
  18363. /** @hidden */
  18364. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18365. /** @hidden */
  18366. _currentAngularSpeed1: number;
  18367. /** @hidden */
  18368. _currentAngularSpeed2: number;
  18369. /** @hidden */
  18370. _currentVelocityGradient: Nullable<FactorGradient>;
  18371. /** @hidden */
  18372. _currentVelocity1: number;
  18373. /** @hidden */
  18374. _currentVelocity2: number;
  18375. /** @hidden */
  18376. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18377. /** @hidden */
  18378. _currentLimitVelocity1: number;
  18379. /** @hidden */
  18380. _currentLimitVelocity2: number;
  18381. /** @hidden */
  18382. _currentDragGradient: Nullable<FactorGradient>;
  18383. /** @hidden */
  18384. _currentDrag1: number;
  18385. /** @hidden */
  18386. _currentDrag2: number;
  18387. /** @hidden */
  18388. _randomNoiseCoordinates1: Vector3;
  18389. /** @hidden */
  18390. _randomNoiseCoordinates2: Vector3;
  18391. /**
  18392. * Creates a new instance Particle
  18393. * @param particleSystem the particle system the particle belongs to
  18394. */
  18395. constructor(
  18396. /**
  18397. * The particle system the particle belongs to.
  18398. */
  18399. particleSystem: ParticleSystem);
  18400. private updateCellInfoFromSystem;
  18401. /**
  18402. * Defines how the sprite cell index is updated for the particle
  18403. */
  18404. updateCellIndex(): void;
  18405. /** @hidden */
  18406. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18407. /** @hidden */
  18408. _inheritParticleInfoToSubEmitters(): void;
  18409. /** @hidden */
  18410. _reset(): void;
  18411. /**
  18412. * Copy the properties of particle to another one.
  18413. * @param other the particle to copy the information to.
  18414. */
  18415. copyTo(other: Particle): void;
  18416. }
  18417. }
  18418. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18419. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18420. import { Effect } from "babylonjs/Materials/effect";
  18421. import { Particle } from "babylonjs/Particles/particle";
  18422. import { Scene } from "babylonjs/scene";
  18423. /**
  18424. * Particle emitter represents a volume emitting particles.
  18425. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18426. */
  18427. export interface IParticleEmitterType {
  18428. /**
  18429. * Called by the particle System when the direction is computed for the created particle.
  18430. * @param worldMatrix is the world matrix of the particle system
  18431. * @param directionToUpdate is the direction vector to update with the result
  18432. * @param particle is the particle we are computed the direction for
  18433. */
  18434. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18435. /**
  18436. * Called by the particle System when the position is computed for the created particle.
  18437. * @param worldMatrix is the world matrix of the particle system
  18438. * @param positionToUpdate is the position vector to update with the result
  18439. * @param particle is the particle we are computed the position for
  18440. */
  18441. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18442. /**
  18443. * Clones the current emitter and returns a copy of it
  18444. * @returns the new emitter
  18445. */
  18446. clone(): IParticleEmitterType;
  18447. /**
  18448. * Called by the GPUParticleSystem to setup the update shader
  18449. * @param effect defines the update shader
  18450. */
  18451. applyToShader(effect: Effect): void;
  18452. /**
  18453. * Returns a string to use to update the GPU particles update shader
  18454. * @returns the effect defines string
  18455. */
  18456. getEffectDefines(): string;
  18457. /**
  18458. * Returns a string representing the class name
  18459. * @returns a string containing the class name
  18460. */
  18461. getClassName(): string;
  18462. /**
  18463. * Serializes the particle system to a JSON object.
  18464. * @returns the JSON object
  18465. */
  18466. serialize(): any;
  18467. /**
  18468. * Parse properties from a JSON object
  18469. * @param serializationObject defines the JSON object
  18470. * @param scene defines the hosting scene
  18471. */
  18472. parse(serializationObject: any, scene: Scene): void;
  18473. }
  18474. }
  18475. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18476. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18477. import { Effect } from "babylonjs/Materials/effect";
  18478. import { Particle } from "babylonjs/Particles/particle";
  18479. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18480. /**
  18481. * Particle emitter emitting particles from the inside of a box.
  18482. * It emits the particles randomly between 2 given directions.
  18483. */
  18484. export class BoxParticleEmitter implements IParticleEmitterType {
  18485. /**
  18486. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18487. */
  18488. direction1: Vector3;
  18489. /**
  18490. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18491. */
  18492. direction2: Vector3;
  18493. /**
  18494. * 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.
  18495. */
  18496. minEmitBox: Vector3;
  18497. /**
  18498. * 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.
  18499. */
  18500. maxEmitBox: Vector3;
  18501. /**
  18502. * Creates a new instance BoxParticleEmitter
  18503. */
  18504. constructor();
  18505. /**
  18506. * Called by the particle System when the direction is computed for the created particle.
  18507. * @param worldMatrix is the world matrix of the particle system
  18508. * @param directionToUpdate is the direction vector to update with the result
  18509. * @param particle is the particle we are computed the direction for
  18510. */
  18511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18512. /**
  18513. * Called by the particle System when the position is computed for the created particle.
  18514. * @param worldMatrix is the world matrix of the particle system
  18515. * @param positionToUpdate is the position vector to update with the result
  18516. * @param particle is the particle we are computed the position for
  18517. */
  18518. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18519. /**
  18520. * Clones the current emitter and returns a copy of it
  18521. * @returns the new emitter
  18522. */
  18523. clone(): BoxParticleEmitter;
  18524. /**
  18525. * Called by the GPUParticleSystem to setup the update shader
  18526. * @param effect defines the update shader
  18527. */
  18528. applyToShader(effect: Effect): void;
  18529. /**
  18530. * Returns a string to use to update the GPU particles update shader
  18531. * @returns a string containng the defines string
  18532. */
  18533. getEffectDefines(): string;
  18534. /**
  18535. * Returns the string "BoxParticleEmitter"
  18536. * @returns a string containing the class name
  18537. */
  18538. getClassName(): string;
  18539. /**
  18540. * Serializes the particle system to a JSON object.
  18541. * @returns the JSON object
  18542. */
  18543. serialize(): any;
  18544. /**
  18545. * Parse properties from a JSON object
  18546. * @param serializationObject defines the JSON object
  18547. */
  18548. parse(serializationObject: any): void;
  18549. }
  18550. }
  18551. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18552. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18553. import { Effect } from "babylonjs/Materials/effect";
  18554. import { Particle } from "babylonjs/Particles/particle";
  18555. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18556. /**
  18557. * Particle emitter emitting particles from the inside of a cone.
  18558. * It emits the particles alongside the cone volume from the base to the particle.
  18559. * The emission direction might be randomized.
  18560. */
  18561. export class ConeParticleEmitter implements IParticleEmitterType {
  18562. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18563. directionRandomizer: number;
  18564. private _radius;
  18565. private _angle;
  18566. private _height;
  18567. /**
  18568. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18569. */
  18570. radiusRange: number;
  18571. /**
  18572. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18573. */
  18574. heightRange: number;
  18575. /**
  18576. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18577. */
  18578. emitFromSpawnPointOnly: boolean;
  18579. /**
  18580. * Gets or sets the radius of the emission cone
  18581. */
  18582. get radius(): number;
  18583. set radius(value: number);
  18584. /**
  18585. * Gets or sets the angle of the emission cone
  18586. */
  18587. get angle(): number;
  18588. set angle(value: number);
  18589. private _buildHeight;
  18590. /**
  18591. * Creates a new instance ConeParticleEmitter
  18592. * @param radius the radius of the emission cone (1 by default)
  18593. * @param angle the cone base angle (PI by default)
  18594. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18595. */
  18596. constructor(radius?: number, angle?: number,
  18597. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18598. directionRandomizer?: number);
  18599. /**
  18600. * Called by the particle System when the direction is computed for the created particle.
  18601. * @param worldMatrix is the world matrix of the particle system
  18602. * @param directionToUpdate is the direction vector to update with the result
  18603. * @param particle is the particle we are computed the direction for
  18604. */
  18605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18606. /**
  18607. * Called by the particle System when the position is computed for the created particle.
  18608. * @param worldMatrix is the world matrix of the particle system
  18609. * @param positionToUpdate is the position vector to update with the result
  18610. * @param particle is the particle we are computed the position for
  18611. */
  18612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18613. /**
  18614. * Clones the current emitter and returns a copy of it
  18615. * @returns the new emitter
  18616. */
  18617. clone(): ConeParticleEmitter;
  18618. /**
  18619. * Called by the GPUParticleSystem to setup the update shader
  18620. * @param effect defines the update shader
  18621. */
  18622. applyToShader(effect: Effect): void;
  18623. /**
  18624. * Returns a string to use to update the GPU particles update shader
  18625. * @returns a string containng the defines string
  18626. */
  18627. getEffectDefines(): string;
  18628. /**
  18629. * Returns the string "ConeParticleEmitter"
  18630. * @returns a string containing the class name
  18631. */
  18632. getClassName(): string;
  18633. /**
  18634. * Serializes the particle system to a JSON object.
  18635. * @returns the JSON object
  18636. */
  18637. serialize(): any;
  18638. /**
  18639. * Parse properties from a JSON object
  18640. * @param serializationObject defines the JSON object
  18641. */
  18642. parse(serializationObject: any): void;
  18643. }
  18644. }
  18645. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18646. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18647. import { Effect } from "babylonjs/Materials/effect";
  18648. import { Particle } from "babylonjs/Particles/particle";
  18649. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18650. /**
  18651. * Particle emitter emitting particles from the inside of a cylinder.
  18652. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18653. */
  18654. export class CylinderParticleEmitter implements IParticleEmitterType {
  18655. /**
  18656. * The radius of the emission cylinder.
  18657. */
  18658. radius: number;
  18659. /**
  18660. * The height of the emission cylinder.
  18661. */
  18662. height: number;
  18663. /**
  18664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18665. */
  18666. radiusRange: number;
  18667. /**
  18668. * How much to randomize the particle direction [0-1].
  18669. */
  18670. directionRandomizer: number;
  18671. /**
  18672. * Creates a new instance CylinderParticleEmitter
  18673. * @param radius the radius of the emission cylinder (1 by default)
  18674. * @param height the height of the emission cylinder (1 by default)
  18675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18676. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18677. */
  18678. constructor(
  18679. /**
  18680. * The radius of the emission cylinder.
  18681. */
  18682. radius?: number,
  18683. /**
  18684. * The height of the emission cylinder.
  18685. */
  18686. height?: number,
  18687. /**
  18688. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18689. */
  18690. radiusRange?: number,
  18691. /**
  18692. * How much to randomize the particle direction [0-1].
  18693. */
  18694. directionRandomizer?: number);
  18695. /**
  18696. * Called by the particle System when the direction is computed for the created particle.
  18697. * @param worldMatrix is the world matrix of the particle system
  18698. * @param directionToUpdate is the direction vector to update with the result
  18699. * @param particle is the particle we are computed the direction for
  18700. */
  18701. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18702. /**
  18703. * Called by the particle System when the position is computed for the created particle.
  18704. * @param worldMatrix is the world matrix of the particle system
  18705. * @param positionToUpdate is the position vector to update with the result
  18706. * @param particle is the particle we are computed the position for
  18707. */
  18708. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18709. /**
  18710. * Clones the current emitter and returns a copy of it
  18711. * @returns the new emitter
  18712. */
  18713. clone(): CylinderParticleEmitter;
  18714. /**
  18715. * Called by the GPUParticleSystem to setup the update shader
  18716. * @param effect defines the update shader
  18717. */
  18718. applyToShader(effect: Effect): void;
  18719. /**
  18720. * Returns a string to use to update the GPU particles update shader
  18721. * @returns a string containng the defines string
  18722. */
  18723. getEffectDefines(): string;
  18724. /**
  18725. * Returns the string "CylinderParticleEmitter"
  18726. * @returns a string containing the class name
  18727. */
  18728. getClassName(): string;
  18729. /**
  18730. * Serializes the particle system to a JSON object.
  18731. * @returns the JSON object
  18732. */
  18733. serialize(): any;
  18734. /**
  18735. * Parse properties from a JSON object
  18736. * @param serializationObject defines the JSON object
  18737. */
  18738. parse(serializationObject: any): void;
  18739. }
  18740. /**
  18741. * Particle emitter emitting particles from the inside of a cylinder.
  18742. * It emits the particles randomly between two vectors.
  18743. */
  18744. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18745. /**
  18746. * The min limit of the emission direction.
  18747. */
  18748. direction1: Vector3;
  18749. /**
  18750. * The max limit of the emission direction.
  18751. */
  18752. direction2: Vector3;
  18753. /**
  18754. * Creates a new instance CylinderDirectedParticleEmitter
  18755. * @param radius the radius of the emission cylinder (1 by default)
  18756. * @param height the height of the emission cylinder (1 by default)
  18757. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18758. * @param direction1 the min limit of the emission direction (up vector by default)
  18759. * @param direction2 the max limit of the emission direction (up vector by default)
  18760. */
  18761. constructor(radius?: number, height?: number, radiusRange?: number,
  18762. /**
  18763. * The min limit of the emission direction.
  18764. */
  18765. direction1?: Vector3,
  18766. /**
  18767. * The max limit of the emission direction.
  18768. */
  18769. direction2?: Vector3);
  18770. /**
  18771. * Called by the particle System when the direction is computed for the created particle.
  18772. * @param worldMatrix is the world matrix of the particle system
  18773. * @param directionToUpdate is the direction vector to update with the result
  18774. * @param particle is the particle we are computed the direction for
  18775. */
  18776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18777. /**
  18778. * Clones the current emitter and returns a copy of it
  18779. * @returns the new emitter
  18780. */
  18781. clone(): CylinderDirectedParticleEmitter;
  18782. /**
  18783. * Called by the GPUParticleSystem to setup the update shader
  18784. * @param effect defines the update shader
  18785. */
  18786. applyToShader(effect: Effect): void;
  18787. /**
  18788. * Returns a string to use to update the GPU particles update shader
  18789. * @returns a string containng the defines string
  18790. */
  18791. getEffectDefines(): string;
  18792. /**
  18793. * Returns the string "CylinderDirectedParticleEmitter"
  18794. * @returns a string containing the class name
  18795. */
  18796. getClassName(): string;
  18797. /**
  18798. * Serializes the particle system to a JSON object.
  18799. * @returns the JSON object
  18800. */
  18801. serialize(): any;
  18802. /**
  18803. * Parse properties from a JSON object
  18804. * @param serializationObject defines the JSON object
  18805. */
  18806. parse(serializationObject: any): void;
  18807. }
  18808. }
  18809. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18811. import { Effect } from "babylonjs/Materials/effect";
  18812. import { Particle } from "babylonjs/Particles/particle";
  18813. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18814. /**
  18815. * Particle emitter emitting particles from the inside of a hemisphere.
  18816. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18817. */
  18818. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18819. /**
  18820. * The radius of the emission hemisphere.
  18821. */
  18822. radius: number;
  18823. /**
  18824. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18825. */
  18826. radiusRange: number;
  18827. /**
  18828. * How much to randomize the particle direction [0-1].
  18829. */
  18830. directionRandomizer: number;
  18831. /**
  18832. * Creates a new instance HemisphericParticleEmitter
  18833. * @param radius the radius of the emission hemisphere (1 by default)
  18834. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18835. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18836. */
  18837. constructor(
  18838. /**
  18839. * The radius of the emission hemisphere.
  18840. */
  18841. radius?: number,
  18842. /**
  18843. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18844. */
  18845. radiusRange?: number,
  18846. /**
  18847. * How much to randomize the particle direction [0-1].
  18848. */
  18849. directionRandomizer?: number);
  18850. /**
  18851. * Called by the particle System when the direction is computed for the created particle.
  18852. * @param worldMatrix is the world matrix of the particle system
  18853. * @param directionToUpdate is the direction vector to update with the result
  18854. * @param particle is the particle we are computed the direction for
  18855. */
  18856. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18857. /**
  18858. * Called by the particle System when the position is computed for the created particle.
  18859. * @param worldMatrix is the world matrix of the particle system
  18860. * @param positionToUpdate is the position vector to update with the result
  18861. * @param particle is the particle we are computed the position for
  18862. */
  18863. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18864. /**
  18865. * Clones the current emitter and returns a copy of it
  18866. * @returns the new emitter
  18867. */
  18868. clone(): HemisphericParticleEmitter;
  18869. /**
  18870. * Called by the GPUParticleSystem to setup the update shader
  18871. * @param effect defines the update shader
  18872. */
  18873. applyToShader(effect: Effect): void;
  18874. /**
  18875. * Returns a string to use to update the GPU particles update shader
  18876. * @returns a string containng the defines string
  18877. */
  18878. getEffectDefines(): string;
  18879. /**
  18880. * Returns the string "HemisphericParticleEmitter"
  18881. * @returns a string containing the class name
  18882. */
  18883. getClassName(): string;
  18884. /**
  18885. * Serializes the particle system to a JSON object.
  18886. * @returns the JSON object
  18887. */
  18888. serialize(): any;
  18889. /**
  18890. * Parse properties from a JSON object
  18891. * @param serializationObject defines the JSON object
  18892. */
  18893. parse(serializationObject: any): void;
  18894. }
  18895. }
  18896. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18897. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18898. import { Effect } from "babylonjs/Materials/effect";
  18899. import { Particle } from "babylonjs/Particles/particle";
  18900. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18901. /**
  18902. * Particle emitter emitting particles from a point.
  18903. * It emits the particles randomly between 2 given directions.
  18904. */
  18905. export class PointParticleEmitter implements IParticleEmitterType {
  18906. /**
  18907. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18908. */
  18909. direction1: Vector3;
  18910. /**
  18911. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18912. */
  18913. direction2: Vector3;
  18914. /**
  18915. * Creates a new instance PointParticleEmitter
  18916. */
  18917. constructor();
  18918. /**
  18919. * Called by the particle System when the direction is computed for the created particle.
  18920. * @param worldMatrix is the world matrix of the particle system
  18921. * @param directionToUpdate is the direction vector to update with the result
  18922. * @param particle is the particle we are computed the direction for
  18923. */
  18924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18925. /**
  18926. * Called by the particle System when the position is computed for the created particle.
  18927. * @param worldMatrix is the world matrix of the particle system
  18928. * @param positionToUpdate is the position vector to update with the result
  18929. * @param particle is the particle we are computed the position for
  18930. */
  18931. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18932. /**
  18933. * Clones the current emitter and returns a copy of it
  18934. * @returns the new emitter
  18935. */
  18936. clone(): PointParticleEmitter;
  18937. /**
  18938. * Called by the GPUParticleSystem to setup the update shader
  18939. * @param effect defines the update shader
  18940. */
  18941. applyToShader(effect: Effect): void;
  18942. /**
  18943. * Returns a string to use to update the GPU particles update shader
  18944. * @returns a string containng the defines string
  18945. */
  18946. getEffectDefines(): string;
  18947. /**
  18948. * Returns the string "PointParticleEmitter"
  18949. * @returns a string containing the class name
  18950. */
  18951. getClassName(): string;
  18952. /**
  18953. * Serializes the particle system to a JSON object.
  18954. * @returns the JSON object
  18955. */
  18956. serialize(): any;
  18957. /**
  18958. * Parse properties from a JSON object
  18959. * @param serializationObject defines the JSON object
  18960. */
  18961. parse(serializationObject: any): void;
  18962. }
  18963. }
  18964. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18965. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18966. import { Effect } from "babylonjs/Materials/effect";
  18967. import { Particle } from "babylonjs/Particles/particle";
  18968. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18969. /**
  18970. * Particle emitter emitting particles from the inside of a sphere.
  18971. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18972. */
  18973. export class SphereParticleEmitter implements IParticleEmitterType {
  18974. /**
  18975. * The radius of the emission sphere.
  18976. */
  18977. radius: number;
  18978. /**
  18979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18980. */
  18981. radiusRange: number;
  18982. /**
  18983. * How much to randomize the particle direction [0-1].
  18984. */
  18985. directionRandomizer: number;
  18986. /**
  18987. * Creates a new instance SphereParticleEmitter
  18988. * @param radius the radius of the emission sphere (1 by default)
  18989. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18990. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18991. */
  18992. constructor(
  18993. /**
  18994. * The radius of the emission sphere.
  18995. */
  18996. radius?: number,
  18997. /**
  18998. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18999. */
  19000. radiusRange?: number,
  19001. /**
  19002. * How much to randomize the particle direction [0-1].
  19003. */
  19004. directionRandomizer?: number);
  19005. /**
  19006. * Called by the particle System when the direction is computed for the created particle.
  19007. * @param worldMatrix is the world matrix of the particle system
  19008. * @param directionToUpdate is the direction vector to update with the result
  19009. * @param particle is the particle we are computed the direction for
  19010. */
  19011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19012. /**
  19013. * Called by the particle System when the position is computed for the created particle.
  19014. * @param worldMatrix is the world matrix of the particle system
  19015. * @param positionToUpdate is the position vector to update with the result
  19016. * @param particle is the particle we are computed the position for
  19017. */
  19018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19019. /**
  19020. * Clones the current emitter and returns a copy of it
  19021. * @returns the new emitter
  19022. */
  19023. clone(): SphereParticleEmitter;
  19024. /**
  19025. * Called by the GPUParticleSystem to setup the update shader
  19026. * @param effect defines the update shader
  19027. */
  19028. applyToShader(effect: Effect): void;
  19029. /**
  19030. * Returns a string to use to update the GPU particles update shader
  19031. * @returns a string containng the defines string
  19032. */
  19033. getEffectDefines(): string;
  19034. /**
  19035. * Returns the string "SphereParticleEmitter"
  19036. * @returns a string containing the class name
  19037. */
  19038. getClassName(): string;
  19039. /**
  19040. * Serializes the particle system to a JSON object.
  19041. * @returns the JSON object
  19042. */
  19043. serialize(): any;
  19044. /**
  19045. * Parse properties from a JSON object
  19046. * @param serializationObject defines the JSON object
  19047. */
  19048. parse(serializationObject: any): void;
  19049. }
  19050. /**
  19051. * Particle emitter emitting particles from the inside of a sphere.
  19052. * It emits the particles randomly between two vectors.
  19053. */
  19054. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19055. /**
  19056. * The min limit of the emission direction.
  19057. */
  19058. direction1: Vector3;
  19059. /**
  19060. * The max limit of the emission direction.
  19061. */
  19062. direction2: Vector3;
  19063. /**
  19064. * Creates a new instance SphereDirectedParticleEmitter
  19065. * @param radius the radius of the emission sphere (1 by default)
  19066. * @param direction1 the min limit of the emission direction (up vector by default)
  19067. * @param direction2 the max limit of the emission direction (up vector by default)
  19068. */
  19069. constructor(radius?: number,
  19070. /**
  19071. * The min limit of the emission direction.
  19072. */
  19073. direction1?: Vector3,
  19074. /**
  19075. * The max limit of the emission direction.
  19076. */
  19077. direction2?: Vector3);
  19078. /**
  19079. * Called by the particle System when the direction is computed for the created particle.
  19080. * @param worldMatrix is the world matrix of the particle system
  19081. * @param directionToUpdate is the direction vector to update with the result
  19082. * @param particle is the particle we are computed the direction for
  19083. */
  19084. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19085. /**
  19086. * Clones the current emitter and returns a copy of it
  19087. * @returns the new emitter
  19088. */
  19089. clone(): SphereDirectedParticleEmitter;
  19090. /**
  19091. * Called by the GPUParticleSystem to setup the update shader
  19092. * @param effect defines the update shader
  19093. */
  19094. applyToShader(effect: Effect): void;
  19095. /**
  19096. * Returns a string to use to update the GPU particles update shader
  19097. * @returns a string containng the defines string
  19098. */
  19099. getEffectDefines(): string;
  19100. /**
  19101. * Returns the string "SphereDirectedParticleEmitter"
  19102. * @returns a string containing the class name
  19103. */
  19104. getClassName(): string;
  19105. /**
  19106. * Serializes the particle system to a JSON object.
  19107. * @returns the JSON object
  19108. */
  19109. serialize(): any;
  19110. /**
  19111. * Parse properties from a JSON object
  19112. * @param serializationObject defines the JSON object
  19113. */
  19114. parse(serializationObject: any): void;
  19115. }
  19116. }
  19117. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  19118. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19119. import { Effect } from "babylonjs/Materials/effect";
  19120. import { Particle } from "babylonjs/Particles/particle";
  19121. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19122. import { Nullable } from "babylonjs/types";
  19123. /**
  19124. * Particle emitter emitting particles from a custom list of positions.
  19125. */
  19126. export class CustomParticleEmitter implements IParticleEmitterType {
  19127. /**
  19128. * Gets or sets the position generator that will create the inital position of each particle.
  19129. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19130. */
  19131. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  19132. /**
  19133. * Gets or sets the destination generator that will create the final destination of each particle.
  19134. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19135. */
  19136. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  19137. /**
  19138. * Creates a new instance CustomParticleEmitter
  19139. */
  19140. constructor();
  19141. /**
  19142. * Called by the particle System when the direction is computed for the created particle.
  19143. * @param worldMatrix is the world matrix of the particle system
  19144. * @param directionToUpdate is the direction vector to update with the result
  19145. * @param particle is the particle we are computed the direction for
  19146. */
  19147. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19148. /**
  19149. * Called by the particle System when the position is computed for the created particle.
  19150. * @param worldMatrix is the world matrix of the particle system
  19151. * @param positionToUpdate is the position vector to update with the result
  19152. * @param particle is the particle we are computed the position for
  19153. */
  19154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19155. /**
  19156. * Clones the current emitter and returns a copy of it
  19157. * @returns the new emitter
  19158. */
  19159. clone(): CustomParticleEmitter;
  19160. /**
  19161. * Called by the GPUParticleSystem to setup the update shader
  19162. * @param effect defines the update shader
  19163. */
  19164. applyToShader(effect: Effect): void;
  19165. /**
  19166. * Returns a string to use to update the GPU particles update shader
  19167. * @returns a string containng the defines string
  19168. */
  19169. getEffectDefines(): string;
  19170. /**
  19171. * Returns the string "PointParticleEmitter"
  19172. * @returns a string containing the class name
  19173. */
  19174. getClassName(): string;
  19175. /**
  19176. * Serializes the particle system to a JSON object.
  19177. * @returns the JSON object
  19178. */
  19179. serialize(): any;
  19180. /**
  19181. * Parse properties from a JSON object
  19182. * @param serializationObject defines the JSON object
  19183. */
  19184. parse(serializationObject: any): void;
  19185. }
  19186. }
  19187. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  19188. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19189. import { Effect } from "babylonjs/Materials/effect";
  19190. import { Particle } from "babylonjs/Particles/particle";
  19191. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19192. import { Scene } from "babylonjs/scene";
  19193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19194. /**
  19195. * Particle emitter emitting particles from the inside of a box.
  19196. * It emits the particles randomly between 2 given directions.
  19197. */
  19198. export class MeshParticleEmitter implements IParticleEmitterType {
  19199. /** Defines the mesh to use as source */
  19200. mesh?: AbstractMesh | undefined;
  19201. private _indices;
  19202. private _positions;
  19203. private _normals;
  19204. private _storedNormal;
  19205. /**
  19206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19207. */
  19208. direction1: Vector3;
  19209. /**
  19210. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19211. */
  19212. direction2: Vector3;
  19213. /**
  19214. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  19215. */
  19216. useMeshNormalsForDirection: boolean;
  19217. /**
  19218. * Creates a new instance MeshParticleEmitter
  19219. * @param mesh defines the mesh to use as source
  19220. */
  19221. constructor(
  19222. /** Defines the mesh to use as source */
  19223. mesh?: AbstractMesh | undefined);
  19224. /**
  19225. * Called by the particle System when the direction is computed for the created particle.
  19226. * @param worldMatrix is the world matrix of the particle system
  19227. * @param directionToUpdate is the direction vector to update with the result
  19228. * @param particle is the particle we are computed the direction for
  19229. */
  19230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19231. /**
  19232. * Called by the particle System when the position is computed for the created particle.
  19233. * @param worldMatrix is the world matrix of the particle system
  19234. * @param positionToUpdate is the position vector to update with the result
  19235. * @param particle is the particle we are computed the position for
  19236. */
  19237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19238. /**
  19239. * Clones the current emitter and returns a copy of it
  19240. * @returns the new emitter
  19241. */
  19242. clone(): MeshParticleEmitter;
  19243. /**
  19244. * Called by the GPUParticleSystem to setup the update shader
  19245. * @param effect defines the update shader
  19246. */
  19247. applyToShader(effect: Effect): void;
  19248. /**
  19249. * Returns a string to use to update the GPU particles update shader
  19250. * @returns a string containng the defines string
  19251. */
  19252. getEffectDefines(): string;
  19253. /**
  19254. * Returns the string "BoxParticleEmitter"
  19255. * @returns a string containing the class name
  19256. */
  19257. getClassName(): string;
  19258. /**
  19259. * Serializes the particle system to a JSON object.
  19260. * @returns the JSON object
  19261. */
  19262. serialize(): any;
  19263. /**
  19264. * Parse properties from a JSON object
  19265. * @param serializationObject defines the JSON object
  19266. * @param scene defines the hosting scene
  19267. */
  19268. parse(serializationObject: any, scene: Scene): void;
  19269. }
  19270. }
  19271. declare module "babylonjs/Particles/EmitterTypes/index" {
  19272. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19273. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19274. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19275. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19276. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19277. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19278. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19279. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  19280. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  19281. }
  19282. declare module "babylonjs/Particles/IParticleSystem" {
  19283. import { Nullable } from "babylonjs/types";
  19284. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19285. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19288. import { Texture } from "babylonjs/Materials/Textures/texture";
  19289. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19290. import { Scene } from "babylonjs/scene";
  19291. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19292. import { Animation } from "babylonjs/Animations/animation";
  19293. /**
  19294. * Interface representing a particle system in Babylon.js.
  19295. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19296. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19297. */
  19298. export interface IParticleSystem {
  19299. /**
  19300. * List of animations used by the particle system.
  19301. */
  19302. animations: Animation[];
  19303. /**
  19304. * The id of the Particle system.
  19305. */
  19306. id: string;
  19307. /**
  19308. * The name of the Particle system.
  19309. */
  19310. name: string;
  19311. /**
  19312. * The emitter represents the Mesh or position we are attaching the particle system to.
  19313. */
  19314. emitter: Nullable<AbstractMesh | Vector3>;
  19315. /**
  19316. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19317. */
  19318. isBillboardBased: boolean;
  19319. /**
  19320. * The rendering group used by the Particle system to chose when to render.
  19321. */
  19322. renderingGroupId: number;
  19323. /**
  19324. * The layer mask we are rendering the particles through.
  19325. */
  19326. layerMask: number;
  19327. /**
  19328. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19329. */
  19330. updateSpeed: number;
  19331. /**
  19332. * The amount of time the particle system is running (depends of the overall update speed).
  19333. */
  19334. targetStopDuration: number;
  19335. /**
  19336. * The texture used to render each particle. (this can be a spritesheet)
  19337. */
  19338. particleTexture: Nullable<Texture>;
  19339. /**
  19340. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19341. */
  19342. blendMode: number;
  19343. /**
  19344. * Minimum life time of emitting particles.
  19345. */
  19346. minLifeTime: number;
  19347. /**
  19348. * Maximum life time of emitting particles.
  19349. */
  19350. maxLifeTime: number;
  19351. /**
  19352. * Minimum Size of emitting particles.
  19353. */
  19354. minSize: number;
  19355. /**
  19356. * Maximum Size of emitting particles.
  19357. */
  19358. maxSize: number;
  19359. /**
  19360. * Minimum scale of emitting particles on X axis.
  19361. */
  19362. minScaleX: number;
  19363. /**
  19364. * Maximum scale of emitting particles on X axis.
  19365. */
  19366. maxScaleX: number;
  19367. /**
  19368. * Minimum scale of emitting particles on Y axis.
  19369. */
  19370. minScaleY: number;
  19371. /**
  19372. * Maximum scale of emitting particles on Y axis.
  19373. */
  19374. maxScaleY: number;
  19375. /**
  19376. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19377. */
  19378. color1: Color4;
  19379. /**
  19380. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19381. */
  19382. color2: Color4;
  19383. /**
  19384. * Color the particle will have at the end of its lifetime.
  19385. */
  19386. colorDead: Color4;
  19387. /**
  19388. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19389. */
  19390. emitRate: number;
  19391. /**
  19392. * You can use gravity if you want to give an orientation to your particles.
  19393. */
  19394. gravity: Vector3;
  19395. /**
  19396. * Minimum power of emitting particles.
  19397. */
  19398. minEmitPower: number;
  19399. /**
  19400. * Maximum power of emitting particles.
  19401. */
  19402. maxEmitPower: number;
  19403. /**
  19404. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19405. */
  19406. minAngularSpeed: number;
  19407. /**
  19408. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19409. */
  19410. maxAngularSpeed: number;
  19411. /**
  19412. * Gets or sets the minimal initial rotation in radians.
  19413. */
  19414. minInitialRotation: number;
  19415. /**
  19416. * Gets or sets the maximal initial rotation in radians.
  19417. */
  19418. maxInitialRotation: number;
  19419. /**
  19420. * The particle emitter type defines the emitter used by the particle system.
  19421. * It can be for example box, sphere, or cone...
  19422. */
  19423. particleEmitterType: Nullable<IParticleEmitterType>;
  19424. /**
  19425. * Defines the delay in milliseconds before starting the system (0 by default)
  19426. */
  19427. startDelay: number;
  19428. /**
  19429. * 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
  19430. */
  19431. preWarmCycles: number;
  19432. /**
  19433. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19434. */
  19435. preWarmStepOffset: number;
  19436. /**
  19437. * 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)
  19438. */
  19439. spriteCellChangeSpeed: number;
  19440. /**
  19441. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19442. */
  19443. startSpriteCellID: number;
  19444. /**
  19445. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19446. */
  19447. endSpriteCellID: number;
  19448. /**
  19449. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19450. */
  19451. spriteCellWidth: number;
  19452. /**
  19453. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19454. */
  19455. spriteCellHeight: number;
  19456. /**
  19457. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19458. */
  19459. spriteRandomStartCell: boolean;
  19460. /**
  19461. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19462. */
  19463. isAnimationSheetEnabled: boolean;
  19464. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19465. translationPivot: Vector2;
  19466. /**
  19467. * Gets or sets a texture used to add random noise to particle positions
  19468. */
  19469. noiseTexture: Nullable<BaseTexture>;
  19470. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19471. noiseStrength: Vector3;
  19472. /**
  19473. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19474. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19475. */
  19476. billboardMode: number;
  19477. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19478. limitVelocityDamping: number;
  19479. /**
  19480. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19481. */
  19482. beginAnimationOnStart: boolean;
  19483. /**
  19484. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19485. */
  19486. beginAnimationFrom: number;
  19487. /**
  19488. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19489. */
  19490. beginAnimationTo: number;
  19491. /**
  19492. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19493. */
  19494. beginAnimationLoop: boolean;
  19495. /**
  19496. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19497. */
  19498. disposeOnStop: boolean;
  19499. /**
  19500. * Gets the maximum number of particles active at the same time.
  19501. * @returns The max number of active particles.
  19502. */
  19503. getCapacity(): number;
  19504. /**
  19505. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19506. * @returns True if it has been started, otherwise false.
  19507. */
  19508. isStarted(): boolean;
  19509. /**
  19510. * Animates the particle system for this frame.
  19511. */
  19512. animate(): void;
  19513. /**
  19514. * Renders the particle system in its current state.
  19515. * @returns the current number of particles
  19516. */
  19517. render(): number;
  19518. /**
  19519. * Dispose the particle system and frees its associated resources.
  19520. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19521. */
  19522. dispose(disposeTexture?: boolean): void;
  19523. /**
  19524. * Clones the particle system.
  19525. * @param name The name of the cloned object
  19526. * @param newEmitter The new emitter to use
  19527. * @returns the cloned particle system
  19528. */
  19529. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19530. /**
  19531. * Serializes the particle system to a JSON object.
  19532. * @returns the JSON object
  19533. */
  19534. serialize(): any;
  19535. /**
  19536. * Rebuild the particle system
  19537. */
  19538. rebuild(): void;
  19539. /**
  19540. * Starts the particle system and begins to emit
  19541. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19542. */
  19543. start(delay?: number): void;
  19544. /**
  19545. * Stops the particle system.
  19546. */
  19547. stop(): void;
  19548. /**
  19549. * Remove all active particles
  19550. */
  19551. reset(): void;
  19552. /**
  19553. * Is this system ready to be used/rendered
  19554. * @return true if the system is ready
  19555. */
  19556. isReady(): boolean;
  19557. /**
  19558. * Adds a new color gradient
  19559. * @param gradient defines the gradient to use (between 0 and 1)
  19560. * @param color1 defines the color to affect to the specified gradient
  19561. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19562. * @returns the current particle system
  19563. */
  19564. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19565. /**
  19566. * Remove a specific color gradient
  19567. * @param gradient defines the gradient to remove
  19568. * @returns the current particle system
  19569. */
  19570. removeColorGradient(gradient: number): IParticleSystem;
  19571. /**
  19572. * Adds a new size gradient
  19573. * @param gradient defines the gradient to use (between 0 and 1)
  19574. * @param factor defines the size factor to affect to the specified gradient
  19575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19576. * @returns the current particle system
  19577. */
  19578. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19579. /**
  19580. * Remove a specific size gradient
  19581. * @param gradient defines the gradient to remove
  19582. * @returns the current particle system
  19583. */
  19584. removeSizeGradient(gradient: number): IParticleSystem;
  19585. /**
  19586. * Gets the current list of color gradients.
  19587. * You must use addColorGradient and removeColorGradient to udpate this list
  19588. * @returns the list of color gradients
  19589. */
  19590. getColorGradients(): Nullable<Array<ColorGradient>>;
  19591. /**
  19592. * Gets the current list of size gradients.
  19593. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19594. * @returns the list of size gradients
  19595. */
  19596. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19597. /**
  19598. * Gets the current list of angular speed gradients.
  19599. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19600. * @returns the list of angular speed gradients
  19601. */
  19602. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19603. /**
  19604. * Adds a new angular speed gradient
  19605. * @param gradient defines the gradient to use (between 0 and 1)
  19606. * @param factor defines the angular speed to affect to the specified gradient
  19607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19608. * @returns the current particle system
  19609. */
  19610. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19611. /**
  19612. * Remove a specific angular speed gradient
  19613. * @param gradient defines the gradient to remove
  19614. * @returns the current particle system
  19615. */
  19616. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19617. /**
  19618. * Gets the current list of velocity gradients.
  19619. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19620. * @returns the list of velocity gradients
  19621. */
  19622. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19623. /**
  19624. * Adds a new velocity gradient
  19625. * @param gradient defines the gradient to use (between 0 and 1)
  19626. * @param factor defines the velocity to affect to the specified gradient
  19627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19628. * @returns the current particle system
  19629. */
  19630. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19631. /**
  19632. * Remove a specific velocity gradient
  19633. * @param gradient defines the gradient to remove
  19634. * @returns the current particle system
  19635. */
  19636. removeVelocityGradient(gradient: number): IParticleSystem;
  19637. /**
  19638. * Gets the current list of limit velocity gradients.
  19639. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19640. * @returns the list of limit velocity gradients
  19641. */
  19642. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19643. /**
  19644. * Adds a new limit velocity gradient
  19645. * @param gradient defines the gradient to use (between 0 and 1)
  19646. * @param factor defines the limit velocity to affect to the specified gradient
  19647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19648. * @returns the current particle system
  19649. */
  19650. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19651. /**
  19652. * Remove a specific limit velocity gradient
  19653. * @param gradient defines the gradient to remove
  19654. * @returns the current particle system
  19655. */
  19656. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19657. /**
  19658. * Adds a new drag gradient
  19659. * @param gradient defines the gradient to use (between 0 and 1)
  19660. * @param factor defines the drag to affect to the specified gradient
  19661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19662. * @returns the current particle system
  19663. */
  19664. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19665. /**
  19666. * Remove a specific drag gradient
  19667. * @param gradient defines the gradient to remove
  19668. * @returns the current particle system
  19669. */
  19670. removeDragGradient(gradient: number): IParticleSystem;
  19671. /**
  19672. * Gets the current list of drag gradients.
  19673. * You must use addDragGradient and removeDragGradient to udpate this list
  19674. * @returns the list of drag gradients
  19675. */
  19676. getDragGradients(): Nullable<Array<FactorGradient>>;
  19677. /**
  19678. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19679. * @param gradient defines the gradient to use (between 0 and 1)
  19680. * @param factor defines the emit rate to affect to the specified gradient
  19681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19682. * @returns the current particle system
  19683. */
  19684. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19685. /**
  19686. * Remove a specific emit rate gradient
  19687. * @param gradient defines the gradient to remove
  19688. * @returns the current particle system
  19689. */
  19690. removeEmitRateGradient(gradient: number): IParticleSystem;
  19691. /**
  19692. * Gets the current list of emit rate gradients.
  19693. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19694. * @returns the list of emit rate gradients
  19695. */
  19696. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19697. /**
  19698. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19699. * @param gradient defines the gradient to use (between 0 and 1)
  19700. * @param factor defines the start size to affect to the specified gradient
  19701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19702. * @returns the current particle system
  19703. */
  19704. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19705. /**
  19706. * Remove a specific start size gradient
  19707. * @param gradient defines the gradient to remove
  19708. * @returns the current particle system
  19709. */
  19710. removeStartSizeGradient(gradient: number): IParticleSystem;
  19711. /**
  19712. * Gets the current list of start size gradients.
  19713. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19714. * @returns the list of start size gradients
  19715. */
  19716. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19717. /**
  19718. * Adds a new life time gradient
  19719. * @param gradient defines the gradient to use (between 0 and 1)
  19720. * @param factor defines the life time factor to affect to the specified gradient
  19721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19722. * @returns the current particle system
  19723. */
  19724. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19725. /**
  19726. * Remove a specific life time gradient
  19727. * @param gradient defines the gradient to remove
  19728. * @returns the current particle system
  19729. */
  19730. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19731. /**
  19732. * Gets the current list of life time gradients.
  19733. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19734. * @returns the list of life time gradients
  19735. */
  19736. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19737. /**
  19738. * Gets the current list of color gradients.
  19739. * You must use addColorGradient and removeColorGradient to udpate this list
  19740. * @returns the list of color gradients
  19741. */
  19742. getColorGradients(): Nullable<Array<ColorGradient>>;
  19743. /**
  19744. * Adds a new ramp gradient used to remap particle colors
  19745. * @param gradient defines the gradient to use (between 0 and 1)
  19746. * @param color defines the color to affect to the specified gradient
  19747. * @returns the current particle system
  19748. */
  19749. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19750. /**
  19751. * Gets the current list of ramp gradients.
  19752. * You must use addRampGradient and removeRampGradient to udpate this list
  19753. * @returns the list of ramp gradients
  19754. */
  19755. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19756. /** Gets or sets a boolean indicating that ramp gradients must be used
  19757. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19758. */
  19759. useRampGradients: boolean;
  19760. /**
  19761. * Adds a new color remap gradient
  19762. * @param gradient defines the gradient to use (between 0 and 1)
  19763. * @param min defines the color remap minimal range
  19764. * @param max defines the color remap maximal range
  19765. * @returns the current particle system
  19766. */
  19767. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19768. /**
  19769. * Gets the current list of color remap gradients.
  19770. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19771. * @returns the list of color remap gradients
  19772. */
  19773. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19774. /**
  19775. * Adds a new alpha remap gradient
  19776. * @param gradient defines the gradient to use (between 0 and 1)
  19777. * @param min defines the alpha remap minimal range
  19778. * @param max defines the alpha remap maximal range
  19779. * @returns the current particle system
  19780. */
  19781. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19782. /**
  19783. * Gets the current list of alpha remap gradients.
  19784. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19785. * @returns the list of alpha remap gradients
  19786. */
  19787. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19788. /**
  19789. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19792. * @returns the emitter
  19793. */
  19794. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19795. /**
  19796. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19797. * @param radius The radius of the hemisphere to emit from
  19798. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19799. * @returns the emitter
  19800. */
  19801. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19802. /**
  19803. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19804. * @param radius The radius of the sphere to emit from
  19805. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19806. * @returns the emitter
  19807. */
  19808. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19809. /**
  19810. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19811. * @param radius The radius of the sphere to emit from
  19812. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19813. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19814. * @returns the emitter
  19815. */
  19816. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19817. /**
  19818. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19819. * @param radius The radius of the emission cylinder
  19820. * @param height The height of the emission cylinder
  19821. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19822. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19823. * @returns the emitter
  19824. */
  19825. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19826. /**
  19827. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19828. * @param radius The radius of the cylinder to emit from
  19829. * @param height The height of the emission cylinder
  19830. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19831. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19832. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19833. * @returns the emitter
  19834. */
  19835. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19836. /**
  19837. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19838. * @param radius The radius of the cone to emit from
  19839. * @param angle The base angle of the cone
  19840. * @returns the emitter
  19841. */
  19842. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19843. /**
  19844. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19845. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19846. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19847. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19848. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19849. * @returns the emitter
  19850. */
  19851. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19852. /**
  19853. * Get hosting scene
  19854. * @returns the scene
  19855. */
  19856. getScene(): Scene;
  19857. }
  19858. }
  19859. declare module "babylonjs/Meshes/instancedMesh" {
  19860. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19861. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19862. import { Camera } from "babylonjs/Cameras/camera";
  19863. import { Node } from "babylonjs/node";
  19864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19865. import { Mesh } from "babylonjs/Meshes/mesh";
  19866. import { Material } from "babylonjs/Materials/material";
  19867. import { Skeleton } from "babylonjs/Bones/skeleton";
  19868. import { Light } from "babylonjs/Lights/light";
  19869. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19870. /**
  19871. * Creates an instance based on a source mesh.
  19872. */
  19873. export class InstancedMesh extends AbstractMesh {
  19874. private _sourceMesh;
  19875. private _currentLOD;
  19876. /** @hidden */
  19877. _indexInSourceMeshInstanceArray: number;
  19878. constructor(name: string, source: Mesh);
  19879. /**
  19880. * Returns the string "InstancedMesh".
  19881. */
  19882. getClassName(): string;
  19883. /** Gets the list of lights affecting that mesh */
  19884. get lightSources(): Light[];
  19885. _resyncLightSources(): void;
  19886. _resyncLightSource(light: Light): void;
  19887. _removeLightSource(light: Light, dispose: boolean): void;
  19888. /**
  19889. * If the source mesh receives shadows
  19890. */
  19891. get receiveShadows(): boolean;
  19892. /**
  19893. * The material of the source mesh
  19894. */
  19895. get material(): Nullable<Material>;
  19896. /**
  19897. * Visibility of the source mesh
  19898. */
  19899. get visibility(): number;
  19900. /**
  19901. * Skeleton of the source mesh
  19902. */
  19903. get skeleton(): Nullable<Skeleton>;
  19904. /**
  19905. * Rendering ground id of the source mesh
  19906. */
  19907. get renderingGroupId(): number;
  19908. set renderingGroupId(value: number);
  19909. /**
  19910. * Returns the total number of vertices (integer).
  19911. */
  19912. getTotalVertices(): number;
  19913. /**
  19914. * Returns a positive integer : the total number of indices in this mesh geometry.
  19915. * @returns the numner of indices or zero if the mesh has no geometry.
  19916. */
  19917. getTotalIndices(): number;
  19918. /**
  19919. * The source mesh of the instance
  19920. */
  19921. get sourceMesh(): Mesh;
  19922. /**
  19923. * Is this node ready to be used/rendered
  19924. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19925. * @return {boolean} is it ready
  19926. */
  19927. isReady(completeCheck?: boolean): boolean;
  19928. /**
  19929. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19930. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19931. * @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.
  19932. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19933. */
  19934. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19935. /**
  19936. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19937. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19938. * The `data` are either a numeric array either a Float32Array.
  19939. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19940. * 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).
  19941. * Note that a new underlying VertexBuffer object is created each call.
  19942. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19943. *
  19944. * Possible `kind` values :
  19945. * - VertexBuffer.PositionKind
  19946. * - VertexBuffer.UVKind
  19947. * - VertexBuffer.UV2Kind
  19948. * - VertexBuffer.UV3Kind
  19949. * - VertexBuffer.UV4Kind
  19950. * - VertexBuffer.UV5Kind
  19951. * - VertexBuffer.UV6Kind
  19952. * - VertexBuffer.ColorKind
  19953. * - VertexBuffer.MatricesIndicesKind
  19954. * - VertexBuffer.MatricesIndicesExtraKind
  19955. * - VertexBuffer.MatricesWeightsKind
  19956. * - VertexBuffer.MatricesWeightsExtraKind
  19957. *
  19958. * Returns the Mesh.
  19959. */
  19960. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19961. /**
  19962. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19963. * If the mesh has no geometry, it is simply returned as it is.
  19964. * The `data` are either a numeric array either a Float32Array.
  19965. * No new underlying VertexBuffer object is created.
  19966. * 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.
  19967. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19968. *
  19969. * Possible `kind` values :
  19970. * - VertexBuffer.PositionKind
  19971. * - VertexBuffer.UVKind
  19972. * - VertexBuffer.UV2Kind
  19973. * - VertexBuffer.UV3Kind
  19974. * - VertexBuffer.UV4Kind
  19975. * - VertexBuffer.UV5Kind
  19976. * - VertexBuffer.UV6Kind
  19977. * - VertexBuffer.ColorKind
  19978. * - VertexBuffer.MatricesIndicesKind
  19979. * - VertexBuffer.MatricesIndicesExtraKind
  19980. * - VertexBuffer.MatricesWeightsKind
  19981. * - VertexBuffer.MatricesWeightsExtraKind
  19982. *
  19983. * Returns the Mesh.
  19984. */
  19985. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19986. /**
  19987. * Sets the mesh indices.
  19988. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19989. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19990. * This method creates a new index buffer each call.
  19991. * Returns the Mesh.
  19992. */
  19993. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19994. /**
  19995. * Boolean : True if the mesh owns the requested kind of data.
  19996. */
  19997. isVerticesDataPresent(kind: string): boolean;
  19998. /**
  19999. * Returns an array of indices (IndicesArray).
  20000. */
  20001. getIndices(): Nullable<IndicesArray>;
  20002. get _positions(): Nullable<Vector3[]>;
  20003. /**
  20004. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20005. * This means the mesh underlying bounding box and sphere are recomputed.
  20006. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20007. * @returns the current mesh
  20008. */
  20009. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  20010. /** @hidden */
  20011. _preActivate(): InstancedMesh;
  20012. /** @hidden */
  20013. _activate(renderId: number, intermediateRendering: boolean): boolean;
  20014. /** @hidden */
  20015. _postActivate(): void;
  20016. getWorldMatrix(): Matrix;
  20017. get isAnInstance(): boolean;
  20018. /**
  20019. * Returns the current associated LOD AbstractMesh.
  20020. */
  20021. getLOD(camera: Camera): AbstractMesh;
  20022. /** @hidden */
  20023. _syncSubMeshes(): InstancedMesh;
  20024. /** @hidden */
  20025. _generatePointsArray(): boolean;
  20026. /**
  20027. * Creates a new InstancedMesh from the current mesh.
  20028. * - name (string) : the cloned mesh name
  20029. * - newParent (optional Node) : the optional Node to parent the clone to.
  20030. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20031. *
  20032. * Returns the clone.
  20033. */
  20034. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  20035. /**
  20036. * Disposes the InstancedMesh.
  20037. * Returns nothing.
  20038. */
  20039. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20040. }
  20041. module "babylonjs/Meshes/mesh" {
  20042. interface Mesh {
  20043. /**
  20044. * Register a custom buffer that will be instanced
  20045. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  20046. * @param kind defines the buffer kind
  20047. * @param stride defines the stride in floats
  20048. */
  20049. registerInstancedBuffer(kind: string, stride: number): void;
  20050. /** @hidden */
  20051. _userInstancedBuffersStorage: {
  20052. data: {
  20053. [key: string]: Float32Array;
  20054. };
  20055. sizes: {
  20056. [key: string]: number;
  20057. };
  20058. vertexBuffers: {
  20059. [key: string]: Nullable<VertexBuffer>;
  20060. };
  20061. strides: {
  20062. [key: string]: number;
  20063. };
  20064. };
  20065. }
  20066. }
  20067. module "babylonjs/Meshes/abstractMesh" {
  20068. interface AbstractMesh {
  20069. /**
  20070. * Object used to store instanced buffers defined by user
  20071. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  20072. */
  20073. instancedBuffers: {
  20074. [key: string]: any;
  20075. };
  20076. }
  20077. }
  20078. }
  20079. declare module "babylonjs/Materials/shaderMaterial" {
  20080. import { Scene } from "babylonjs/scene";
  20081. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  20082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20083. import { Mesh } from "babylonjs/Meshes/mesh";
  20084. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  20085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20086. import { Texture } from "babylonjs/Materials/Textures/texture";
  20087. import { Material } from "babylonjs/Materials/material";
  20088. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  20089. /**
  20090. * Defines the options associated with the creation of a shader material.
  20091. */
  20092. export interface IShaderMaterialOptions {
  20093. /**
  20094. * Does the material work in alpha blend mode
  20095. */
  20096. needAlphaBlending: boolean;
  20097. /**
  20098. * Does the material work in alpha test mode
  20099. */
  20100. needAlphaTesting: boolean;
  20101. /**
  20102. * The list of attribute names used in the shader
  20103. */
  20104. attributes: string[];
  20105. /**
  20106. * The list of unifrom names used in the shader
  20107. */
  20108. uniforms: string[];
  20109. /**
  20110. * The list of UBO names used in the shader
  20111. */
  20112. uniformBuffers: string[];
  20113. /**
  20114. * The list of sampler names used in the shader
  20115. */
  20116. samplers: string[];
  20117. /**
  20118. * The list of defines used in the shader
  20119. */
  20120. defines: string[];
  20121. }
  20122. /**
  20123. * 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.
  20124. *
  20125. * This returned material effects how the mesh will look based on the code in the shaders.
  20126. *
  20127. * @see http://doc.babylonjs.com/how_to/shader_material
  20128. */
  20129. export class ShaderMaterial extends Material {
  20130. private _shaderPath;
  20131. private _options;
  20132. private _textures;
  20133. private _textureArrays;
  20134. private _floats;
  20135. private _ints;
  20136. private _floatsArrays;
  20137. private _colors3;
  20138. private _colors3Arrays;
  20139. private _colors4;
  20140. private _colors4Arrays;
  20141. private _vectors2;
  20142. private _vectors3;
  20143. private _vectors4;
  20144. private _matrices;
  20145. private _matrixArrays;
  20146. private _matrices3x3;
  20147. private _matrices2x2;
  20148. private _vectors2Arrays;
  20149. private _vectors3Arrays;
  20150. private _vectors4Arrays;
  20151. private _cachedWorldViewMatrix;
  20152. private _cachedWorldViewProjectionMatrix;
  20153. private _renderId;
  20154. private _multiview;
  20155. /**
  20156. * Instantiate a new shader material.
  20157. * 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.
  20158. * This returned material effects how the mesh will look based on the code in the shaders.
  20159. * @see http://doc.babylonjs.com/how_to/shader_material
  20160. * @param name Define the name of the material in the scene
  20161. * @param scene Define the scene the material belongs to
  20162. * @param shaderPath Defines the route to the shader code in one of three ways:
  20163. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  20164. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  20165. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  20166. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  20167. * @param options Define the options used to create the shader
  20168. */
  20169. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  20170. /**
  20171. * Gets the shader path used to define the shader code
  20172. * It can be modified to trigger a new compilation
  20173. */
  20174. get shaderPath(): any;
  20175. /**
  20176. * Sets the shader path used to define the shader code
  20177. * It can be modified to trigger a new compilation
  20178. */
  20179. set shaderPath(shaderPath: any);
  20180. /**
  20181. * Gets the options used to compile the shader.
  20182. * They can be modified to trigger a new compilation
  20183. */
  20184. get options(): IShaderMaterialOptions;
  20185. /**
  20186. * Gets the current class name of the material e.g. "ShaderMaterial"
  20187. * Mainly use in serialization.
  20188. * @returns the class name
  20189. */
  20190. getClassName(): string;
  20191. /**
  20192. * Specifies if the material will require alpha blending
  20193. * @returns a boolean specifying if alpha blending is needed
  20194. */
  20195. needAlphaBlending(): boolean;
  20196. /**
  20197. * Specifies if this material should be rendered in alpha test mode
  20198. * @returns a boolean specifying if an alpha test is needed.
  20199. */
  20200. needAlphaTesting(): boolean;
  20201. private _checkUniform;
  20202. /**
  20203. * Set a texture in the shader.
  20204. * @param name Define the name of the uniform samplers as defined in the shader
  20205. * @param texture Define the texture to bind to this sampler
  20206. * @return the material itself allowing "fluent" like uniform updates
  20207. */
  20208. setTexture(name: string, texture: Texture): ShaderMaterial;
  20209. /**
  20210. * Set a texture array in the shader.
  20211. * @param name Define the name of the uniform sampler array as defined in the shader
  20212. * @param textures Define the list of textures to bind to this sampler
  20213. * @return the material itself allowing "fluent" like uniform updates
  20214. */
  20215. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20216. /**
  20217. * Set a float in the shader.
  20218. * @param name Define the name of the uniform as defined in the shader
  20219. * @param value Define the value to give to the uniform
  20220. * @return the material itself allowing "fluent" like uniform updates
  20221. */
  20222. setFloat(name: string, value: number): ShaderMaterial;
  20223. /**
  20224. * Set a int in the shader.
  20225. * @param name Define the name of the uniform as defined in the shader
  20226. * @param value Define the value to give to the uniform
  20227. * @return the material itself allowing "fluent" like uniform updates
  20228. */
  20229. setInt(name: string, value: number): ShaderMaterial;
  20230. /**
  20231. * Set an array of floats in the shader.
  20232. * @param name Define the name of the uniform as defined in the shader
  20233. * @param value Define the value to give to the uniform
  20234. * @return the material itself allowing "fluent" like uniform updates
  20235. */
  20236. setFloats(name: string, value: number[]): ShaderMaterial;
  20237. /**
  20238. * Set a vec3 in the shader from a Color3.
  20239. * @param name Define the name of the uniform as defined in the shader
  20240. * @param value Define the value to give to the uniform
  20241. * @return the material itself allowing "fluent" like uniform updates
  20242. */
  20243. setColor3(name: string, value: Color3): ShaderMaterial;
  20244. /**
  20245. * Set a vec3 array in the shader from a Color3 array.
  20246. * @param name Define the name of the uniform as defined in the shader
  20247. * @param value Define the value to give to the uniform
  20248. * @return the material itself allowing "fluent" like uniform updates
  20249. */
  20250. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20251. /**
  20252. * Set a vec4 in the shader from a Color4.
  20253. * @param name Define the name of the uniform as defined in the shader
  20254. * @param value Define the value to give to the uniform
  20255. * @return the material itself allowing "fluent" like uniform updates
  20256. */
  20257. setColor4(name: string, value: Color4): ShaderMaterial;
  20258. /**
  20259. * Set a vec4 array in the shader from a Color4 array.
  20260. * @param name Define the name of the uniform as defined in the shader
  20261. * @param value Define the value to give to the uniform
  20262. * @return the material itself allowing "fluent" like uniform updates
  20263. */
  20264. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20265. /**
  20266. * Set a vec2 in the shader from a Vector2.
  20267. * @param name Define the name of the uniform as defined in the shader
  20268. * @param value Define the value to give to the uniform
  20269. * @return the material itself allowing "fluent" like uniform updates
  20270. */
  20271. setVector2(name: string, value: Vector2): ShaderMaterial;
  20272. /**
  20273. * Set a vec3 in the shader from a Vector3.
  20274. * @param name Define the name of the uniform as defined in the shader
  20275. * @param value Define the value to give to the uniform
  20276. * @return the material itself allowing "fluent" like uniform updates
  20277. */
  20278. setVector3(name: string, value: Vector3): ShaderMaterial;
  20279. /**
  20280. * Set a vec4 in the shader from a Vector4.
  20281. * @param name Define the name of the uniform as defined in the shader
  20282. * @param value Define the value to give to the uniform
  20283. * @return the material itself allowing "fluent" like uniform updates
  20284. */
  20285. setVector4(name: string, value: Vector4): ShaderMaterial;
  20286. /**
  20287. * Set a mat4 in the shader from a Matrix.
  20288. * @param name Define the name of the uniform as defined in the shader
  20289. * @param value Define the value to give to the uniform
  20290. * @return the material itself allowing "fluent" like uniform updates
  20291. */
  20292. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20293. /**
  20294. * Set a float32Array in the shader from a matrix array.
  20295. * @param name Define the name of the uniform as defined in the shader
  20296. * @param value Define the value to give to the uniform
  20297. * @return the material itself allowing "fluent" like uniform updates
  20298. */
  20299. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20300. /**
  20301. * Set a mat3 in the shader from a Float32Array.
  20302. * @param name Define the name of the uniform as defined in the shader
  20303. * @param value Define the value to give to the uniform
  20304. * @return the material itself allowing "fluent" like uniform updates
  20305. */
  20306. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20307. /**
  20308. * Set a mat2 in the shader from a Float32Array.
  20309. * @param name Define the name of the uniform as defined in the shader
  20310. * @param value Define the value to give to the uniform
  20311. * @return the material itself allowing "fluent" like uniform updates
  20312. */
  20313. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20314. /**
  20315. * Set a vec2 array in the shader from a number array.
  20316. * @param name Define the name of the uniform as defined in the shader
  20317. * @param value Define the value to give to the uniform
  20318. * @return the material itself allowing "fluent" like uniform updates
  20319. */
  20320. setArray2(name: string, value: number[]): ShaderMaterial;
  20321. /**
  20322. * Set a vec3 array in the shader from a number array.
  20323. * @param name Define the name of the uniform as defined in the shader
  20324. * @param value Define the value to give to the uniform
  20325. * @return the material itself allowing "fluent" like uniform updates
  20326. */
  20327. setArray3(name: string, value: number[]): ShaderMaterial;
  20328. /**
  20329. * Set a vec4 array in the shader from a number array.
  20330. * @param name Define the name of the uniform as defined in the shader
  20331. * @param value Define the value to give to the uniform
  20332. * @return the material itself allowing "fluent" like uniform updates
  20333. */
  20334. setArray4(name: string, value: number[]): ShaderMaterial;
  20335. private _checkCache;
  20336. /**
  20337. * Specifies that the submesh is ready to be used
  20338. * @param mesh defines the mesh to check
  20339. * @param subMesh defines which submesh to check
  20340. * @param useInstances specifies that instances should be used
  20341. * @returns a boolean indicating that the submesh is ready or not
  20342. */
  20343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20344. /**
  20345. * Checks if the material is ready to render the requested mesh
  20346. * @param mesh Define the mesh to render
  20347. * @param useInstances Define whether or not the material is used with instances
  20348. * @returns true if ready, otherwise false
  20349. */
  20350. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20351. /**
  20352. * Binds the world matrix to the material
  20353. * @param world defines the world transformation matrix
  20354. */
  20355. bindOnlyWorldMatrix(world: Matrix): void;
  20356. /**
  20357. * Binds the material to the mesh
  20358. * @param world defines the world transformation matrix
  20359. * @param mesh defines the mesh to bind the material to
  20360. */
  20361. bind(world: Matrix, mesh?: Mesh): void;
  20362. /**
  20363. * Gets the active textures from the material
  20364. * @returns an array of textures
  20365. */
  20366. getActiveTextures(): BaseTexture[];
  20367. /**
  20368. * Specifies if the material uses a texture
  20369. * @param texture defines the texture to check against the material
  20370. * @returns a boolean specifying if the material uses the texture
  20371. */
  20372. hasTexture(texture: BaseTexture): boolean;
  20373. /**
  20374. * Makes a duplicate of the material, and gives it a new name
  20375. * @param name defines the new name for the duplicated material
  20376. * @returns the cloned material
  20377. */
  20378. clone(name: string): ShaderMaterial;
  20379. /**
  20380. * Disposes the material
  20381. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20382. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20383. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20384. */
  20385. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20386. /**
  20387. * Serializes this material in a JSON representation
  20388. * @returns the serialized material object
  20389. */
  20390. serialize(): any;
  20391. /**
  20392. * Creates a shader material from parsed shader material data
  20393. * @param source defines the JSON represnetation of the material
  20394. * @param scene defines the hosting scene
  20395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20396. * @returns a new material
  20397. */
  20398. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20399. }
  20400. }
  20401. declare module "babylonjs/Shaders/color.fragment" {
  20402. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20403. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20404. /** @hidden */
  20405. export var colorPixelShader: {
  20406. name: string;
  20407. shader: string;
  20408. };
  20409. }
  20410. declare module "babylonjs/Shaders/color.vertex" {
  20411. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20412. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20413. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20414. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20415. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20416. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20417. /** @hidden */
  20418. export var colorVertexShader: {
  20419. name: string;
  20420. shader: string;
  20421. };
  20422. }
  20423. declare module "babylonjs/Meshes/linesMesh" {
  20424. import { Nullable } from "babylonjs/types";
  20425. import { Scene } from "babylonjs/scene";
  20426. import { Color3 } from "babylonjs/Maths/math.color";
  20427. import { Node } from "babylonjs/node";
  20428. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20429. import { Mesh } from "babylonjs/Meshes/mesh";
  20430. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20431. import { Effect } from "babylonjs/Materials/effect";
  20432. import { Material } from "babylonjs/Materials/material";
  20433. import "babylonjs/Shaders/color.fragment";
  20434. import "babylonjs/Shaders/color.vertex";
  20435. /**
  20436. * Line mesh
  20437. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20438. */
  20439. export class LinesMesh extends Mesh {
  20440. /**
  20441. * If vertex color should be applied to the mesh
  20442. */
  20443. readonly useVertexColor?: boolean | undefined;
  20444. /**
  20445. * If vertex alpha should be applied to the mesh
  20446. */
  20447. readonly useVertexAlpha?: boolean | undefined;
  20448. /**
  20449. * Color of the line (Default: White)
  20450. */
  20451. color: Color3;
  20452. /**
  20453. * Alpha of the line (Default: 1)
  20454. */
  20455. alpha: number;
  20456. /**
  20457. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20458. * This margin is expressed in world space coordinates, so its value may vary.
  20459. * Default value is 0.1
  20460. */
  20461. intersectionThreshold: number;
  20462. private _colorShader;
  20463. private color4;
  20464. /**
  20465. * Creates a new LinesMesh
  20466. * @param name defines the name
  20467. * @param scene defines the hosting scene
  20468. * @param parent defines the parent mesh if any
  20469. * @param source defines the optional source LinesMesh used to clone data from
  20470. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20471. * When false, achieved by calling a clone(), also passing False.
  20472. * This will make creation of children, recursive.
  20473. * @param useVertexColor defines if this LinesMesh supports vertex color
  20474. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20475. */
  20476. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20477. /**
  20478. * If vertex color should be applied to the mesh
  20479. */
  20480. useVertexColor?: boolean | undefined,
  20481. /**
  20482. * If vertex alpha should be applied to the mesh
  20483. */
  20484. useVertexAlpha?: boolean | undefined);
  20485. private _addClipPlaneDefine;
  20486. private _removeClipPlaneDefine;
  20487. isReady(): boolean;
  20488. /**
  20489. * Returns the string "LineMesh"
  20490. */
  20491. getClassName(): string;
  20492. /**
  20493. * @hidden
  20494. */
  20495. get material(): Material;
  20496. /**
  20497. * @hidden
  20498. */
  20499. set material(value: Material);
  20500. /**
  20501. * @hidden
  20502. */
  20503. get checkCollisions(): boolean;
  20504. /** @hidden */
  20505. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20506. /** @hidden */
  20507. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20508. /**
  20509. * Disposes of the line mesh
  20510. * @param doNotRecurse If children should be disposed
  20511. */
  20512. dispose(doNotRecurse?: boolean): void;
  20513. /**
  20514. * Returns a new LineMesh object cloned from the current one.
  20515. */
  20516. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  20517. /**
  20518. * Creates a new InstancedLinesMesh object from the mesh model.
  20519. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20520. * @param name defines the name of the new instance
  20521. * @returns a new InstancedLinesMesh
  20522. */
  20523. createInstance(name: string): InstancedLinesMesh;
  20524. }
  20525. /**
  20526. * Creates an instance based on a source LinesMesh
  20527. */
  20528. export class InstancedLinesMesh extends InstancedMesh {
  20529. /**
  20530. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20531. * This margin is expressed in world space coordinates, so its value may vary.
  20532. * Initilized with the intersectionThreshold value of the source LinesMesh
  20533. */
  20534. intersectionThreshold: number;
  20535. constructor(name: string, source: LinesMesh);
  20536. /**
  20537. * Returns the string "InstancedLinesMesh".
  20538. */
  20539. getClassName(): string;
  20540. }
  20541. }
  20542. declare module "babylonjs/Shaders/line.fragment" {
  20543. /** @hidden */
  20544. export var linePixelShader: {
  20545. name: string;
  20546. shader: string;
  20547. };
  20548. }
  20549. declare module "babylonjs/Shaders/line.vertex" {
  20550. /** @hidden */
  20551. export var lineVertexShader: {
  20552. name: string;
  20553. shader: string;
  20554. };
  20555. }
  20556. declare module "babylonjs/Rendering/edgesRenderer" {
  20557. import { Nullable } from "babylonjs/types";
  20558. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20560. import { Vector3 } from "babylonjs/Maths/math.vector";
  20561. import { IDisposable } from "babylonjs/scene";
  20562. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20563. import "babylonjs/Shaders/line.fragment";
  20564. import "babylonjs/Shaders/line.vertex";
  20565. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20566. module "babylonjs/Meshes/abstractMesh" {
  20567. interface AbstractMesh {
  20568. /**
  20569. * Gets the edgesRenderer associated with the mesh
  20570. */
  20571. edgesRenderer: Nullable<EdgesRenderer>;
  20572. }
  20573. }
  20574. module "babylonjs/Meshes/linesMesh" {
  20575. interface LinesMesh {
  20576. /**
  20577. * Enables the edge rendering mode on the mesh.
  20578. * This mode makes the mesh edges visible
  20579. * @param epsilon defines the maximal distance between two angles to detect a face
  20580. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20581. * @returns the currentAbstractMesh
  20582. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20583. */
  20584. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20585. }
  20586. }
  20587. module "babylonjs/Meshes/linesMesh" {
  20588. interface InstancedLinesMesh {
  20589. /**
  20590. * Enables the edge rendering mode on the mesh.
  20591. * This mode makes the mesh edges visible
  20592. * @param epsilon defines the maximal distance between two angles to detect a face
  20593. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20594. * @returns the current InstancedLinesMesh
  20595. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20596. */
  20597. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20598. }
  20599. }
  20600. /**
  20601. * Defines the minimum contract an Edges renderer should follow.
  20602. */
  20603. export interface IEdgesRenderer extends IDisposable {
  20604. /**
  20605. * Gets or sets a boolean indicating if the edgesRenderer is active
  20606. */
  20607. isEnabled: boolean;
  20608. /**
  20609. * Renders the edges of the attached mesh,
  20610. */
  20611. render(): void;
  20612. /**
  20613. * Checks wether or not the edges renderer is ready to render.
  20614. * @return true if ready, otherwise false.
  20615. */
  20616. isReady(): boolean;
  20617. }
  20618. /**
  20619. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20620. */
  20621. export class EdgesRenderer implements IEdgesRenderer {
  20622. /**
  20623. * Define the size of the edges with an orthographic camera
  20624. */
  20625. edgesWidthScalerForOrthographic: number;
  20626. /**
  20627. * Define the size of the edges with a perspective camera
  20628. */
  20629. edgesWidthScalerForPerspective: number;
  20630. protected _source: AbstractMesh;
  20631. protected _linesPositions: number[];
  20632. protected _linesNormals: number[];
  20633. protected _linesIndices: number[];
  20634. protected _epsilon: number;
  20635. protected _indicesCount: number;
  20636. protected _lineShader: ShaderMaterial;
  20637. protected _ib: DataBuffer;
  20638. protected _buffers: {
  20639. [key: string]: Nullable<VertexBuffer>;
  20640. };
  20641. protected _checkVerticesInsteadOfIndices: boolean;
  20642. private _meshRebuildObserver;
  20643. private _meshDisposeObserver;
  20644. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20645. isEnabled: boolean;
  20646. /**
  20647. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20648. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20649. * @param source Mesh used to create edges
  20650. * @param epsilon sum of angles in adjacency to check for edge
  20651. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20652. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20653. */
  20654. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20655. protected _prepareRessources(): void;
  20656. /** @hidden */
  20657. _rebuild(): void;
  20658. /**
  20659. * Releases the required resources for the edges renderer
  20660. */
  20661. dispose(): void;
  20662. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20663. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20664. /**
  20665. * Checks if the pair of p0 and p1 is en edge
  20666. * @param faceIndex
  20667. * @param edge
  20668. * @param faceNormals
  20669. * @param p0
  20670. * @param p1
  20671. * @private
  20672. */
  20673. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20674. /**
  20675. * push line into the position, normal and index buffer
  20676. * @protected
  20677. */
  20678. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20679. /**
  20680. * Generates lines edges from adjacencjes
  20681. * @private
  20682. */
  20683. _generateEdgesLines(): void;
  20684. /**
  20685. * Checks wether or not the edges renderer is ready to render.
  20686. * @return true if ready, otherwise false.
  20687. */
  20688. isReady(): boolean;
  20689. /**
  20690. * Renders the edges of the attached mesh,
  20691. */
  20692. render(): void;
  20693. }
  20694. /**
  20695. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20696. */
  20697. export class LineEdgesRenderer extends EdgesRenderer {
  20698. /**
  20699. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20700. * @param source LineMesh used to generate edges
  20701. * @param epsilon not important (specified angle for edge detection)
  20702. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20703. */
  20704. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20705. /**
  20706. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20707. */
  20708. _generateEdgesLines(): void;
  20709. }
  20710. }
  20711. declare module "babylonjs/Rendering/renderingGroup" {
  20712. import { SmartArray } from "babylonjs/Misc/smartArray";
  20713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20715. import { Nullable } from "babylonjs/types";
  20716. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20717. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20718. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20719. import { Material } from "babylonjs/Materials/material";
  20720. import { Scene } from "babylonjs/scene";
  20721. /**
  20722. * This represents the object necessary to create a rendering group.
  20723. * This is exclusively used and created by the rendering manager.
  20724. * To modify the behavior, you use the available helpers in your scene or meshes.
  20725. * @hidden
  20726. */
  20727. export class RenderingGroup {
  20728. index: number;
  20729. private static _zeroVector;
  20730. private _scene;
  20731. private _opaqueSubMeshes;
  20732. private _transparentSubMeshes;
  20733. private _alphaTestSubMeshes;
  20734. private _depthOnlySubMeshes;
  20735. private _particleSystems;
  20736. private _spriteManagers;
  20737. private _opaqueSortCompareFn;
  20738. private _alphaTestSortCompareFn;
  20739. private _transparentSortCompareFn;
  20740. private _renderOpaque;
  20741. private _renderAlphaTest;
  20742. private _renderTransparent;
  20743. /** @hidden */
  20744. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20745. onBeforeTransparentRendering: () => void;
  20746. /**
  20747. * Set the opaque sort comparison function.
  20748. * If null the sub meshes will be render in the order they were created
  20749. */
  20750. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20751. /**
  20752. * Set the alpha test sort comparison function.
  20753. * If null the sub meshes will be render in the order they were created
  20754. */
  20755. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20756. /**
  20757. * Set the transparent sort comparison function.
  20758. * If null the sub meshes will be render in the order they were created
  20759. */
  20760. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20761. /**
  20762. * Creates a new rendering group.
  20763. * @param index The rendering group index
  20764. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20765. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20766. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20767. */
  20768. 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>);
  20769. /**
  20770. * Render all the sub meshes contained in the group.
  20771. * @param customRenderFunction Used to override the default render behaviour of the group.
  20772. * @returns true if rendered some submeshes.
  20773. */
  20774. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20775. /**
  20776. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20777. * @param subMeshes The submeshes to render
  20778. */
  20779. private renderOpaqueSorted;
  20780. /**
  20781. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20782. * @param subMeshes The submeshes to render
  20783. */
  20784. private renderAlphaTestSorted;
  20785. /**
  20786. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20787. * @param subMeshes The submeshes to render
  20788. */
  20789. private renderTransparentSorted;
  20790. /**
  20791. * Renders the submeshes in a specified order.
  20792. * @param subMeshes The submeshes to sort before render
  20793. * @param sortCompareFn The comparison function use to sort
  20794. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20795. * @param transparent Specifies to activate blending if true
  20796. */
  20797. private static renderSorted;
  20798. /**
  20799. * Renders the submeshes in the order they were dispatched (no sort applied).
  20800. * @param subMeshes The submeshes to render
  20801. */
  20802. private static renderUnsorted;
  20803. /**
  20804. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20805. * are rendered back to front if in the same alpha index.
  20806. *
  20807. * @param a The first submesh
  20808. * @param b The second submesh
  20809. * @returns The result of the comparison
  20810. */
  20811. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20812. /**
  20813. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20814. * are rendered back to front.
  20815. *
  20816. * @param a The first submesh
  20817. * @param b The second submesh
  20818. * @returns The result of the comparison
  20819. */
  20820. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20821. /**
  20822. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20823. * are rendered front to back (prevent overdraw).
  20824. *
  20825. * @param a The first submesh
  20826. * @param b The second submesh
  20827. * @returns The result of the comparison
  20828. */
  20829. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20830. /**
  20831. * Resets the different lists of submeshes to prepare a new frame.
  20832. */
  20833. prepare(): void;
  20834. dispose(): void;
  20835. /**
  20836. * Inserts the submesh in its correct queue depending on its material.
  20837. * @param subMesh The submesh to dispatch
  20838. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20839. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20840. */
  20841. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20842. dispatchSprites(spriteManager: ISpriteManager): void;
  20843. dispatchParticles(particleSystem: IParticleSystem): void;
  20844. private _renderParticles;
  20845. private _renderSprites;
  20846. }
  20847. }
  20848. declare module "babylonjs/Rendering/renderingManager" {
  20849. import { Nullable } from "babylonjs/types";
  20850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20851. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20852. import { SmartArray } from "babylonjs/Misc/smartArray";
  20853. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20854. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20855. import { Material } from "babylonjs/Materials/material";
  20856. import { Scene } from "babylonjs/scene";
  20857. import { Camera } from "babylonjs/Cameras/camera";
  20858. /**
  20859. * Interface describing the different options available in the rendering manager
  20860. * regarding Auto Clear between groups.
  20861. */
  20862. export interface IRenderingManagerAutoClearSetup {
  20863. /**
  20864. * Defines whether or not autoclear is enable.
  20865. */
  20866. autoClear: boolean;
  20867. /**
  20868. * Defines whether or not to autoclear the depth buffer.
  20869. */
  20870. depth: boolean;
  20871. /**
  20872. * Defines whether or not to autoclear the stencil buffer.
  20873. */
  20874. stencil: boolean;
  20875. }
  20876. /**
  20877. * This class is used by the onRenderingGroupObservable
  20878. */
  20879. export class RenderingGroupInfo {
  20880. /**
  20881. * The Scene that being rendered
  20882. */
  20883. scene: Scene;
  20884. /**
  20885. * The camera currently used for the rendering pass
  20886. */
  20887. camera: Nullable<Camera>;
  20888. /**
  20889. * The ID of the renderingGroup being processed
  20890. */
  20891. renderingGroupId: number;
  20892. }
  20893. /**
  20894. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20895. * It is enable to manage the different groups as well as the different necessary sort functions.
  20896. * This should not be used directly aside of the few static configurations
  20897. */
  20898. export class RenderingManager {
  20899. /**
  20900. * The max id used for rendering groups (not included)
  20901. */
  20902. static MAX_RENDERINGGROUPS: number;
  20903. /**
  20904. * The min id used for rendering groups (included)
  20905. */
  20906. static MIN_RENDERINGGROUPS: number;
  20907. /**
  20908. * Used to globally prevent autoclearing scenes.
  20909. */
  20910. static AUTOCLEAR: boolean;
  20911. /**
  20912. * @hidden
  20913. */
  20914. _useSceneAutoClearSetup: boolean;
  20915. private _scene;
  20916. private _renderingGroups;
  20917. private _depthStencilBufferAlreadyCleaned;
  20918. private _autoClearDepthStencil;
  20919. private _customOpaqueSortCompareFn;
  20920. private _customAlphaTestSortCompareFn;
  20921. private _customTransparentSortCompareFn;
  20922. private _renderingGroupInfo;
  20923. /**
  20924. * Instantiates a new rendering group for a particular scene
  20925. * @param scene Defines the scene the groups belongs to
  20926. */
  20927. constructor(scene: Scene);
  20928. private _clearDepthStencilBuffer;
  20929. /**
  20930. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20931. * @hidden
  20932. */
  20933. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20934. /**
  20935. * Resets the different information of the group to prepare a new frame
  20936. * @hidden
  20937. */
  20938. reset(): void;
  20939. /**
  20940. * Dispose and release the group and its associated resources.
  20941. * @hidden
  20942. */
  20943. dispose(): void;
  20944. /**
  20945. * Clear the info related to rendering groups preventing retention points during dispose.
  20946. */
  20947. freeRenderingGroups(): void;
  20948. private _prepareRenderingGroup;
  20949. /**
  20950. * Add a sprite manager to the rendering manager in order to render it this frame.
  20951. * @param spriteManager Define the sprite manager to render
  20952. */
  20953. dispatchSprites(spriteManager: ISpriteManager): void;
  20954. /**
  20955. * Add a particle system to the rendering manager in order to render it this frame.
  20956. * @param particleSystem Define the particle system to render
  20957. */
  20958. dispatchParticles(particleSystem: IParticleSystem): void;
  20959. /**
  20960. * Add a submesh to the manager in order to render it this frame
  20961. * @param subMesh The submesh to dispatch
  20962. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20963. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20964. */
  20965. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20966. /**
  20967. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20968. * This allowed control for front to back rendering or reversly depending of the special needs.
  20969. *
  20970. * @param renderingGroupId The rendering group id corresponding to its index
  20971. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20972. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20973. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20974. */
  20975. 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;
  20976. /**
  20977. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20978. *
  20979. * @param renderingGroupId The rendering group id corresponding to its index
  20980. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20981. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20982. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20983. */
  20984. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20985. /**
  20986. * Gets the current auto clear configuration for one rendering group of the rendering
  20987. * manager.
  20988. * @param index the rendering group index to get the information for
  20989. * @returns The auto clear setup for the requested rendering group
  20990. */
  20991. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20992. }
  20993. }
  20994. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20995. import { Observable } from "babylonjs/Misc/observable";
  20996. import { SmartArray } from "babylonjs/Misc/smartArray";
  20997. import { Nullable, Immutable } from "babylonjs/types";
  20998. import { Camera } from "babylonjs/Cameras/camera";
  20999. import { Scene } from "babylonjs/scene";
  21000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21001. import { Color4 } from "babylonjs/Maths/math.color";
  21002. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21006. import { Texture } from "babylonjs/Materials/Textures/texture";
  21007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21008. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21009. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21010. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21011. import { Engine } from "babylonjs/Engines/engine";
  21012. /**
  21013. * This Helps creating a texture that will be created from a camera in your scene.
  21014. * It is basically a dynamic texture that could be used to create special effects for instance.
  21015. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21016. */
  21017. export class RenderTargetTexture extends Texture {
  21018. isCube: boolean;
  21019. /**
  21020. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21021. */
  21022. static readonly REFRESHRATE_RENDER_ONCE: number;
  21023. /**
  21024. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21025. */
  21026. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21027. /**
  21028. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21029. * the central point of your effect and can save a lot of performances.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21032. /**
  21033. * Use this predicate to dynamically define the list of mesh you want to render.
  21034. * If set, the renderList property will be overwritten.
  21035. */
  21036. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21037. private _renderList;
  21038. /**
  21039. * Use this list to define the list of mesh you want to render.
  21040. */
  21041. get renderList(): Nullable<Array<AbstractMesh>>;
  21042. set renderList(value: Nullable<Array<AbstractMesh>>);
  21043. /**
  21044. * Use this function to overload the renderList array at rendering time.
  21045. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21046. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21047. * the cube (if the RTT is a cube, else layerOrFace=0).
  21048. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  21049. */
  21050. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  21051. private _hookArray;
  21052. /**
  21053. * Define if particles should be rendered in your texture.
  21054. */
  21055. renderParticles: boolean;
  21056. /**
  21057. * Define if sprites should be rendered in your texture.
  21058. */
  21059. renderSprites: boolean;
  21060. /**
  21061. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21062. */
  21063. coordinatesMode: number;
  21064. /**
  21065. * Define the camera used to render the texture.
  21066. */
  21067. activeCamera: Nullable<Camera>;
  21068. /**
  21069. * Override the render function of the texture with your own one.
  21070. */
  21071. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21072. /**
  21073. * Define if camera post processes should be use while rendering the texture.
  21074. */
  21075. useCameraPostProcesses: boolean;
  21076. /**
  21077. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21078. */
  21079. ignoreCameraViewport: boolean;
  21080. private _postProcessManager;
  21081. private _postProcesses;
  21082. private _resizeObserver;
  21083. /**
  21084. * An event triggered when the texture is unbind.
  21085. */
  21086. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21087. /**
  21088. * An event triggered when the texture is unbind.
  21089. */
  21090. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21091. private _onAfterUnbindObserver;
  21092. /**
  21093. * Set a after unbind callback in the texture.
  21094. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21095. */
  21096. set onAfterUnbind(callback: () => void);
  21097. /**
  21098. * An event triggered before rendering the texture
  21099. */
  21100. onBeforeRenderObservable: Observable<number>;
  21101. private _onBeforeRenderObserver;
  21102. /**
  21103. * Set a before render callback in the texture.
  21104. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21105. */
  21106. set onBeforeRender(callback: (faceIndex: number) => void);
  21107. /**
  21108. * An event triggered after rendering the texture
  21109. */
  21110. onAfterRenderObservable: Observable<number>;
  21111. private _onAfterRenderObserver;
  21112. /**
  21113. * Set a after render callback in the texture.
  21114. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21115. */
  21116. set onAfterRender(callback: (faceIndex: number) => void);
  21117. /**
  21118. * An event triggered after the texture clear
  21119. */
  21120. onClearObservable: Observable<Engine>;
  21121. private _onClearObserver;
  21122. /**
  21123. * Set a clear callback in the texture.
  21124. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21125. */
  21126. set onClear(callback: (Engine: Engine) => void);
  21127. /**
  21128. * An event triggered when the texture is resized.
  21129. */
  21130. onResizeObservable: Observable<RenderTargetTexture>;
  21131. /**
  21132. * Define the clear color of the Render Target if it should be different from the scene.
  21133. */
  21134. clearColor: Color4;
  21135. protected _size: number | {
  21136. width: number;
  21137. height: number;
  21138. layers?: number;
  21139. };
  21140. protected _initialSizeParameter: number | {
  21141. width: number;
  21142. height: number;
  21143. } | {
  21144. ratio: number;
  21145. };
  21146. protected _sizeRatio: Nullable<number>;
  21147. /** @hidden */
  21148. _generateMipMaps: boolean;
  21149. protected _renderingManager: RenderingManager;
  21150. /** @hidden */
  21151. _waitingRenderList: string[];
  21152. protected _doNotChangeAspectRatio: boolean;
  21153. protected _currentRefreshId: number;
  21154. protected _refreshRate: number;
  21155. protected _textureMatrix: Matrix;
  21156. protected _samples: number;
  21157. protected _renderTargetOptions: RenderTargetCreationOptions;
  21158. /**
  21159. * Gets render target creation options that were used.
  21160. */
  21161. get renderTargetOptions(): RenderTargetCreationOptions;
  21162. protected _engine: Engine;
  21163. protected _onRatioRescale(): void;
  21164. /**
  21165. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21166. * It must define where the camera used to render the texture is set
  21167. */
  21168. boundingBoxPosition: Vector3;
  21169. private _boundingBoxSize;
  21170. /**
  21171. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21172. * When defined, the cubemap will switch to local mode
  21173. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21174. * @example https://www.babylonjs-playground.com/#RNASML
  21175. */
  21176. set boundingBoxSize(value: Vector3);
  21177. get boundingBoxSize(): Vector3;
  21178. /**
  21179. * In case the RTT has been created with a depth texture, get the associated
  21180. * depth texture.
  21181. * Otherwise, return null.
  21182. */
  21183. get depthStencilTexture(): Nullable<InternalTexture>;
  21184. /**
  21185. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21186. * or used a shadow, depth texture...
  21187. * @param name The friendly name of the texture
  21188. * @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)
  21189. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21190. * @param generateMipMaps True if mip maps need to be generated after render.
  21191. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21192. * @param type The type of the buffer in the RTT (int, half float, float...)
  21193. * @param isCube True if a cube texture needs to be created
  21194. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21195. * @param generateDepthBuffer True to generate a depth buffer
  21196. * @param generateStencilBuffer True to generate a stencil buffer
  21197. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21198. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21199. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21200. */
  21201. constructor(name: string, size: number | {
  21202. width: number;
  21203. height: number;
  21204. layers?: number;
  21205. } | {
  21206. ratio: number;
  21207. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21208. /**
  21209. * Creates a depth stencil texture.
  21210. * This is only available in WebGL 2 or with the depth texture extension available.
  21211. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21212. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21213. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21214. */
  21215. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21216. private _processSizeParameter;
  21217. /**
  21218. * Define the number of samples to use in case of MSAA.
  21219. * It defaults to one meaning no MSAA has been enabled.
  21220. */
  21221. get samples(): number;
  21222. set samples(value: number);
  21223. /**
  21224. * Resets the refresh counter of the texture and start bak from scratch.
  21225. * Could be useful to regenerate the texture if it is setup to render only once.
  21226. */
  21227. resetRefreshCounter(): void;
  21228. /**
  21229. * Define the refresh rate of the texture or the rendering frequency.
  21230. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21231. */
  21232. get refreshRate(): number;
  21233. set refreshRate(value: number);
  21234. /**
  21235. * Adds a post process to the render target rendering passes.
  21236. * @param postProcess define the post process to add
  21237. */
  21238. addPostProcess(postProcess: PostProcess): void;
  21239. /**
  21240. * Clear all the post processes attached to the render target
  21241. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21242. */
  21243. clearPostProcesses(dispose?: boolean): void;
  21244. /**
  21245. * Remove one of the post process from the list of attached post processes to the texture
  21246. * @param postProcess define the post process to remove from the list
  21247. */
  21248. removePostProcess(postProcess: PostProcess): void;
  21249. /** @hidden */
  21250. _shouldRender(): boolean;
  21251. /**
  21252. * Gets the actual render size of the texture.
  21253. * @returns the width of the render size
  21254. */
  21255. getRenderSize(): number;
  21256. /**
  21257. * Gets the actual render width of the texture.
  21258. * @returns the width of the render size
  21259. */
  21260. getRenderWidth(): number;
  21261. /**
  21262. * Gets the actual render height of the texture.
  21263. * @returns the height of the render size
  21264. */
  21265. getRenderHeight(): number;
  21266. /**
  21267. * Gets the actual number of layers of the texture.
  21268. * @returns the number of layers
  21269. */
  21270. getRenderLayers(): number;
  21271. /**
  21272. * Get if the texture can be rescaled or not.
  21273. */
  21274. get canRescale(): boolean;
  21275. /**
  21276. * Resize the texture using a ratio.
  21277. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21278. */
  21279. scale(ratio: number): void;
  21280. /**
  21281. * Get the texture reflection matrix used to rotate/transform the reflection.
  21282. * @returns the reflection matrix
  21283. */
  21284. getReflectionTextureMatrix(): Matrix;
  21285. /**
  21286. * Resize the texture to a new desired size.
  21287. * Be carrefull as it will recreate all the data in the new texture.
  21288. * @param size Define the new size. It can be:
  21289. * - a number for squared texture,
  21290. * - an object containing { width: number, height: number }
  21291. * - or an object containing a ratio { ratio: number }
  21292. */
  21293. resize(size: number | {
  21294. width: number;
  21295. height: number;
  21296. } | {
  21297. ratio: number;
  21298. }): void;
  21299. private _defaultRenderListPrepared;
  21300. /**
  21301. * Renders all the objects from the render list into the texture.
  21302. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21303. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21304. */
  21305. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21306. private _bestReflectionRenderTargetDimension;
  21307. private _prepareRenderingManager;
  21308. /**
  21309. * @hidden
  21310. * @param faceIndex face index to bind to if this is a cubetexture
  21311. * @param layer defines the index of the texture to bind in the array
  21312. */
  21313. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21314. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21315. private renderToTarget;
  21316. /**
  21317. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21318. * This allowed control for front to back rendering or reversly depending of the special needs.
  21319. *
  21320. * @param renderingGroupId The rendering group id corresponding to its index
  21321. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21322. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21323. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21324. */
  21325. 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;
  21326. /**
  21327. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21328. *
  21329. * @param renderingGroupId The rendering group id corresponding to its index
  21330. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21331. */
  21332. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21333. /**
  21334. * Clones the texture.
  21335. * @returns the cloned texture
  21336. */
  21337. clone(): RenderTargetTexture;
  21338. /**
  21339. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21340. * @returns The JSON representation of the texture
  21341. */
  21342. serialize(): any;
  21343. /**
  21344. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21345. */
  21346. disposeFramebufferObjects(): void;
  21347. /**
  21348. * Dispose the texture and release its associated resources.
  21349. */
  21350. dispose(): void;
  21351. /** @hidden */
  21352. _rebuild(): void;
  21353. /**
  21354. * Clear the info related to rendering groups preventing retention point in material dispose.
  21355. */
  21356. freeRenderingGroups(): void;
  21357. /**
  21358. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21359. * @returns the view count
  21360. */
  21361. getViewCount(): number;
  21362. }
  21363. }
  21364. declare module "babylonjs/Materials/material" {
  21365. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21366. import { SmartArray } from "babylonjs/Misc/smartArray";
  21367. import { Observable } from "babylonjs/Misc/observable";
  21368. import { Nullable } from "babylonjs/types";
  21369. import { Scene } from "babylonjs/scene";
  21370. import { Matrix } from "babylonjs/Maths/math.vector";
  21371. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21373. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21374. import { Effect } from "babylonjs/Materials/effect";
  21375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21377. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21378. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21379. import { Mesh } from "babylonjs/Meshes/mesh";
  21380. import { Animation } from "babylonjs/Animations/animation";
  21381. /**
  21382. * Options for compiling materials.
  21383. */
  21384. export interface IMaterialCompilationOptions {
  21385. /**
  21386. * Defines whether clip planes are enabled.
  21387. */
  21388. clipPlane: boolean;
  21389. /**
  21390. * Defines whether instances are enabled.
  21391. */
  21392. useInstances: boolean;
  21393. }
  21394. /**
  21395. * Base class for the main features of a material in Babylon.js
  21396. */
  21397. export class Material implements IAnimatable {
  21398. /**
  21399. * Returns the triangle fill mode
  21400. */
  21401. static readonly TriangleFillMode: number;
  21402. /**
  21403. * Returns the wireframe mode
  21404. */
  21405. static readonly WireFrameFillMode: number;
  21406. /**
  21407. * Returns the point fill mode
  21408. */
  21409. static readonly PointFillMode: number;
  21410. /**
  21411. * Returns the point list draw mode
  21412. */
  21413. static readonly PointListDrawMode: number;
  21414. /**
  21415. * Returns the line list draw mode
  21416. */
  21417. static readonly LineListDrawMode: number;
  21418. /**
  21419. * Returns the line loop draw mode
  21420. */
  21421. static readonly LineLoopDrawMode: number;
  21422. /**
  21423. * Returns the line strip draw mode
  21424. */
  21425. static readonly LineStripDrawMode: number;
  21426. /**
  21427. * Returns the triangle strip draw mode
  21428. */
  21429. static readonly TriangleStripDrawMode: number;
  21430. /**
  21431. * Returns the triangle fan draw mode
  21432. */
  21433. static readonly TriangleFanDrawMode: number;
  21434. /**
  21435. * Stores the clock-wise side orientation
  21436. */
  21437. static readonly ClockWiseSideOrientation: number;
  21438. /**
  21439. * Stores the counter clock-wise side orientation
  21440. */
  21441. static readonly CounterClockWiseSideOrientation: number;
  21442. /**
  21443. * The dirty texture flag value
  21444. */
  21445. static readonly TextureDirtyFlag: number;
  21446. /**
  21447. * The dirty light flag value
  21448. */
  21449. static readonly LightDirtyFlag: number;
  21450. /**
  21451. * The dirty fresnel flag value
  21452. */
  21453. static readonly FresnelDirtyFlag: number;
  21454. /**
  21455. * The dirty attribute flag value
  21456. */
  21457. static readonly AttributesDirtyFlag: number;
  21458. /**
  21459. * The dirty misc flag value
  21460. */
  21461. static readonly MiscDirtyFlag: number;
  21462. /**
  21463. * The all dirty flag value
  21464. */
  21465. static readonly AllDirtyFlag: number;
  21466. /**
  21467. * The ID of the material
  21468. */
  21469. id: string;
  21470. /**
  21471. * Gets or sets the unique id of the material
  21472. */
  21473. uniqueId: number;
  21474. /**
  21475. * The name of the material
  21476. */
  21477. name: string;
  21478. /**
  21479. * Gets or sets user defined metadata
  21480. */
  21481. metadata: any;
  21482. /**
  21483. * For internal use only. Please do not use.
  21484. */
  21485. reservedDataStore: any;
  21486. /**
  21487. * Specifies if the ready state should be checked on each call
  21488. */
  21489. checkReadyOnEveryCall: boolean;
  21490. /**
  21491. * Specifies if the ready state should be checked once
  21492. */
  21493. checkReadyOnlyOnce: boolean;
  21494. /**
  21495. * The state of the material
  21496. */
  21497. state: string;
  21498. /**
  21499. * The alpha value of the material
  21500. */
  21501. protected _alpha: number;
  21502. /**
  21503. * List of inspectable custom properties (used by the Inspector)
  21504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21505. */
  21506. inspectableCustomProperties: IInspectable[];
  21507. /**
  21508. * Sets the alpha value of the material
  21509. */
  21510. set alpha(value: number);
  21511. /**
  21512. * Gets the alpha value of the material
  21513. */
  21514. get alpha(): number;
  21515. /**
  21516. * Specifies if back face culling is enabled
  21517. */
  21518. protected _backFaceCulling: boolean;
  21519. /**
  21520. * Sets the back-face culling state
  21521. */
  21522. set backFaceCulling(value: boolean);
  21523. /**
  21524. * Gets the back-face culling state
  21525. */
  21526. get backFaceCulling(): boolean;
  21527. /**
  21528. * Stores the value for side orientation
  21529. */
  21530. sideOrientation: number;
  21531. /**
  21532. * Callback triggered when the material is compiled
  21533. */
  21534. onCompiled: Nullable<(effect: Effect) => void>;
  21535. /**
  21536. * Callback triggered when an error occurs
  21537. */
  21538. onError: Nullable<(effect: Effect, errors: string) => void>;
  21539. /**
  21540. * Callback triggered to get the render target textures
  21541. */
  21542. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21543. /**
  21544. * Gets a boolean indicating that current material needs to register RTT
  21545. */
  21546. get hasRenderTargetTextures(): boolean;
  21547. /**
  21548. * Specifies if the material should be serialized
  21549. */
  21550. doNotSerialize: boolean;
  21551. /**
  21552. * @hidden
  21553. */
  21554. _storeEffectOnSubMeshes: boolean;
  21555. /**
  21556. * Stores the animations for the material
  21557. */
  21558. animations: Nullable<Array<Animation>>;
  21559. /**
  21560. * An event triggered when the material is disposed
  21561. */
  21562. onDisposeObservable: Observable<Material>;
  21563. /**
  21564. * An observer which watches for dispose events
  21565. */
  21566. private _onDisposeObserver;
  21567. private _onUnBindObservable;
  21568. /**
  21569. * Called during a dispose event
  21570. */
  21571. set onDispose(callback: () => void);
  21572. private _onBindObservable;
  21573. /**
  21574. * An event triggered when the material is bound
  21575. */
  21576. get onBindObservable(): Observable<AbstractMesh>;
  21577. /**
  21578. * An observer which watches for bind events
  21579. */
  21580. private _onBindObserver;
  21581. /**
  21582. * Called during a bind event
  21583. */
  21584. set onBind(callback: (Mesh: AbstractMesh) => void);
  21585. /**
  21586. * An event triggered when the material is unbound
  21587. */
  21588. get onUnBindObservable(): Observable<Material>;
  21589. /**
  21590. * Stores the value of the alpha mode
  21591. */
  21592. private _alphaMode;
  21593. /**
  21594. * Sets the value of the alpha mode.
  21595. *
  21596. * | Value | Type | Description |
  21597. * | --- | --- | --- |
  21598. * | 0 | ALPHA_DISABLE | |
  21599. * | 1 | ALPHA_ADD | |
  21600. * | 2 | ALPHA_COMBINE | |
  21601. * | 3 | ALPHA_SUBTRACT | |
  21602. * | 4 | ALPHA_MULTIPLY | |
  21603. * | 5 | ALPHA_MAXIMIZED | |
  21604. * | 6 | ALPHA_ONEONE | |
  21605. * | 7 | ALPHA_PREMULTIPLIED | |
  21606. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21607. * | 9 | ALPHA_INTERPOLATE | |
  21608. * | 10 | ALPHA_SCREENMODE | |
  21609. *
  21610. */
  21611. set alphaMode(value: number);
  21612. /**
  21613. * Gets the value of the alpha mode
  21614. */
  21615. get alphaMode(): number;
  21616. /**
  21617. * Stores the state of the need depth pre-pass value
  21618. */
  21619. private _needDepthPrePass;
  21620. /**
  21621. * Sets the need depth pre-pass value
  21622. */
  21623. set needDepthPrePass(value: boolean);
  21624. /**
  21625. * Gets the depth pre-pass value
  21626. */
  21627. get needDepthPrePass(): boolean;
  21628. /**
  21629. * Specifies if depth writing should be disabled
  21630. */
  21631. disableDepthWrite: boolean;
  21632. /**
  21633. * Specifies if depth writing should be forced
  21634. */
  21635. forceDepthWrite: boolean;
  21636. /**
  21637. * Specifies the depth function that should be used. 0 means the default engine function
  21638. */
  21639. depthFunction: number;
  21640. /**
  21641. * Specifies if there should be a separate pass for culling
  21642. */
  21643. separateCullingPass: boolean;
  21644. /**
  21645. * Stores the state specifing if fog should be enabled
  21646. */
  21647. private _fogEnabled;
  21648. /**
  21649. * Sets the state for enabling fog
  21650. */
  21651. set fogEnabled(value: boolean);
  21652. /**
  21653. * Gets the value of the fog enabled state
  21654. */
  21655. get fogEnabled(): boolean;
  21656. /**
  21657. * Stores the size of points
  21658. */
  21659. pointSize: number;
  21660. /**
  21661. * Stores the z offset value
  21662. */
  21663. zOffset: number;
  21664. /**
  21665. * Gets a value specifying if wireframe mode is enabled
  21666. */
  21667. get wireframe(): boolean;
  21668. /**
  21669. * Sets the state of wireframe mode
  21670. */
  21671. set wireframe(value: boolean);
  21672. /**
  21673. * Gets the value specifying if point clouds are enabled
  21674. */
  21675. get pointsCloud(): boolean;
  21676. /**
  21677. * Sets the state of point cloud mode
  21678. */
  21679. set pointsCloud(value: boolean);
  21680. /**
  21681. * Gets the material fill mode
  21682. */
  21683. get fillMode(): number;
  21684. /**
  21685. * Sets the material fill mode
  21686. */
  21687. set fillMode(value: number);
  21688. /**
  21689. * @hidden
  21690. * Stores the effects for the material
  21691. */
  21692. _effect: Nullable<Effect>;
  21693. /**
  21694. * Specifies if uniform buffers should be used
  21695. */
  21696. private _useUBO;
  21697. /**
  21698. * Stores a reference to the scene
  21699. */
  21700. private _scene;
  21701. /**
  21702. * Stores the fill mode state
  21703. */
  21704. private _fillMode;
  21705. /**
  21706. * Specifies if the depth write state should be cached
  21707. */
  21708. private _cachedDepthWriteState;
  21709. /**
  21710. * Specifies if the depth function state should be cached
  21711. */
  21712. private _cachedDepthFunctionState;
  21713. /**
  21714. * Stores the uniform buffer
  21715. */
  21716. protected _uniformBuffer: UniformBuffer;
  21717. /** @hidden */
  21718. _indexInSceneMaterialArray: number;
  21719. /** @hidden */
  21720. meshMap: Nullable<{
  21721. [id: string]: AbstractMesh | undefined;
  21722. }>;
  21723. /**
  21724. * Creates a material instance
  21725. * @param name defines the name of the material
  21726. * @param scene defines the scene to reference
  21727. * @param doNotAdd specifies if the material should be added to the scene
  21728. */
  21729. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21730. /**
  21731. * Returns a string representation of the current material
  21732. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21733. * @returns a string with material information
  21734. */
  21735. toString(fullDetails?: boolean): string;
  21736. /**
  21737. * Gets the class name of the material
  21738. * @returns a string with the class name of the material
  21739. */
  21740. getClassName(): string;
  21741. /**
  21742. * Specifies if updates for the material been locked
  21743. */
  21744. get isFrozen(): boolean;
  21745. /**
  21746. * Locks updates for the material
  21747. */
  21748. freeze(): void;
  21749. /**
  21750. * Unlocks updates for the material
  21751. */
  21752. unfreeze(): void;
  21753. /**
  21754. * Specifies if the material is ready to be used
  21755. * @param mesh defines the mesh to check
  21756. * @param useInstances specifies if instances should be used
  21757. * @returns a boolean indicating if the material is ready to be used
  21758. */
  21759. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21760. /**
  21761. * Specifies that the submesh is ready to be used
  21762. * @param mesh defines the mesh to check
  21763. * @param subMesh defines which submesh to check
  21764. * @param useInstances specifies that instances should be used
  21765. * @returns a boolean indicating that the submesh is ready or not
  21766. */
  21767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21768. /**
  21769. * Returns the material effect
  21770. * @returns the effect associated with the material
  21771. */
  21772. getEffect(): Nullable<Effect>;
  21773. /**
  21774. * Returns the current scene
  21775. * @returns a Scene
  21776. */
  21777. getScene(): Scene;
  21778. /**
  21779. * Specifies if the material will require alpha blending
  21780. * @returns a boolean specifying if alpha blending is needed
  21781. */
  21782. needAlphaBlending(): boolean;
  21783. /**
  21784. * Specifies if the mesh will require alpha blending
  21785. * @param mesh defines the mesh to check
  21786. * @returns a boolean specifying if alpha blending is needed for the mesh
  21787. */
  21788. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21789. /**
  21790. * Specifies if this material should be rendered in alpha test mode
  21791. * @returns a boolean specifying if an alpha test is needed.
  21792. */
  21793. needAlphaTesting(): boolean;
  21794. /**
  21795. * Gets the texture used for the alpha test
  21796. * @returns the texture to use for alpha testing
  21797. */
  21798. getAlphaTestTexture(): Nullable<BaseTexture>;
  21799. /**
  21800. * Marks the material to indicate that it needs to be re-calculated
  21801. */
  21802. markDirty(): void;
  21803. /** @hidden */
  21804. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21805. /**
  21806. * Binds the material to the mesh
  21807. * @param world defines the world transformation matrix
  21808. * @param mesh defines the mesh to bind the material to
  21809. */
  21810. bind(world: Matrix, mesh?: Mesh): void;
  21811. /**
  21812. * Binds the submesh to the material
  21813. * @param world defines the world transformation matrix
  21814. * @param mesh defines the mesh containing the submesh
  21815. * @param subMesh defines the submesh to bind the material to
  21816. */
  21817. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21818. /**
  21819. * Binds the world matrix to the material
  21820. * @param world defines the world transformation matrix
  21821. */
  21822. bindOnlyWorldMatrix(world: Matrix): void;
  21823. /**
  21824. * Binds the scene's uniform buffer to the effect.
  21825. * @param effect defines the effect to bind to the scene uniform buffer
  21826. * @param sceneUbo defines the uniform buffer storing scene data
  21827. */
  21828. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21829. /**
  21830. * Binds the view matrix to the effect
  21831. * @param effect defines the effect to bind the view matrix to
  21832. */
  21833. bindView(effect: Effect): void;
  21834. /**
  21835. * Binds the view projection matrix to the effect
  21836. * @param effect defines the effect to bind the view projection matrix to
  21837. */
  21838. bindViewProjection(effect: Effect): void;
  21839. /**
  21840. * Specifies if material alpha testing should be turned on for the mesh
  21841. * @param mesh defines the mesh to check
  21842. */
  21843. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21844. /**
  21845. * Processes to execute after binding the material to a mesh
  21846. * @param mesh defines the rendered mesh
  21847. */
  21848. protected _afterBind(mesh?: Mesh): void;
  21849. /**
  21850. * Unbinds the material from the mesh
  21851. */
  21852. unbind(): void;
  21853. /**
  21854. * Gets the active textures from the material
  21855. * @returns an array of textures
  21856. */
  21857. getActiveTextures(): BaseTexture[];
  21858. /**
  21859. * Specifies if the material uses a texture
  21860. * @param texture defines the texture to check against the material
  21861. * @returns a boolean specifying if the material uses the texture
  21862. */
  21863. hasTexture(texture: BaseTexture): boolean;
  21864. /**
  21865. * Makes a duplicate of the material, and gives it a new name
  21866. * @param name defines the new name for the duplicated material
  21867. * @returns the cloned material
  21868. */
  21869. clone(name: string): Nullable<Material>;
  21870. /**
  21871. * Gets the meshes bound to the material
  21872. * @returns an array of meshes bound to the material
  21873. */
  21874. getBindedMeshes(): AbstractMesh[];
  21875. /**
  21876. * Force shader compilation
  21877. * @param mesh defines the mesh associated with this material
  21878. * @param onCompiled defines a function to execute once the material is compiled
  21879. * @param options defines the options to configure the compilation
  21880. * @param onError defines a function to execute if the material fails compiling
  21881. */
  21882. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21883. /**
  21884. * Force shader compilation
  21885. * @param mesh defines the mesh that will use this material
  21886. * @param options defines additional options for compiling the shaders
  21887. * @returns a promise that resolves when the compilation completes
  21888. */
  21889. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21890. private static readonly _AllDirtyCallBack;
  21891. private static readonly _ImageProcessingDirtyCallBack;
  21892. private static readonly _TextureDirtyCallBack;
  21893. private static readonly _FresnelDirtyCallBack;
  21894. private static readonly _MiscDirtyCallBack;
  21895. private static readonly _LightsDirtyCallBack;
  21896. private static readonly _AttributeDirtyCallBack;
  21897. private static _FresnelAndMiscDirtyCallBack;
  21898. private static _TextureAndMiscDirtyCallBack;
  21899. private static readonly _DirtyCallbackArray;
  21900. private static readonly _RunDirtyCallBacks;
  21901. /**
  21902. * Marks a define in the material to indicate that it needs to be re-computed
  21903. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21904. */
  21905. markAsDirty(flag: number): void;
  21906. /**
  21907. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21908. * @param func defines a function which checks material defines against the submeshes
  21909. */
  21910. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21911. /**
  21912. * Indicates that we need to re-calculated for all submeshes
  21913. */
  21914. protected _markAllSubMeshesAsAllDirty(): void;
  21915. /**
  21916. * Indicates that image processing needs to be re-calculated for all submeshes
  21917. */
  21918. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21919. /**
  21920. * Indicates that textures need to be re-calculated for all submeshes
  21921. */
  21922. protected _markAllSubMeshesAsTexturesDirty(): void;
  21923. /**
  21924. * Indicates that fresnel needs to be re-calculated for all submeshes
  21925. */
  21926. protected _markAllSubMeshesAsFresnelDirty(): void;
  21927. /**
  21928. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21929. */
  21930. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21931. /**
  21932. * Indicates that lights need to be re-calculated for all submeshes
  21933. */
  21934. protected _markAllSubMeshesAsLightsDirty(): void;
  21935. /**
  21936. * Indicates that attributes need to be re-calculated for all submeshes
  21937. */
  21938. protected _markAllSubMeshesAsAttributesDirty(): void;
  21939. /**
  21940. * Indicates that misc needs to be re-calculated for all submeshes
  21941. */
  21942. protected _markAllSubMeshesAsMiscDirty(): void;
  21943. /**
  21944. * Indicates that textures and misc need to be re-calculated for all submeshes
  21945. */
  21946. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21947. /**
  21948. * Disposes the material
  21949. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21950. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21951. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21952. */
  21953. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21954. /** @hidden */
  21955. private releaseVertexArrayObject;
  21956. /**
  21957. * Serializes this material
  21958. * @returns the serialized material object
  21959. */
  21960. serialize(): any;
  21961. /**
  21962. * Creates a material from parsed material data
  21963. * @param parsedMaterial defines parsed material data
  21964. * @param scene defines the hosting scene
  21965. * @param rootUrl defines the root URL to use to load textures
  21966. * @returns a new material
  21967. */
  21968. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21969. }
  21970. }
  21971. declare module "babylonjs/Materials/multiMaterial" {
  21972. import { Nullable } from "babylonjs/types";
  21973. import { Scene } from "babylonjs/scene";
  21974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21975. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21977. import { Material } from "babylonjs/Materials/material";
  21978. /**
  21979. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21980. * separate meshes. This can be use to improve performances.
  21981. * @see http://doc.babylonjs.com/how_to/multi_materials
  21982. */
  21983. export class MultiMaterial extends Material {
  21984. private _subMaterials;
  21985. /**
  21986. * Gets or Sets the list of Materials used within the multi material.
  21987. * They need to be ordered according to the submeshes order in the associated mesh
  21988. */
  21989. get subMaterials(): Nullable<Material>[];
  21990. set subMaterials(value: Nullable<Material>[]);
  21991. /**
  21992. * Function used to align with Node.getChildren()
  21993. * @returns the list of Materials used within the multi material
  21994. */
  21995. getChildren(): Nullable<Material>[];
  21996. /**
  21997. * Instantiates a new Multi Material
  21998. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21999. * separate meshes. This can be use to improve performances.
  22000. * @see http://doc.babylonjs.com/how_to/multi_materials
  22001. * @param name Define the name in the scene
  22002. * @param scene Define the scene the material belongs to
  22003. */
  22004. constructor(name: string, scene: Scene);
  22005. private _hookArray;
  22006. /**
  22007. * Get one of the submaterial by its index in the submaterials array
  22008. * @param index The index to look the sub material at
  22009. * @returns The Material if the index has been defined
  22010. */
  22011. getSubMaterial(index: number): Nullable<Material>;
  22012. /**
  22013. * Get the list of active textures for the whole sub materials list.
  22014. * @returns All the textures that will be used during the rendering
  22015. */
  22016. getActiveTextures(): BaseTexture[];
  22017. /**
  22018. * Gets the current class name of the material e.g. "MultiMaterial"
  22019. * Mainly use in serialization.
  22020. * @returns the class name
  22021. */
  22022. getClassName(): string;
  22023. /**
  22024. * Checks if the material is ready to render the requested sub mesh
  22025. * @param mesh Define the mesh the submesh belongs to
  22026. * @param subMesh Define the sub mesh to look readyness for
  22027. * @param useInstances Define whether or not the material is used with instances
  22028. * @returns true if ready, otherwise false
  22029. */
  22030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22031. /**
  22032. * Clones the current material and its related sub materials
  22033. * @param name Define the name of the newly cloned material
  22034. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22035. * @returns the cloned material
  22036. */
  22037. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22038. /**
  22039. * Serializes the materials into a JSON representation.
  22040. * @returns the JSON representation
  22041. */
  22042. serialize(): any;
  22043. /**
  22044. * Dispose the material and release its associated resources
  22045. * @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)
  22046. * @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)
  22047. * @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)
  22048. */
  22049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22050. /**
  22051. * Creates a MultiMaterial from parsed MultiMaterial data.
  22052. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22053. * @param scene defines the hosting scene
  22054. * @returns a new MultiMaterial
  22055. */
  22056. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22057. }
  22058. }
  22059. declare module "babylonjs/Meshes/subMesh" {
  22060. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22061. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22062. import { Engine } from "babylonjs/Engines/engine";
  22063. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22064. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22065. import { Effect } from "babylonjs/Materials/effect";
  22066. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22067. import { Plane } from "babylonjs/Maths/math.plane";
  22068. import { Collider } from "babylonjs/Collisions/collider";
  22069. import { Material } from "babylonjs/Materials/material";
  22070. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22072. import { Mesh } from "babylonjs/Meshes/mesh";
  22073. import { Ray } from "babylonjs/Culling/ray";
  22074. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22075. /**
  22076. * Base class for submeshes
  22077. */
  22078. export class BaseSubMesh {
  22079. /** @hidden */
  22080. _materialDefines: Nullable<MaterialDefines>;
  22081. /** @hidden */
  22082. _materialEffect: Nullable<Effect>;
  22083. /**
  22084. * Gets material defines used by the effect associated to the sub mesh
  22085. */
  22086. get materialDefines(): Nullable<MaterialDefines>;
  22087. /**
  22088. * Sets material defines used by the effect associated to the sub mesh
  22089. */
  22090. set materialDefines(defines: Nullable<MaterialDefines>);
  22091. /**
  22092. * Gets associated effect
  22093. */
  22094. get effect(): Nullable<Effect>;
  22095. /**
  22096. * Sets associated effect (effect used to render this submesh)
  22097. * @param effect defines the effect to associate with
  22098. * @param defines defines the set of defines used to compile this effect
  22099. */
  22100. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22101. }
  22102. /**
  22103. * Defines a subdivision inside a mesh
  22104. */
  22105. export class SubMesh extends BaseSubMesh implements ICullable {
  22106. /** the material index to use */
  22107. materialIndex: number;
  22108. /** vertex index start */
  22109. verticesStart: number;
  22110. /** vertices count */
  22111. verticesCount: number;
  22112. /** index start */
  22113. indexStart: number;
  22114. /** indices count */
  22115. indexCount: number;
  22116. /** @hidden */
  22117. _linesIndexCount: number;
  22118. private _mesh;
  22119. private _renderingMesh;
  22120. private _boundingInfo;
  22121. private _linesIndexBuffer;
  22122. /** @hidden */
  22123. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22124. /** @hidden */
  22125. _trianglePlanes: Plane[];
  22126. /** @hidden */
  22127. _lastColliderTransformMatrix: Nullable<Matrix>;
  22128. /** @hidden */
  22129. _renderId: number;
  22130. /** @hidden */
  22131. _alphaIndex: number;
  22132. /** @hidden */
  22133. _distanceToCamera: number;
  22134. /** @hidden */
  22135. _id: number;
  22136. private _currentMaterial;
  22137. /**
  22138. * Add a new submesh to a mesh
  22139. * @param materialIndex defines the material index to use
  22140. * @param verticesStart defines vertex index start
  22141. * @param verticesCount defines vertices count
  22142. * @param indexStart defines index start
  22143. * @param indexCount defines indices count
  22144. * @param mesh defines the parent mesh
  22145. * @param renderingMesh defines an optional rendering mesh
  22146. * @param createBoundingBox defines if bounding box should be created for this submesh
  22147. * @returns the new submesh
  22148. */
  22149. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22150. /**
  22151. * Creates a new submesh
  22152. * @param materialIndex defines the material index to use
  22153. * @param verticesStart defines vertex index start
  22154. * @param verticesCount defines vertices count
  22155. * @param indexStart defines index start
  22156. * @param indexCount defines indices count
  22157. * @param mesh defines the parent mesh
  22158. * @param renderingMesh defines an optional rendering mesh
  22159. * @param createBoundingBox defines if bounding box should be created for this submesh
  22160. */
  22161. constructor(
  22162. /** the material index to use */
  22163. materialIndex: number,
  22164. /** vertex index start */
  22165. verticesStart: number,
  22166. /** vertices count */
  22167. verticesCount: number,
  22168. /** index start */
  22169. indexStart: number,
  22170. /** indices count */
  22171. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22172. /**
  22173. * Returns true if this submesh covers the entire parent mesh
  22174. * @ignorenaming
  22175. */
  22176. get IsGlobal(): boolean;
  22177. /**
  22178. * Returns the submesh BoudingInfo object
  22179. * @returns current bounding info (or mesh's one if the submesh is global)
  22180. */
  22181. getBoundingInfo(): BoundingInfo;
  22182. /**
  22183. * Sets the submesh BoundingInfo
  22184. * @param boundingInfo defines the new bounding info to use
  22185. * @returns the SubMesh
  22186. */
  22187. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22188. /**
  22189. * Returns the mesh of the current submesh
  22190. * @return the parent mesh
  22191. */
  22192. getMesh(): AbstractMesh;
  22193. /**
  22194. * Returns the rendering mesh of the submesh
  22195. * @returns the rendering mesh (could be different from parent mesh)
  22196. */
  22197. getRenderingMesh(): Mesh;
  22198. /**
  22199. * Returns the submesh material
  22200. * @returns null or the current material
  22201. */
  22202. getMaterial(): Nullable<Material>;
  22203. /**
  22204. * Sets a new updated BoundingInfo object to the submesh
  22205. * @param data defines an optional position array to use to determine the bounding info
  22206. * @returns the SubMesh
  22207. */
  22208. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22209. /** @hidden */
  22210. _checkCollision(collider: Collider): boolean;
  22211. /**
  22212. * Updates the submesh BoundingInfo
  22213. * @param world defines the world matrix to use to update the bounding info
  22214. * @returns the submesh
  22215. */
  22216. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22217. /**
  22218. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22219. * @param frustumPlanes defines the frustum planes
  22220. * @returns true if the submesh is intersecting with the frustum
  22221. */
  22222. isInFrustum(frustumPlanes: Plane[]): boolean;
  22223. /**
  22224. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22225. * @param frustumPlanes defines the frustum planes
  22226. * @returns true if the submesh is inside the frustum
  22227. */
  22228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22229. /**
  22230. * Renders the submesh
  22231. * @param enableAlphaMode defines if alpha needs to be used
  22232. * @returns the submesh
  22233. */
  22234. render(enableAlphaMode: boolean): SubMesh;
  22235. /**
  22236. * @hidden
  22237. */
  22238. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22239. /**
  22240. * Checks if the submesh intersects with a ray
  22241. * @param ray defines the ray to test
  22242. * @returns true is the passed ray intersects the submesh bounding box
  22243. */
  22244. canIntersects(ray: Ray): boolean;
  22245. /**
  22246. * Intersects current submesh with a ray
  22247. * @param ray defines the ray to test
  22248. * @param positions defines mesh's positions array
  22249. * @param indices defines mesh's indices array
  22250. * @param fastCheck defines if only bounding info should be used
  22251. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22252. * @returns intersection info or null if no intersection
  22253. */
  22254. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22255. /** @hidden */
  22256. private _intersectLines;
  22257. /** @hidden */
  22258. private _intersectUnIndexedLines;
  22259. /** @hidden */
  22260. private _intersectTriangles;
  22261. /** @hidden */
  22262. private _intersectUnIndexedTriangles;
  22263. /** @hidden */
  22264. _rebuild(): void;
  22265. /**
  22266. * Creates a new submesh from the passed mesh
  22267. * @param newMesh defines the new hosting mesh
  22268. * @param newRenderingMesh defines an optional rendering mesh
  22269. * @returns the new submesh
  22270. */
  22271. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22272. /**
  22273. * Release associated resources
  22274. */
  22275. dispose(): void;
  22276. /**
  22277. * Gets the class name
  22278. * @returns the string "SubMesh".
  22279. */
  22280. getClassName(): string;
  22281. /**
  22282. * Creates a new submesh from indices data
  22283. * @param materialIndex the index of the main mesh material
  22284. * @param startIndex the index where to start the copy in the mesh indices array
  22285. * @param indexCount the number of indices to copy then from the startIndex
  22286. * @param mesh the main mesh to create the submesh from
  22287. * @param renderingMesh the optional rendering mesh
  22288. * @returns a new submesh
  22289. */
  22290. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22291. }
  22292. }
  22293. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22294. /**
  22295. * Class used to represent data loading progression
  22296. */
  22297. export class SceneLoaderFlags {
  22298. private static _ForceFullSceneLoadingForIncremental;
  22299. private static _ShowLoadingScreen;
  22300. private static _CleanBoneMatrixWeights;
  22301. private static _loggingLevel;
  22302. /**
  22303. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22304. */
  22305. static get ForceFullSceneLoadingForIncremental(): boolean;
  22306. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22307. /**
  22308. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22309. */
  22310. static get ShowLoadingScreen(): boolean;
  22311. static set ShowLoadingScreen(value: boolean);
  22312. /**
  22313. * Defines the current logging level (while loading the scene)
  22314. * @ignorenaming
  22315. */
  22316. static get loggingLevel(): number;
  22317. static set loggingLevel(value: number);
  22318. /**
  22319. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22320. */
  22321. static get CleanBoneMatrixWeights(): boolean;
  22322. static set CleanBoneMatrixWeights(value: boolean);
  22323. }
  22324. }
  22325. declare module "babylonjs/Meshes/geometry" {
  22326. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22327. import { Scene } from "babylonjs/scene";
  22328. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22329. import { Engine } from "babylonjs/Engines/engine";
  22330. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22331. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22332. import { Effect } from "babylonjs/Materials/effect";
  22333. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22335. import { Mesh } from "babylonjs/Meshes/mesh";
  22336. /**
  22337. * Class used to store geometry data (vertex buffers + index buffer)
  22338. */
  22339. export class Geometry implements IGetSetVerticesData {
  22340. /**
  22341. * Gets or sets the ID of the geometry
  22342. */
  22343. id: string;
  22344. /**
  22345. * Gets or sets the unique ID of the geometry
  22346. */
  22347. uniqueId: number;
  22348. /**
  22349. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22350. */
  22351. delayLoadState: number;
  22352. /**
  22353. * Gets the file containing the data to load when running in delay load state
  22354. */
  22355. delayLoadingFile: Nullable<string>;
  22356. /**
  22357. * Callback called when the geometry is updated
  22358. */
  22359. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22360. private _scene;
  22361. private _engine;
  22362. private _meshes;
  22363. private _totalVertices;
  22364. /** @hidden */
  22365. _indices: IndicesArray;
  22366. /** @hidden */
  22367. _vertexBuffers: {
  22368. [key: string]: VertexBuffer;
  22369. };
  22370. private _isDisposed;
  22371. private _extend;
  22372. private _boundingBias;
  22373. /** @hidden */
  22374. _delayInfo: Array<string>;
  22375. private _indexBuffer;
  22376. private _indexBufferIsUpdatable;
  22377. /** @hidden */
  22378. _boundingInfo: Nullable<BoundingInfo>;
  22379. /** @hidden */
  22380. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22381. /** @hidden */
  22382. _softwareSkinningFrameId: number;
  22383. private _vertexArrayObjects;
  22384. private _updatable;
  22385. /** @hidden */
  22386. _positions: Nullable<Vector3[]>;
  22387. /**
  22388. * 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
  22389. */
  22390. get boundingBias(): Vector2;
  22391. /**
  22392. * 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
  22393. */
  22394. set boundingBias(value: Vector2);
  22395. /**
  22396. * Static function used to attach a new empty geometry to a mesh
  22397. * @param mesh defines the mesh to attach the geometry to
  22398. * @returns the new Geometry
  22399. */
  22400. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22401. /**
  22402. * Creates a new geometry
  22403. * @param id defines the unique ID
  22404. * @param scene defines the hosting scene
  22405. * @param vertexData defines the VertexData used to get geometry data
  22406. * @param updatable defines if geometry must be updatable (false by default)
  22407. * @param mesh defines the mesh that will be associated with the geometry
  22408. */
  22409. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22410. /**
  22411. * Gets the current extend of the geometry
  22412. */
  22413. get extend(): {
  22414. minimum: Vector3;
  22415. maximum: Vector3;
  22416. };
  22417. /**
  22418. * Gets the hosting scene
  22419. * @returns the hosting Scene
  22420. */
  22421. getScene(): Scene;
  22422. /**
  22423. * Gets the hosting engine
  22424. * @returns the hosting Engine
  22425. */
  22426. getEngine(): Engine;
  22427. /**
  22428. * Defines if the geometry is ready to use
  22429. * @returns true if the geometry is ready to be used
  22430. */
  22431. isReady(): boolean;
  22432. /**
  22433. * Gets a value indicating that the geometry should not be serialized
  22434. */
  22435. get doNotSerialize(): boolean;
  22436. /** @hidden */
  22437. _rebuild(): void;
  22438. /**
  22439. * Affects all geometry data in one call
  22440. * @param vertexData defines the geometry data
  22441. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22442. */
  22443. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22444. /**
  22445. * Set specific vertex data
  22446. * @param kind defines the data kind (Position, normal, etc...)
  22447. * @param data defines the vertex data to use
  22448. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22449. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22450. */
  22451. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22452. /**
  22453. * Removes a specific vertex data
  22454. * @param kind defines the data kind (Position, normal, etc...)
  22455. */
  22456. removeVerticesData(kind: string): void;
  22457. /**
  22458. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22459. * @param buffer defines the vertex buffer to use
  22460. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22461. */
  22462. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22463. /**
  22464. * Update a specific vertex buffer
  22465. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22466. * It will do nothing if the buffer is not updatable
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @param data defines the data to use
  22469. * @param offset defines the offset in the target buffer where to store the data
  22470. * @param useBytes set to true if the offset is in bytes
  22471. */
  22472. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22473. /**
  22474. * Update a specific vertex buffer
  22475. * This function will create a new buffer if the current one is not updatable
  22476. * @param kind defines the data kind (Position, normal, etc...)
  22477. * @param data defines the data to use
  22478. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22479. */
  22480. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22481. private _updateBoundingInfo;
  22482. /** @hidden */
  22483. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22484. /**
  22485. * Gets total number of vertices
  22486. * @returns the total number of vertices
  22487. */
  22488. getTotalVertices(): number;
  22489. /**
  22490. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22491. * @param kind defines the data kind (Position, normal, etc...)
  22492. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22493. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22494. * @returns a float array containing vertex data
  22495. */
  22496. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22497. /**
  22498. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22499. * @param kind defines the data kind (Position, normal, etc...)
  22500. * @returns true if the vertex buffer with the specified kind is updatable
  22501. */
  22502. isVertexBufferUpdatable(kind: string): boolean;
  22503. /**
  22504. * Gets a specific vertex buffer
  22505. * @param kind defines the data kind (Position, normal, etc...)
  22506. * @returns a VertexBuffer
  22507. */
  22508. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22509. /**
  22510. * Returns all vertex buffers
  22511. * @return an object holding all vertex buffers indexed by kind
  22512. */
  22513. getVertexBuffers(): Nullable<{
  22514. [key: string]: VertexBuffer;
  22515. }>;
  22516. /**
  22517. * Gets a boolean indicating if specific vertex buffer is present
  22518. * @param kind defines the data kind (Position, normal, etc...)
  22519. * @returns true if data is present
  22520. */
  22521. isVerticesDataPresent(kind: string): boolean;
  22522. /**
  22523. * Gets a list of all attached data kinds (Position, normal, etc...)
  22524. * @returns a list of string containing all kinds
  22525. */
  22526. getVerticesDataKinds(): string[];
  22527. /**
  22528. * Update index buffer
  22529. * @param indices defines the indices to store in the index buffer
  22530. * @param offset defines the offset in the target buffer where to store the data
  22531. * @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)
  22532. */
  22533. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22534. /**
  22535. * Creates a new index buffer
  22536. * @param indices defines the indices to store in the index buffer
  22537. * @param totalVertices defines the total number of vertices (could be null)
  22538. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22539. */
  22540. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22541. /**
  22542. * Return the total number of indices
  22543. * @returns the total number of indices
  22544. */
  22545. getTotalIndices(): number;
  22546. /**
  22547. * Gets the index buffer array
  22548. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22549. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22550. * @returns the index buffer array
  22551. */
  22552. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22553. /**
  22554. * Gets the index buffer
  22555. * @return the index buffer
  22556. */
  22557. getIndexBuffer(): Nullable<DataBuffer>;
  22558. /** @hidden */
  22559. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22560. /**
  22561. * Release the associated resources for a specific mesh
  22562. * @param mesh defines the source mesh
  22563. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22564. */
  22565. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22566. /**
  22567. * Apply current geometry to a given mesh
  22568. * @param mesh defines the mesh to apply geometry to
  22569. */
  22570. applyToMesh(mesh: Mesh): void;
  22571. private _updateExtend;
  22572. private _applyToMesh;
  22573. private notifyUpdate;
  22574. /**
  22575. * Load the geometry if it was flagged as delay loaded
  22576. * @param scene defines the hosting scene
  22577. * @param onLoaded defines a callback called when the geometry is loaded
  22578. */
  22579. load(scene: Scene, onLoaded?: () => void): void;
  22580. private _queueLoad;
  22581. /**
  22582. * Invert the geometry to move from a right handed system to a left handed one.
  22583. */
  22584. toLeftHanded(): void;
  22585. /** @hidden */
  22586. _resetPointsArrayCache(): void;
  22587. /** @hidden */
  22588. _generatePointsArray(): boolean;
  22589. /**
  22590. * Gets a value indicating if the geometry is disposed
  22591. * @returns true if the geometry was disposed
  22592. */
  22593. isDisposed(): boolean;
  22594. private _disposeVertexArrayObjects;
  22595. /**
  22596. * Free all associated resources
  22597. */
  22598. dispose(): void;
  22599. /**
  22600. * Clone the current geometry into a new geometry
  22601. * @param id defines the unique ID of the new geometry
  22602. * @returns a new geometry object
  22603. */
  22604. copy(id: string): Geometry;
  22605. /**
  22606. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22607. * @return a JSON representation of the current geometry data (without the vertices data)
  22608. */
  22609. serialize(): any;
  22610. private toNumberArray;
  22611. /**
  22612. * Serialize all vertices data into a JSON oject
  22613. * @returns a JSON representation of the current geometry data
  22614. */
  22615. serializeVerticeData(): any;
  22616. /**
  22617. * Extracts a clone of a mesh geometry
  22618. * @param mesh defines the source mesh
  22619. * @param id defines the unique ID of the new geometry object
  22620. * @returns the new geometry object
  22621. */
  22622. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22623. /**
  22624. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22625. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22626. * Be aware Math.random() could cause collisions, but:
  22627. * "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"
  22628. * @returns a string containing a new GUID
  22629. */
  22630. static RandomId(): string;
  22631. /** @hidden */
  22632. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22633. private static _CleanMatricesWeights;
  22634. /**
  22635. * Create a new geometry from persisted data (Using .babylon file format)
  22636. * @param parsedVertexData defines the persisted data
  22637. * @param scene defines the hosting scene
  22638. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22639. * @returns the new geometry object
  22640. */
  22641. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22642. }
  22643. }
  22644. declare module "babylonjs/Meshes/mesh.vertexData" {
  22645. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22646. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22647. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22648. import { Geometry } from "babylonjs/Meshes/geometry";
  22649. import { Mesh } from "babylonjs/Meshes/mesh";
  22650. /**
  22651. * Define an interface for all classes that will get and set the data on vertices
  22652. */
  22653. export interface IGetSetVerticesData {
  22654. /**
  22655. * Gets a boolean indicating if specific vertex data is present
  22656. * @param kind defines the vertex data kind to use
  22657. * @returns true is data kind is present
  22658. */
  22659. isVerticesDataPresent(kind: string): boolean;
  22660. /**
  22661. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22662. * @param kind defines the data kind (Position, normal, etc...)
  22663. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22664. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22665. * @returns a float array containing vertex data
  22666. */
  22667. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22668. /**
  22669. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22670. * @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.
  22671. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22672. * @returns the indices array or an empty array if the mesh has no geometry
  22673. */
  22674. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22675. /**
  22676. * Set specific vertex data
  22677. * @param kind defines the data kind (Position, normal, etc...)
  22678. * @param data defines the vertex data to use
  22679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22681. */
  22682. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22683. /**
  22684. * Update a specific associated vertex buffer
  22685. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22686. * - VertexBuffer.PositionKind
  22687. * - VertexBuffer.UVKind
  22688. * - VertexBuffer.UV2Kind
  22689. * - VertexBuffer.UV3Kind
  22690. * - VertexBuffer.UV4Kind
  22691. * - VertexBuffer.UV5Kind
  22692. * - VertexBuffer.UV6Kind
  22693. * - VertexBuffer.ColorKind
  22694. * - VertexBuffer.MatricesIndicesKind
  22695. * - VertexBuffer.MatricesIndicesExtraKind
  22696. * - VertexBuffer.MatricesWeightsKind
  22697. * - VertexBuffer.MatricesWeightsExtraKind
  22698. * @param data defines the data source
  22699. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22700. * @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)
  22701. */
  22702. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22703. /**
  22704. * Creates a new index buffer
  22705. * @param indices defines the indices to store in the index buffer
  22706. * @param totalVertices defines the total number of vertices (could be null)
  22707. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22708. */
  22709. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22710. }
  22711. /**
  22712. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22713. */
  22714. export class VertexData {
  22715. /**
  22716. * Mesh side orientation : usually the external or front surface
  22717. */
  22718. static readonly FRONTSIDE: number;
  22719. /**
  22720. * Mesh side orientation : usually the internal or back surface
  22721. */
  22722. static readonly BACKSIDE: number;
  22723. /**
  22724. * Mesh side orientation : both internal and external or front and back surfaces
  22725. */
  22726. static readonly DOUBLESIDE: number;
  22727. /**
  22728. * Mesh side orientation : by default, `FRONTSIDE`
  22729. */
  22730. static readonly DEFAULTSIDE: number;
  22731. /**
  22732. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22733. */
  22734. positions: Nullable<FloatArray>;
  22735. /**
  22736. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22737. */
  22738. normals: Nullable<FloatArray>;
  22739. /**
  22740. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22741. */
  22742. tangents: Nullable<FloatArray>;
  22743. /**
  22744. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22745. */
  22746. uvs: Nullable<FloatArray>;
  22747. /**
  22748. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22749. */
  22750. uvs2: Nullable<FloatArray>;
  22751. /**
  22752. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22753. */
  22754. uvs3: Nullable<FloatArray>;
  22755. /**
  22756. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22757. */
  22758. uvs4: Nullable<FloatArray>;
  22759. /**
  22760. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22761. */
  22762. uvs5: Nullable<FloatArray>;
  22763. /**
  22764. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22765. */
  22766. uvs6: Nullable<FloatArray>;
  22767. /**
  22768. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22769. */
  22770. colors: Nullable<FloatArray>;
  22771. /**
  22772. * 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).
  22773. */
  22774. matricesIndices: Nullable<FloatArray>;
  22775. /**
  22776. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22777. */
  22778. matricesWeights: Nullable<FloatArray>;
  22779. /**
  22780. * An array extending the number of possible indices
  22781. */
  22782. matricesIndicesExtra: Nullable<FloatArray>;
  22783. /**
  22784. * An array extending the number of possible weights when the number of indices is extended
  22785. */
  22786. matricesWeightsExtra: Nullable<FloatArray>;
  22787. /**
  22788. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22789. */
  22790. indices: Nullable<IndicesArray>;
  22791. /**
  22792. * Uses the passed data array to set the set the values for the specified kind of data
  22793. * @param data a linear array of floating numbers
  22794. * @param kind the type of data that is being set, eg positions, colors etc
  22795. */
  22796. set(data: FloatArray, kind: string): void;
  22797. /**
  22798. * Associates the vertexData to the passed Mesh.
  22799. * Sets it as updatable or not (default `false`)
  22800. * @param mesh the mesh the vertexData is applied to
  22801. * @param updatable when used and having the value true allows new data to update the vertexData
  22802. * @returns the VertexData
  22803. */
  22804. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22805. /**
  22806. * Associates the vertexData to the passed Geometry.
  22807. * Sets it as updatable or not (default `false`)
  22808. * @param geometry the geometry the vertexData is applied to
  22809. * @param updatable when used and having the value true allows new data to update the vertexData
  22810. * @returns VertexData
  22811. */
  22812. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22813. /**
  22814. * Updates the associated mesh
  22815. * @param mesh the mesh to be updated
  22816. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22817. * @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
  22818. * @returns VertexData
  22819. */
  22820. updateMesh(mesh: Mesh): VertexData;
  22821. /**
  22822. * Updates the associated geometry
  22823. * @param geometry the geometry to be updated
  22824. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22825. * @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
  22826. * @returns VertexData.
  22827. */
  22828. updateGeometry(geometry: Geometry): VertexData;
  22829. private _applyTo;
  22830. private _update;
  22831. /**
  22832. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22833. * @param matrix the transforming matrix
  22834. * @returns the VertexData
  22835. */
  22836. transform(matrix: Matrix): VertexData;
  22837. /**
  22838. * Merges the passed VertexData into the current one
  22839. * @param other the VertexData to be merged into the current one
  22840. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22841. * @returns the modified VertexData
  22842. */
  22843. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22844. private _mergeElement;
  22845. private _validate;
  22846. /**
  22847. * Serializes the VertexData
  22848. * @returns a serialized object
  22849. */
  22850. serialize(): any;
  22851. /**
  22852. * Extracts the vertexData from a mesh
  22853. * @param mesh the mesh from which to extract the VertexData
  22854. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22855. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22856. * @returns the object VertexData associated to the passed mesh
  22857. */
  22858. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22859. /**
  22860. * Extracts the vertexData from the geometry
  22861. * @param geometry the geometry from which to extract the VertexData
  22862. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22863. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22864. * @returns the object VertexData associated to the passed mesh
  22865. */
  22866. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22867. private static _ExtractFrom;
  22868. /**
  22869. * Creates the VertexData for a Ribbon
  22870. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22871. * * pathArray array of paths, each of which an array of successive Vector3
  22872. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22873. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22874. * * 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
  22875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22876. * * 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)
  22877. * * 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)
  22878. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22879. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22880. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22881. * @returns the VertexData of the ribbon
  22882. */
  22883. static CreateRibbon(options: {
  22884. pathArray: Vector3[][];
  22885. closeArray?: boolean;
  22886. closePath?: boolean;
  22887. offset?: number;
  22888. sideOrientation?: number;
  22889. frontUVs?: Vector4;
  22890. backUVs?: Vector4;
  22891. invertUV?: boolean;
  22892. uvs?: Vector2[];
  22893. colors?: Color4[];
  22894. }): VertexData;
  22895. /**
  22896. * Creates the VertexData for a box
  22897. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22898. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22899. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22900. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22901. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22902. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22903. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22905. * * 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)
  22906. * * 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)
  22907. * @returns the VertexData of the box
  22908. */
  22909. static CreateBox(options: {
  22910. size?: number;
  22911. width?: number;
  22912. height?: number;
  22913. depth?: number;
  22914. faceUV?: Vector4[];
  22915. faceColors?: Color4[];
  22916. sideOrientation?: number;
  22917. frontUVs?: Vector4;
  22918. backUVs?: Vector4;
  22919. }): VertexData;
  22920. /**
  22921. * Creates the VertexData for a tiled box
  22922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22923. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22924. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22925. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22927. * @returns the VertexData of the box
  22928. */
  22929. static CreateTiledBox(options: {
  22930. pattern?: number;
  22931. width?: number;
  22932. height?: number;
  22933. depth?: number;
  22934. tileSize?: number;
  22935. tileWidth?: number;
  22936. tileHeight?: number;
  22937. alignHorizontal?: number;
  22938. alignVertical?: number;
  22939. faceUV?: Vector4[];
  22940. faceColors?: Color4[];
  22941. sideOrientation?: number;
  22942. }): VertexData;
  22943. /**
  22944. * Creates the VertexData for a tiled plane
  22945. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22946. * * pattern a limited pattern arrangement depending on the number
  22947. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22948. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22949. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22950. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22951. * * 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)
  22952. * * 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)
  22953. * @returns the VertexData of the tiled plane
  22954. */
  22955. static CreateTiledPlane(options: {
  22956. pattern?: number;
  22957. tileSize?: number;
  22958. tileWidth?: number;
  22959. tileHeight?: number;
  22960. size?: number;
  22961. width?: number;
  22962. height?: number;
  22963. alignHorizontal?: number;
  22964. alignVertical?: number;
  22965. sideOrientation?: number;
  22966. frontUVs?: Vector4;
  22967. backUVs?: Vector4;
  22968. }): VertexData;
  22969. /**
  22970. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22971. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22972. * * segments sets the number of horizontal strips optional, default 32
  22973. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22974. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22975. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22976. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22977. * * 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
  22978. * * 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
  22979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22980. * * 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)
  22981. * * 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)
  22982. * @returns the VertexData of the ellipsoid
  22983. */
  22984. static CreateSphere(options: {
  22985. segments?: number;
  22986. diameter?: number;
  22987. diameterX?: number;
  22988. diameterY?: number;
  22989. diameterZ?: number;
  22990. arc?: number;
  22991. slice?: number;
  22992. sideOrientation?: number;
  22993. frontUVs?: Vector4;
  22994. backUVs?: Vector4;
  22995. }): VertexData;
  22996. /**
  22997. * Creates the VertexData for a cylinder, cone or prism
  22998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22999. * * height sets the height (y direction) of the cylinder, optional, default 2
  23000. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23001. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23002. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23003. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23004. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23005. * * 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
  23006. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23007. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23008. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23009. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23011. * * 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)
  23012. * * 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)
  23013. * @returns the VertexData of the cylinder, cone or prism
  23014. */
  23015. static CreateCylinder(options: {
  23016. height?: number;
  23017. diameterTop?: number;
  23018. diameterBottom?: number;
  23019. diameter?: number;
  23020. tessellation?: number;
  23021. subdivisions?: number;
  23022. arc?: number;
  23023. faceColors?: Color4[];
  23024. faceUV?: Vector4[];
  23025. hasRings?: boolean;
  23026. enclose?: boolean;
  23027. sideOrientation?: number;
  23028. frontUVs?: Vector4;
  23029. backUVs?: Vector4;
  23030. }): VertexData;
  23031. /**
  23032. * Creates the VertexData for a torus
  23033. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23034. * * diameter the diameter of the torus, optional default 1
  23035. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23036. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23038. * * 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)
  23039. * * 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)
  23040. * @returns the VertexData of the torus
  23041. */
  23042. static CreateTorus(options: {
  23043. diameter?: number;
  23044. thickness?: number;
  23045. tessellation?: number;
  23046. sideOrientation?: number;
  23047. frontUVs?: Vector4;
  23048. backUVs?: Vector4;
  23049. }): VertexData;
  23050. /**
  23051. * Creates the VertexData of the LineSystem
  23052. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23053. * - lines an array of lines, each line being an array of successive Vector3
  23054. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23055. * @returns the VertexData of the LineSystem
  23056. */
  23057. static CreateLineSystem(options: {
  23058. lines: Vector3[][];
  23059. colors?: Nullable<Color4[][]>;
  23060. }): VertexData;
  23061. /**
  23062. * Create the VertexData for a DashedLines
  23063. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23064. * - points an array successive Vector3
  23065. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23066. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23067. * - dashNb the intended total number of dashes, optional, default 200
  23068. * @returns the VertexData for the DashedLines
  23069. */
  23070. static CreateDashedLines(options: {
  23071. points: Vector3[];
  23072. dashSize?: number;
  23073. gapSize?: number;
  23074. dashNb?: number;
  23075. }): VertexData;
  23076. /**
  23077. * Creates the VertexData for a Ground
  23078. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23079. * - width the width (x direction) of the ground, optional, default 1
  23080. * - height the height (z direction) of the ground, optional, default 1
  23081. * - subdivisions the number of subdivisions per side, optional, default 1
  23082. * @returns the VertexData of the Ground
  23083. */
  23084. static CreateGround(options: {
  23085. width?: number;
  23086. height?: number;
  23087. subdivisions?: number;
  23088. subdivisionsX?: number;
  23089. subdivisionsY?: number;
  23090. }): VertexData;
  23091. /**
  23092. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23093. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23094. * * xmin the ground minimum X coordinate, optional, default -1
  23095. * * zmin the ground minimum Z coordinate, optional, default -1
  23096. * * xmax the ground maximum X coordinate, optional, default 1
  23097. * * zmax the ground maximum Z coordinate, optional, default 1
  23098. * * 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}
  23099. * * 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}
  23100. * @returns the VertexData of the TiledGround
  23101. */
  23102. static CreateTiledGround(options: {
  23103. xmin: number;
  23104. zmin: number;
  23105. xmax: number;
  23106. zmax: number;
  23107. subdivisions?: {
  23108. w: number;
  23109. h: number;
  23110. };
  23111. precision?: {
  23112. w: number;
  23113. h: number;
  23114. };
  23115. }): VertexData;
  23116. /**
  23117. * Creates the VertexData of the Ground designed from a heightmap
  23118. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23119. * * width the width (x direction) of the ground
  23120. * * height the height (z direction) of the ground
  23121. * * subdivisions the number of subdivisions per side
  23122. * * minHeight the minimum altitude on the ground, optional, default 0
  23123. * * maxHeight the maximum altitude on the ground, optional default 1
  23124. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23125. * * buffer the array holding the image color data
  23126. * * bufferWidth the width of image
  23127. * * bufferHeight the height of image
  23128. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23129. * @returns the VertexData of the Ground designed from a heightmap
  23130. */
  23131. static CreateGroundFromHeightMap(options: {
  23132. width: number;
  23133. height: number;
  23134. subdivisions: number;
  23135. minHeight: number;
  23136. maxHeight: number;
  23137. colorFilter: Color3;
  23138. buffer: Uint8Array;
  23139. bufferWidth: number;
  23140. bufferHeight: number;
  23141. alphaFilter: number;
  23142. }): VertexData;
  23143. /**
  23144. * Creates the VertexData for a Plane
  23145. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23146. * * size sets the width and height of the plane to the value of size, optional default 1
  23147. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23148. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23150. * * 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)
  23151. * * 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)
  23152. * @returns the VertexData of the box
  23153. */
  23154. static CreatePlane(options: {
  23155. size?: number;
  23156. width?: number;
  23157. height?: number;
  23158. sideOrientation?: number;
  23159. frontUVs?: Vector4;
  23160. backUVs?: Vector4;
  23161. }): VertexData;
  23162. /**
  23163. * Creates the VertexData of the Disc or regular Polygon
  23164. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23165. * * radius the radius of the disc, optional default 0.5
  23166. * * tessellation the number of polygon sides, optional, default 64
  23167. * * 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
  23168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23169. * * 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)
  23170. * * 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)
  23171. * @returns the VertexData of the box
  23172. */
  23173. static CreateDisc(options: {
  23174. radius?: number;
  23175. tessellation?: number;
  23176. arc?: number;
  23177. sideOrientation?: number;
  23178. frontUVs?: Vector4;
  23179. backUVs?: Vector4;
  23180. }): VertexData;
  23181. /**
  23182. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23183. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23184. * @param polygon a mesh built from polygonTriangulation.build()
  23185. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23187. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23188. * @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)
  23189. * @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)
  23190. * @returns the VertexData of the Polygon
  23191. */
  23192. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23193. /**
  23194. * Creates the VertexData of the IcoSphere
  23195. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23196. * * radius the radius of the IcoSphere, optional default 1
  23197. * * radiusX allows stretching in the x direction, optional, default radius
  23198. * * radiusY allows stretching in the y direction, optional, default radius
  23199. * * radiusZ allows stretching in the z direction, optional, default radius
  23200. * * flat when true creates a flat shaded mesh, optional, default true
  23201. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23203. * * 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)
  23204. * * 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)
  23205. * @returns the VertexData of the IcoSphere
  23206. */
  23207. static CreateIcoSphere(options: {
  23208. radius?: number;
  23209. radiusX?: number;
  23210. radiusY?: number;
  23211. radiusZ?: number;
  23212. flat?: boolean;
  23213. subdivisions?: number;
  23214. sideOrientation?: number;
  23215. frontUVs?: Vector4;
  23216. backUVs?: Vector4;
  23217. }): VertexData;
  23218. /**
  23219. * Creates the VertexData for a Polyhedron
  23220. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23221. * * type provided types are:
  23222. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23223. * * 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)
  23224. * * size the size of the IcoSphere, optional default 1
  23225. * * sizeX allows stretching in the x direction, optional, default size
  23226. * * sizeY allows stretching in the y direction, optional, default size
  23227. * * sizeZ allows stretching in the z direction, optional, default size
  23228. * * 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
  23229. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23230. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23231. * * flat when true creates a flat shaded mesh, optional, default true
  23232. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23234. * * 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)
  23235. * * 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)
  23236. * @returns the VertexData of the Polyhedron
  23237. */
  23238. static CreatePolyhedron(options: {
  23239. type?: number;
  23240. size?: number;
  23241. sizeX?: number;
  23242. sizeY?: number;
  23243. sizeZ?: number;
  23244. custom?: any;
  23245. faceUV?: Vector4[];
  23246. faceColors?: Color4[];
  23247. flat?: boolean;
  23248. sideOrientation?: number;
  23249. frontUVs?: Vector4;
  23250. backUVs?: Vector4;
  23251. }): VertexData;
  23252. /**
  23253. * Creates the VertexData for a TorusKnot
  23254. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23255. * * radius the radius of the torus knot, optional, default 2
  23256. * * tube the thickness of the tube, optional, default 0.5
  23257. * * radialSegments the number of sides on each tube segments, optional, default 32
  23258. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23259. * * p the number of windings around the z axis, optional, default 2
  23260. * * q the number of windings around the x axis, optional, default 3
  23261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23262. * * 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)
  23263. * * 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)
  23264. * @returns the VertexData of the Torus Knot
  23265. */
  23266. static CreateTorusKnot(options: {
  23267. radius?: number;
  23268. tube?: number;
  23269. radialSegments?: number;
  23270. tubularSegments?: number;
  23271. p?: number;
  23272. q?: number;
  23273. sideOrientation?: number;
  23274. frontUVs?: Vector4;
  23275. backUVs?: Vector4;
  23276. }): VertexData;
  23277. /**
  23278. * Compute normals for given positions and indices
  23279. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23280. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23281. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23282. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23283. * * facetNormals : optional array of facet normals (vector3)
  23284. * * facetPositions : optional array of facet positions (vector3)
  23285. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23286. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23287. * * bInfo : optional bounding info, required for facetPartitioning computation
  23288. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23289. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23290. * * useRightHandedSystem: optional boolean to for right handed system computation
  23291. * * depthSort : optional boolean to enable the facet depth sort computation
  23292. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23293. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23294. */
  23295. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23296. facetNormals?: any;
  23297. facetPositions?: any;
  23298. facetPartitioning?: any;
  23299. ratio?: number;
  23300. bInfo?: any;
  23301. bbSize?: Vector3;
  23302. subDiv?: any;
  23303. useRightHandedSystem?: boolean;
  23304. depthSort?: boolean;
  23305. distanceTo?: Vector3;
  23306. depthSortedFacets?: any;
  23307. }): void;
  23308. /** @hidden */
  23309. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23310. /**
  23311. * Applies VertexData created from the imported parameters to the geometry
  23312. * @param parsedVertexData the parsed data from an imported file
  23313. * @param geometry the geometry to apply the VertexData to
  23314. */
  23315. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23316. }
  23317. }
  23318. declare module "babylonjs/Morph/morphTarget" {
  23319. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23320. import { Observable } from "babylonjs/Misc/observable";
  23321. import { Nullable, FloatArray } from "babylonjs/types";
  23322. import { Scene } from "babylonjs/scene";
  23323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23324. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23325. /**
  23326. * Defines a target to use with MorphTargetManager
  23327. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23328. */
  23329. export class MorphTarget implements IAnimatable {
  23330. /** defines the name of the target */
  23331. name: string;
  23332. /**
  23333. * Gets or sets the list of animations
  23334. */
  23335. animations: import("babylonjs/Animations/animation").Animation[];
  23336. private _scene;
  23337. private _positions;
  23338. private _normals;
  23339. private _tangents;
  23340. private _uvs;
  23341. private _influence;
  23342. private _uniqueId;
  23343. /**
  23344. * Observable raised when the influence changes
  23345. */
  23346. onInfluenceChanged: Observable<boolean>;
  23347. /** @hidden */
  23348. _onDataLayoutChanged: Observable<void>;
  23349. /**
  23350. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23351. */
  23352. get influence(): number;
  23353. set influence(influence: number);
  23354. /**
  23355. * Gets or sets the id of the morph Target
  23356. */
  23357. id: string;
  23358. private _animationPropertiesOverride;
  23359. /**
  23360. * Gets or sets the animation properties override
  23361. */
  23362. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23363. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23364. /**
  23365. * Creates a new MorphTarget
  23366. * @param name defines the name of the target
  23367. * @param influence defines the influence to use
  23368. * @param scene defines the scene the morphtarget belongs to
  23369. */
  23370. constructor(
  23371. /** defines the name of the target */
  23372. name: string, influence?: number, scene?: Nullable<Scene>);
  23373. /**
  23374. * Gets the unique ID of this manager
  23375. */
  23376. get uniqueId(): number;
  23377. /**
  23378. * Gets a boolean defining if the target contains position data
  23379. */
  23380. get hasPositions(): boolean;
  23381. /**
  23382. * Gets a boolean defining if the target contains normal data
  23383. */
  23384. get hasNormals(): boolean;
  23385. /**
  23386. * Gets a boolean defining if the target contains tangent data
  23387. */
  23388. get hasTangents(): boolean;
  23389. /**
  23390. * Gets a boolean defining if the target contains texture coordinates data
  23391. */
  23392. get hasUVs(): boolean;
  23393. /**
  23394. * Affects position data to this target
  23395. * @param data defines the position data to use
  23396. */
  23397. setPositions(data: Nullable<FloatArray>): void;
  23398. /**
  23399. * Gets the position data stored in this target
  23400. * @returns a FloatArray containing the position data (or null if not present)
  23401. */
  23402. getPositions(): Nullable<FloatArray>;
  23403. /**
  23404. * Affects normal data to this target
  23405. * @param data defines the normal data to use
  23406. */
  23407. setNormals(data: Nullable<FloatArray>): void;
  23408. /**
  23409. * Gets the normal data stored in this target
  23410. * @returns a FloatArray containing the normal data (or null if not present)
  23411. */
  23412. getNormals(): Nullable<FloatArray>;
  23413. /**
  23414. * Affects tangent data to this target
  23415. * @param data defines the tangent data to use
  23416. */
  23417. setTangents(data: Nullable<FloatArray>): void;
  23418. /**
  23419. * Gets the tangent data stored in this target
  23420. * @returns a FloatArray containing the tangent data (or null if not present)
  23421. */
  23422. getTangents(): Nullable<FloatArray>;
  23423. /**
  23424. * Affects texture coordinates data to this target
  23425. * @param data defines the texture coordinates data to use
  23426. */
  23427. setUVs(data: Nullable<FloatArray>): void;
  23428. /**
  23429. * Gets the texture coordinates data stored in this target
  23430. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23431. */
  23432. getUVs(): Nullable<FloatArray>;
  23433. /**
  23434. * Clone the current target
  23435. * @returns a new MorphTarget
  23436. */
  23437. clone(): MorphTarget;
  23438. /**
  23439. * Serializes the current target into a Serialization object
  23440. * @returns the serialized object
  23441. */
  23442. serialize(): any;
  23443. /**
  23444. * Returns the string "MorphTarget"
  23445. * @returns "MorphTarget"
  23446. */
  23447. getClassName(): string;
  23448. /**
  23449. * Creates a new target from serialized data
  23450. * @param serializationObject defines the serialized data to use
  23451. * @returns a new MorphTarget
  23452. */
  23453. static Parse(serializationObject: any): MorphTarget;
  23454. /**
  23455. * Creates a MorphTarget from mesh data
  23456. * @param mesh defines the source mesh
  23457. * @param name defines the name to use for the new target
  23458. * @param influence defines the influence to attach to the target
  23459. * @returns a new MorphTarget
  23460. */
  23461. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23462. }
  23463. }
  23464. declare module "babylonjs/Morph/morphTargetManager" {
  23465. import { Nullable } from "babylonjs/types";
  23466. import { Scene } from "babylonjs/scene";
  23467. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23468. /**
  23469. * This class is used to deform meshes using morphing between different targets
  23470. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23471. */
  23472. export class MorphTargetManager {
  23473. private _targets;
  23474. private _targetInfluenceChangedObservers;
  23475. private _targetDataLayoutChangedObservers;
  23476. private _activeTargets;
  23477. private _scene;
  23478. private _influences;
  23479. private _supportsNormals;
  23480. private _supportsTangents;
  23481. private _supportsUVs;
  23482. private _vertexCount;
  23483. private _uniqueId;
  23484. private _tempInfluences;
  23485. /**
  23486. * Gets or sets a boolean indicating if normals must be morphed
  23487. */
  23488. enableNormalMorphing: boolean;
  23489. /**
  23490. * Gets or sets a boolean indicating if tangents must be morphed
  23491. */
  23492. enableTangentMorphing: boolean;
  23493. /**
  23494. * Gets or sets a boolean indicating if UV must be morphed
  23495. */
  23496. enableUVMorphing: boolean;
  23497. /**
  23498. * Creates a new MorphTargetManager
  23499. * @param scene defines the current scene
  23500. */
  23501. constructor(scene?: Nullable<Scene>);
  23502. /**
  23503. * Gets the unique ID of this manager
  23504. */
  23505. get uniqueId(): number;
  23506. /**
  23507. * Gets the number of vertices handled by this manager
  23508. */
  23509. get vertexCount(): number;
  23510. /**
  23511. * Gets a boolean indicating if this manager supports morphing of normals
  23512. */
  23513. get supportsNormals(): boolean;
  23514. /**
  23515. * Gets a boolean indicating if this manager supports morphing of tangents
  23516. */
  23517. get supportsTangents(): boolean;
  23518. /**
  23519. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23520. */
  23521. get supportsUVs(): boolean;
  23522. /**
  23523. * Gets the number of targets stored in this manager
  23524. */
  23525. get numTargets(): number;
  23526. /**
  23527. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23528. */
  23529. get numInfluencers(): number;
  23530. /**
  23531. * Gets the list of influences (one per target)
  23532. */
  23533. get influences(): Float32Array;
  23534. /**
  23535. * Gets the active target at specified index. An active target is a target with an influence > 0
  23536. * @param index defines the index to check
  23537. * @returns the requested target
  23538. */
  23539. getActiveTarget(index: number): MorphTarget;
  23540. /**
  23541. * Gets the target at specified index
  23542. * @param index defines the index to check
  23543. * @returns the requested target
  23544. */
  23545. getTarget(index: number): MorphTarget;
  23546. /**
  23547. * Add a new target to this manager
  23548. * @param target defines the target to add
  23549. */
  23550. addTarget(target: MorphTarget): void;
  23551. /**
  23552. * Removes a target from the manager
  23553. * @param target defines the target to remove
  23554. */
  23555. removeTarget(target: MorphTarget): void;
  23556. /**
  23557. * Clone the current manager
  23558. * @returns a new MorphTargetManager
  23559. */
  23560. clone(): MorphTargetManager;
  23561. /**
  23562. * Serializes the current manager into a Serialization object
  23563. * @returns the serialized object
  23564. */
  23565. serialize(): any;
  23566. private _syncActiveTargets;
  23567. /**
  23568. * Syncrhonize the targets with all the meshes using this morph target manager
  23569. */
  23570. synchronize(): void;
  23571. /**
  23572. * Creates a new MorphTargetManager from serialized data
  23573. * @param serializationObject defines the serialized data
  23574. * @param scene defines the hosting scene
  23575. * @returns the new MorphTargetManager
  23576. */
  23577. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23578. }
  23579. }
  23580. declare module "babylonjs/Meshes/meshLODLevel" {
  23581. import { Mesh } from "babylonjs/Meshes/mesh";
  23582. import { Nullable } from "babylonjs/types";
  23583. /**
  23584. * Class used to represent a specific level of detail of a mesh
  23585. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23586. */
  23587. export class MeshLODLevel {
  23588. /** Defines the distance where this level should start being displayed */
  23589. distance: number;
  23590. /** Defines the mesh to use to render this level */
  23591. mesh: Nullable<Mesh>;
  23592. /**
  23593. * Creates a new LOD level
  23594. * @param distance defines the distance where this level should star being displayed
  23595. * @param mesh defines the mesh to use to render this level
  23596. */
  23597. constructor(
  23598. /** Defines the distance where this level should start being displayed */
  23599. distance: number,
  23600. /** Defines the mesh to use to render this level */
  23601. mesh: Nullable<Mesh>);
  23602. }
  23603. }
  23604. declare module "babylonjs/Meshes/groundMesh" {
  23605. import { Scene } from "babylonjs/scene";
  23606. import { Vector3 } from "babylonjs/Maths/math.vector";
  23607. import { Mesh } from "babylonjs/Meshes/mesh";
  23608. /**
  23609. * Mesh representing the gorund
  23610. */
  23611. export class GroundMesh extends Mesh {
  23612. /** If octree should be generated */
  23613. generateOctree: boolean;
  23614. private _heightQuads;
  23615. /** @hidden */
  23616. _subdivisionsX: number;
  23617. /** @hidden */
  23618. _subdivisionsY: number;
  23619. /** @hidden */
  23620. _width: number;
  23621. /** @hidden */
  23622. _height: number;
  23623. /** @hidden */
  23624. _minX: number;
  23625. /** @hidden */
  23626. _maxX: number;
  23627. /** @hidden */
  23628. _minZ: number;
  23629. /** @hidden */
  23630. _maxZ: number;
  23631. constructor(name: string, scene: Scene);
  23632. /**
  23633. * "GroundMesh"
  23634. * @returns "GroundMesh"
  23635. */
  23636. getClassName(): string;
  23637. /**
  23638. * The minimum of x and y subdivisions
  23639. */
  23640. get subdivisions(): number;
  23641. /**
  23642. * X subdivisions
  23643. */
  23644. get subdivisionsX(): number;
  23645. /**
  23646. * Y subdivisions
  23647. */
  23648. get subdivisionsY(): number;
  23649. /**
  23650. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23651. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23652. * @param chunksCount the number of subdivisions for x and y
  23653. * @param octreeBlocksSize (Default: 32)
  23654. */
  23655. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23656. /**
  23657. * Returns a height (y) value in the Worl system :
  23658. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23659. * @param x x coordinate
  23660. * @param z z coordinate
  23661. * @returns the ground y position if (x, z) are outside the ground surface.
  23662. */
  23663. getHeightAtCoordinates(x: number, z: number): number;
  23664. /**
  23665. * Returns a normalized vector (Vector3) orthogonal to the ground
  23666. * at the ground coordinates (x, z) expressed in the World system.
  23667. * @param x x coordinate
  23668. * @param z z coordinate
  23669. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23670. */
  23671. getNormalAtCoordinates(x: number, z: number): Vector3;
  23672. /**
  23673. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23674. * at the ground coordinates (x, z) expressed in the World system.
  23675. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23676. * @param x x coordinate
  23677. * @param z z coordinate
  23678. * @param ref vector to store the result
  23679. * @returns the GroundMesh.
  23680. */
  23681. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23682. /**
  23683. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23684. * if the ground has been updated.
  23685. * This can be used in the render loop.
  23686. * @returns the GroundMesh.
  23687. */
  23688. updateCoordinateHeights(): GroundMesh;
  23689. private _getFacetAt;
  23690. private _initHeightQuads;
  23691. private _computeHeightQuads;
  23692. /**
  23693. * Serializes this ground mesh
  23694. * @param serializationObject object to write serialization to
  23695. */
  23696. serialize(serializationObject: any): void;
  23697. /**
  23698. * Parses a serialized ground mesh
  23699. * @param parsedMesh the serialized mesh
  23700. * @param scene the scene to create the ground mesh in
  23701. * @returns the created ground mesh
  23702. */
  23703. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23704. }
  23705. }
  23706. declare module "babylonjs/Physics/physicsJoint" {
  23707. import { Vector3 } from "babylonjs/Maths/math.vector";
  23708. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23709. /**
  23710. * Interface for Physics-Joint data
  23711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23712. */
  23713. export interface PhysicsJointData {
  23714. /**
  23715. * The main pivot of the joint
  23716. */
  23717. mainPivot?: Vector3;
  23718. /**
  23719. * The connected pivot of the joint
  23720. */
  23721. connectedPivot?: Vector3;
  23722. /**
  23723. * The main axis of the joint
  23724. */
  23725. mainAxis?: Vector3;
  23726. /**
  23727. * The connected axis of the joint
  23728. */
  23729. connectedAxis?: Vector3;
  23730. /**
  23731. * The collision of the joint
  23732. */
  23733. collision?: boolean;
  23734. /**
  23735. * Native Oimo/Cannon/Energy data
  23736. */
  23737. nativeParams?: any;
  23738. }
  23739. /**
  23740. * This is a holder class for the physics joint created by the physics plugin
  23741. * It holds a set of functions to control the underlying joint
  23742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23743. */
  23744. export class PhysicsJoint {
  23745. /**
  23746. * The type of the physics joint
  23747. */
  23748. type: number;
  23749. /**
  23750. * The data for the physics joint
  23751. */
  23752. jointData: PhysicsJointData;
  23753. private _physicsJoint;
  23754. protected _physicsPlugin: IPhysicsEnginePlugin;
  23755. /**
  23756. * Initializes the physics joint
  23757. * @param type The type of the physics joint
  23758. * @param jointData The data for the physics joint
  23759. */
  23760. constructor(
  23761. /**
  23762. * The type of the physics joint
  23763. */
  23764. type: number,
  23765. /**
  23766. * The data for the physics joint
  23767. */
  23768. jointData: PhysicsJointData);
  23769. /**
  23770. * Gets the physics joint
  23771. */
  23772. get physicsJoint(): any;
  23773. /**
  23774. * Sets the physics joint
  23775. */
  23776. set physicsJoint(newJoint: any);
  23777. /**
  23778. * Sets the physics plugin
  23779. */
  23780. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23781. /**
  23782. * Execute a function that is physics-plugin specific.
  23783. * @param {Function} func the function that will be executed.
  23784. * It accepts two parameters: the physics world and the physics joint
  23785. */
  23786. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23787. /**
  23788. * Distance-Joint type
  23789. */
  23790. static DistanceJoint: number;
  23791. /**
  23792. * Hinge-Joint type
  23793. */
  23794. static HingeJoint: number;
  23795. /**
  23796. * Ball-and-Socket joint type
  23797. */
  23798. static BallAndSocketJoint: number;
  23799. /**
  23800. * Wheel-Joint type
  23801. */
  23802. static WheelJoint: number;
  23803. /**
  23804. * Slider-Joint type
  23805. */
  23806. static SliderJoint: number;
  23807. /**
  23808. * Prismatic-Joint type
  23809. */
  23810. static PrismaticJoint: number;
  23811. /**
  23812. * Universal-Joint type
  23813. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23814. */
  23815. static UniversalJoint: number;
  23816. /**
  23817. * Hinge-Joint 2 type
  23818. */
  23819. static Hinge2Joint: number;
  23820. /**
  23821. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23822. */
  23823. static PointToPointJoint: number;
  23824. /**
  23825. * Spring-Joint type
  23826. */
  23827. static SpringJoint: number;
  23828. /**
  23829. * Lock-Joint type
  23830. */
  23831. static LockJoint: number;
  23832. }
  23833. /**
  23834. * A class representing a physics distance joint
  23835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23836. */
  23837. export class DistanceJoint extends PhysicsJoint {
  23838. /**
  23839. *
  23840. * @param jointData The data for the Distance-Joint
  23841. */
  23842. constructor(jointData: DistanceJointData);
  23843. /**
  23844. * Update the predefined distance.
  23845. * @param maxDistance The maximum preferred distance
  23846. * @param minDistance The minimum preferred distance
  23847. */
  23848. updateDistance(maxDistance: number, minDistance?: number): void;
  23849. }
  23850. /**
  23851. * Represents a Motor-Enabled Joint
  23852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23853. */
  23854. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23855. /**
  23856. * Initializes the Motor-Enabled Joint
  23857. * @param type The type of the joint
  23858. * @param jointData The physica joint data for the joint
  23859. */
  23860. constructor(type: number, jointData: PhysicsJointData);
  23861. /**
  23862. * Set the motor values.
  23863. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23864. * @param force the force to apply
  23865. * @param maxForce max force for this motor.
  23866. */
  23867. setMotor(force?: number, maxForce?: number): void;
  23868. /**
  23869. * Set the motor's limits.
  23870. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23871. * @param upperLimit The upper limit of the motor
  23872. * @param lowerLimit The lower limit of the motor
  23873. */
  23874. setLimit(upperLimit: number, lowerLimit?: number): void;
  23875. }
  23876. /**
  23877. * This class represents a single physics Hinge-Joint
  23878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23879. */
  23880. export class HingeJoint extends MotorEnabledJoint {
  23881. /**
  23882. * Initializes the Hinge-Joint
  23883. * @param jointData The joint data for the Hinge-Joint
  23884. */
  23885. constructor(jointData: PhysicsJointData);
  23886. /**
  23887. * Set the motor values.
  23888. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23889. * @param {number} force the force to apply
  23890. * @param {number} maxForce max force for this motor.
  23891. */
  23892. setMotor(force?: number, maxForce?: number): void;
  23893. /**
  23894. * Set the motor's limits.
  23895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23896. * @param upperLimit The upper limit of the motor
  23897. * @param lowerLimit The lower limit of the motor
  23898. */
  23899. setLimit(upperLimit: number, lowerLimit?: number): void;
  23900. }
  23901. /**
  23902. * This class represents a dual hinge physics joint (same as wheel joint)
  23903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23904. */
  23905. export class Hinge2Joint extends MotorEnabledJoint {
  23906. /**
  23907. * Initializes the Hinge2-Joint
  23908. * @param jointData The joint data for the Hinge2-Joint
  23909. */
  23910. constructor(jointData: PhysicsJointData);
  23911. /**
  23912. * Set the motor values.
  23913. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23914. * @param {number} targetSpeed the speed the motor is to reach
  23915. * @param {number} maxForce max force for this motor.
  23916. * @param {motorIndex} the motor's index, 0 or 1.
  23917. */
  23918. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23919. /**
  23920. * Set the motor limits.
  23921. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23922. * @param {number} upperLimit the upper limit
  23923. * @param {number} lowerLimit lower limit
  23924. * @param {motorIndex} the motor's index, 0 or 1.
  23925. */
  23926. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23927. }
  23928. /**
  23929. * Interface for a motor enabled joint
  23930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23931. */
  23932. export interface IMotorEnabledJoint {
  23933. /**
  23934. * Physics joint
  23935. */
  23936. physicsJoint: any;
  23937. /**
  23938. * Sets the motor of the motor-enabled joint
  23939. * @param force The force of the motor
  23940. * @param maxForce The maximum force of the motor
  23941. * @param motorIndex The index of the motor
  23942. */
  23943. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23944. /**
  23945. * Sets the limit of the motor
  23946. * @param upperLimit The upper limit of the motor
  23947. * @param lowerLimit The lower limit of the motor
  23948. * @param motorIndex The index of the motor
  23949. */
  23950. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23951. }
  23952. /**
  23953. * Joint data for a Distance-Joint
  23954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23955. */
  23956. export interface DistanceJointData extends PhysicsJointData {
  23957. /**
  23958. * Max distance the 2 joint objects can be apart
  23959. */
  23960. maxDistance: number;
  23961. }
  23962. /**
  23963. * Joint data from a spring joint
  23964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23965. */
  23966. export interface SpringJointData extends PhysicsJointData {
  23967. /**
  23968. * Length of the spring
  23969. */
  23970. length: number;
  23971. /**
  23972. * Stiffness of the spring
  23973. */
  23974. stiffness: number;
  23975. /**
  23976. * Damping of the spring
  23977. */
  23978. damping: number;
  23979. /** this callback will be called when applying the force to the impostors. */
  23980. forceApplicationCallback: () => void;
  23981. }
  23982. }
  23983. declare module "babylonjs/Physics/physicsRaycastResult" {
  23984. import { Vector3 } from "babylonjs/Maths/math.vector";
  23985. /**
  23986. * Holds the data for the raycast result
  23987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23988. */
  23989. export class PhysicsRaycastResult {
  23990. private _hasHit;
  23991. private _hitDistance;
  23992. private _hitNormalWorld;
  23993. private _hitPointWorld;
  23994. private _rayFromWorld;
  23995. private _rayToWorld;
  23996. /**
  23997. * Gets if there was a hit
  23998. */
  23999. get hasHit(): boolean;
  24000. /**
  24001. * Gets the distance from the hit
  24002. */
  24003. get hitDistance(): number;
  24004. /**
  24005. * Gets the hit normal/direction in the world
  24006. */
  24007. get hitNormalWorld(): Vector3;
  24008. /**
  24009. * Gets the hit point in the world
  24010. */
  24011. get hitPointWorld(): Vector3;
  24012. /**
  24013. * Gets the ray "start point" of the ray in the world
  24014. */
  24015. get rayFromWorld(): Vector3;
  24016. /**
  24017. * Gets the ray "end point" of the ray in the world
  24018. */
  24019. get rayToWorld(): Vector3;
  24020. /**
  24021. * Sets the hit data (normal & point in world space)
  24022. * @param hitNormalWorld defines the normal in world space
  24023. * @param hitPointWorld defines the point in world space
  24024. */
  24025. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24026. /**
  24027. * Sets the distance from the start point to the hit point
  24028. * @param distance
  24029. */
  24030. setHitDistance(distance: number): void;
  24031. /**
  24032. * Calculates the distance manually
  24033. */
  24034. calculateHitDistance(): void;
  24035. /**
  24036. * Resets all the values to default
  24037. * @param from The from point on world space
  24038. * @param to The to point on world space
  24039. */
  24040. reset(from?: Vector3, to?: Vector3): void;
  24041. }
  24042. /**
  24043. * Interface for the size containing width and height
  24044. */
  24045. interface IXYZ {
  24046. /**
  24047. * X
  24048. */
  24049. x: number;
  24050. /**
  24051. * Y
  24052. */
  24053. y: number;
  24054. /**
  24055. * Z
  24056. */
  24057. z: number;
  24058. }
  24059. }
  24060. declare module "babylonjs/Physics/IPhysicsEngine" {
  24061. import { Nullable } from "babylonjs/types";
  24062. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24064. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24065. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24066. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24067. /**
  24068. * Interface used to describe a physics joint
  24069. */
  24070. export interface PhysicsImpostorJoint {
  24071. /** Defines the main impostor to which the joint is linked */
  24072. mainImpostor: PhysicsImpostor;
  24073. /** Defines the impostor that is connected to the main impostor using this joint */
  24074. connectedImpostor: PhysicsImpostor;
  24075. /** Defines the joint itself */
  24076. joint: PhysicsJoint;
  24077. }
  24078. /** @hidden */
  24079. export interface IPhysicsEnginePlugin {
  24080. world: any;
  24081. name: string;
  24082. setGravity(gravity: Vector3): void;
  24083. setTimeStep(timeStep: number): void;
  24084. getTimeStep(): number;
  24085. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24086. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24087. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24088. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24089. removePhysicsBody(impostor: PhysicsImpostor): void;
  24090. generateJoint(joint: PhysicsImpostorJoint): void;
  24091. removeJoint(joint: PhysicsImpostorJoint): void;
  24092. isSupported(): boolean;
  24093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24094. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24095. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24096. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24097. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24098. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24099. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24100. getBodyMass(impostor: PhysicsImpostor): number;
  24101. getBodyFriction(impostor: PhysicsImpostor): number;
  24102. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24103. getBodyRestitution(impostor: PhysicsImpostor): number;
  24104. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24105. getBodyPressure?(impostor: PhysicsImpostor): number;
  24106. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24107. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24108. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24109. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24110. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24111. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24112. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24113. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24114. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24115. sleepBody(impostor: PhysicsImpostor): void;
  24116. wakeUpBody(impostor: PhysicsImpostor): void;
  24117. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24118. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24119. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24120. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24121. getRadius(impostor: PhysicsImpostor): number;
  24122. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24123. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24124. dispose(): void;
  24125. }
  24126. /**
  24127. * Interface used to define a physics engine
  24128. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24129. */
  24130. export interface IPhysicsEngine {
  24131. /**
  24132. * Gets the gravity vector used by the simulation
  24133. */
  24134. gravity: Vector3;
  24135. /**
  24136. * Sets the gravity vector used by the simulation
  24137. * @param gravity defines the gravity vector to use
  24138. */
  24139. setGravity(gravity: Vector3): void;
  24140. /**
  24141. * Set the time step of the physics engine.
  24142. * Default is 1/60.
  24143. * To slow it down, enter 1/600 for example.
  24144. * To speed it up, 1/30
  24145. * @param newTimeStep the new timestep to apply to this world.
  24146. */
  24147. setTimeStep(newTimeStep: number): void;
  24148. /**
  24149. * Get the time step of the physics engine.
  24150. * @returns the current time step
  24151. */
  24152. getTimeStep(): number;
  24153. /**
  24154. * Set the sub time step of the physics engine.
  24155. * Default is 0 meaning there is no sub steps
  24156. * To increase physics resolution precision, set a small value (like 1 ms)
  24157. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24158. */
  24159. setSubTimeStep(subTimeStep: number): void;
  24160. /**
  24161. * Get the sub time step of the physics engine.
  24162. * @returns the current sub time step
  24163. */
  24164. getSubTimeStep(): number;
  24165. /**
  24166. * Release all resources
  24167. */
  24168. dispose(): void;
  24169. /**
  24170. * Gets the name of the current physics plugin
  24171. * @returns the name of the plugin
  24172. */
  24173. getPhysicsPluginName(): string;
  24174. /**
  24175. * Adding a new impostor for the impostor tracking.
  24176. * This will be done by the impostor itself.
  24177. * @param impostor the impostor to add
  24178. */
  24179. addImpostor(impostor: PhysicsImpostor): void;
  24180. /**
  24181. * Remove an impostor from the engine.
  24182. * This impostor and its mesh will not longer be updated by the physics engine.
  24183. * @param impostor the impostor to remove
  24184. */
  24185. removeImpostor(impostor: PhysicsImpostor): void;
  24186. /**
  24187. * Add a joint to the physics engine
  24188. * @param mainImpostor defines the main impostor to which the joint is added.
  24189. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24190. * @param joint defines the joint that will connect both impostors.
  24191. */
  24192. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24193. /**
  24194. * Removes a joint from the simulation
  24195. * @param mainImpostor defines the impostor used with the joint
  24196. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24197. * @param joint defines the joint to remove
  24198. */
  24199. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24200. /**
  24201. * Gets the current plugin used to run the simulation
  24202. * @returns current plugin
  24203. */
  24204. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24205. /**
  24206. * Gets the list of physic impostors
  24207. * @returns an array of PhysicsImpostor
  24208. */
  24209. getImpostors(): Array<PhysicsImpostor>;
  24210. /**
  24211. * Gets the impostor for a physics enabled object
  24212. * @param object defines the object impersonated by the impostor
  24213. * @returns the PhysicsImpostor or null if not found
  24214. */
  24215. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24216. /**
  24217. * Gets the impostor for a physics body object
  24218. * @param body defines physics body used by the impostor
  24219. * @returns the PhysicsImpostor or null if not found
  24220. */
  24221. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24222. /**
  24223. * Does a raycast in the physics world
  24224. * @param from when should the ray start?
  24225. * @param to when should the ray end?
  24226. * @returns PhysicsRaycastResult
  24227. */
  24228. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24229. /**
  24230. * Called by the scene. No need to call it.
  24231. * @param delta defines the timespam between frames
  24232. */
  24233. _step(delta: number): void;
  24234. }
  24235. }
  24236. declare module "babylonjs/Physics/physicsImpostor" {
  24237. import { Nullable, IndicesArray } from "babylonjs/types";
  24238. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24241. import { Scene } from "babylonjs/scene";
  24242. import { Bone } from "babylonjs/Bones/bone";
  24243. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24244. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24245. import { Space } from "babylonjs/Maths/math.axis";
  24246. /**
  24247. * The interface for the physics imposter parameters
  24248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24249. */
  24250. export interface PhysicsImpostorParameters {
  24251. /**
  24252. * The mass of the physics imposter
  24253. */
  24254. mass: number;
  24255. /**
  24256. * The friction of the physics imposter
  24257. */
  24258. friction?: number;
  24259. /**
  24260. * The coefficient of restitution of the physics imposter
  24261. */
  24262. restitution?: number;
  24263. /**
  24264. * The native options of the physics imposter
  24265. */
  24266. nativeOptions?: any;
  24267. /**
  24268. * Specifies if the parent should be ignored
  24269. */
  24270. ignoreParent?: boolean;
  24271. /**
  24272. * Specifies if bi-directional transformations should be disabled
  24273. */
  24274. disableBidirectionalTransformation?: boolean;
  24275. /**
  24276. * The pressure inside the physics imposter, soft object only
  24277. */
  24278. pressure?: number;
  24279. /**
  24280. * The stiffness the physics imposter, soft object only
  24281. */
  24282. stiffness?: number;
  24283. /**
  24284. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24285. */
  24286. velocityIterations?: number;
  24287. /**
  24288. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24289. */
  24290. positionIterations?: number;
  24291. /**
  24292. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24293. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24294. * Add to fix multiple points
  24295. */
  24296. fixedPoints?: number;
  24297. /**
  24298. * The collision margin around a soft object
  24299. */
  24300. margin?: number;
  24301. /**
  24302. * The collision margin around a soft object
  24303. */
  24304. damping?: number;
  24305. /**
  24306. * The path for a rope based on an extrusion
  24307. */
  24308. path?: any;
  24309. /**
  24310. * The shape of an extrusion used for a rope based on an extrusion
  24311. */
  24312. shape?: any;
  24313. }
  24314. /**
  24315. * Interface for a physics-enabled object
  24316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24317. */
  24318. export interface IPhysicsEnabledObject {
  24319. /**
  24320. * The position of the physics-enabled object
  24321. */
  24322. position: Vector3;
  24323. /**
  24324. * The rotation of the physics-enabled object
  24325. */
  24326. rotationQuaternion: Nullable<Quaternion>;
  24327. /**
  24328. * The scale of the physics-enabled object
  24329. */
  24330. scaling: Vector3;
  24331. /**
  24332. * The rotation of the physics-enabled object
  24333. */
  24334. rotation?: Vector3;
  24335. /**
  24336. * The parent of the physics-enabled object
  24337. */
  24338. parent?: any;
  24339. /**
  24340. * The bounding info of the physics-enabled object
  24341. * @returns The bounding info of the physics-enabled object
  24342. */
  24343. getBoundingInfo(): BoundingInfo;
  24344. /**
  24345. * Computes the world matrix
  24346. * @param force Specifies if the world matrix should be computed by force
  24347. * @returns A world matrix
  24348. */
  24349. computeWorldMatrix(force: boolean): Matrix;
  24350. /**
  24351. * Gets the world matrix
  24352. * @returns A world matrix
  24353. */
  24354. getWorldMatrix?(): Matrix;
  24355. /**
  24356. * Gets the child meshes
  24357. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24358. * @returns An array of abstract meshes
  24359. */
  24360. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24361. /**
  24362. * Gets the vertex data
  24363. * @param kind The type of vertex data
  24364. * @returns A nullable array of numbers, or a float32 array
  24365. */
  24366. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24367. /**
  24368. * Gets the indices from the mesh
  24369. * @returns A nullable array of index arrays
  24370. */
  24371. getIndices?(): Nullable<IndicesArray>;
  24372. /**
  24373. * Gets the scene from the mesh
  24374. * @returns the indices array or null
  24375. */
  24376. getScene?(): Scene;
  24377. /**
  24378. * Gets the absolute position from the mesh
  24379. * @returns the absolute position
  24380. */
  24381. getAbsolutePosition(): Vector3;
  24382. /**
  24383. * Gets the absolute pivot point from the mesh
  24384. * @returns the absolute pivot point
  24385. */
  24386. getAbsolutePivotPoint(): Vector3;
  24387. /**
  24388. * Rotates the mesh
  24389. * @param axis The axis of rotation
  24390. * @param amount The amount of rotation
  24391. * @param space The space of the rotation
  24392. * @returns The rotation transform node
  24393. */
  24394. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24395. /**
  24396. * Translates the mesh
  24397. * @param axis The axis of translation
  24398. * @param distance The distance of translation
  24399. * @param space The space of the translation
  24400. * @returns The transform node
  24401. */
  24402. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24403. /**
  24404. * Sets the absolute position of the mesh
  24405. * @param absolutePosition The absolute position of the mesh
  24406. * @returns The transform node
  24407. */
  24408. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24409. /**
  24410. * Gets the class name of the mesh
  24411. * @returns The class name
  24412. */
  24413. getClassName(): string;
  24414. }
  24415. /**
  24416. * Represents a physics imposter
  24417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24418. */
  24419. export class PhysicsImpostor {
  24420. /**
  24421. * The physics-enabled object used as the physics imposter
  24422. */
  24423. object: IPhysicsEnabledObject;
  24424. /**
  24425. * The type of the physics imposter
  24426. */
  24427. type: number;
  24428. private _options;
  24429. private _scene?;
  24430. /**
  24431. * The default object size of the imposter
  24432. */
  24433. static DEFAULT_OBJECT_SIZE: Vector3;
  24434. /**
  24435. * The identity quaternion of the imposter
  24436. */
  24437. static IDENTITY_QUATERNION: Quaternion;
  24438. /** @hidden */
  24439. _pluginData: any;
  24440. private _physicsEngine;
  24441. private _physicsBody;
  24442. private _bodyUpdateRequired;
  24443. private _onBeforePhysicsStepCallbacks;
  24444. private _onAfterPhysicsStepCallbacks;
  24445. /** @hidden */
  24446. _onPhysicsCollideCallbacks: Array<{
  24447. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24448. otherImpostors: Array<PhysicsImpostor>;
  24449. }>;
  24450. private _deltaPosition;
  24451. private _deltaRotation;
  24452. private _deltaRotationConjugated;
  24453. /** @hidden */
  24454. _isFromLine: boolean;
  24455. private _parent;
  24456. private _isDisposed;
  24457. private static _tmpVecs;
  24458. private static _tmpQuat;
  24459. /**
  24460. * Specifies if the physics imposter is disposed
  24461. */
  24462. get isDisposed(): boolean;
  24463. /**
  24464. * Gets the mass of the physics imposter
  24465. */
  24466. get mass(): number;
  24467. set mass(value: number);
  24468. /**
  24469. * Gets the coefficient of friction
  24470. */
  24471. get friction(): number;
  24472. /**
  24473. * Sets the coefficient of friction
  24474. */
  24475. set friction(value: number);
  24476. /**
  24477. * Gets the coefficient of restitution
  24478. */
  24479. get restitution(): number;
  24480. /**
  24481. * Sets the coefficient of restitution
  24482. */
  24483. set restitution(value: number);
  24484. /**
  24485. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24486. */
  24487. get pressure(): number;
  24488. /**
  24489. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24490. */
  24491. set pressure(value: number);
  24492. /**
  24493. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24494. */
  24495. get stiffness(): number;
  24496. /**
  24497. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24498. */
  24499. set stiffness(value: number);
  24500. /**
  24501. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24502. */
  24503. get velocityIterations(): number;
  24504. /**
  24505. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24506. */
  24507. set velocityIterations(value: number);
  24508. /**
  24509. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24510. */
  24511. get positionIterations(): number;
  24512. /**
  24513. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24514. */
  24515. set positionIterations(value: number);
  24516. /**
  24517. * The unique id of the physics imposter
  24518. * set by the physics engine when adding this impostor to the array
  24519. */
  24520. uniqueId: number;
  24521. /**
  24522. * @hidden
  24523. */
  24524. soft: boolean;
  24525. /**
  24526. * @hidden
  24527. */
  24528. segments: number;
  24529. private _joints;
  24530. /**
  24531. * Initializes the physics imposter
  24532. * @param object The physics-enabled object used as the physics imposter
  24533. * @param type The type of the physics imposter
  24534. * @param _options The options for the physics imposter
  24535. * @param _scene The Babylon scene
  24536. */
  24537. constructor(
  24538. /**
  24539. * The physics-enabled object used as the physics imposter
  24540. */
  24541. object: IPhysicsEnabledObject,
  24542. /**
  24543. * The type of the physics imposter
  24544. */
  24545. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24546. /**
  24547. * This function will completly initialize this impostor.
  24548. * It will create a new body - but only if this mesh has no parent.
  24549. * If it has, this impostor will not be used other than to define the impostor
  24550. * of the child mesh.
  24551. * @hidden
  24552. */
  24553. _init(): void;
  24554. private _getPhysicsParent;
  24555. /**
  24556. * Should a new body be generated.
  24557. * @returns boolean specifying if body initialization is required
  24558. */
  24559. isBodyInitRequired(): boolean;
  24560. /**
  24561. * Sets the updated scaling
  24562. * @param updated Specifies if the scaling is updated
  24563. */
  24564. setScalingUpdated(): void;
  24565. /**
  24566. * Force a regeneration of this or the parent's impostor's body.
  24567. * Use under cautious - This will remove all joints already implemented.
  24568. */
  24569. forceUpdate(): void;
  24570. /**
  24571. * Gets the body that holds this impostor. Either its own, or its parent.
  24572. */
  24573. get physicsBody(): any;
  24574. /**
  24575. * Get the parent of the physics imposter
  24576. * @returns Physics imposter or null
  24577. */
  24578. get parent(): Nullable<PhysicsImpostor>;
  24579. /**
  24580. * Sets the parent of the physics imposter
  24581. */
  24582. set parent(value: Nullable<PhysicsImpostor>);
  24583. /**
  24584. * Set the physics body. Used mainly by the physics engine/plugin
  24585. */
  24586. set physicsBody(physicsBody: any);
  24587. /**
  24588. * Resets the update flags
  24589. */
  24590. resetUpdateFlags(): void;
  24591. /**
  24592. * Gets the object extend size
  24593. * @returns the object extend size
  24594. */
  24595. getObjectExtendSize(): Vector3;
  24596. /**
  24597. * Gets the object center
  24598. * @returns The object center
  24599. */
  24600. getObjectCenter(): Vector3;
  24601. /**
  24602. * Get a specific parameter from the options parameters
  24603. * @param paramName The object parameter name
  24604. * @returns The object parameter
  24605. */
  24606. getParam(paramName: string): any;
  24607. /**
  24608. * Sets a specific parameter in the options given to the physics plugin
  24609. * @param paramName The parameter name
  24610. * @param value The value of the parameter
  24611. */
  24612. setParam(paramName: string, value: number): void;
  24613. /**
  24614. * Specifically change the body's mass option. Won't recreate the physics body object
  24615. * @param mass The mass of the physics imposter
  24616. */
  24617. setMass(mass: number): void;
  24618. /**
  24619. * Gets the linear velocity
  24620. * @returns linear velocity or null
  24621. */
  24622. getLinearVelocity(): Nullable<Vector3>;
  24623. /**
  24624. * Sets the linear velocity
  24625. * @param velocity linear velocity or null
  24626. */
  24627. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24628. /**
  24629. * Gets the angular velocity
  24630. * @returns angular velocity or null
  24631. */
  24632. getAngularVelocity(): Nullable<Vector3>;
  24633. /**
  24634. * Sets the angular velocity
  24635. * @param velocity The velocity or null
  24636. */
  24637. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24638. /**
  24639. * Execute a function with the physics plugin native code
  24640. * Provide a function the will have two variables - the world object and the physics body object
  24641. * @param func The function to execute with the physics plugin native code
  24642. */
  24643. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24644. /**
  24645. * Register a function that will be executed before the physics world is stepping forward
  24646. * @param func The function to execute before the physics world is stepped forward
  24647. */
  24648. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24649. /**
  24650. * Unregister a function that will be executed before the physics world is stepping forward
  24651. * @param func The function to execute before the physics world is stepped forward
  24652. */
  24653. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24654. /**
  24655. * Register a function that will be executed after the physics step
  24656. * @param func The function to execute after physics step
  24657. */
  24658. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24659. /**
  24660. * Unregisters a function that will be executed after the physics step
  24661. * @param func The function to execute after physics step
  24662. */
  24663. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24664. /**
  24665. * register a function that will be executed when this impostor collides against a different body
  24666. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24667. * @param func Callback that is executed on collision
  24668. */
  24669. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24670. /**
  24671. * Unregisters the physics imposter on contact
  24672. * @param collideAgainst The physics object to collide against
  24673. * @param func Callback to execute on collision
  24674. */
  24675. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24676. private _tmpQuat;
  24677. private _tmpQuat2;
  24678. /**
  24679. * Get the parent rotation
  24680. * @returns The parent rotation
  24681. */
  24682. getParentsRotation(): Quaternion;
  24683. /**
  24684. * this function is executed by the physics engine.
  24685. */
  24686. beforeStep: () => void;
  24687. /**
  24688. * this function is executed by the physics engine
  24689. */
  24690. afterStep: () => void;
  24691. /**
  24692. * Legacy collision detection event support
  24693. */
  24694. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24695. /**
  24696. * event and body object due to cannon's event-based architecture.
  24697. */
  24698. onCollide: (e: {
  24699. body: any;
  24700. }) => void;
  24701. /**
  24702. * Apply a force
  24703. * @param force The force to apply
  24704. * @param contactPoint The contact point for the force
  24705. * @returns The physics imposter
  24706. */
  24707. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24708. /**
  24709. * Apply an impulse
  24710. * @param force The impulse force
  24711. * @param contactPoint The contact point for the impulse force
  24712. * @returns The physics imposter
  24713. */
  24714. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24715. /**
  24716. * A help function to create a joint
  24717. * @param otherImpostor A physics imposter used to create a joint
  24718. * @param jointType The type of joint
  24719. * @param jointData The data for the joint
  24720. * @returns The physics imposter
  24721. */
  24722. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24723. /**
  24724. * Add a joint to this impostor with a different impostor
  24725. * @param otherImpostor A physics imposter used to add a joint
  24726. * @param joint The joint to add
  24727. * @returns The physics imposter
  24728. */
  24729. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24730. /**
  24731. * Add an anchor to a cloth impostor
  24732. * @param otherImpostor rigid impostor to anchor to
  24733. * @param width ratio across width from 0 to 1
  24734. * @param height ratio up height from 0 to 1
  24735. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24736. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24737. * @returns impostor the soft imposter
  24738. */
  24739. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24740. /**
  24741. * Add a hook to a rope impostor
  24742. * @param otherImpostor rigid impostor to anchor to
  24743. * @param length ratio across rope from 0 to 1
  24744. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24745. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24746. * @returns impostor the rope imposter
  24747. */
  24748. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24749. /**
  24750. * Will keep this body still, in a sleep mode.
  24751. * @returns the physics imposter
  24752. */
  24753. sleep(): PhysicsImpostor;
  24754. /**
  24755. * Wake the body up.
  24756. * @returns The physics imposter
  24757. */
  24758. wakeUp(): PhysicsImpostor;
  24759. /**
  24760. * Clones the physics imposter
  24761. * @param newObject The physics imposter clones to this physics-enabled object
  24762. * @returns A nullable physics imposter
  24763. */
  24764. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24765. /**
  24766. * Disposes the physics imposter
  24767. */
  24768. dispose(): void;
  24769. /**
  24770. * Sets the delta position
  24771. * @param position The delta position amount
  24772. */
  24773. setDeltaPosition(position: Vector3): void;
  24774. /**
  24775. * Sets the delta rotation
  24776. * @param rotation The delta rotation amount
  24777. */
  24778. setDeltaRotation(rotation: Quaternion): void;
  24779. /**
  24780. * Gets the box size of the physics imposter and stores the result in the input parameter
  24781. * @param result Stores the box size
  24782. * @returns The physics imposter
  24783. */
  24784. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24785. /**
  24786. * Gets the radius of the physics imposter
  24787. * @returns Radius of the physics imposter
  24788. */
  24789. getRadius(): number;
  24790. /**
  24791. * Sync a bone with this impostor
  24792. * @param bone The bone to sync to the impostor.
  24793. * @param boneMesh The mesh that the bone is influencing.
  24794. * @param jointPivot The pivot of the joint / bone in local space.
  24795. * @param distToJoint Optional distance from the impostor to the joint.
  24796. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24797. */
  24798. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24799. /**
  24800. * Sync impostor to a bone
  24801. * @param bone The bone that the impostor will be synced to.
  24802. * @param boneMesh The mesh that the bone is influencing.
  24803. * @param jointPivot The pivot of the joint / bone in local space.
  24804. * @param distToJoint Optional distance from the impostor to the joint.
  24805. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24806. * @param boneAxis Optional vector3 axis the bone is aligned with
  24807. */
  24808. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24809. /**
  24810. * No-Imposter type
  24811. */
  24812. static NoImpostor: number;
  24813. /**
  24814. * Sphere-Imposter type
  24815. */
  24816. static SphereImpostor: number;
  24817. /**
  24818. * Box-Imposter type
  24819. */
  24820. static BoxImpostor: number;
  24821. /**
  24822. * Plane-Imposter type
  24823. */
  24824. static PlaneImpostor: number;
  24825. /**
  24826. * Mesh-imposter type
  24827. */
  24828. static MeshImpostor: number;
  24829. /**
  24830. * Capsule-Impostor type (Ammo.js plugin only)
  24831. */
  24832. static CapsuleImpostor: number;
  24833. /**
  24834. * Cylinder-Imposter type
  24835. */
  24836. static CylinderImpostor: number;
  24837. /**
  24838. * Particle-Imposter type
  24839. */
  24840. static ParticleImpostor: number;
  24841. /**
  24842. * Heightmap-Imposter type
  24843. */
  24844. static HeightmapImpostor: number;
  24845. /**
  24846. * ConvexHull-Impostor type (Ammo.js plugin only)
  24847. */
  24848. static ConvexHullImpostor: number;
  24849. /**
  24850. * Custom-Imposter type (Ammo.js plugin only)
  24851. */
  24852. static CustomImpostor: number;
  24853. /**
  24854. * Rope-Imposter type
  24855. */
  24856. static RopeImpostor: number;
  24857. /**
  24858. * Cloth-Imposter type
  24859. */
  24860. static ClothImpostor: number;
  24861. /**
  24862. * Softbody-Imposter type
  24863. */
  24864. static SoftbodyImpostor: number;
  24865. }
  24866. }
  24867. declare module "babylonjs/Meshes/mesh" {
  24868. import { Observable } from "babylonjs/Misc/observable";
  24869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24870. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24871. import { Camera } from "babylonjs/Cameras/camera";
  24872. import { Scene } from "babylonjs/scene";
  24873. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24874. import { Color4 } from "babylonjs/Maths/math.color";
  24875. import { Engine } from "babylonjs/Engines/engine";
  24876. import { Node } from "babylonjs/node";
  24877. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24878. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24879. import { Buffer } from "babylonjs/Meshes/buffer";
  24880. import { Geometry } from "babylonjs/Meshes/geometry";
  24881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24884. import { Effect } from "babylonjs/Materials/effect";
  24885. import { Material } from "babylonjs/Materials/material";
  24886. import { Skeleton } from "babylonjs/Bones/skeleton";
  24887. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24888. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24889. import { Path3D } from "babylonjs/Maths/math.path";
  24890. import { Plane } from "babylonjs/Maths/math.plane";
  24891. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24892. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24893. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24894. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24895. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24896. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24897. /**
  24898. * @hidden
  24899. **/
  24900. export class _CreationDataStorage {
  24901. closePath?: boolean;
  24902. closeArray?: boolean;
  24903. idx: number[];
  24904. dashSize: number;
  24905. gapSize: number;
  24906. path3D: Path3D;
  24907. pathArray: Vector3[][];
  24908. arc: number;
  24909. radius: number;
  24910. cap: number;
  24911. tessellation: number;
  24912. }
  24913. /**
  24914. * @hidden
  24915. **/
  24916. class _InstanceDataStorage {
  24917. visibleInstances: any;
  24918. batchCache: _InstancesBatch;
  24919. instancesBufferSize: number;
  24920. instancesBuffer: Nullable<Buffer>;
  24921. instancesData: Float32Array;
  24922. overridenInstanceCount: number;
  24923. isFrozen: boolean;
  24924. previousBatch: Nullable<_InstancesBatch>;
  24925. hardwareInstancedRendering: boolean;
  24926. sideOrientation: number;
  24927. manualUpdate: boolean;
  24928. }
  24929. /**
  24930. * @hidden
  24931. **/
  24932. export class _InstancesBatch {
  24933. mustReturn: boolean;
  24934. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24935. renderSelf: boolean[];
  24936. hardwareInstancedRendering: boolean[];
  24937. }
  24938. /**
  24939. * Class used to represent renderable models
  24940. */
  24941. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24942. /**
  24943. * Mesh side orientation : usually the external or front surface
  24944. */
  24945. static readonly FRONTSIDE: number;
  24946. /**
  24947. * Mesh side orientation : usually the internal or back surface
  24948. */
  24949. static readonly BACKSIDE: number;
  24950. /**
  24951. * Mesh side orientation : both internal and external or front and back surfaces
  24952. */
  24953. static readonly DOUBLESIDE: number;
  24954. /**
  24955. * Mesh side orientation : by default, `FRONTSIDE`
  24956. */
  24957. static readonly DEFAULTSIDE: number;
  24958. /**
  24959. * Mesh cap setting : no cap
  24960. */
  24961. static readonly NO_CAP: number;
  24962. /**
  24963. * Mesh cap setting : one cap at the beginning of the mesh
  24964. */
  24965. static readonly CAP_START: number;
  24966. /**
  24967. * Mesh cap setting : one cap at the end of the mesh
  24968. */
  24969. static readonly CAP_END: number;
  24970. /**
  24971. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24972. */
  24973. static readonly CAP_ALL: number;
  24974. /**
  24975. * Mesh pattern setting : no flip or rotate
  24976. */
  24977. static readonly NO_FLIP: number;
  24978. /**
  24979. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24980. */
  24981. static readonly FLIP_TILE: number;
  24982. /**
  24983. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24984. */
  24985. static readonly ROTATE_TILE: number;
  24986. /**
  24987. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24988. */
  24989. static readonly FLIP_ROW: number;
  24990. /**
  24991. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24992. */
  24993. static readonly ROTATE_ROW: number;
  24994. /**
  24995. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24996. */
  24997. static readonly FLIP_N_ROTATE_TILE: number;
  24998. /**
  24999. * Mesh pattern setting : rotate pattern and rotate
  25000. */
  25001. static readonly FLIP_N_ROTATE_ROW: number;
  25002. /**
  25003. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25004. */
  25005. static readonly CENTER: number;
  25006. /**
  25007. * Mesh tile positioning : part tiles on left
  25008. */
  25009. static readonly LEFT: number;
  25010. /**
  25011. * Mesh tile positioning : part tiles on right
  25012. */
  25013. static readonly RIGHT: number;
  25014. /**
  25015. * Mesh tile positioning : part tiles on top
  25016. */
  25017. static readonly TOP: number;
  25018. /**
  25019. * Mesh tile positioning : part tiles on bottom
  25020. */
  25021. static readonly BOTTOM: number;
  25022. /**
  25023. * Gets the default side orientation.
  25024. * @param orientation the orientation to value to attempt to get
  25025. * @returns the default orientation
  25026. * @hidden
  25027. */
  25028. static _GetDefaultSideOrientation(orientation?: number): number;
  25029. private _internalMeshDataInfo;
  25030. /**
  25031. * An event triggered before rendering the mesh
  25032. */
  25033. get onBeforeRenderObservable(): Observable<Mesh>;
  25034. /**
  25035. * An event triggered before binding the mesh
  25036. */
  25037. get onBeforeBindObservable(): Observable<Mesh>;
  25038. /**
  25039. * An event triggered after rendering the mesh
  25040. */
  25041. get onAfterRenderObservable(): Observable<Mesh>;
  25042. /**
  25043. * An event triggered before drawing the mesh
  25044. */
  25045. get onBeforeDrawObservable(): Observable<Mesh>;
  25046. private _onBeforeDrawObserver;
  25047. /**
  25048. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25049. */
  25050. set onBeforeDraw(callback: () => void);
  25051. get hasInstances(): boolean;
  25052. /**
  25053. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25054. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25055. */
  25056. delayLoadState: number;
  25057. /**
  25058. * Gets the list of instances created from this mesh
  25059. * it is not supposed to be modified manually.
  25060. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25061. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25062. */
  25063. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25064. /**
  25065. * Gets the file containing delay loading data for this mesh
  25066. */
  25067. delayLoadingFile: string;
  25068. /** @hidden */
  25069. _binaryInfo: any;
  25070. /**
  25071. * User defined function used to change how LOD level selection is done
  25072. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25073. */
  25074. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25075. /**
  25076. * Gets or sets the morph target manager
  25077. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25078. */
  25079. get morphTargetManager(): Nullable<MorphTargetManager>;
  25080. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25081. /** @hidden */
  25082. _creationDataStorage: Nullable<_CreationDataStorage>;
  25083. /** @hidden */
  25084. _geometry: Nullable<Geometry>;
  25085. /** @hidden */
  25086. _delayInfo: Array<string>;
  25087. /** @hidden */
  25088. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25089. /** @hidden */
  25090. _instanceDataStorage: _InstanceDataStorage;
  25091. private _effectiveMaterial;
  25092. /** @hidden */
  25093. _shouldGenerateFlatShading: boolean;
  25094. /** @hidden */
  25095. _originalBuilderSideOrientation: number;
  25096. /**
  25097. * Use this property to change the original side orientation defined at construction time
  25098. */
  25099. overrideMaterialSideOrientation: Nullable<number>;
  25100. /**
  25101. * Gets the source mesh (the one used to clone this one from)
  25102. */
  25103. get source(): Nullable<Mesh>;
  25104. /**
  25105. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25106. */
  25107. get isUnIndexed(): boolean;
  25108. set isUnIndexed(value: boolean);
  25109. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25110. get worldMatrixInstancedBuffer(): Float32Array;
  25111. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25112. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25113. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25114. /**
  25115. * @constructor
  25116. * @param name The value used by scene.getMeshByName() to do a lookup.
  25117. * @param scene The scene to add this mesh to.
  25118. * @param parent The parent of this mesh, if it has one
  25119. * @param source An optional Mesh from which geometry is shared, cloned.
  25120. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25121. * When false, achieved by calling a clone(), also passing False.
  25122. * This will make creation of children, recursive.
  25123. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25124. */
  25125. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25126. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25127. doNotInstantiate: boolean;
  25128. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25129. /**
  25130. * Gets the class name
  25131. * @returns the string "Mesh".
  25132. */
  25133. getClassName(): string;
  25134. /** @hidden */
  25135. get _isMesh(): boolean;
  25136. /**
  25137. * Returns a description of this mesh
  25138. * @param fullDetails define if full details about this mesh must be used
  25139. * @returns a descriptive string representing this mesh
  25140. */
  25141. toString(fullDetails?: boolean): string;
  25142. /** @hidden */
  25143. _unBindEffect(): void;
  25144. /**
  25145. * Gets a boolean indicating if this mesh has LOD
  25146. */
  25147. get hasLODLevels(): boolean;
  25148. /**
  25149. * Gets the list of MeshLODLevel associated with the current mesh
  25150. * @returns an array of MeshLODLevel
  25151. */
  25152. getLODLevels(): MeshLODLevel[];
  25153. private _sortLODLevels;
  25154. /**
  25155. * Add a mesh as LOD level triggered at the given distance.
  25156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25157. * @param distance The distance from the center of the object to show this level
  25158. * @param mesh The mesh to be added as LOD level (can be null)
  25159. * @return This mesh (for chaining)
  25160. */
  25161. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25162. /**
  25163. * Returns the LOD level mesh at the passed distance or null if not found.
  25164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25165. * @param distance The distance from the center of the object to show this level
  25166. * @returns a Mesh or `null`
  25167. */
  25168. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25169. /**
  25170. * Remove a mesh from the LOD array
  25171. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25172. * @param mesh defines the mesh to be removed
  25173. * @return This mesh (for chaining)
  25174. */
  25175. removeLODLevel(mesh: Mesh): Mesh;
  25176. /**
  25177. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25178. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25179. * @param camera defines the camera to use to compute distance
  25180. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25181. * @return This mesh (for chaining)
  25182. */
  25183. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25184. /**
  25185. * Gets the mesh internal Geometry object
  25186. */
  25187. get geometry(): Nullable<Geometry>;
  25188. /**
  25189. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25190. * @returns the total number of vertices
  25191. */
  25192. getTotalVertices(): number;
  25193. /**
  25194. * Returns the content of an associated vertex buffer
  25195. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25196. * - VertexBuffer.PositionKind
  25197. * - VertexBuffer.UVKind
  25198. * - VertexBuffer.UV2Kind
  25199. * - VertexBuffer.UV3Kind
  25200. * - VertexBuffer.UV4Kind
  25201. * - VertexBuffer.UV5Kind
  25202. * - VertexBuffer.UV6Kind
  25203. * - VertexBuffer.ColorKind
  25204. * - VertexBuffer.MatricesIndicesKind
  25205. * - VertexBuffer.MatricesIndicesExtraKind
  25206. * - VertexBuffer.MatricesWeightsKind
  25207. * - VertexBuffer.MatricesWeightsExtraKind
  25208. * @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
  25209. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25210. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25211. */
  25212. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25213. /**
  25214. * Returns the mesh VertexBuffer object from the requested `kind`
  25215. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25216. * - VertexBuffer.PositionKind
  25217. * - VertexBuffer.NormalKind
  25218. * - VertexBuffer.UVKind
  25219. * - VertexBuffer.UV2Kind
  25220. * - VertexBuffer.UV3Kind
  25221. * - VertexBuffer.UV4Kind
  25222. * - VertexBuffer.UV5Kind
  25223. * - VertexBuffer.UV6Kind
  25224. * - VertexBuffer.ColorKind
  25225. * - VertexBuffer.MatricesIndicesKind
  25226. * - VertexBuffer.MatricesIndicesExtraKind
  25227. * - VertexBuffer.MatricesWeightsKind
  25228. * - VertexBuffer.MatricesWeightsExtraKind
  25229. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25230. */
  25231. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25232. /**
  25233. * Tests if a specific vertex buffer is associated with this mesh
  25234. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25235. * - VertexBuffer.PositionKind
  25236. * - VertexBuffer.NormalKind
  25237. * - VertexBuffer.UVKind
  25238. * - VertexBuffer.UV2Kind
  25239. * - VertexBuffer.UV3Kind
  25240. * - VertexBuffer.UV4Kind
  25241. * - VertexBuffer.UV5Kind
  25242. * - VertexBuffer.UV6Kind
  25243. * - VertexBuffer.ColorKind
  25244. * - VertexBuffer.MatricesIndicesKind
  25245. * - VertexBuffer.MatricesIndicesExtraKind
  25246. * - VertexBuffer.MatricesWeightsKind
  25247. * - VertexBuffer.MatricesWeightsExtraKind
  25248. * @returns a boolean
  25249. */
  25250. isVerticesDataPresent(kind: string): boolean;
  25251. /**
  25252. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25253. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25254. * - VertexBuffer.PositionKind
  25255. * - VertexBuffer.UVKind
  25256. * - VertexBuffer.UV2Kind
  25257. * - VertexBuffer.UV3Kind
  25258. * - VertexBuffer.UV4Kind
  25259. * - VertexBuffer.UV5Kind
  25260. * - VertexBuffer.UV6Kind
  25261. * - VertexBuffer.ColorKind
  25262. * - VertexBuffer.MatricesIndicesKind
  25263. * - VertexBuffer.MatricesIndicesExtraKind
  25264. * - VertexBuffer.MatricesWeightsKind
  25265. * - VertexBuffer.MatricesWeightsExtraKind
  25266. * @returns a boolean
  25267. */
  25268. isVertexBufferUpdatable(kind: string): boolean;
  25269. /**
  25270. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25271. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25272. * - VertexBuffer.PositionKind
  25273. * - VertexBuffer.NormalKind
  25274. * - VertexBuffer.UVKind
  25275. * - VertexBuffer.UV2Kind
  25276. * - VertexBuffer.UV3Kind
  25277. * - VertexBuffer.UV4Kind
  25278. * - VertexBuffer.UV5Kind
  25279. * - VertexBuffer.UV6Kind
  25280. * - VertexBuffer.ColorKind
  25281. * - VertexBuffer.MatricesIndicesKind
  25282. * - VertexBuffer.MatricesIndicesExtraKind
  25283. * - VertexBuffer.MatricesWeightsKind
  25284. * - VertexBuffer.MatricesWeightsExtraKind
  25285. * @returns an array of strings
  25286. */
  25287. getVerticesDataKinds(): string[];
  25288. /**
  25289. * Returns a positive integer : the total number of indices in this mesh geometry.
  25290. * @returns the numner of indices or zero if the mesh has no geometry.
  25291. */
  25292. getTotalIndices(): number;
  25293. /**
  25294. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25295. * @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.
  25296. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25297. * @returns the indices array or an empty array if the mesh has no geometry
  25298. */
  25299. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25300. get isBlocked(): boolean;
  25301. /**
  25302. * Determine if the current mesh is ready to be rendered
  25303. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25304. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25305. * @returns true if all associated assets are ready (material, textures, shaders)
  25306. */
  25307. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25308. /**
  25309. * 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.
  25310. */
  25311. get areNormalsFrozen(): boolean;
  25312. /**
  25313. * 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.
  25314. * @returns the current mesh
  25315. */
  25316. freezeNormals(): Mesh;
  25317. /**
  25318. * 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
  25319. * @returns the current mesh
  25320. */
  25321. unfreezeNormals(): Mesh;
  25322. /**
  25323. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25324. */
  25325. set overridenInstanceCount(count: number);
  25326. /** @hidden */
  25327. _preActivate(): Mesh;
  25328. /** @hidden */
  25329. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25330. /** @hidden */
  25331. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25332. /**
  25333. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25334. * This means the mesh underlying bounding box and sphere are recomputed.
  25335. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25336. * @returns the current mesh
  25337. */
  25338. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25339. /** @hidden */
  25340. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25341. /**
  25342. * This function will subdivide the mesh into multiple submeshes
  25343. * @param count defines the expected number of submeshes
  25344. */
  25345. subdivide(count: number): void;
  25346. /**
  25347. * Copy a FloatArray into a specific associated vertex buffer
  25348. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25349. * - VertexBuffer.PositionKind
  25350. * - VertexBuffer.UVKind
  25351. * - VertexBuffer.UV2Kind
  25352. * - VertexBuffer.UV3Kind
  25353. * - VertexBuffer.UV4Kind
  25354. * - VertexBuffer.UV5Kind
  25355. * - VertexBuffer.UV6Kind
  25356. * - VertexBuffer.ColorKind
  25357. * - VertexBuffer.MatricesIndicesKind
  25358. * - VertexBuffer.MatricesIndicesExtraKind
  25359. * - VertexBuffer.MatricesWeightsKind
  25360. * - VertexBuffer.MatricesWeightsExtraKind
  25361. * @param data defines the data source
  25362. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25363. * @param stride defines the data stride size (can be null)
  25364. * @returns the current mesh
  25365. */
  25366. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25367. /**
  25368. * Delete a vertex buffer associated with this mesh
  25369. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25370. * - VertexBuffer.PositionKind
  25371. * - VertexBuffer.UVKind
  25372. * - VertexBuffer.UV2Kind
  25373. * - VertexBuffer.UV3Kind
  25374. * - VertexBuffer.UV4Kind
  25375. * - VertexBuffer.UV5Kind
  25376. * - VertexBuffer.UV6Kind
  25377. * - VertexBuffer.ColorKind
  25378. * - VertexBuffer.MatricesIndicesKind
  25379. * - VertexBuffer.MatricesIndicesExtraKind
  25380. * - VertexBuffer.MatricesWeightsKind
  25381. * - VertexBuffer.MatricesWeightsExtraKind
  25382. */
  25383. removeVerticesData(kind: string): void;
  25384. /**
  25385. * Flags an associated vertex buffer as updatable
  25386. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25387. * - VertexBuffer.PositionKind
  25388. * - VertexBuffer.UVKind
  25389. * - VertexBuffer.UV2Kind
  25390. * - VertexBuffer.UV3Kind
  25391. * - VertexBuffer.UV4Kind
  25392. * - VertexBuffer.UV5Kind
  25393. * - VertexBuffer.UV6Kind
  25394. * - VertexBuffer.ColorKind
  25395. * - VertexBuffer.MatricesIndicesKind
  25396. * - VertexBuffer.MatricesIndicesExtraKind
  25397. * - VertexBuffer.MatricesWeightsKind
  25398. * - VertexBuffer.MatricesWeightsExtraKind
  25399. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25400. */
  25401. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25402. /**
  25403. * Sets the mesh global Vertex Buffer
  25404. * @param buffer defines the buffer to use
  25405. * @returns the current mesh
  25406. */
  25407. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25408. /**
  25409. * Update a specific associated vertex buffer
  25410. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25411. * - VertexBuffer.PositionKind
  25412. * - VertexBuffer.UVKind
  25413. * - VertexBuffer.UV2Kind
  25414. * - VertexBuffer.UV3Kind
  25415. * - VertexBuffer.UV4Kind
  25416. * - VertexBuffer.UV5Kind
  25417. * - VertexBuffer.UV6Kind
  25418. * - VertexBuffer.ColorKind
  25419. * - VertexBuffer.MatricesIndicesKind
  25420. * - VertexBuffer.MatricesIndicesExtraKind
  25421. * - VertexBuffer.MatricesWeightsKind
  25422. * - VertexBuffer.MatricesWeightsExtraKind
  25423. * @param data defines the data source
  25424. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25425. * @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)
  25426. * @returns the current mesh
  25427. */
  25428. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25429. /**
  25430. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25431. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25432. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25433. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25434. * @returns the current mesh
  25435. */
  25436. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25437. /**
  25438. * Creates a un-shared specific occurence of the geometry for the mesh.
  25439. * @returns the current mesh
  25440. */
  25441. makeGeometryUnique(): Mesh;
  25442. /**
  25443. * Set the index buffer of this mesh
  25444. * @param indices defines the source data
  25445. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25446. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25447. * @returns the current mesh
  25448. */
  25449. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25450. /**
  25451. * Update the current index buffer
  25452. * @param indices defines the source data
  25453. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25454. * @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)
  25455. * @returns the current mesh
  25456. */
  25457. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25458. /**
  25459. * Invert the geometry to move from a right handed system to a left handed one.
  25460. * @returns the current mesh
  25461. */
  25462. toLeftHanded(): Mesh;
  25463. /** @hidden */
  25464. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25465. /** @hidden */
  25466. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25467. /**
  25468. * Registers for this mesh a javascript function called just before the rendering process
  25469. * @param func defines the function to call before rendering this mesh
  25470. * @returns the current mesh
  25471. */
  25472. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25473. /**
  25474. * Disposes a previously registered javascript function called before the rendering
  25475. * @param func defines the function to remove
  25476. * @returns the current mesh
  25477. */
  25478. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25479. /**
  25480. * Registers for this mesh a javascript function called just after the rendering is complete
  25481. * @param func defines the function to call after rendering this mesh
  25482. * @returns the current mesh
  25483. */
  25484. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25485. /**
  25486. * Disposes a previously registered javascript function called after the rendering.
  25487. * @param func defines the function to remove
  25488. * @returns the current mesh
  25489. */
  25490. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25491. /** @hidden */
  25492. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25493. /** @hidden */
  25494. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25495. /** @hidden */
  25496. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25497. /** @hidden */
  25498. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25499. /** @hidden */
  25500. _rebuild(): void;
  25501. /** @hidden */
  25502. _freeze(): void;
  25503. /** @hidden */
  25504. _unFreeze(): void;
  25505. /**
  25506. * 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
  25507. * @param subMesh defines the subMesh to render
  25508. * @param enableAlphaMode defines if alpha mode can be changed
  25509. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25510. * @returns the current mesh
  25511. */
  25512. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25513. private _onBeforeDraw;
  25514. /**
  25515. * Renormalize the mesh and patch it up if there are no weights
  25516. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25517. * However in the case of zero weights then we set just a single influence to 1.
  25518. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25519. */
  25520. cleanMatrixWeights(): void;
  25521. private normalizeSkinFourWeights;
  25522. private normalizeSkinWeightsAndExtra;
  25523. /**
  25524. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25525. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25526. * the user know there was an issue with importing the mesh
  25527. * @returns a validation object with skinned, valid and report string
  25528. */
  25529. validateSkinning(): {
  25530. skinned: boolean;
  25531. valid: boolean;
  25532. report: string;
  25533. };
  25534. /** @hidden */
  25535. _checkDelayState(): Mesh;
  25536. private _queueLoad;
  25537. /**
  25538. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25539. * A mesh is in the frustum if its bounding box intersects the frustum
  25540. * @param frustumPlanes defines the frustum to test
  25541. * @returns true if the mesh is in the frustum planes
  25542. */
  25543. isInFrustum(frustumPlanes: Plane[]): boolean;
  25544. /**
  25545. * Sets the mesh material by the material or multiMaterial `id` property
  25546. * @param id is a string identifying the material or the multiMaterial
  25547. * @returns the current mesh
  25548. */
  25549. setMaterialByID(id: string): Mesh;
  25550. /**
  25551. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25552. * @returns an array of IAnimatable
  25553. */
  25554. getAnimatables(): IAnimatable[];
  25555. /**
  25556. * Modifies the mesh geometry according to the passed transformation matrix.
  25557. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25558. * The mesh normals are modified using the same transformation.
  25559. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25560. * @param transform defines the transform matrix to use
  25561. * @see http://doc.babylonjs.com/resources/baking_transformations
  25562. * @returns the current mesh
  25563. */
  25564. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25565. /**
  25566. * Modifies the mesh geometry according to its own current World Matrix.
  25567. * The mesh World Matrix is then reset.
  25568. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25569. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25570. * @see http://doc.babylonjs.com/resources/baking_transformations
  25571. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25572. * @returns the current mesh
  25573. */
  25574. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25575. /** @hidden */
  25576. get _positions(): Nullable<Vector3[]>;
  25577. /** @hidden */
  25578. _resetPointsArrayCache(): Mesh;
  25579. /** @hidden */
  25580. _generatePointsArray(): boolean;
  25581. /**
  25582. * Returns a new Mesh object generated from the current mesh properties.
  25583. * This method must not get confused with createInstance()
  25584. * @param name is a string, the name given to the new mesh
  25585. * @param newParent can be any Node object (default `null`)
  25586. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25587. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25588. * @returns a new mesh
  25589. */
  25590. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25591. /**
  25592. * Releases resources associated with this mesh.
  25593. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25594. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25595. */
  25596. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25597. /** @hidden */
  25598. _disposeInstanceSpecificData(): void;
  25599. /**
  25600. * Modifies the mesh geometry according to a displacement map.
  25601. * 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.
  25602. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25603. * @param url is a string, the URL from the image file is to be downloaded.
  25604. * @param minHeight is the lower limit of the displacement.
  25605. * @param maxHeight is the upper limit of the displacement.
  25606. * @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.
  25607. * @param uvOffset is an optional vector2 used to offset UV.
  25608. * @param uvScale is an optional vector2 used to scale UV.
  25609. * @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.
  25610. * @returns the Mesh.
  25611. */
  25612. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25613. /**
  25614. * Modifies the mesh geometry according to a displacementMap buffer.
  25615. * 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.
  25616. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25617. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25618. * @param heightMapWidth is the width of the buffer image.
  25619. * @param heightMapHeight is the height of the buffer image.
  25620. * @param minHeight is the lower limit of the displacement.
  25621. * @param maxHeight is the upper limit of the displacement.
  25622. * @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.
  25623. * @param uvOffset is an optional vector2 used to offset UV.
  25624. * @param uvScale is an optional vector2 used to scale UV.
  25625. * @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.
  25626. * @returns the Mesh.
  25627. */
  25628. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25629. /**
  25630. * Modify the mesh to get a flat shading rendering.
  25631. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25632. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25633. * @returns current mesh
  25634. */
  25635. convertToFlatShadedMesh(): Mesh;
  25636. /**
  25637. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25638. * In other words, more vertices, no more indices and a single bigger VBO.
  25639. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25640. * @returns current mesh
  25641. */
  25642. convertToUnIndexedMesh(): Mesh;
  25643. /**
  25644. * Inverses facet orientations.
  25645. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25646. * @param flipNormals will also inverts the normals
  25647. * @returns current mesh
  25648. */
  25649. flipFaces(flipNormals?: boolean): Mesh;
  25650. /**
  25651. * Increase the number of facets and hence vertices in a mesh
  25652. * Vertex normals are interpolated from existing vertex normals
  25653. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25654. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25655. */
  25656. increaseVertices(numberPerEdge: number): void;
  25657. /**
  25658. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25659. * This will undo any application of covertToFlatShadedMesh
  25660. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25661. */
  25662. forceSharedVertices(): void;
  25663. /** @hidden */
  25664. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25665. /** @hidden */
  25666. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25667. /**
  25668. * Creates a new InstancedMesh object from the mesh model.
  25669. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25670. * @param name defines the name of the new instance
  25671. * @returns a new InstancedMesh
  25672. */
  25673. createInstance(name: string): InstancedMesh;
  25674. /**
  25675. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25676. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25677. * @returns the current mesh
  25678. */
  25679. synchronizeInstances(): Mesh;
  25680. /**
  25681. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25682. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25683. * This should be used together with the simplification to avoid disappearing triangles.
  25684. * @param successCallback an optional success callback to be called after the optimization finished.
  25685. * @returns the current mesh
  25686. */
  25687. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25688. /**
  25689. * Serialize current mesh
  25690. * @param serializationObject defines the object which will receive the serialization data
  25691. */
  25692. serialize(serializationObject: any): void;
  25693. /** @hidden */
  25694. _syncGeometryWithMorphTargetManager(): void;
  25695. /** @hidden */
  25696. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25697. /**
  25698. * Returns a new Mesh object parsed from the source provided.
  25699. * @param parsedMesh is the source
  25700. * @param scene defines the hosting scene
  25701. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25702. * @returns a new Mesh
  25703. */
  25704. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25705. /**
  25706. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25707. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25708. * @param name defines the name of the mesh to create
  25709. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25710. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25711. * @param closePath creates a seam between the first and the last points of each path of the path array
  25712. * @param offset is taken in account only if the `pathArray` is containing a single path
  25713. * @param scene defines the hosting scene
  25714. * @param updatable defines if the mesh must be flagged as updatable
  25715. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25716. * @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)
  25717. * @returns a new Mesh
  25718. */
  25719. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25720. /**
  25721. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25722. * @param name defines the name of the mesh to create
  25723. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25724. * @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
  25725. * @param scene defines the hosting scene
  25726. * @param updatable defines if the mesh must be flagged as updatable
  25727. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25728. * @returns a new Mesh
  25729. */
  25730. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25731. /**
  25732. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25733. * @param name defines the name of the mesh to create
  25734. * @param size sets the size (float) of each box side (default 1)
  25735. * @param scene defines the hosting scene
  25736. * @param updatable defines if the mesh must be flagged as updatable
  25737. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25738. * @returns a new Mesh
  25739. */
  25740. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25741. /**
  25742. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25743. * @param name defines the name of the mesh to create
  25744. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25745. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25746. * @param scene defines the hosting scene
  25747. * @param updatable defines if the mesh must be flagged as updatable
  25748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25749. * @returns a new Mesh
  25750. */
  25751. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25752. /**
  25753. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25754. * @param name defines the name of the mesh to create
  25755. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25756. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25757. * @param scene defines the hosting scene
  25758. * @returns a new Mesh
  25759. */
  25760. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25761. /**
  25762. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  25765. * @param diameterTop set the top cap diameter (floats, default 1)
  25766. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25767. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25768. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25769. * @param scene defines the hosting scene
  25770. * @param updatable defines if the mesh must be flagged as updatable
  25771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25772. * @returns a new Mesh
  25773. */
  25774. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25775. /**
  25776. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25777. * @param name defines the name of the mesh to create
  25778. * @param diameter sets the diameter size (float) of the torus (default 1)
  25779. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25780. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25781. * @param scene defines the hosting scene
  25782. * @param updatable defines if the mesh must be flagged as updatable
  25783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25784. * @returns a new Mesh
  25785. */
  25786. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25787. /**
  25788. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25789. * @param name defines the name of the mesh to create
  25790. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25791. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25792. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25793. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25794. * @param p the number of windings on X axis (positive integers, default 2)
  25795. * @param q the number of windings on Y axis (positive integers, default 3)
  25796. * @param scene defines the hosting scene
  25797. * @param updatable defines if the mesh must be flagged as updatable
  25798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25799. * @returns a new Mesh
  25800. */
  25801. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25802. /**
  25803. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25804. * @param name defines the name of the mesh to create
  25805. * @param points is an array successive Vector3
  25806. * @param scene defines the hosting scene
  25807. * @param updatable defines if the mesh must be flagged as updatable
  25808. * @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).
  25809. * @returns a new Mesh
  25810. */
  25811. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25812. /**
  25813. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25814. * @param name defines the name of the mesh to create
  25815. * @param points is an array successive Vector3
  25816. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25817. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25818. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25819. * @param scene defines the hosting scene
  25820. * @param updatable defines if the mesh must be flagged as updatable
  25821. * @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)
  25822. * @returns a new Mesh
  25823. */
  25824. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25825. /**
  25826. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25827. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25828. * 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.
  25829. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25830. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25831. * Remember you can only change the shape positions, not their number when updating a polygon.
  25832. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25833. * @param name defines the name of the mesh to create
  25834. * @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
  25835. * @param scene defines the hosting scene
  25836. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25837. * @param updatable defines if the mesh must be flagged as updatable
  25838. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25839. * @param earcutInjection can be used to inject your own earcut reference
  25840. * @returns a new Mesh
  25841. */
  25842. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25843. /**
  25844. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25845. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25846. * @param name defines the name of the mesh to create
  25847. * @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
  25848. * @param depth defines the height of extrusion
  25849. * @param scene defines the hosting scene
  25850. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25851. * @param updatable defines if the mesh must be flagged as updatable
  25852. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25853. * @param earcutInjection can be used to inject your own earcut reference
  25854. * @returns a new Mesh
  25855. */
  25856. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25857. /**
  25858. * Creates an extruded shape mesh.
  25859. * 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
  25860. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25861. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25862. * @param name defines the name of the mesh to create
  25863. * @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
  25864. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25865. * @param scale is the value to scale the shape
  25866. * @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
  25867. * @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
  25868. * @param scene defines the hosting scene
  25869. * @param updatable defines if the mesh must be flagged as updatable
  25870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25871. * @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)
  25872. * @returns a new Mesh
  25873. */
  25874. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25875. /**
  25876. * Creates an custom extruded shape mesh.
  25877. * The custom extrusion is a parametric shape.
  25878. * It has no predefined shape. Its final shape will depend on the input parameters.
  25879. * Please consider using the same method from the MeshBuilder class instead
  25880. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25881. * @param name defines the name of the mesh to create
  25882. * @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
  25883. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25884. * @param scaleFunction is a custom Javascript function called on each path point
  25885. * @param rotationFunction is a custom Javascript function called on each path point
  25886. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25887. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25888. * @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
  25889. * @param scene defines the hosting scene
  25890. * @param updatable defines if the mesh must be flagged as updatable
  25891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25892. * @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)
  25893. * @returns a new Mesh
  25894. */
  25895. 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;
  25896. /**
  25897. * Creates lathe mesh.
  25898. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25899. * Please consider using the same method from the MeshBuilder class instead
  25900. * @param name defines the name of the mesh to create
  25901. * @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
  25902. * @param radius is the radius value of the lathe
  25903. * @param tessellation is the side number of the lathe.
  25904. * @param scene defines the hosting scene
  25905. * @param updatable defines if the mesh must be flagged as updatable
  25906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25907. * @returns a new Mesh
  25908. */
  25909. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25910. /**
  25911. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25912. * @param name defines the name of the mesh to create
  25913. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25914. * @param scene defines the hosting scene
  25915. * @param updatable defines if the mesh must be flagged as updatable
  25916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25917. * @returns a new Mesh
  25918. */
  25919. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25920. /**
  25921. * Creates a ground mesh.
  25922. * Please consider using the same method from the MeshBuilder class instead
  25923. * @param name defines the name of the mesh to create
  25924. * @param width set the width of the ground
  25925. * @param height set the height of the ground
  25926. * @param subdivisions sets the number of subdivisions per side
  25927. * @param scene defines the hosting scene
  25928. * @param updatable defines if the mesh must be flagged as updatable
  25929. * @returns a new Mesh
  25930. */
  25931. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25932. /**
  25933. * Creates a tiled ground mesh.
  25934. * Please consider using the same method from the MeshBuilder class instead
  25935. * @param name defines the name of the mesh to create
  25936. * @param xmin set the ground minimum X coordinate
  25937. * @param zmin set the ground minimum Y coordinate
  25938. * @param xmax set the ground maximum X coordinate
  25939. * @param zmax set the ground maximum Z coordinate
  25940. * @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
  25941. * @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
  25942. * @param scene defines the hosting scene
  25943. * @param updatable defines if the mesh must be flagged as updatable
  25944. * @returns a new Mesh
  25945. */
  25946. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25947. w: number;
  25948. h: number;
  25949. }, precision: {
  25950. w: number;
  25951. h: number;
  25952. }, scene: Scene, updatable?: boolean): Mesh;
  25953. /**
  25954. * Creates a ground mesh from a height map.
  25955. * Please consider using the same method from the MeshBuilder class instead
  25956. * @see http://doc.babylonjs.com/babylon101/height_map
  25957. * @param name defines the name of the mesh to create
  25958. * @param url sets the URL of the height map image resource
  25959. * @param width set the ground width size
  25960. * @param height set the ground height size
  25961. * @param subdivisions sets the number of subdivision per side
  25962. * @param minHeight is the minimum altitude on the ground
  25963. * @param maxHeight is the maximum altitude on the ground
  25964. * @param scene defines the hosting scene
  25965. * @param updatable defines if the mesh must be flagged as updatable
  25966. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25967. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25968. * @returns a new Mesh
  25969. */
  25970. 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;
  25971. /**
  25972. * Creates a tube mesh.
  25973. * The tube is a parametric shape.
  25974. * It has no predefined shape. Its final shape will depend on the input parameters.
  25975. * Please consider using the same method from the MeshBuilder class instead
  25976. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25977. * @param name defines the name of the mesh to create
  25978. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25979. * @param radius sets the tube radius size
  25980. * @param tessellation is the number of sides on the tubular surface
  25981. * @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
  25982. * @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
  25983. * @param scene defines the hosting scene
  25984. * @param updatable defines if the mesh must be flagged as updatable
  25985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25986. * @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)
  25987. * @returns a new Mesh
  25988. */
  25989. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25990. (i: number, distance: number): number;
  25991. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25992. /**
  25993. * Creates a polyhedron mesh.
  25994. * Please consider using the same method from the MeshBuilder class instead.
  25995. * * 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
  25996. * * The parameter `size` (positive float, default 1) sets the polygon size
  25997. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25998. * * 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`
  25999. * * 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
  26000. * * 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)`)
  26001. * * 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
  26002. * * 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
  26003. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26004. * * If you create a double-sided mesh, you can choose what parts of 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
  26005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26006. * @param name defines the name of the mesh to create
  26007. * @param options defines the options used to create the mesh
  26008. * @param scene defines the hosting scene
  26009. * @returns a new Mesh
  26010. */
  26011. static CreatePolyhedron(name: string, options: {
  26012. type?: number;
  26013. size?: number;
  26014. sizeX?: number;
  26015. sizeY?: number;
  26016. sizeZ?: number;
  26017. custom?: any;
  26018. faceUV?: Vector4[];
  26019. faceColors?: Color4[];
  26020. updatable?: boolean;
  26021. sideOrientation?: number;
  26022. }, scene: Scene): Mesh;
  26023. /**
  26024. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26025. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26026. * * 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`)
  26027. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26028. * * 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
  26029. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26030. * * If you create a double-sided mesh, you can choose what parts of 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
  26031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26032. * @param name defines the name of the mesh
  26033. * @param options defines the options used to create the mesh
  26034. * @param scene defines the hosting scene
  26035. * @returns a new Mesh
  26036. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26037. */
  26038. static CreateIcoSphere(name: string, options: {
  26039. radius?: number;
  26040. flat?: boolean;
  26041. subdivisions?: number;
  26042. sideOrientation?: number;
  26043. updatable?: boolean;
  26044. }, scene: Scene): Mesh;
  26045. /**
  26046. * Creates a decal mesh.
  26047. * Please consider using the same method from the MeshBuilder class instead.
  26048. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26049. * @param name defines the name of the mesh
  26050. * @param sourceMesh defines the mesh receiving the decal
  26051. * @param position sets the position of the decal in world coordinates
  26052. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26053. * @param size sets the decal scaling
  26054. * @param angle sets the angle to rotate the decal
  26055. * @returns a new Mesh
  26056. */
  26057. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26058. /**
  26059. * Prepare internal position array for software CPU skinning
  26060. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26061. */
  26062. setPositionsForCPUSkinning(): Float32Array;
  26063. /**
  26064. * Prepare internal normal array for software CPU skinning
  26065. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26066. */
  26067. setNormalsForCPUSkinning(): Float32Array;
  26068. /**
  26069. * Updates the vertex buffer by applying transformation from the bones
  26070. * @param skeleton defines the skeleton to apply to current mesh
  26071. * @returns the current mesh
  26072. */
  26073. applySkeleton(skeleton: Skeleton): Mesh;
  26074. /**
  26075. * 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
  26076. * @param meshes defines the list of meshes to scan
  26077. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26078. */
  26079. static MinMax(meshes: AbstractMesh[]): {
  26080. min: Vector3;
  26081. max: Vector3;
  26082. };
  26083. /**
  26084. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26085. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26086. * @returns a vector3
  26087. */
  26088. static Center(meshesOrMinMaxVector: {
  26089. min: Vector3;
  26090. max: Vector3;
  26091. } | AbstractMesh[]): Vector3;
  26092. /**
  26093. * Merge the array of meshes into a single mesh for performance reasons.
  26094. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26095. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26096. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26097. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26098. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26099. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26100. * @returns a new mesh
  26101. */
  26102. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26103. /** @hidden */
  26104. addInstance(instance: InstancedMesh): void;
  26105. /** @hidden */
  26106. removeInstance(instance: InstancedMesh): void;
  26107. }
  26108. }
  26109. declare module "babylonjs/Cameras/camera" {
  26110. import { SmartArray } from "babylonjs/Misc/smartArray";
  26111. import { Observable } from "babylonjs/Misc/observable";
  26112. import { Nullable } from "babylonjs/types";
  26113. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26114. import { Scene } from "babylonjs/scene";
  26115. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26116. import { Node } from "babylonjs/node";
  26117. import { Mesh } from "babylonjs/Meshes/mesh";
  26118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26119. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26120. import { Viewport } from "babylonjs/Maths/math.viewport";
  26121. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26123. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26124. import { Ray } from "babylonjs/Culling/ray";
  26125. /**
  26126. * This is the base class of all the camera used in the application.
  26127. * @see http://doc.babylonjs.com/features/cameras
  26128. */
  26129. export class Camera extends Node {
  26130. /** @hidden */
  26131. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26132. /**
  26133. * This is the default projection mode used by the cameras.
  26134. * It helps recreating a feeling of perspective and better appreciate depth.
  26135. * This is the best way to simulate real life cameras.
  26136. */
  26137. static readonly PERSPECTIVE_CAMERA: number;
  26138. /**
  26139. * This helps creating camera with an orthographic mode.
  26140. * 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.
  26141. */
  26142. static readonly ORTHOGRAPHIC_CAMERA: number;
  26143. /**
  26144. * This is the default FOV mode for perspective cameras.
  26145. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26146. */
  26147. static readonly FOVMODE_VERTICAL_FIXED: number;
  26148. /**
  26149. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26150. */
  26151. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26152. /**
  26153. * This specifies ther is no need for a camera rig.
  26154. * Basically only one eye is rendered corresponding to the camera.
  26155. */
  26156. static readonly RIG_MODE_NONE: number;
  26157. /**
  26158. * Simulates a camera Rig with one blue eye and one red eye.
  26159. * This can be use with 3d blue and red glasses.
  26160. */
  26161. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26162. /**
  26163. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26164. */
  26165. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26166. /**
  26167. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26168. */
  26169. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26170. /**
  26171. * Defines that both eyes of the camera will be rendered over under each other.
  26172. */
  26173. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26174. /**
  26175. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26176. */
  26177. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26178. /**
  26179. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26180. */
  26181. static readonly RIG_MODE_VR: number;
  26182. /**
  26183. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26184. */
  26185. static readonly RIG_MODE_WEBVR: number;
  26186. /**
  26187. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26188. */
  26189. static readonly RIG_MODE_CUSTOM: number;
  26190. /**
  26191. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26192. */
  26193. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26194. /**
  26195. * Define the input manager associated with the camera.
  26196. */
  26197. inputs: CameraInputsManager<Camera>;
  26198. /** @hidden */
  26199. _position: Vector3;
  26200. /**
  26201. * Define the current local position of the camera in the scene
  26202. */
  26203. get position(): Vector3;
  26204. set position(newPosition: Vector3);
  26205. /**
  26206. * The vector the camera should consider as up.
  26207. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26208. */
  26209. upVector: Vector3;
  26210. /**
  26211. * Define the current limit on the left side for an orthographic camera
  26212. * In scene unit
  26213. */
  26214. orthoLeft: Nullable<number>;
  26215. /**
  26216. * Define the current limit on the right side for an orthographic camera
  26217. * In scene unit
  26218. */
  26219. orthoRight: Nullable<number>;
  26220. /**
  26221. * Define the current limit on the bottom side for an orthographic camera
  26222. * In scene unit
  26223. */
  26224. orthoBottom: Nullable<number>;
  26225. /**
  26226. * Define the current limit on the top side for an orthographic camera
  26227. * In scene unit
  26228. */
  26229. orthoTop: Nullable<number>;
  26230. /**
  26231. * Field Of View is set in Radians. (default is 0.8)
  26232. */
  26233. fov: number;
  26234. /**
  26235. * Define the minimum distance the camera can see from.
  26236. * This is important to note that the depth buffer are not infinite and the closer it starts
  26237. * the more your scene might encounter depth fighting issue.
  26238. */
  26239. minZ: number;
  26240. /**
  26241. * Define the maximum distance the camera can see to.
  26242. * This is important to note that the depth buffer are not infinite and the further it end
  26243. * the more your scene might encounter depth fighting issue.
  26244. */
  26245. maxZ: number;
  26246. /**
  26247. * Define the default inertia of the camera.
  26248. * This helps giving a smooth feeling to the camera movement.
  26249. */
  26250. inertia: number;
  26251. /**
  26252. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26253. */
  26254. mode: number;
  26255. /**
  26256. * Define whether the camera is intermediate.
  26257. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26258. */
  26259. isIntermediate: boolean;
  26260. /**
  26261. * Define the viewport of the camera.
  26262. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26263. */
  26264. viewport: Viewport;
  26265. /**
  26266. * Restricts the camera to viewing objects with the same layerMask.
  26267. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26268. */
  26269. layerMask: number;
  26270. /**
  26271. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26272. */
  26273. fovMode: number;
  26274. /**
  26275. * Rig mode of the camera.
  26276. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26277. * This is normally controlled byt the camera themselves as internal use.
  26278. */
  26279. cameraRigMode: number;
  26280. /**
  26281. * Defines the distance between both "eyes" in case of a RIG
  26282. */
  26283. interaxialDistance: number;
  26284. /**
  26285. * Defines if stereoscopic rendering is done side by side or over under.
  26286. */
  26287. isStereoscopicSideBySide: boolean;
  26288. /**
  26289. * 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
  26290. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26291. * else in the scene. (Eg. security camera)
  26292. *
  26293. * 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)
  26294. */
  26295. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26296. /**
  26297. * When set, the camera will render to this render target instead of the default canvas
  26298. *
  26299. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26300. */
  26301. outputRenderTarget: Nullable<RenderTargetTexture>;
  26302. /**
  26303. * Observable triggered when the camera view matrix has changed.
  26304. */
  26305. onViewMatrixChangedObservable: Observable<Camera>;
  26306. /**
  26307. * Observable triggered when the camera Projection matrix has changed.
  26308. */
  26309. onProjectionMatrixChangedObservable: Observable<Camera>;
  26310. /**
  26311. * Observable triggered when the inputs have been processed.
  26312. */
  26313. onAfterCheckInputsObservable: Observable<Camera>;
  26314. /**
  26315. * Observable triggered when reset has been called and applied to the camera.
  26316. */
  26317. onRestoreStateObservable: Observable<Camera>;
  26318. /**
  26319. * Is this camera a part of a rig system?
  26320. */
  26321. isRigCamera: boolean;
  26322. /**
  26323. * If isRigCamera set to true this will be set with the parent camera.
  26324. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26325. */
  26326. rigParent?: Camera;
  26327. /** @hidden */
  26328. _cameraRigParams: any;
  26329. /** @hidden */
  26330. _rigCameras: Camera[];
  26331. /** @hidden */
  26332. _rigPostProcess: Nullable<PostProcess>;
  26333. protected _webvrViewMatrix: Matrix;
  26334. /** @hidden */
  26335. _skipRendering: boolean;
  26336. /** @hidden */
  26337. _projectionMatrix: Matrix;
  26338. /** @hidden */
  26339. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26340. /** @hidden */
  26341. _activeMeshes: SmartArray<AbstractMesh>;
  26342. protected _globalPosition: Vector3;
  26343. /** @hidden */
  26344. _computedViewMatrix: Matrix;
  26345. private _doNotComputeProjectionMatrix;
  26346. private _transformMatrix;
  26347. private _frustumPlanes;
  26348. private _refreshFrustumPlanes;
  26349. private _storedFov;
  26350. private _stateStored;
  26351. /**
  26352. * Instantiates a new camera object.
  26353. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26354. * @see http://doc.babylonjs.com/features/cameras
  26355. * @param name Defines the name of the camera in the scene
  26356. * @param position Defines the position of the camera
  26357. * @param scene Defines the scene the camera belongs too
  26358. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26359. */
  26360. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26361. /**
  26362. * Store current camera state (fov, position, etc..)
  26363. * @returns the camera
  26364. */
  26365. storeState(): Camera;
  26366. /**
  26367. * Restores the camera state values if it has been stored. You must call storeState() first
  26368. */
  26369. protected _restoreStateValues(): boolean;
  26370. /**
  26371. * Restored camera state. You must call storeState() first.
  26372. * @returns true if restored and false otherwise
  26373. */
  26374. restoreState(): boolean;
  26375. /**
  26376. * Gets the class name of the camera.
  26377. * @returns the class name
  26378. */
  26379. getClassName(): string;
  26380. /** @hidden */
  26381. readonly _isCamera: boolean;
  26382. /**
  26383. * Gets a string representation of the camera useful for debug purpose.
  26384. * @param fullDetails Defines that a more verboe level of logging is required
  26385. * @returns the string representation
  26386. */
  26387. toString(fullDetails?: boolean): string;
  26388. /**
  26389. * Gets the current world space position of the camera.
  26390. */
  26391. get globalPosition(): Vector3;
  26392. /**
  26393. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26394. * @returns the active meshe list
  26395. */
  26396. getActiveMeshes(): SmartArray<AbstractMesh>;
  26397. /**
  26398. * Check whether a mesh is part of the current active mesh list of the camera
  26399. * @param mesh Defines the mesh to check
  26400. * @returns true if active, false otherwise
  26401. */
  26402. isActiveMesh(mesh: Mesh): boolean;
  26403. /**
  26404. * Is this camera ready to be used/rendered
  26405. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26406. * @return true if the camera is ready
  26407. */
  26408. isReady(completeCheck?: boolean): boolean;
  26409. /** @hidden */
  26410. _initCache(): void;
  26411. /** @hidden */
  26412. _updateCache(ignoreParentClass?: boolean): void;
  26413. /** @hidden */
  26414. _isSynchronized(): boolean;
  26415. /** @hidden */
  26416. _isSynchronizedViewMatrix(): boolean;
  26417. /** @hidden */
  26418. _isSynchronizedProjectionMatrix(): boolean;
  26419. /**
  26420. * Attach the input controls to a specific dom element to get the input from.
  26421. * @param element Defines the element the controls should be listened from
  26422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26423. */
  26424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26425. /**
  26426. * Detach the current controls from the specified dom element.
  26427. * @param element Defines the element to stop listening the inputs from
  26428. */
  26429. detachControl(element: HTMLElement): void;
  26430. /**
  26431. * Update the camera state according to the different inputs gathered during the frame.
  26432. */
  26433. update(): void;
  26434. /** @hidden */
  26435. _checkInputs(): void;
  26436. /** @hidden */
  26437. get rigCameras(): Camera[];
  26438. /**
  26439. * Gets the post process used by the rig cameras
  26440. */
  26441. get rigPostProcess(): Nullable<PostProcess>;
  26442. /**
  26443. * Internal, gets the first post proces.
  26444. * @returns the first post process to be run on this camera.
  26445. */
  26446. _getFirstPostProcess(): Nullable<PostProcess>;
  26447. private _cascadePostProcessesToRigCams;
  26448. /**
  26449. * Attach a post process to the camera.
  26450. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26451. * @param postProcess The post process to attach to the camera
  26452. * @param insertAt The position of the post process in case several of them are in use in the scene
  26453. * @returns the position the post process has been inserted at
  26454. */
  26455. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26456. /**
  26457. * Detach a post process to the camera.
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26459. * @param postProcess The post process to detach from the camera
  26460. */
  26461. detachPostProcess(postProcess: PostProcess): void;
  26462. /**
  26463. * Gets the current world matrix of the camera
  26464. */
  26465. getWorldMatrix(): Matrix;
  26466. /** @hidden */
  26467. _getViewMatrix(): Matrix;
  26468. /**
  26469. * Gets the current view matrix of the camera.
  26470. * @param force forces the camera to recompute the matrix without looking at the cached state
  26471. * @returns the view matrix
  26472. */
  26473. getViewMatrix(force?: boolean): Matrix;
  26474. /**
  26475. * Freeze the projection matrix.
  26476. * It will prevent the cache check of the camera projection compute and can speed up perf
  26477. * if no parameter of the camera are meant to change
  26478. * @param projection Defines manually a projection if necessary
  26479. */
  26480. freezeProjectionMatrix(projection?: Matrix): void;
  26481. /**
  26482. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26483. */
  26484. unfreezeProjectionMatrix(): void;
  26485. /**
  26486. * Gets the current projection matrix of the camera.
  26487. * @param force forces the camera to recompute the matrix without looking at the cached state
  26488. * @returns the projection matrix
  26489. */
  26490. getProjectionMatrix(force?: boolean): Matrix;
  26491. /**
  26492. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26493. * @returns a Matrix
  26494. */
  26495. getTransformationMatrix(): Matrix;
  26496. private _updateFrustumPlanes;
  26497. /**
  26498. * Checks if a cullable object (mesh...) is in the camera frustum
  26499. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26500. * @param target The object to check
  26501. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26502. * @returns true if the object is in frustum otherwise false
  26503. */
  26504. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26505. /**
  26506. * Checks if a cullable object (mesh...) is in the camera frustum
  26507. * Unlike isInFrustum this cheks the full bounding box
  26508. * @param target The object to check
  26509. * @returns true if the object is in frustum otherwise false
  26510. */
  26511. isCompletelyInFrustum(target: ICullable): boolean;
  26512. /**
  26513. * Gets a ray in the forward direction from the camera.
  26514. * @param length Defines the length of the ray to create
  26515. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26516. * @param origin Defines the start point of the ray which defaults to the camera position
  26517. * @returns the forward ray
  26518. */
  26519. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26520. /**
  26521. * Releases resources associated with this node.
  26522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26524. */
  26525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26526. /** @hidden */
  26527. _isLeftCamera: boolean;
  26528. /**
  26529. * Gets the left camera of a rig setup in case of Rigged Camera
  26530. */
  26531. get isLeftCamera(): boolean;
  26532. /** @hidden */
  26533. _isRightCamera: boolean;
  26534. /**
  26535. * Gets the right camera of a rig setup in case of Rigged Camera
  26536. */
  26537. get isRightCamera(): boolean;
  26538. /**
  26539. * Gets the left camera of a rig setup in case of Rigged Camera
  26540. */
  26541. get leftCamera(): Nullable<FreeCamera>;
  26542. /**
  26543. * Gets the right camera of a rig setup in case of Rigged Camera
  26544. */
  26545. get rightCamera(): Nullable<FreeCamera>;
  26546. /**
  26547. * Gets the left camera target of a rig setup in case of Rigged Camera
  26548. * @returns the target position
  26549. */
  26550. getLeftTarget(): Nullable<Vector3>;
  26551. /**
  26552. * Gets the right camera target of a rig setup in case of Rigged Camera
  26553. * @returns the target position
  26554. */
  26555. getRightTarget(): Nullable<Vector3>;
  26556. /**
  26557. * @hidden
  26558. */
  26559. setCameraRigMode(mode: number, rigParams: any): void;
  26560. /** @hidden */
  26561. static _setStereoscopicRigMode(camera: Camera): void;
  26562. /** @hidden */
  26563. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26564. /** @hidden */
  26565. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26566. /** @hidden */
  26567. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26568. /** @hidden */
  26569. _getVRProjectionMatrix(): Matrix;
  26570. protected _updateCameraRotationMatrix(): void;
  26571. protected _updateWebVRCameraRotationMatrix(): void;
  26572. /**
  26573. * This function MUST be overwritten by the different WebVR cameras available.
  26574. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26575. * @hidden
  26576. */
  26577. _getWebVRProjectionMatrix(): Matrix;
  26578. /**
  26579. * This function MUST be overwritten by the different WebVR cameras available.
  26580. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26581. * @hidden
  26582. */
  26583. _getWebVRViewMatrix(): Matrix;
  26584. /** @hidden */
  26585. setCameraRigParameter(name: string, value: any): void;
  26586. /**
  26587. * needs to be overridden by children so sub has required properties to be copied
  26588. * @hidden
  26589. */
  26590. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26591. /**
  26592. * May need to be overridden by children
  26593. * @hidden
  26594. */
  26595. _updateRigCameras(): void;
  26596. /** @hidden */
  26597. _setupInputs(): void;
  26598. /**
  26599. * Serialiaze the camera setup to a json represention
  26600. * @returns the JSON representation
  26601. */
  26602. serialize(): any;
  26603. /**
  26604. * Clones the current camera.
  26605. * @param name The cloned camera name
  26606. * @returns the cloned camera
  26607. */
  26608. clone(name: string): Camera;
  26609. /**
  26610. * Gets the direction of the camera relative to a given local axis.
  26611. * @param localAxis Defines the reference axis to provide a relative direction.
  26612. * @return the direction
  26613. */
  26614. getDirection(localAxis: Vector3): Vector3;
  26615. /**
  26616. * Returns the current camera absolute rotation
  26617. */
  26618. get absoluteRotation(): Quaternion;
  26619. /**
  26620. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26621. * @param localAxis Defines the reference axis to provide a relative direction.
  26622. * @param result Defines the vector to store the result in
  26623. */
  26624. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26625. /**
  26626. * Gets a camera constructor for a given camera type
  26627. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26628. * @param name The name of the camera the result will be able to instantiate
  26629. * @param scene The scene the result will construct the camera in
  26630. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26631. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26632. * @returns a factory method to construc the camera
  26633. */
  26634. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26635. /**
  26636. * Compute the world matrix of the camera.
  26637. * @returns the camera world matrix
  26638. */
  26639. computeWorldMatrix(): Matrix;
  26640. /**
  26641. * Parse a JSON and creates the camera from the parsed information
  26642. * @param parsedCamera The JSON to parse
  26643. * @param scene The scene to instantiate the camera in
  26644. * @returns the newly constructed camera
  26645. */
  26646. static Parse(parsedCamera: any, scene: Scene): Camera;
  26647. }
  26648. }
  26649. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26650. import { Nullable } from "babylonjs/types";
  26651. import { Scene } from "babylonjs/scene";
  26652. import { Vector4 } from "babylonjs/Maths/math.vector";
  26653. import { Mesh } from "babylonjs/Meshes/mesh";
  26654. /**
  26655. * Class containing static functions to help procedurally build meshes
  26656. */
  26657. export class DiscBuilder {
  26658. /**
  26659. * Creates a plane polygonal mesh. By default, this is a disc
  26660. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26661. * * 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
  26662. * * 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
  26663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26666. * @param name defines the name of the mesh
  26667. * @param options defines the options used to create the mesh
  26668. * @param scene defines the hosting scene
  26669. * @returns the plane polygonal mesh
  26670. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26671. */
  26672. static CreateDisc(name: string, options: {
  26673. radius?: number;
  26674. tessellation?: number;
  26675. arc?: number;
  26676. updatable?: boolean;
  26677. sideOrientation?: number;
  26678. frontUVs?: Vector4;
  26679. backUVs?: Vector4;
  26680. }, scene?: Nullable<Scene>): Mesh;
  26681. }
  26682. }
  26683. declare module "babylonjs/Materials/fresnelParameters" {
  26684. import { Color3 } from "babylonjs/Maths/math.color";
  26685. /**
  26686. * This represents all the required information to add a fresnel effect on a material:
  26687. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26688. */
  26689. export class FresnelParameters {
  26690. private _isEnabled;
  26691. /**
  26692. * Define if the fresnel effect is enable or not.
  26693. */
  26694. get isEnabled(): boolean;
  26695. set isEnabled(value: boolean);
  26696. /**
  26697. * Define the color used on edges (grazing angle)
  26698. */
  26699. leftColor: Color3;
  26700. /**
  26701. * Define the color used on center
  26702. */
  26703. rightColor: Color3;
  26704. /**
  26705. * Define bias applied to computed fresnel term
  26706. */
  26707. bias: number;
  26708. /**
  26709. * Defined the power exponent applied to fresnel term
  26710. */
  26711. power: number;
  26712. /**
  26713. * Clones the current fresnel and its valuues
  26714. * @returns a clone fresnel configuration
  26715. */
  26716. clone(): FresnelParameters;
  26717. /**
  26718. * Serializes the current fresnel parameters to a JSON representation.
  26719. * @return the JSON serialization
  26720. */
  26721. serialize(): any;
  26722. /**
  26723. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26724. * @param parsedFresnelParameters Define the JSON representation
  26725. * @returns the parsed parameters
  26726. */
  26727. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26728. }
  26729. }
  26730. declare module "babylonjs/Materials/pushMaterial" {
  26731. import { Nullable } from "babylonjs/types";
  26732. import { Scene } from "babylonjs/scene";
  26733. import { Matrix } from "babylonjs/Maths/math.vector";
  26734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26735. import { Mesh } from "babylonjs/Meshes/mesh";
  26736. import { Material } from "babylonjs/Materials/material";
  26737. import { Effect } from "babylonjs/Materials/effect";
  26738. /**
  26739. * Base class of materials working in push mode in babylon JS
  26740. * @hidden
  26741. */
  26742. export class PushMaterial extends Material {
  26743. protected _activeEffect: Effect;
  26744. protected _normalMatrix: Matrix;
  26745. /**
  26746. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26747. * This means that the material can keep using a previous shader while a new one is being compiled.
  26748. * This is mostly used when shader parallel compilation is supported (true by default)
  26749. */
  26750. allowShaderHotSwapping: boolean;
  26751. constructor(name: string, scene: Scene);
  26752. getEffect(): Effect;
  26753. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26754. /**
  26755. * Binds the given world matrix to the active effect
  26756. *
  26757. * @param world the matrix to bind
  26758. */
  26759. bindOnlyWorldMatrix(world: Matrix): void;
  26760. /**
  26761. * Binds the given normal matrix to the active effect
  26762. *
  26763. * @param normalMatrix the matrix to bind
  26764. */
  26765. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26766. bind(world: Matrix, mesh?: Mesh): void;
  26767. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26768. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26769. }
  26770. }
  26771. declare module "babylonjs/Materials/materialFlags" {
  26772. /**
  26773. * This groups all the flags used to control the materials channel.
  26774. */
  26775. export class MaterialFlags {
  26776. private static _DiffuseTextureEnabled;
  26777. /**
  26778. * Are diffuse textures enabled in the application.
  26779. */
  26780. static get DiffuseTextureEnabled(): boolean;
  26781. static set DiffuseTextureEnabled(value: boolean);
  26782. private static _AmbientTextureEnabled;
  26783. /**
  26784. * Are ambient textures enabled in the application.
  26785. */
  26786. static get AmbientTextureEnabled(): boolean;
  26787. static set AmbientTextureEnabled(value: boolean);
  26788. private static _OpacityTextureEnabled;
  26789. /**
  26790. * Are opacity textures enabled in the application.
  26791. */
  26792. static get OpacityTextureEnabled(): boolean;
  26793. static set OpacityTextureEnabled(value: boolean);
  26794. private static _ReflectionTextureEnabled;
  26795. /**
  26796. * Are reflection textures enabled in the application.
  26797. */
  26798. static get ReflectionTextureEnabled(): boolean;
  26799. static set ReflectionTextureEnabled(value: boolean);
  26800. private static _EmissiveTextureEnabled;
  26801. /**
  26802. * Are emissive textures enabled in the application.
  26803. */
  26804. static get EmissiveTextureEnabled(): boolean;
  26805. static set EmissiveTextureEnabled(value: boolean);
  26806. private static _SpecularTextureEnabled;
  26807. /**
  26808. * Are specular textures enabled in the application.
  26809. */
  26810. static get SpecularTextureEnabled(): boolean;
  26811. static set SpecularTextureEnabled(value: boolean);
  26812. private static _BumpTextureEnabled;
  26813. /**
  26814. * Are bump textures enabled in the application.
  26815. */
  26816. static get BumpTextureEnabled(): boolean;
  26817. static set BumpTextureEnabled(value: boolean);
  26818. private static _LightmapTextureEnabled;
  26819. /**
  26820. * Are lightmap textures enabled in the application.
  26821. */
  26822. static get LightmapTextureEnabled(): boolean;
  26823. static set LightmapTextureEnabled(value: boolean);
  26824. private static _RefractionTextureEnabled;
  26825. /**
  26826. * Are refraction textures enabled in the application.
  26827. */
  26828. static get RefractionTextureEnabled(): boolean;
  26829. static set RefractionTextureEnabled(value: boolean);
  26830. private static _ColorGradingTextureEnabled;
  26831. /**
  26832. * Are color grading textures enabled in the application.
  26833. */
  26834. static get ColorGradingTextureEnabled(): boolean;
  26835. static set ColorGradingTextureEnabled(value: boolean);
  26836. private static _FresnelEnabled;
  26837. /**
  26838. * Are fresnels enabled in the application.
  26839. */
  26840. static get FresnelEnabled(): boolean;
  26841. static set FresnelEnabled(value: boolean);
  26842. private static _ClearCoatTextureEnabled;
  26843. /**
  26844. * Are clear coat textures enabled in the application.
  26845. */
  26846. static get ClearCoatTextureEnabled(): boolean;
  26847. static set ClearCoatTextureEnabled(value: boolean);
  26848. private static _ClearCoatBumpTextureEnabled;
  26849. /**
  26850. * Are clear coat bump textures enabled in the application.
  26851. */
  26852. static get ClearCoatBumpTextureEnabled(): boolean;
  26853. static set ClearCoatBumpTextureEnabled(value: boolean);
  26854. private static _ClearCoatTintTextureEnabled;
  26855. /**
  26856. * Are clear coat tint textures enabled in the application.
  26857. */
  26858. static get ClearCoatTintTextureEnabled(): boolean;
  26859. static set ClearCoatTintTextureEnabled(value: boolean);
  26860. private static _SheenTextureEnabled;
  26861. /**
  26862. * Are sheen textures enabled in the application.
  26863. */
  26864. static get SheenTextureEnabled(): boolean;
  26865. static set SheenTextureEnabled(value: boolean);
  26866. private static _AnisotropicTextureEnabled;
  26867. /**
  26868. * Are anisotropic textures enabled in the application.
  26869. */
  26870. static get AnisotropicTextureEnabled(): boolean;
  26871. static set AnisotropicTextureEnabled(value: boolean);
  26872. private static _ThicknessTextureEnabled;
  26873. /**
  26874. * Are thickness textures enabled in the application.
  26875. */
  26876. static get ThicknessTextureEnabled(): boolean;
  26877. static set ThicknessTextureEnabled(value: boolean);
  26878. }
  26879. }
  26880. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26881. /** @hidden */
  26882. export var defaultFragmentDeclaration: {
  26883. name: string;
  26884. shader: string;
  26885. };
  26886. }
  26887. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26888. /** @hidden */
  26889. export var defaultUboDeclaration: {
  26890. name: string;
  26891. shader: string;
  26892. };
  26893. }
  26894. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26895. /** @hidden */
  26896. export var lightFragmentDeclaration: {
  26897. name: string;
  26898. shader: string;
  26899. };
  26900. }
  26901. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26902. /** @hidden */
  26903. export var lightUboDeclaration: {
  26904. name: string;
  26905. shader: string;
  26906. };
  26907. }
  26908. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26909. /** @hidden */
  26910. export var lightsFragmentFunctions: {
  26911. name: string;
  26912. shader: string;
  26913. };
  26914. }
  26915. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26916. /** @hidden */
  26917. export var shadowsFragmentFunctions: {
  26918. name: string;
  26919. shader: string;
  26920. };
  26921. }
  26922. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26923. /** @hidden */
  26924. export var fresnelFunction: {
  26925. name: string;
  26926. shader: string;
  26927. };
  26928. }
  26929. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26930. /** @hidden */
  26931. export var reflectionFunction: {
  26932. name: string;
  26933. shader: string;
  26934. };
  26935. }
  26936. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26937. /** @hidden */
  26938. export var bumpFragmentFunctions: {
  26939. name: string;
  26940. shader: string;
  26941. };
  26942. }
  26943. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26944. /** @hidden */
  26945. export var logDepthDeclaration: {
  26946. name: string;
  26947. shader: string;
  26948. };
  26949. }
  26950. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26951. /** @hidden */
  26952. export var bumpFragment: {
  26953. name: string;
  26954. shader: string;
  26955. };
  26956. }
  26957. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26958. /** @hidden */
  26959. export var depthPrePass: {
  26960. name: string;
  26961. shader: string;
  26962. };
  26963. }
  26964. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26965. /** @hidden */
  26966. export var lightFragment: {
  26967. name: string;
  26968. shader: string;
  26969. };
  26970. }
  26971. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26972. /** @hidden */
  26973. export var logDepthFragment: {
  26974. name: string;
  26975. shader: string;
  26976. };
  26977. }
  26978. declare module "babylonjs/Shaders/default.fragment" {
  26979. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26980. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26981. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26982. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26983. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26984. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26985. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26986. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26987. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26988. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26990. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26991. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26992. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26993. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26995. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26996. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26997. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26998. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26999. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27000. /** @hidden */
  27001. export var defaultPixelShader: {
  27002. name: string;
  27003. shader: string;
  27004. };
  27005. }
  27006. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27007. /** @hidden */
  27008. export var defaultVertexDeclaration: {
  27009. name: string;
  27010. shader: string;
  27011. };
  27012. }
  27013. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27014. /** @hidden */
  27015. export var bumpVertexDeclaration: {
  27016. name: string;
  27017. shader: string;
  27018. };
  27019. }
  27020. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27021. /** @hidden */
  27022. export var bumpVertex: {
  27023. name: string;
  27024. shader: string;
  27025. };
  27026. }
  27027. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27028. /** @hidden */
  27029. export var fogVertex: {
  27030. name: string;
  27031. shader: string;
  27032. };
  27033. }
  27034. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27035. /** @hidden */
  27036. export var shadowsVertex: {
  27037. name: string;
  27038. shader: string;
  27039. };
  27040. }
  27041. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27042. /** @hidden */
  27043. export var pointCloudVertex: {
  27044. name: string;
  27045. shader: string;
  27046. };
  27047. }
  27048. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27049. /** @hidden */
  27050. export var logDepthVertex: {
  27051. name: string;
  27052. shader: string;
  27053. };
  27054. }
  27055. declare module "babylonjs/Shaders/default.vertex" {
  27056. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27057. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27059. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27060. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27061. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27064. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27070. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27071. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27072. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27073. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27074. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27078. /** @hidden */
  27079. export var defaultVertexShader: {
  27080. name: string;
  27081. shader: string;
  27082. };
  27083. }
  27084. declare module "babylonjs/Materials/standardMaterial" {
  27085. import { SmartArray } from "babylonjs/Misc/smartArray";
  27086. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27087. import { Nullable } from "babylonjs/types";
  27088. import { Scene } from "babylonjs/scene";
  27089. import { Matrix } from "babylonjs/Maths/math.vector";
  27090. import { Color3 } from "babylonjs/Maths/math.color";
  27091. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27093. import { Mesh } from "babylonjs/Meshes/mesh";
  27094. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27095. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27096. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27097. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27098. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27101. import "babylonjs/Shaders/default.fragment";
  27102. import "babylonjs/Shaders/default.vertex";
  27103. /** @hidden */
  27104. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27105. MAINUV1: boolean;
  27106. MAINUV2: boolean;
  27107. DIFFUSE: boolean;
  27108. DIFFUSEDIRECTUV: number;
  27109. AMBIENT: boolean;
  27110. AMBIENTDIRECTUV: number;
  27111. OPACITY: boolean;
  27112. OPACITYDIRECTUV: number;
  27113. OPACITYRGB: boolean;
  27114. REFLECTION: boolean;
  27115. EMISSIVE: boolean;
  27116. EMISSIVEDIRECTUV: number;
  27117. SPECULAR: boolean;
  27118. SPECULARDIRECTUV: number;
  27119. BUMP: boolean;
  27120. BUMPDIRECTUV: number;
  27121. PARALLAX: boolean;
  27122. PARALLAXOCCLUSION: boolean;
  27123. SPECULAROVERALPHA: boolean;
  27124. CLIPPLANE: boolean;
  27125. CLIPPLANE2: boolean;
  27126. CLIPPLANE3: boolean;
  27127. CLIPPLANE4: boolean;
  27128. CLIPPLANE5: boolean;
  27129. CLIPPLANE6: boolean;
  27130. ALPHATEST: boolean;
  27131. DEPTHPREPASS: boolean;
  27132. ALPHAFROMDIFFUSE: boolean;
  27133. POINTSIZE: boolean;
  27134. FOG: boolean;
  27135. SPECULARTERM: boolean;
  27136. DIFFUSEFRESNEL: boolean;
  27137. OPACITYFRESNEL: boolean;
  27138. REFLECTIONFRESNEL: boolean;
  27139. REFRACTIONFRESNEL: boolean;
  27140. EMISSIVEFRESNEL: boolean;
  27141. FRESNEL: boolean;
  27142. NORMAL: boolean;
  27143. UV1: boolean;
  27144. UV2: boolean;
  27145. VERTEXCOLOR: boolean;
  27146. VERTEXALPHA: boolean;
  27147. NUM_BONE_INFLUENCERS: number;
  27148. BonesPerMesh: number;
  27149. BONETEXTURE: boolean;
  27150. INSTANCES: boolean;
  27151. GLOSSINESS: boolean;
  27152. ROUGHNESS: boolean;
  27153. EMISSIVEASILLUMINATION: boolean;
  27154. LINKEMISSIVEWITHDIFFUSE: boolean;
  27155. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27156. LIGHTMAP: boolean;
  27157. LIGHTMAPDIRECTUV: number;
  27158. OBJECTSPACE_NORMALMAP: boolean;
  27159. USELIGHTMAPASSHADOWMAP: boolean;
  27160. REFLECTIONMAP_3D: boolean;
  27161. REFLECTIONMAP_SPHERICAL: boolean;
  27162. REFLECTIONMAP_PLANAR: boolean;
  27163. REFLECTIONMAP_CUBIC: boolean;
  27164. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27165. REFLECTIONMAP_PROJECTION: boolean;
  27166. REFLECTIONMAP_SKYBOX: boolean;
  27167. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27168. REFLECTIONMAP_EXPLICIT: boolean;
  27169. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27170. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27171. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27172. INVERTCUBICMAP: boolean;
  27173. LOGARITHMICDEPTH: boolean;
  27174. REFRACTION: boolean;
  27175. REFRACTIONMAP_3D: boolean;
  27176. REFLECTIONOVERALPHA: boolean;
  27177. TWOSIDEDLIGHTING: boolean;
  27178. SHADOWFLOAT: boolean;
  27179. MORPHTARGETS: boolean;
  27180. MORPHTARGETS_NORMAL: boolean;
  27181. MORPHTARGETS_TANGENT: boolean;
  27182. MORPHTARGETS_UV: boolean;
  27183. NUM_MORPH_INFLUENCERS: number;
  27184. NONUNIFORMSCALING: boolean;
  27185. PREMULTIPLYALPHA: boolean;
  27186. IMAGEPROCESSING: boolean;
  27187. VIGNETTE: boolean;
  27188. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27189. VIGNETTEBLENDMODEOPAQUE: boolean;
  27190. TONEMAPPING: boolean;
  27191. TONEMAPPING_ACES: boolean;
  27192. CONTRAST: boolean;
  27193. COLORCURVES: boolean;
  27194. COLORGRADING: boolean;
  27195. COLORGRADING3D: boolean;
  27196. SAMPLER3DGREENDEPTH: boolean;
  27197. SAMPLER3DBGRMAP: boolean;
  27198. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27199. MULTIVIEW: boolean;
  27200. /**
  27201. * If the reflection texture on this material is in linear color space
  27202. * @hidden
  27203. */
  27204. IS_REFLECTION_LINEAR: boolean;
  27205. /**
  27206. * If the refraction texture on this material is in linear color space
  27207. * @hidden
  27208. */
  27209. IS_REFRACTION_LINEAR: boolean;
  27210. EXPOSURE: boolean;
  27211. constructor();
  27212. setReflectionMode(modeToEnable: string): void;
  27213. }
  27214. /**
  27215. * This is the default material used in Babylon. It is the best trade off between quality
  27216. * and performances.
  27217. * @see http://doc.babylonjs.com/babylon101/materials
  27218. */
  27219. export class StandardMaterial extends PushMaterial {
  27220. private _diffuseTexture;
  27221. /**
  27222. * The basic texture of the material as viewed under a light.
  27223. */
  27224. diffuseTexture: Nullable<BaseTexture>;
  27225. private _ambientTexture;
  27226. /**
  27227. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27228. */
  27229. ambientTexture: Nullable<BaseTexture>;
  27230. private _opacityTexture;
  27231. /**
  27232. * Define the transparency of the material from a texture.
  27233. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27234. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27235. */
  27236. opacityTexture: Nullable<BaseTexture>;
  27237. private _reflectionTexture;
  27238. /**
  27239. * Define the texture used to display the reflection.
  27240. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27241. */
  27242. reflectionTexture: Nullable<BaseTexture>;
  27243. private _emissiveTexture;
  27244. /**
  27245. * Define texture of the material as if self lit.
  27246. * This will be mixed in the final result even in the absence of light.
  27247. */
  27248. emissiveTexture: Nullable<BaseTexture>;
  27249. private _specularTexture;
  27250. /**
  27251. * Define how the color and intensity of the highlight given by the light in the material.
  27252. */
  27253. specularTexture: Nullable<BaseTexture>;
  27254. private _bumpTexture;
  27255. /**
  27256. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27257. * 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.
  27258. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27259. */
  27260. bumpTexture: Nullable<BaseTexture>;
  27261. private _lightmapTexture;
  27262. /**
  27263. * Complex lighting can be computationally expensive to compute at runtime.
  27264. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27265. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27266. */
  27267. lightmapTexture: Nullable<BaseTexture>;
  27268. private _refractionTexture;
  27269. /**
  27270. * Define the texture used to display the refraction.
  27271. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27272. */
  27273. refractionTexture: Nullable<BaseTexture>;
  27274. /**
  27275. * The color of the material lit by the environmental background lighting.
  27276. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27277. */
  27278. ambientColor: Color3;
  27279. /**
  27280. * The basic color of the material as viewed under a light.
  27281. */
  27282. diffuseColor: Color3;
  27283. /**
  27284. * Define how the color and intensity of the highlight given by the light in the material.
  27285. */
  27286. specularColor: Color3;
  27287. /**
  27288. * Define the color of the material as if self lit.
  27289. * This will be mixed in the final result even in the absence of light.
  27290. */
  27291. emissiveColor: Color3;
  27292. /**
  27293. * Defines how sharp are the highlights in the material.
  27294. * The bigger the value the sharper giving a more glossy feeling to the result.
  27295. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27296. */
  27297. specularPower: number;
  27298. private _useAlphaFromDiffuseTexture;
  27299. /**
  27300. * Does the transparency come from the diffuse texture alpha channel.
  27301. */
  27302. useAlphaFromDiffuseTexture: boolean;
  27303. private _useEmissiveAsIllumination;
  27304. /**
  27305. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27306. */
  27307. useEmissiveAsIllumination: boolean;
  27308. private _linkEmissiveWithDiffuse;
  27309. /**
  27310. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27311. * the emissive level when the final color is close to one.
  27312. */
  27313. linkEmissiveWithDiffuse: boolean;
  27314. private _useSpecularOverAlpha;
  27315. /**
  27316. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27317. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27318. */
  27319. useSpecularOverAlpha: boolean;
  27320. private _useReflectionOverAlpha;
  27321. /**
  27322. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27323. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27324. */
  27325. useReflectionOverAlpha: boolean;
  27326. private _disableLighting;
  27327. /**
  27328. * Does lights from the scene impacts this material.
  27329. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27330. */
  27331. disableLighting: boolean;
  27332. private _useObjectSpaceNormalMap;
  27333. /**
  27334. * Allows using an object space normal map (instead of tangent space).
  27335. */
  27336. useObjectSpaceNormalMap: boolean;
  27337. private _useParallax;
  27338. /**
  27339. * Is parallax enabled or not.
  27340. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27341. */
  27342. useParallax: boolean;
  27343. private _useParallaxOcclusion;
  27344. /**
  27345. * Is parallax occlusion enabled or not.
  27346. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27347. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27348. */
  27349. useParallaxOcclusion: boolean;
  27350. /**
  27351. * 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.
  27352. */
  27353. parallaxScaleBias: number;
  27354. private _roughness;
  27355. /**
  27356. * Helps to define how blurry the reflections should appears in the material.
  27357. */
  27358. roughness: number;
  27359. /**
  27360. * In case of refraction, define the value of the index of refraction.
  27361. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27362. */
  27363. indexOfRefraction: number;
  27364. /**
  27365. * Invert the refraction texture alongside the y axis.
  27366. * It can be useful with procedural textures or probe for instance.
  27367. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27368. */
  27369. invertRefractionY: boolean;
  27370. /**
  27371. * Defines the alpha limits in alpha test mode.
  27372. */
  27373. alphaCutOff: number;
  27374. private _useLightmapAsShadowmap;
  27375. /**
  27376. * In case of light mapping, define whether the map contains light or shadow informations.
  27377. */
  27378. useLightmapAsShadowmap: boolean;
  27379. private _diffuseFresnelParameters;
  27380. /**
  27381. * Define the diffuse fresnel parameters of the material.
  27382. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27383. */
  27384. diffuseFresnelParameters: FresnelParameters;
  27385. private _opacityFresnelParameters;
  27386. /**
  27387. * Define the opacity fresnel parameters of the material.
  27388. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27389. */
  27390. opacityFresnelParameters: FresnelParameters;
  27391. private _reflectionFresnelParameters;
  27392. /**
  27393. * Define the reflection fresnel parameters of the material.
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27395. */
  27396. reflectionFresnelParameters: FresnelParameters;
  27397. private _refractionFresnelParameters;
  27398. /**
  27399. * Define the refraction fresnel parameters of the material.
  27400. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27401. */
  27402. refractionFresnelParameters: FresnelParameters;
  27403. private _emissiveFresnelParameters;
  27404. /**
  27405. * Define the emissive fresnel parameters of the material.
  27406. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27407. */
  27408. emissiveFresnelParameters: FresnelParameters;
  27409. private _useReflectionFresnelFromSpecular;
  27410. /**
  27411. * If true automatically deducts the fresnels values from the material specularity.
  27412. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27413. */
  27414. useReflectionFresnelFromSpecular: boolean;
  27415. private _useGlossinessFromSpecularMapAlpha;
  27416. /**
  27417. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27418. */
  27419. useGlossinessFromSpecularMapAlpha: boolean;
  27420. private _maxSimultaneousLights;
  27421. /**
  27422. * Defines the maximum number of lights that can be used in the material
  27423. */
  27424. maxSimultaneousLights: number;
  27425. private _invertNormalMapX;
  27426. /**
  27427. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27428. */
  27429. invertNormalMapX: boolean;
  27430. private _invertNormalMapY;
  27431. /**
  27432. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27433. */
  27434. invertNormalMapY: boolean;
  27435. private _twoSidedLighting;
  27436. /**
  27437. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27438. */
  27439. twoSidedLighting: boolean;
  27440. /**
  27441. * Default configuration related to image processing available in the standard Material.
  27442. */
  27443. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27444. /**
  27445. * Gets the image processing configuration used either in this material.
  27446. */
  27447. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27448. /**
  27449. * Sets the Default image processing configuration used either in the this material.
  27450. *
  27451. * If sets to null, the scene one is in use.
  27452. */
  27453. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27454. /**
  27455. * Keep track of the image processing observer to allow dispose and replace.
  27456. */
  27457. private _imageProcessingObserver;
  27458. /**
  27459. * Attaches a new image processing configuration to the Standard Material.
  27460. * @param configuration
  27461. */
  27462. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27463. /**
  27464. * Gets wether the color curves effect is enabled.
  27465. */
  27466. get cameraColorCurvesEnabled(): boolean;
  27467. /**
  27468. * Sets wether the color curves effect is enabled.
  27469. */
  27470. set cameraColorCurvesEnabled(value: boolean);
  27471. /**
  27472. * Gets wether the color grading effect is enabled.
  27473. */
  27474. get cameraColorGradingEnabled(): boolean;
  27475. /**
  27476. * Gets wether the color grading effect is enabled.
  27477. */
  27478. set cameraColorGradingEnabled(value: boolean);
  27479. /**
  27480. * Gets wether tonemapping is enabled or not.
  27481. */
  27482. get cameraToneMappingEnabled(): boolean;
  27483. /**
  27484. * Sets wether tonemapping is enabled or not
  27485. */
  27486. set cameraToneMappingEnabled(value: boolean);
  27487. /**
  27488. * The camera exposure used on this material.
  27489. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27490. * This corresponds to a photographic exposure.
  27491. */
  27492. get cameraExposure(): number;
  27493. /**
  27494. * The camera exposure used on this material.
  27495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27496. * This corresponds to a photographic exposure.
  27497. */
  27498. set cameraExposure(value: number);
  27499. /**
  27500. * Gets The camera contrast used on this material.
  27501. */
  27502. get cameraContrast(): number;
  27503. /**
  27504. * Sets The camera contrast used on this material.
  27505. */
  27506. set cameraContrast(value: number);
  27507. /**
  27508. * Gets the Color Grading 2D Lookup Texture.
  27509. */
  27510. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27511. /**
  27512. * Sets the Color Grading 2D Lookup Texture.
  27513. */
  27514. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27515. /**
  27516. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27517. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27518. * 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;
  27519. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27520. */
  27521. get cameraColorCurves(): Nullable<ColorCurves>;
  27522. /**
  27523. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27524. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27525. * 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;
  27526. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27527. */
  27528. set cameraColorCurves(value: Nullable<ColorCurves>);
  27529. /**
  27530. * Custom callback helping to override the default shader used in the material.
  27531. */
  27532. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27533. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27534. protected _worldViewProjectionMatrix: Matrix;
  27535. protected _globalAmbientColor: Color3;
  27536. protected _useLogarithmicDepth: boolean;
  27537. protected _rebuildInParallel: boolean;
  27538. /**
  27539. * Instantiates a new standard material.
  27540. * This is the default material used in Babylon. It is the best trade off between quality
  27541. * and performances.
  27542. * @see http://doc.babylonjs.com/babylon101/materials
  27543. * @param name Define the name of the material in the scene
  27544. * @param scene Define the scene the material belong to
  27545. */
  27546. constructor(name: string, scene: Scene);
  27547. /**
  27548. * Gets a boolean indicating that current material needs to register RTT
  27549. */
  27550. get hasRenderTargetTextures(): boolean;
  27551. /**
  27552. * Gets the current class name of the material e.g. "StandardMaterial"
  27553. * Mainly use in serialization.
  27554. * @returns the class name
  27555. */
  27556. getClassName(): string;
  27557. /**
  27558. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27559. * You can try switching to logarithmic depth.
  27560. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27561. */
  27562. get useLogarithmicDepth(): boolean;
  27563. set useLogarithmicDepth(value: boolean);
  27564. /**
  27565. * Specifies if the material will require alpha blending
  27566. * @returns a boolean specifying if alpha blending is needed
  27567. */
  27568. needAlphaBlending(): boolean;
  27569. /**
  27570. * Specifies if this material should be rendered in alpha test mode
  27571. * @returns a boolean specifying if an alpha test is needed.
  27572. */
  27573. needAlphaTesting(): boolean;
  27574. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27575. /**
  27576. * Get the texture used for alpha test purpose.
  27577. * @returns the diffuse texture in case of the standard material.
  27578. */
  27579. getAlphaTestTexture(): Nullable<BaseTexture>;
  27580. /**
  27581. * Get if the submesh is ready to be used and all its information available.
  27582. * Child classes can use it to update shaders
  27583. * @param mesh defines the mesh to check
  27584. * @param subMesh defines which submesh to check
  27585. * @param useInstances specifies that instances should be used
  27586. * @returns a boolean indicating that the submesh is ready or not
  27587. */
  27588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27589. /**
  27590. * Builds the material UBO layouts.
  27591. * Used internally during the effect preparation.
  27592. */
  27593. buildUniformLayout(): void;
  27594. /**
  27595. * Unbinds the material from the mesh
  27596. */
  27597. unbind(): void;
  27598. /**
  27599. * Binds the submesh to this material by preparing the effect and shader to draw
  27600. * @param world defines the world transformation matrix
  27601. * @param mesh defines the mesh containing the submesh
  27602. * @param subMesh defines the submesh to bind the material to
  27603. */
  27604. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27605. /**
  27606. * Get the list of animatables in the material.
  27607. * @returns the list of animatables object used in the material
  27608. */
  27609. getAnimatables(): IAnimatable[];
  27610. /**
  27611. * Gets the active textures from the material
  27612. * @returns an array of textures
  27613. */
  27614. getActiveTextures(): BaseTexture[];
  27615. /**
  27616. * Specifies if the material uses a texture
  27617. * @param texture defines the texture to check against the material
  27618. * @returns a boolean specifying if the material uses the texture
  27619. */
  27620. hasTexture(texture: BaseTexture): boolean;
  27621. /**
  27622. * Disposes the material
  27623. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27624. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27625. */
  27626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27627. /**
  27628. * Makes a duplicate of the material, and gives it a new name
  27629. * @param name defines the new name for the duplicated material
  27630. * @returns the cloned material
  27631. */
  27632. clone(name: string): StandardMaterial;
  27633. /**
  27634. * Serializes this material in a JSON representation
  27635. * @returns the serialized material object
  27636. */
  27637. serialize(): any;
  27638. /**
  27639. * Creates a standard material from parsed material data
  27640. * @param source defines the JSON representation of the material
  27641. * @param scene defines the hosting scene
  27642. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27643. * @returns a new standard material
  27644. */
  27645. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27646. /**
  27647. * Are diffuse textures enabled in the application.
  27648. */
  27649. static get DiffuseTextureEnabled(): boolean;
  27650. static set DiffuseTextureEnabled(value: boolean);
  27651. /**
  27652. * Are ambient textures enabled in the application.
  27653. */
  27654. static get AmbientTextureEnabled(): boolean;
  27655. static set AmbientTextureEnabled(value: boolean);
  27656. /**
  27657. * Are opacity textures enabled in the application.
  27658. */
  27659. static get OpacityTextureEnabled(): boolean;
  27660. static set OpacityTextureEnabled(value: boolean);
  27661. /**
  27662. * Are reflection textures enabled in the application.
  27663. */
  27664. static get ReflectionTextureEnabled(): boolean;
  27665. static set ReflectionTextureEnabled(value: boolean);
  27666. /**
  27667. * Are emissive textures enabled in the application.
  27668. */
  27669. static get EmissiveTextureEnabled(): boolean;
  27670. static set EmissiveTextureEnabled(value: boolean);
  27671. /**
  27672. * Are specular textures enabled in the application.
  27673. */
  27674. static get SpecularTextureEnabled(): boolean;
  27675. static set SpecularTextureEnabled(value: boolean);
  27676. /**
  27677. * Are bump textures enabled in the application.
  27678. */
  27679. static get BumpTextureEnabled(): boolean;
  27680. static set BumpTextureEnabled(value: boolean);
  27681. /**
  27682. * Are lightmap textures enabled in the application.
  27683. */
  27684. static get LightmapTextureEnabled(): boolean;
  27685. static set LightmapTextureEnabled(value: boolean);
  27686. /**
  27687. * Are refraction textures enabled in the application.
  27688. */
  27689. static get RefractionTextureEnabled(): boolean;
  27690. static set RefractionTextureEnabled(value: boolean);
  27691. /**
  27692. * Are color grading textures enabled in the application.
  27693. */
  27694. static get ColorGradingTextureEnabled(): boolean;
  27695. static set ColorGradingTextureEnabled(value: boolean);
  27696. /**
  27697. * Are fresnels enabled in the application.
  27698. */
  27699. static get FresnelEnabled(): boolean;
  27700. static set FresnelEnabled(value: boolean);
  27701. }
  27702. }
  27703. declare module "babylonjs/Particles/solidParticleSystem" {
  27704. import { Nullable } from "babylonjs/types";
  27705. import { Vector3 } from "babylonjs/Maths/math.vector";
  27706. import { Mesh } from "babylonjs/Meshes/mesh";
  27707. import { Scene, IDisposable } from "babylonjs/scene";
  27708. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27709. import { Material } from "babylonjs/Materials/material";
  27710. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27711. /**
  27712. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27713. *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.
  27714. * The SPS is also a particle system. It provides some methods to manage the particles.
  27715. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27716. *
  27717. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27718. */
  27719. export class SolidParticleSystem implements IDisposable {
  27720. /**
  27721. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27722. * Example : var p = SPS.particles[i];
  27723. */
  27724. particles: SolidParticle[];
  27725. /**
  27726. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27727. */
  27728. nbParticles: number;
  27729. /**
  27730. * If the particles must ever face the camera (default false). Useful for planar particles.
  27731. */
  27732. billboard: boolean;
  27733. /**
  27734. * Recompute normals when adding a shape
  27735. */
  27736. recomputeNormals: boolean;
  27737. /**
  27738. * This a counter ofr your own usage. It's not set by any SPS functions.
  27739. */
  27740. counter: number;
  27741. /**
  27742. * The SPS name. This name is also given to the underlying mesh.
  27743. */
  27744. name: string;
  27745. /**
  27746. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27747. */
  27748. mesh: Mesh;
  27749. /**
  27750. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27751. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27752. */
  27753. vars: any;
  27754. /**
  27755. * This array is populated when the SPS is set as 'pickable'.
  27756. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27757. * Each element of this array is an object `{idx: int, faceId: int}`.
  27758. * `idx` is the picked particle index in the `SPS.particles` array
  27759. * `faceId` is the picked face index counted within this particle.
  27760. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27761. */
  27762. pickedParticles: {
  27763. idx: number;
  27764. faceId: number;
  27765. }[];
  27766. /**
  27767. * This array is populated when `enableDepthSort` is set to true.
  27768. * Each element of this array is an instance of the class DepthSortedParticle.
  27769. */
  27770. depthSortedParticles: DepthSortedParticle[];
  27771. /**
  27772. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27773. * @hidden
  27774. */
  27775. _bSphereOnly: boolean;
  27776. /**
  27777. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27778. * @hidden
  27779. */
  27780. _bSphereRadiusFactor: number;
  27781. private _scene;
  27782. private _positions;
  27783. private _indices;
  27784. private _normals;
  27785. private _colors;
  27786. private _uvs;
  27787. private _indices32;
  27788. private _positions32;
  27789. private _normals32;
  27790. private _fixedNormal32;
  27791. private _colors32;
  27792. private _uvs32;
  27793. private _index;
  27794. private _updatable;
  27795. private _pickable;
  27796. private _isVisibilityBoxLocked;
  27797. private _alwaysVisible;
  27798. private _depthSort;
  27799. private _expandable;
  27800. private _shapeCounter;
  27801. private _copy;
  27802. private _color;
  27803. private _computeParticleColor;
  27804. private _computeParticleTexture;
  27805. private _computeParticleRotation;
  27806. private _computeParticleVertex;
  27807. private _computeBoundingBox;
  27808. private _depthSortParticles;
  27809. private _camera;
  27810. private _mustUnrotateFixedNormals;
  27811. private _particlesIntersect;
  27812. private _needs32Bits;
  27813. private _isNotBuilt;
  27814. private _lastParticleId;
  27815. private _idxOfId;
  27816. private _multimaterialEnabled;
  27817. private _useModelMaterial;
  27818. private _indicesByMaterial;
  27819. private _materialIndexes;
  27820. private _depthSortFunction;
  27821. private _materialSortFunction;
  27822. private _materials;
  27823. private _multimaterial;
  27824. private _materialIndexesById;
  27825. private _defaultMaterial;
  27826. private _autoUpdateSubMeshes;
  27827. /**
  27828. * Creates a SPS (Solid Particle System) object.
  27829. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27830. * @param scene (Scene) is the scene in which the SPS is added.
  27831. * @param options defines the options of the sps e.g.
  27832. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27833. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27834. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27835. * * 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.
  27836. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27837. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27838. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27839. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27840. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27841. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27842. */
  27843. constructor(name: string, scene: Scene, options?: {
  27844. updatable?: boolean;
  27845. isPickable?: boolean;
  27846. enableDepthSort?: boolean;
  27847. particleIntersection?: boolean;
  27848. boundingSphereOnly?: boolean;
  27849. bSphereRadiusFactor?: number;
  27850. expandable?: boolean;
  27851. useModelMaterial?: boolean;
  27852. enableMultiMaterial?: boolean;
  27853. });
  27854. /**
  27855. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27856. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27857. * @returns the created mesh
  27858. */
  27859. buildMesh(): Mesh;
  27860. /**
  27861. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27862. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27863. * Thus the particles generated from `digest()` have their property `position` set yet.
  27864. * @param mesh ( Mesh ) is the mesh to be digested
  27865. * @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
  27866. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27867. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27868. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27869. * @returns the current SPS
  27870. */
  27871. digest(mesh: Mesh, options?: {
  27872. facetNb?: number;
  27873. number?: number;
  27874. delta?: number;
  27875. storage?: [];
  27876. }): SolidParticleSystem;
  27877. /**
  27878. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27879. * @hidden
  27880. */
  27881. private _unrotateFixedNormals;
  27882. /**
  27883. * Resets the temporary working copy particle
  27884. * @hidden
  27885. */
  27886. private _resetCopy;
  27887. /**
  27888. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27889. * @param p the current index in the positions array to be updated
  27890. * @param ind the current index in the indices array
  27891. * @param shape a Vector3 array, the shape geometry
  27892. * @param positions the positions array to be updated
  27893. * @param meshInd the shape indices array
  27894. * @param indices the indices array to be updated
  27895. * @param meshUV the shape uv array
  27896. * @param uvs the uv array to be updated
  27897. * @param meshCol the shape color array
  27898. * @param colors the color array to be updated
  27899. * @param meshNor the shape normals array
  27900. * @param normals the normals array to be updated
  27901. * @param idx the particle index
  27902. * @param idxInShape the particle index in its shape
  27903. * @param options the addShape() method passed options
  27904. * @model the particle model
  27905. * @hidden
  27906. */
  27907. private _meshBuilder;
  27908. /**
  27909. * Returns a shape Vector3 array from positions float array
  27910. * @param positions float array
  27911. * @returns a vector3 array
  27912. * @hidden
  27913. */
  27914. private _posToShape;
  27915. /**
  27916. * Returns a shapeUV array from a float uvs (array deep copy)
  27917. * @param uvs as a float array
  27918. * @returns a shapeUV array
  27919. * @hidden
  27920. */
  27921. private _uvsToShapeUV;
  27922. /**
  27923. * Adds a new particle object in the particles array
  27924. * @param idx particle index in particles array
  27925. * @param id particle id
  27926. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27927. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27928. * @param model particle ModelShape object
  27929. * @param shapeId model shape identifier
  27930. * @param idxInShape index of the particle in the current model
  27931. * @param bInfo model bounding info object
  27932. * @param storage target storage array, if any
  27933. * @hidden
  27934. */
  27935. private _addParticle;
  27936. /**
  27937. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27938. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27939. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27940. * @param nb (positive integer) the number of particles to be created from this model
  27941. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27942. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27943. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27944. * @returns the number of shapes in the system
  27945. */
  27946. addShape(mesh: Mesh, nb: number, options?: {
  27947. positionFunction?: any;
  27948. vertexFunction?: any;
  27949. storage?: [];
  27950. }): number;
  27951. /**
  27952. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27953. * @hidden
  27954. */
  27955. private _rebuildParticle;
  27956. /**
  27957. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27958. * @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.
  27959. * @returns the SPS.
  27960. */
  27961. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27962. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27963. * Returns an array with the removed particles.
  27964. * 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.
  27965. * The SPS can't be empty so at least one particle needs to remain in place.
  27966. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27967. * @param start index of the first particle to remove
  27968. * @param end index of the last particle to remove (included)
  27969. * @returns an array populated with the removed particles
  27970. */
  27971. removeParticles(start: number, end: number): SolidParticle[];
  27972. /**
  27973. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27974. * @param solidParticleArray an array populated with Solid Particles objects
  27975. * @returns the SPS
  27976. */
  27977. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27978. /**
  27979. * Creates a new particle and modifies the SPS mesh geometry :
  27980. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27981. * - calls _addParticle() to populate the particle array
  27982. * factorized code from addShape() and insertParticlesFromArray()
  27983. * @param idx particle index in the particles array
  27984. * @param i particle index in its shape
  27985. * @param modelShape particle ModelShape object
  27986. * @param shape shape vertex array
  27987. * @param meshInd shape indices array
  27988. * @param meshUV shape uv array
  27989. * @param meshCol shape color array
  27990. * @param meshNor shape normals array
  27991. * @param bbInfo shape bounding info
  27992. * @param storage target particle storage
  27993. * @options addShape() passed options
  27994. * @hidden
  27995. */
  27996. private _insertNewParticle;
  27997. /**
  27998. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27999. * This method calls `updateParticle()` for each particle of the SPS.
  28000. * For an animated SPS, it is usually called within the render loop.
  28001. * 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.
  28002. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28003. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28004. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28005. * @returns the SPS.
  28006. */
  28007. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28008. /**
  28009. * Disposes the SPS.
  28010. */
  28011. dispose(): void;
  28012. /**
  28013. * Returns a SolidParticle object from its identifier : particle.id
  28014. * @param id (integer) the particle Id
  28015. * @returns the searched particle or null if not found in the SPS.
  28016. */
  28017. getParticleById(id: number): Nullable<SolidParticle>;
  28018. /**
  28019. * Returns a new array populated with the particles having the passed shapeId.
  28020. * @param shapeId (integer) the shape identifier
  28021. * @returns a new solid particle array
  28022. */
  28023. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28024. /**
  28025. * Populates the passed array "ref" with the particles having the passed shapeId.
  28026. * @param shapeId the shape identifier
  28027. * @returns the SPS
  28028. * @param ref
  28029. */
  28030. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28031. /**
  28032. * Computes the required SubMeshes according the materials assigned to the particles.
  28033. * @returns the solid particle system.
  28034. * Does nothing if called before the SPS mesh is built.
  28035. */
  28036. computeSubMeshes(): SolidParticleSystem;
  28037. /**
  28038. * Sorts the solid particles by material when MultiMaterial is enabled.
  28039. * Updates the indices32 array.
  28040. * Updates the indicesByMaterial array.
  28041. * Updates the mesh indices array.
  28042. * @returns the SPS
  28043. * @hidden
  28044. */
  28045. private _sortParticlesByMaterial;
  28046. /**
  28047. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28048. * @hidden
  28049. */
  28050. private _setMaterialIndexesById;
  28051. /**
  28052. * Returns an array with unique values of Materials from the passed array
  28053. * @param array the material array to be checked and filtered
  28054. * @hidden
  28055. */
  28056. private _filterUniqueMaterialId;
  28057. /**
  28058. * Sets a new Standard Material as _defaultMaterial if not already set.
  28059. * @hidden
  28060. */
  28061. private _setDefaultMaterial;
  28062. /**
  28063. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28064. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28065. * @returns the SPS.
  28066. */
  28067. refreshVisibleSize(): SolidParticleSystem;
  28068. /**
  28069. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28070. * @param size the size (float) of the visibility box
  28071. * note : this doesn't lock the SPS mesh bounding box.
  28072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28073. */
  28074. setVisibilityBox(size: number): void;
  28075. /**
  28076. * Gets whether the SPS as always visible or not
  28077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28078. */
  28079. get isAlwaysVisible(): boolean;
  28080. /**
  28081. * Sets the SPS as always visible or not
  28082. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28083. */
  28084. set isAlwaysVisible(val: boolean);
  28085. /**
  28086. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28087. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28088. */
  28089. set isVisibilityBoxLocked(val: boolean);
  28090. /**
  28091. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28092. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28093. */
  28094. get isVisibilityBoxLocked(): boolean;
  28095. /**
  28096. * Tells to `setParticles()` to compute the particle rotations or not.
  28097. * Default value : true. The SPS is faster when it's set to false.
  28098. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28099. */
  28100. set computeParticleRotation(val: boolean);
  28101. /**
  28102. * Tells to `setParticles()` to compute the particle colors or not.
  28103. * Default value : true. The SPS is faster when it's set to false.
  28104. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28105. */
  28106. set computeParticleColor(val: boolean);
  28107. set computeParticleTexture(val: boolean);
  28108. /**
  28109. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28110. * Default value : false. The SPS is faster when it's set to false.
  28111. * Note : the particle custom vertex positions aren't stored values.
  28112. */
  28113. set computeParticleVertex(val: boolean);
  28114. /**
  28115. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28116. */
  28117. set computeBoundingBox(val: boolean);
  28118. /**
  28119. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28120. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28121. * Default : `true`
  28122. */
  28123. set depthSortParticles(val: boolean);
  28124. /**
  28125. * Gets if `setParticles()` computes 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. get computeParticleRotation(): boolean;
  28130. /**
  28131. * Gets if `setParticles()` computes 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. get computeParticleColor(): boolean;
  28136. /**
  28137. * Gets if `setParticles()` computes the particle textures or not.
  28138. * Default value : true. The SPS is faster when it's set to false.
  28139. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28140. */
  28141. get computeParticleTexture(): boolean;
  28142. /**
  28143. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28144. * Default value : false. The SPS is faster when it's set to false.
  28145. * Note : the particle custom vertex positions aren't stored values.
  28146. */
  28147. get computeParticleVertex(): boolean;
  28148. /**
  28149. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28150. */
  28151. get computeBoundingBox(): boolean;
  28152. /**
  28153. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28154. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28155. * Default : `true`
  28156. */
  28157. get depthSortParticles(): boolean;
  28158. /**
  28159. * Gets if the SPS is created as expandable at construction time.
  28160. * Default : `false`
  28161. */
  28162. get expandable(): boolean;
  28163. /**
  28164. * Gets if the SPS supports the Multi Materials
  28165. */
  28166. get multimaterialEnabled(): boolean;
  28167. /**
  28168. * Gets if the SPS uses the model materials for its own multimaterial.
  28169. */
  28170. get useModelMaterial(): boolean;
  28171. /**
  28172. * The SPS used material array.
  28173. */
  28174. get materials(): Material[];
  28175. /**
  28176. * Sets the SPS MultiMaterial from the passed materials.
  28177. * Note : the passed array is internally copied and not used then by reference.
  28178. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28179. */
  28180. setMultiMaterial(materials: Material[]): void;
  28181. /**
  28182. * The SPS computed multimaterial object
  28183. */
  28184. get multimaterial(): MultiMaterial;
  28185. set multimaterial(mm: MultiMaterial);
  28186. /**
  28187. * If the subMeshes must be updated on the next call to setParticles()
  28188. */
  28189. get autoUpdateSubMeshes(): boolean;
  28190. set autoUpdateSubMeshes(val: boolean);
  28191. /**
  28192. * This function does nothing. It may be overwritten to set all the particle first values.
  28193. * The SPS doesn't call this function, you may have to call it by your own.
  28194. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28195. */
  28196. initParticles(): void;
  28197. /**
  28198. * This function does nothing. It may be overwritten to recycle a particle.
  28199. * The SPS doesn't call this function, you may have to call it by your own.
  28200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28201. * @param particle The particle to recycle
  28202. * @returns the recycled particle
  28203. */
  28204. recycleParticle(particle: SolidParticle): SolidParticle;
  28205. /**
  28206. * Updates a particle : this function should be overwritten by the user.
  28207. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28208. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28209. * @example : just set a particle position or velocity and recycle conditions
  28210. * @param particle The particle to update
  28211. * @returns the updated particle
  28212. */
  28213. updateParticle(particle: SolidParticle): SolidParticle;
  28214. /**
  28215. * Updates a vertex of a particle : it can be overwritten by the user.
  28216. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28217. * @param particle the current particle
  28218. * @param vertex the current index of the current particle
  28219. * @param pt the index of the current vertex in the particle shape
  28220. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28221. * @example : just set a vertex particle position
  28222. * @returns the updated vertex
  28223. */
  28224. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28225. /**
  28226. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28227. * This does nothing and may be overwritten by the user.
  28228. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28229. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28230. * @param update the boolean update value actually passed to setParticles()
  28231. */
  28232. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28233. /**
  28234. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28235. * This will be passed three parameters.
  28236. * This does nothing and may be overwritten by the user.
  28237. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28238. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28239. * @param update the boolean update value actually passed to setParticles()
  28240. */
  28241. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28242. }
  28243. }
  28244. declare module "babylonjs/Particles/solidParticle" {
  28245. import { Nullable } from "babylonjs/types";
  28246. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28247. import { Color4 } from "babylonjs/Maths/math.color";
  28248. import { Mesh } from "babylonjs/Meshes/mesh";
  28249. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28250. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28251. import { Plane } from "babylonjs/Maths/math.plane";
  28252. import { Material } from "babylonjs/Materials/material";
  28253. /**
  28254. * Represents one particle of a solid particle system.
  28255. */
  28256. export class SolidParticle {
  28257. /**
  28258. * particle global index
  28259. */
  28260. idx: number;
  28261. /**
  28262. * particle identifier
  28263. */
  28264. id: number;
  28265. /**
  28266. * The color of the particle
  28267. */
  28268. color: Nullable<Color4>;
  28269. /**
  28270. * The world space position of the particle.
  28271. */
  28272. position: Vector3;
  28273. /**
  28274. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28275. */
  28276. rotation: Vector3;
  28277. /**
  28278. * The world space rotation quaternion of the particle.
  28279. */
  28280. rotationQuaternion: Nullable<Quaternion>;
  28281. /**
  28282. * The scaling of the particle.
  28283. */
  28284. scaling: Vector3;
  28285. /**
  28286. * The uvs of the particle.
  28287. */
  28288. uvs: Vector4;
  28289. /**
  28290. * The current speed of the particle.
  28291. */
  28292. velocity: Vector3;
  28293. /**
  28294. * The pivot point in the particle local space.
  28295. */
  28296. pivot: Vector3;
  28297. /**
  28298. * Must the particle be translated from its pivot point in its local space ?
  28299. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28300. * Default : false
  28301. */
  28302. translateFromPivot: boolean;
  28303. /**
  28304. * Is the particle active or not ?
  28305. */
  28306. alive: boolean;
  28307. /**
  28308. * Is the particle visible or not ?
  28309. */
  28310. isVisible: boolean;
  28311. /**
  28312. * Index of this particle in the global "positions" array (Internal use)
  28313. * @hidden
  28314. */
  28315. _pos: number;
  28316. /**
  28317. * @hidden Index of this particle in the global "indices" array (Internal use)
  28318. */
  28319. _ind: number;
  28320. /**
  28321. * @hidden ModelShape of this particle (Internal use)
  28322. */
  28323. _model: ModelShape;
  28324. /**
  28325. * ModelShape id of this particle
  28326. */
  28327. shapeId: number;
  28328. /**
  28329. * Index of the particle in its shape id
  28330. */
  28331. idxInShape: number;
  28332. /**
  28333. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28334. */
  28335. _modelBoundingInfo: BoundingInfo;
  28336. /**
  28337. * @hidden Particle BoundingInfo object (Internal use)
  28338. */
  28339. _boundingInfo: BoundingInfo;
  28340. /**
  28341. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28342. */
  28343. _sps: SolidParticleSystem;
  28344. /**
  28345. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28346. */
  28347. _stillInvisible: boolean;
  28348. /**
  28349. * @hidden Last computed particle rotation matrix
  28350. */
  28351. _rotationMatrix: number[];
  28352. /**
  28353. * Parent particle Id, if any.
  28354. * Default null.
  28355. */
  28356. parentId: Nullable<number>;
  28357. /**
  28358. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28359. */
  28360. materialIndex: Nullable<number>;
  28361. /**
  28362. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28363. * The possible values are :
  28364. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28365. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28366. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28367. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28368. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28369. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28370. * */
  28371. cullingStrategy: number;
  28372. /**
  28373. * @hidden Internal global position in the SPS.
  28374. */
  28375. _globalPosition: Vector3;
  28376. /**
  28377. * Creates a Solid Particle object.
  28378. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28379. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28380. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28381. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28382. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28383. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28384. * @param shapeId (integer) is the model shape identifier in the SPS.
  28385. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28386. * @param sps defines the sps it is associated to
  28387. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28388. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28389. */
  28390. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28391. /**
  28392. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28393. * @param target the particle target
  28394. * @returns the current particle
  28395. */
  28396. copyToRef(target: SolidParticle): SolidParticle;
  28397. /**
  28398. * Legacy support, changed scale to scaling
  28399. */
  28400. get scale(): Vector3;
  28401. /**
  28402. * Legacy support, changed scale to scaling
  28403. */
  28404. set scale(scale: Vector3);
  28405. /**
  28406. * Legacy support, changed quaternion to rotationQuaternion
  28407. */
  28408. get quaternion(): Nullable<Quaternion>;
  28409. /**
  28410. * Legacy support, changed quaternion to rotationQuaternion
  28411. */
  28412. set quaternion(q: Nullable<Quaternion>);
  28413. /**
  28414. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28415. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28416. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28417. * @returns true if it intersects
  28418. */
  28419. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28420. /**
  28421. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28422. * A particle is in the frustum if its bounding box intersects the frustum
  28423. * @param frustumPlanes defines the frustum to test
  28424. * @returns true if the particle is in the frustum planes
  28425. */
  28426. isInFrustum(frustumPlanes: Plane[]): boolean;
  28427. /**
  28428. * get the rotation matrix of the particle
  28429. * @hidden
  28430. */
  28431. getRotationMatrix(m: Matrix): void;
  28432. }
  28433. /**
  28434. * Represents the shape of the model used by one particle of a solid particle system.
  28435. * SPS internal tool, don't use it manually.
  28436. */
  28437. export class ModelShape {
  28438. /**
  28439. * The shape id
  28440. * @hidden
  28441. */
  28442. shapeID: number;
  28443. /**
  28444. * flat array of model positions (internal use)
  28445. * @hidden
  28446. */
  28447. _shape: Vector3[];
  28448. /**
  28449. * flat array of model UVs (internal use)
  28450. * @hidden
  28451. */
  28452. _shapeUV: number[];
  28453. /**
  28454. * color array of the model
  28455. * @hidden
  28456. */
  28457. _shapeColors: number[];
  28458. /**
  28459. * indices array of the model
  28460. * @hidden
  28461. */
  28462. _indices: number[];
  28463. /**
  28464. * normals array of the model
  28465. * @hidden
  28466. */
  28467. _normals: number[];
  28468. /**
  28469. * length of the shape in the model indices array (internal use)
  28470. * @hidden
  28471. */
  28472. _indicesLength: number;
  28473. /**
  28474. * Custom position function (internal use)
  28475. * @hidden
  28476. */
  28477. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28478. /**
  28479. * Custom vertex function (internal use)
  28480. * @hidden
  28481. */
  28482. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28483. /**
  28484. * Model material (internal use)
  28485. * @hidden
  28486. */
  28487. _material: Nullable<Material>;
  28488. /**
  28489. * 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.
  28490. * SPS internal tool, don't use it manually.
  28491. * @hidden
  28492. */
  28493. 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>);
  28494. }
  28495. /**
  28496. * Represents a Depth Sorted Particle in the solid particle system.
  28497. * @hidden
  28498. */
  28499. export class DepthSortedParticle {
  28500. /**
  28501. * Index of the particle in the "indices" array
  28502. */
  28503. ind: number;
  28504. /**
  28505. * Length of the particle shape in the "indices" array
  28506. */
  28507. indicesLength: number;
  28508. /**
  28509. * Squared distance from the particle to the camera
  28510. */
  28511. sqDistance: number;
  28512. /**
  28513. * Material index when used with MultiMaterials
  28514. */
  28515. materialIndex: number;
  28516. /**
  28517. * Creates a new sorted particle
  28518. * @param materialIndex
  28519. */
  28520. constructor(ind: number, indLength: number, materialIndex: number);
  28521. }
  28522. }
  28523. declare module "babylonjs/Collisions/meshCollisionData" {
  28524. import { Collider } from "babylonjs/Collisions/collider";
  28525. import { Vector3 } from "babylonjs/Maths/math.vector";
  28526. import { Nullable } from "babylonjs/types";
  28527. import { Observer } from "babylonjs/Misc/observable";
  28528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28529. /**
  28530. * @hidden
  28531. */
  28532. export class _MeshCollisionData {
  28533. _checkCollisions: boolean;
  28534. _collisionMask: number;
  28535. _collisionGroup: number;
  28536. _collider: Nullable<Collider>;
  28537. _oldPositionForCollisions: Vector3;
  28538. _diffPositionForCollisions: Vector3;
  28539. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28540. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28541. }
  28542. }
  28543. declare module "babylonjs/Meshes/abstractMesh" {
  28544. import { Observable } from "babylonjs/Misc/observable";
  28545. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28546. import { Camera } from "babylonjs/Cameras/camera";
  28547. import { Scene, IDisposable } from "babylonjs/scene";
  28548. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28549. import { Node } from "babylonjs/node";
  28550. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28552. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28554. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28555. import { Material } from "babylonjs/Materials/material";
  28556. import { Light } from "babylonjs/Lights/light";
  28557. import { Skeleton } from "babylonjs/Bones/skeleton";
  28558. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28559. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28560. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28561. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28562. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28563. import { Plane } from "babylonjs/Maths/math.plane";
  28564. import { Ray } from "babylonjs/Culling/ray";
  28565. import { Collider } from "babylonjs/Collisions/collider";
  28566. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28567. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28568. /** @hidden */
  28569. class _FacetDataStorage {
  28570. facetPositions: Vector3[];
  28571. facetNormals: Vector3[];
  28572. facetPartitioning: number[][];
  28573. facetNb: number;
  28574. partitioningSubdivisions: number;
  28575. partitioningBBoxRatio: number;
  28576. facetDataEnabled: boolean;
  28577. facetParameters: any;
  28578. bbSize: Vector3;
  28579. subDiv: {
  28580. max: number;
  28581. X: number;
  28582. Y: number;
  28583. Z: number;
  28584. };
  28585. facetDepthSort: boolean;
  28586. facetDepthSortEnabled: boolean;
  28587. depthSortedIndices: IndicesArray;
  28588. depthSortedFacets: {
  28589. ind: number;
  28590. sqDistance: number;
  28591. }[];
  28592. facetDepthSortFunction: (f1: {
  28593. ind: number;
  28594. sqDistance: number;
  28595. }, f2: {
  28596. ind: number;
  28597. sqDistance: number;
  28598. }) => number;
  28599. facetDepthSortFrom: Vector3;
  28600. facetDepthSortOrigin: Vector3;
  28601. invertedMatrix: Matrix;
  28602. }
  28603. /**
  28604. * @hidden
  28605. **/
  28606. class _InternalAbstractMeshDataInfo {
  28607. _hasVertexAlpha: boolean;
  28608. _useVertexColors: boolean;
  28609. _numBoneInfluencers: number;
  28610. _applyFog: boolean;
  28611. _receiveShadows: boolean;
  28612. _facetData: _FacetDataStorage;
  28613. _visibility: number;
  28614. _skeleton: Nullable<Skeleton>;
  28615. _layerMask: number;
  28616. _computeBonesUsingShaders: boolean;
  28617. _isActive: boolean;
  28618. _onlyForInstances: boolean;
  28619. _isActiveIntermediate: boolean;
  28620. _onlyForInstancesIntermediate: boolean;
  28621. _actAsRegularMesh: boolean;
  28622. }
  28623. /**
  28624. * Class used to store all common mesh properties
  28625. */
  28626. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28627. /** No occlusion */
  28628. static OCCLUSION_TYPE_NONE: number;
  28629. /** Occlusion set to optimisitic */
  28630. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28631. /** Occlusion set to strict */
  28632. static OCCLUSION_TYPE_STRICT: number;
  28633. /** Use an accurante occlusion algorithm */
  28634. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28635. /** Use a conservative occlusion algorithm */
  28636. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28637. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28638. * Test order :
  28639. * Is the bounding sphere outside the frustum ?
  28640. * If not, are the bounding box vertices outside the frustum ?
  28641. * It not, then the cullable object is in the frustum.
  28642. */
  28643. static readonly CULLINGSTRATEGY_STANDARD: number;
  28644. /** Culling strategy : Bounding Sphere Only.
  28645. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28646. * It's also less accurate than the standard because some not visible objects can still be selected.
  28647. * Test : is the bounding sphere outside the frustum ?
  28648. * If not, then the cullable object is in the frustum.
  28649. */
  28650. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28651. /** Culling strategy : Optimistic Inclusion.
  28652. * This in an inclusion test first, then the standard exclusion test.
  28653. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28654. * 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.
  28655. * Anyway, it's as accurate as the standard strategy.
  28656. * Test :
  28657. * Is the cullable object bounding sphere center in the frustum ?
  28658. * If not, apply the default culling strategy.
  28659. */
  28660. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28661. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28662. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28663. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28664. * 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.
  28665. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28666. * Test :
  28667. * Is the cullable object bounding sphere center in the frustum ?
  28668. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28669. */
  28670. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28671. /**
  28672. * No billboard
  28673. */
  28674. static get BILLBOARDMODE_NONE(): number;
  28675. /** Billboard on X axis */
  28676. static get BILLBOARDMODE_X(): number;
  28677. /** Billboard on Y axis */
  28678. static get BILLBOARDMODE_Y(): number;
  28679. /** Billboard on Z axis */
  28680. static get BILLBOARDMODE_Z(): number;
  28681. /** Billboard on all axes */
  28682. static get BILLBOARDMODE_ALL(): number;
  28683. /** Billboard on using position instead of orientation */
  28684. static get BILLBOARDMODE_USE_POSITION(): number;
  28685. /** @hidden */
  28686. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28687. /**
  28688. * The culling strategy to use to check whether the mesh must be rendered or not.
  28689. * This value can be changed at any time and will be used on the next render mesh selection.
  28690. * The possible values are :
  28691. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28692. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28694. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28695. * Please read each static variable documentation to get details about the culling process.
  28696. * */
  28697. cullingStrategy: number;
  28698. /**
  28699. * Gets the number of facets in the mesh
  28700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28701. */
  28702. get facetNb(): number;
  28703. /**
  28704. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28706. */
  28707. get partitioningSubdivisions(): number;
  28708. set partitioningSubdivisions(nb: number);
  28709. /**
  28710. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28711. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28713. */
  28714. get partitioningBBoxRatio(): number;
  28715. set partitioningBBoxRatio(ratio: number);
  28716. /**
  28717. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28718. * Works only for updatable meshes.
  28719. * Doesn't work with multi-materials
  28720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28721. */
  28722. get mustDepthSortFacets(): boolean;
  28723. set mustDepthSortFacets(sort: boolean);
  28724. /**
  28725. * The location (Vector3) where the facet depth sort must be computed from.
  28726. * By default, the active camera position.
  28727. * Used only when facet depth sort is enabled
  28728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28729. */
  28730. get facetDepthSortFrom(): Vector3;
  28731. set facetDepthSortFrom(location: Vector3);
  28732. /**
  28733. * gets a boolean indicating if facetData is enabled
  28734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28735. */
  28736. get isFacetDataEnabled(): boolean;
  28737. /** @hidden */
  28738. _updateNonUniformScalingState(value: boolean): boolean;
  28739. /**
  28740. * An event triggered when this mesh collides with another one
  28741. */
  28742. onCollideObservable: Observable<AbstractMesh>;
  28743. /** Set a function to call when this mesh collides with another one */
  28744. set onCollide(callback: () => void);
  28745. /**
  28746. * An event triggered when the collision's position changes
  28747. */
  28748. onCollisionPositionChangeObservable: Observable<Vector3>;
  28749. /** Set a function to call when the collision's position changes */
  28750. set onCollisionPositionChange(callback: () => void);
  28751. /**
  28752. * An event triggered when material is changed
  28753. */
  28754. onMaterialChangedObservable: Observable<AbstractMesh>;
  28755. /**
  28756. * Gets or sets the orientation for POV movement & rotation
  28757. */
  28758. definedFacingForward: boolean;
  28759. /** @hidden */
  28760. _occlusionQuery: Nullable<WebGLQuery>;
  28761. /** @hidden */
  28762. _renderingGroup: Nullable<RenderingGroup>;
  28763. /**
  28764. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28765. */
  28766. get visibility(): number;
  28767. /**
  28768. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28769. */
  28770. set visibility(value: number);
  28771. /** Gets or sets the alpha index used to sort transparent meshes
  28772. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28773. */
  28774. alphaIndex: number;
  28775. /**
  28776. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28777. */
  28778. isVisible: boolean;
  28779. /**
  28780. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28781. */
  28782. isPickable: boolean;
  28783. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28784. showSubMeshesBoundingBox: boolean;
  28785. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28786. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28787. */
  28788. isBlocker: boolean;
  28789. /**
  28790. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28791. */
  28792. enablePointerMoveEvents: boolean;
  28793. /**
  28794. * Specifies the rendering group id for this mesh (0 by default)
  28795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28796. */
  28797. renderingGroupId: number;
  28798. private _material;
  28799. /** Gets or sets current material */
  28800. get material(): Nullable<Material>;
  28801. set material(value: Nullable<Material>);
  28802. /**
  28803. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28804. * @see http://doc.babylonjs.com/babylon101/shadows
  28805. */
  28806. get receiveShadows(): boolean;
  28807. set receiveShadows(value: boolean);
  28808. /** Defines color to use when rendering outline */
  28809. outlineColor: Color3;
  28810. /** Define width to use when rendering outline */
  28811. outlineWidth: number;
  28812. /** Defines color to use when rendering overlay */
  28813. overlayColor: Color3;
  28814. /** Defines alpha to use when rendering overlay */
  28815. overlayAlpha: number;
  28816. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28817. get hasVertexAlpha(): boolean;
  28818. set hasVertexAlpha(value: boolean);
  28819. /** 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) */
  28820. get useVertexColors(): boolean;
  28821. set useVertexColors(value: boolean);
  28822. /**
  28823. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28824. */
  28825. get computeBonesUsingShaders(): boolean;
  28826. set computeBonesUsingShaders(value: boolean);
  28827. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28828. get numBoneInfluencers(): number;
  28829. set numBoneInfluencers(value: number);
  28830. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28831. get applyFog(): boolean;
  28832. set applyFog(value: boolean);
  28833. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28834. useOctreeForRenderingSelection: boolean;
  28835. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28836. useOctreeForPicking: boolean;
  28837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28838. useOctreeForCollisions: boolean;
  28839. /**
  28840. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28841. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28842. */
  28843. get layerMask(): number;
  28844. set layerMask(value: number);
  28845. /**
  28846. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28847. */
  28848. alwaysSelectAsActiveMesh: boolean;
  28849. /**
  28850. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28851. */
  28852. doNotSyncBoundingInfo: boolean;
  28853. /**
  28854. * Gets or sets the current action manager
  28855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28856. */
  28857. actionManager: Nullable<AbstractActionManager>;
  28858. private _meshCollisionData;
  28859. /**
  28860. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28861. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28862. */
  28863. ellipsoid: Vector3;
  28864. /**
  28865. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28867. */
  28868. ellipsoidOffset: Vector3;
  28869. /**
  28870. * Gets or sets a collision mask used to mask collisions (default is -1).
  28871. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28872. */
  28873. get collisionMask(): number;
  28874. set collisionMask(mask: number);
  28875. /**
  28876. * Gets or sets the current collision group mask (-1 by default).
  28877. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28878. */
  28879. get collisionGroup(): number;
  28880. set collisionGroup(mask: number);
  28881. /**
  28882. * Defines edge width used when edgesRenderer is enabled
  28883. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28884. */
  28885. edgesWidth: number;
  28886. /**
  28887. * Defines edge color used when edgesRenderer is enabled
  28888. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28889. */
  28890. edgesColor: Color4;
  28891. /** @hidden */
  28892. _edgesRenderer: Nullable<IEdgesRenderer>;
  28893. /** @hidden */
  28894. _masterMesh: Nullable<AbstractMesh>;
  28895. /** @hidden */
  28896. _boundingInfo: Nullable<BoundingInfo>;
  28897. /** @hidden */
  28898. _renderId: number;
  28899. /**
  28900. * Gets or sets the list of subMeshes
  28901. * @see http://doc.babylonjs.com/how_to/multi_materials
  28902. */
  28903. subMeshes: SubMesh[];
  28904. /** @hidden */
  28905. _intersectionsInProgress: AbstractMesh[];
  28906. /** @hidden */
  28907. _unIndexed: boolean;
  28908. /** @hidden */
  28909. _lightSources: Light[];
  28910. /** Gets the list of lights affecting that mesh */
  28911. get lightSources(): Light[];
  28912. /** @hidden */
  28913. get _positions(): Nullable<Vector3[]>;
  28914. /** @hidden */
  28915. _waitingData: {
  28916. lods: Nullable<any>;
  28917. actions: Nullable<any>;
  28918. freezeWorldMatrix: Nullable<boolean>;
  28919. };
  28920. /** @hidden */
  28921. _bonesTransformMatrices: Nullable<Float32Array>;
  28922. /** @hidden */
  28923. _transformMatrixTexture: Nullable<RawTexture>;
  28924. /**
  28925. * Gets or sets a skeleton to apply skining transformations
  28926. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28927. */
  28928. set skeleton(value: Nullable<Skeleton>);
  28929. get skeleton(): Nullable<Skeleton>;
  28930. /**
  28931. * An event triggered when the mesh is rebuilt.
  28932. */
  28933. onRebuildObservable: Observable<AbstractMesh>;
  28934. /**
  28935. * Creates a new AbstractMesh
  28936. * @param name defines the name of the mesh
  28937. * @param scene defines the hosting scene
  28938. */
  28939. constructor(name: string, scene?: Nullable<Scene>);
  28940. /**
  28941. * Returns the string "AbstractMesh"
  28942. * @returns "AbstractMesh"
  28943. */
  28944. getClassName(): string;
  28945. /**
  28946. * Gets a string representation of the current mesh
  28947. * @param fullDetails defines a boolean indicating if full details must be included
  28948. * @returns a string representation of the current mesh
  28949. */
  28950. toString(fullDetails?: boolean): string;
  28951. /**
  28952. * @hidden
  28953. */
  28954. protected _getEffectiveParent(): Nullable<Node>;
  28955. /** @hidden */
  28956. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28957. /** @hidden */
  28958. _rebuild(): void;
  28959. /** @hidden */
  28960. _resyncLightSources(): void;
  28961. /** @hidden */
  28962. _resyncLightSource(light: Light): void;
  28963. /** @hidden */
  28964. _unBindEffect(): void;
  28965. /** @hidden */
  28966. _removeLightSource(light: Light, dispose: boolean): void;
  28967. private _markSubMeshesAsDirty;
  28968. /** @hidden */
  28969. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28970. /** @hidden */
  28971. _markSubMeshesAsAttributesDirty(): void;
  28972. /** @hidden */
  28973. _markSubMeshesAsMiscDirty(): void;
  28974. /**
  28975. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28976. */
  28977. get scaling(): Vector3;
  28978. set scaling(newScaling: Vector3);
  28979. /**
  28980. * Returns true if the mesh is blocked. Implemented by child classes
  28981. */
  28982. get isBlocked(): boolean;
  28983. /**
  28984. * Returns the mesh itself by default. Implemented by child classes
  28985. * @param camera defines the camera to use to pick the right LOD level
  28986. * @returns the currentAbstractMesh
  28987. */
  28988. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28989. /**
  28990. * Returns 0 by default. Implemented by child classes
  28991. * @returns an integer
  28992. */
  28993. getTotalVertices(): number;
  28994. /**
  28995. * Returns a positive integer : the total number of indices in this mesh geometry.
  28996. * @returns the numner of indices or zero if the mesh has no geometry.
  28997. */
  28998. getTotalIndices(): number;
  28999. /**
  29000. * Returns null by default. Implemented by child classes
  29001. * @returns null
  29002. */
  29003. getIndices(): Nullable<IndicesArray>;
  29004. /**
  29005. * Returns the array of the requested vertex data kind. Implemented by child classes
  29006. * @param kind defines the vertex data kind to use
  29007. * @returns null
  29008. */
  29009. getVerticesData(kind: string): Nullable<FloatArray>;
  29010. /**
  29011. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29012. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29013. * Note that a new underlying VertexBuffer object is created each call.
  29014. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29015. * @param kind defines vertex data kind:
  29016. * * VertexBuffer.PositionKind
  29017. * * VertexBuffer.UVKind
  29018. * * VertexBuffer.UV2Kind
  29019. * * VertexBuffer.UV3Kind
  29020. * * VertexBuffer.UV4Kind
  29021. * * VertexBuffer.UV5Kind
  29022. * * VertexBuffer.UV6Kind
  29023. * * VertexBuffer.ColorKind
  29024. * * VertexBuffer.MatricesIndicesKind
  29025. * * VertexBuffer.MatricesIndicesExtraKind
  29026. * * VertexBuffer.MatricesWeightsKind
  29027. * * VertexBuffer.MatricesWeightsExtraKind
  29028. * @param data defines the data source
  29029. * @param updatable defines if the data must be flagged as updatable (or static)
  29030. * @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
  29031. * @returns the current mesh
  29032. */
  29033. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29034. /**
  29035. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29036. * If the mesh has no geometry, it is simply returned as it is.
  29037. * @param kind defines vertex data kind:
  29038. * * VertexBuffer.PositionKind
  29039. * * VertexBuffer.UVKind
  29040. * * VertexBuffer.UV2Kind
  29041. * * VertexBuffer.UV3Kind
  29042. * * VertexBuffer.UV4Kind
  29043. * * VertexBuffer.UV5Kind
  29044. * * VertexBuffer.UV6Kind
  29045. * * VertexBuffer.ColorKind
  29046. * * VertexBuffer.MatricesIndicesKind
  29047. * * VertexBuffer.MatricesIndicesExtraKind
  29048. * * VertexBuffer.MatricesWeightsKind
  29049. * * VertexBuffer.MatricesWeightsExtraKind
  29050. * @param data defines the data source
  29051. * @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
  29052. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29053. * @returns the current mesh
  29054. */
  29055. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29056. /**
  29057. * Sets the mesh indices,
  29058. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29059. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29060. * @param totalVertices Defines the total number of vertices
  29061. * @returns the current mesh
  29062. */
  29063. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29064. /**
  29065. * Gets a boolean indicating if specific vertex data is present
  29066. * @param kind defines the vertex data kind to use
  29067. * @returns true is data kind is present
  29068. */
  29069. isVerticesDataPresent(kind: string): boolean;
  29070. /**
  29071. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29072. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29073. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29074. * @returns a BoundingInfo
  29075. */
  29076. getBoundingInfo(): BoundingInfo;
  29077. /**
  29078. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29079. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29080. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29081. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29082. * @returns the current mesh
  29083. */
  29084. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29085. /**
  29086. * Overwrite the current bounding info
  29087. * @param boundingInfo defines the new bounding info
  29088. * @returns the current mesh
  29089. */
  29090. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29091. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29092. get useBones(): boolean;
  29093. /** @hidden */
  29094. _preActivate(): void;
  29095. /** @hidden */
  29096. _preActivateForIntermediateRendering(renderId: number): void;
  29097. /** @hidden */
  29098. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29099. /** @hidden */
  29100. _postActivate(): void;
  29101. /** @hidden */
  29102. _freeze(): void;
  29103. /** @hidden */
  29104. _unFreeze(): void;
  29105. /**
  29106. * Gets the current world matrix
  29107. * @returns a Matrix
  29108. */
  29109. getWorldMatrix(): Matrix;
  29110. /** @hidden */
  29111. _getWorldMatrixDeterminant(): number;
  29112. /**
  29113. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29114. */
  29115. get isAnInstance(): boolean;
  29116. /**
  29117. * Gets a boolean indicating if this mesh has instances
  29118. */
  29119. get hasInstances(): boolean;
  29120. /**
  29121. * Perform relative position change from the point of view of behind the front of the mesh.
  29122. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29123. * Supports definition of mesh facing forward or backward
  29124. * @param amountRight defines the distance on the right axis
  29125. * @param amountUp defines the distance on the up axis
  29126. * @param amountForward defines the distance on the forward axis
  29127. * @returns the current mesh
  29128. */
  29129. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29130. /**
  29131. * Calculate relative position change from the point of view of behind the front of the mesh.
  29132. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29133. * Supports definition of mesh facing forward or backward
  29134. * @param amountRight defines the distance on the right axis
  29135. * @param amountUp defines the distance on the up axis
  29136. * @param amountForward defines the distance on the forward axis
  29137. * @returns the new displacement vector
  29138. */
  29139. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29140. /**
  29141. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29142. * Supports definition of mesh facing forward or backward
  29143. * @param flipBack defines the flip
  29144. * @param twirlClockwise defines the twirl
  29145. * @param tiltRight defines the tilt
  29146. * @returns the current mesh
  29147. */
  29148. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29149. /**
  29150. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29151. * Supports definition of mesh facing forward or backward.
  29152. * @param flipBack defines the flip
  29153. * @param twirlClockwise defines the twirl
  29154. * @param tiltRight defines the tilt
  29155. * @returns the new rotation vector
  29156. */
  29157. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29158. /**
  29159. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29160. * This means the mesh underlying bounding box and sphere are recomputed.
  29161. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29162. * @returns the current mesh
  29163. */
  29164. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29165. /** @hidden */
  29166. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29167. /** @hidden */
  29168. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29169. /** @hidden */
  29170. _updateBoundingInfo(): AbstractMesh;
  29171. /** @hidden */
  29172. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29173. /** @hidden */
  29174. protected _afterComputeWorldMatrix(): void;
  29175. /** @hidden */
  29176. get _effectiveMesh(): AbstractMesh;
  29177. /**
  29178. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29179. * A mesh is in the frustum if its bounding box intersects the frustum
  29180. * @param frustumPlanes defines the frustum to test
  29181. * @returns true if the mesh is in the frustum planes
  29182. */
  29183. isInFrustum(frustumPlanes: Plane[]): boolean;
  29184. /**
  29185. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29186. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29187. * @param frustumPlanes defines the frustum to test
  29188. * @returns true if the mesh is completely in the frustum planes
  29189. */
  29190. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29191. /**
  29192. * True if the mesh intersects another mesh or a SolidParticle object
  29193. * @param mesh defines a target mesh or SolidParticle to test
  29194. * @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)
  29195. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29196. * @returns true if there is an intersection
  29197. */
  29198. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29199. /**
  29200. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29201. * @param point defines the point to test
  29202. * @returns true if there is an intersection
  29203. */
  29204. intersectsPoint(point: Vector3): boolean;
  29205. /**
  29206. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29208. */
  29209. get checkCollisions(): boolean;
  29210. set checkCollisions(collisionEnabled: boolean);
  29211. /**
  29212. * Gets Collider object used to compute collisions (not physics)
  29213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29214. */
  29215. get collider(): Nullable<Collider>;
  29216. /**
  29217. * Move the mesh using collision engine
  29218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29219. * @param displacement defines the requested displacement vector
  29220. * @returns the current mesh
  29221. */
  29222. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29223. private _onCollisionPositionChange;
  29224. /** @hidden */
  29225. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29226. /** @hidden */
  29227. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29228. /** @hidden */
  29229. _checkCollision(collider: Collider): AbstractMesh;
  29230. /** @hidden */
  29231. _generatePointsArray(): boolean;
  29232. /**
  29233. * Checks if the passed Ray intersects with the mesh
  29234. * @param ray defines the ray to use
  29235. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29236. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29237. * @returns the picking info
  29238. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29239. */
  29240. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29241. /**
  29242. * Clones the current mesh
  29243. * @param name defines the mesh name
  29244. * @param newParent defines the new mesh parent
  29245. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29246. * @returns the new mesh
  29247. */
  29248. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29249. /**
  29250. * Disposes all the submeshes of the current meshnp
  29251. * @returns the current mesh
  29252. */
  29253. releaseSubMeshes(): AbstractMesh;
  29254. /**
  29255. * Releases resources associated with this abstract mesh.
  29256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29258. */
  29259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29260. /**
  29261. * Adds the passed mesh as a child to the current mesh
  29262. * @param mesh defines the child mesh
  29263. * @returns the current mesh
  29264. */
  29265. addChild(mesh: AbstractMesh): AbstractMesh;
  29266. /**
  29267. * Removes the passed mesh from the current mesh children list
  29268. * @param mesh defines the child mesh
  29269. * @returns the current mesh
  29270. */
  29271. removeChild(mesh: AbstractMesh): AbstractMesh;
  29272. /** @hidden */
  29273. private _initFacetData;
  29274. /**
  29275. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29276. * This method can be called within the render loop.
  29277. * 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
  29278. * @returns the current mesh
  29279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29280. */
  29281. updateFacetData(): AbstractMesh;
  29282. /**
  29283. * Returns the facetLocalNormals array.
  29284. * The normals are expressed in the mesh local spac
  29285. * @returns an array of Vector3
  29286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29287. */
  29288. getFacetLocalNormals(): Vector3[];
  29289. /**
  29290. * Returns the facetLocalPositions array.
  29291. * The facet positions are expressed in the mesh local space
  29292. * @returns an array of Vector3
  29293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29294. */
  29295. getFacetLocalPositions(): Vector3[];
  29296. /**
  29297. * Returns the facetLocalPartioning array
  29298. * @returns an array of array of numbers
  29299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29300. */
  29301. getFacetLocalPartitioning(): number[][];
  29302. /**
  29303. * Returns the i-th facet position in the world system.
  29304. * This method allocates a new Vector3 per call
  29305. * @param i defines the facet index
  29306. * @returns a new Vector3
  29307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29308. */
  29309. getFacetPosition(i: number): Vector3;
  29310. /**
  29311. * Sets the reference Vector3 with the i-th facet position in the world system
  29312. * @param i defines the facet index
  29313. * @param ref defines the target vector
  29314. * @returns the current mesh
  29315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29316. */
  29317. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29318. /**
  29319. * Returns the i-th facet normal in the world system.
  29320. * This method allocates a new Vector3 per call
  29321. * @param i defines the facet index
  29322. * @returns a new Vector3
  29323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29324. */
  29325. getFacetNormal(i: number): Vector3;
  29326. /**
  29327. * Sets the reference Vector3 with the i-th facet normal in the world system
  29328. * @param i defines the facet index
  29329. * @param ref defines the target vector
  29330. * @returns the current mesh
  29331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29332. */
  29333. getFacetNormalToRef(i: number, ref: Vector3): this;
  29334. /**
  29335. * 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)
  29336. * @param x defines x coordinate
  29337. * @param y defines y coordinate
  29338. * @param z defines z coordinate
  29339. * @returns the array of facet indexes
  29340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29341. */
  29342. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29343. /**
  29344. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29345. * @param projected sets as the (x,y,z) world projection on the facet
  29346. * @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
  29347. * @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
  29348. * @param x defines x coordinate
  29349. * @param y defines y coordinate
  29350. * @param z defines z coordinate
  29351. * @returns the face index if found (or null instead)
  29352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29353. */
  29354. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29355. /**
  29356. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29357. * @param projected sets as the (x,y,z) local projection on the facet
  29358. * @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
  29359. * @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
  29360. * @param x defines x coordinate
  29361. * @param y defines y coordinate
  29362. * @param z defines z coordinate
  29363. * @returns the face index if found (or null instead)
  29364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29365. */
  29366. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29367. /**
  29368. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29369. * @returns the parameters
  29370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29371. */
  29372. getFacetDataParameters(): any;
  29373. /**
  29374. * Disables the feature FacetData and frees the related memory
  29375. * @returns the current mesh
  29376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29377. */
  29378. disableFacetData(): AbstractMesh;
  29379. /**
  29380. * Updates the AbstractMesh indices array
  29381. * @param indices defines the data source
  29382. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29383. * @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)
  29384. * @returns the current mesh
  29385. */
  29386. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29387. /**
  29388. * Creates new normals data for the mesh
  29389. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29390. * @returns the current mesh
  29391. */
  29392. createNormals(updatable: boolean): AbstractMesh;
  29393. /**
  29394. * Align the mesh with a normal
  29395. * @param normal defines the normal to use
  29396. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29397. * @returns the current mesh
  29398. */
  29399. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29400. /** @hidden */
  29401. _checkOcclusionQuery(): boolean;
  29402. /**
  29403. * Disables the mesh edge rendering mode
  29404. * @returns the currentAbstractMesh
  29405. */
  29406. disableEdgesRendering(): AbstractMesh;
  29407. /**
  29408. * Enables the edge rendering mode on the mesh.
  29409. * This mode makes the mesh edges visible
  29410. * @param epsilon defines the maximal distance between two angles to detect a face
  29411. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29412. * @returns the currentAbstractMesh
  29413. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29414. */
  29415. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29416. }
  29417. }
  29418. declare module "babylonjs/Actions/actionEvent" {
  29419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29420. import { Nullable } from "babylonjs/types";
  29421. import { Sprite } from "babylonjs/Sprites/sprite";
  29422. import { Scene } from "babylonjs/scene";
  29423. import { Vector2 } from "babylonjs/Maths/math.vector";
  29424. /**
  29425. * Interface used to define ActionEvent
  29426. */
  29427. export interface IActionEvent {
  29428. /** The mesh or sprite that triggered the action */
  29429. source: any;
  29430. /** The X mouse cursor position at the time of the event */
  29431. pointerX: number;
  29432. /** The Y mouse cursor position at the time of the event */
  29433. pointerY: number;
  29434. /** The mesh that is currently pointed at (can be null) */
  29435. meshUnderPointer: Nullable<AbstractMesh>;
  29436. /** the original (browser) event that triggered the ActionEvent */
  29437. sourceEvent?: any;
  29438. /** additional data for the event */
  29439. additionalData?: any;
  29440. }
  29441. /**
  29442. * ActionEvent is the event being sent when an action is triggered.
  29443. */
  29444. export class ActionEvent implements IActionEvent {
  29445. /** The mesh or sprite that triggered the action */
  29446. source: any;
  29447. /** The X mouse cursor position at the time of the event */
  29448. pointerX: number;
  29449. /** The Y mouse cursor position at the time of the event */
  29450. pointerY: number;
  29451. /** The mesh that is currently pointed at (can be null) */
  29452. meshUnderPointer: Nullable<AbstractMesh>;
  29453. /** the original (browser) event that triggered the ActionEvent */
  29454. sourceEvent?: any;
  29455. /** additional data for the event */
  29456. additionalData?: any;
  29457. /**
  29458. * Creates a new ActionEvent
  29459. * @param source The mesh or sprite that triggered the action
  29460. * @param pointerX The X mouse cursor position at the time of the event
  29461. * @param pointerY The Y mouse cursor position at the time of the event
  29462. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29463. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29464. * @param additionalData additional data for the event
  29465. */
  29466. constructor(
  29467. /** The mesh or sprite that triggered the action */
  29468. source: any,
  29469. /** The X mouse cursor position at the time of the event */
  29470. pointerX: number,
  29471. /** The Y mouse cursor position at the time of the event */
  29472. pointerY: number,
  29473. /** The mesh that is currently pointed at (can be null) */
  29474. meshUnderPointer: Nullable<AbstractMesh>,
  29475. /** the original (browser) event that triggered the ActionEvent */
  29476. sourceEvent?: any,
  29477. /** additional data for the event */
  29478. additionalData?: any);
  29479. /**
  29480. * Helper function to auto-create an ActionEvent from a source mesh.
  29481. * @param source The source mesh that triggered the event
  29482. * @param evt The original (browser) event
  29483. * @param additionalData additional data for the event
  29484. * @returns the new ActionEvent
  29485. */
  29486. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29487. /**
  29488. * Helper function to auto-create an ActionEvent from a source sprite
  29489. * @param source The source sprite that triggered the event
  29490. * @param scene Scene associated with the sprite
  29491. * @param evt The original (browser) event
  29492. * @param additionalData additional data for the event
  29493. * @returns the new ActionEvent
  29494. */
  29495. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29496. /**
  29497. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29498. * @param scene the scene where the event occurred
  29499. * @param evt The original (browser) event
  29500. * @returns the new ActionEvent
  29501. */
  29502. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29503. /**
  29504. * Helper function to auto-create an ActionEvent from a primitive
  29505. * @param prim defines the target primitive
  29506. * @param pointerPos defines the pointer position
  29507. * @param evt The original (browser) event
  29508. * @param additionalData additional data for the event
  29509. * @returns the new ActionEvent
  29510. */
  29511. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29512. }
  29513. }
  29514. declare module "babylonjs/Actions/abstractActionManager" {
  29515. import { IDisposable } from "babylonjs/scene";
  29516. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29517. import { IAction } from "babylonjs/Actions/action";
  29518. import { Nullable } from "babylonjs/types";
  29519. /**
  29520. * Abstract class used to decouple action Manager from scene and meshes.
  29521. * Do not instantiate.
  29522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29523. */
  29524. export abstract class AbstractActionManager implements IDisposable {
  29525. /** Gets the list of active triggers */
  29526. static Triggers: {
  29527. [key: string]: number;
  29528. };
  29529. /** Gets the cursor to use when hovering items */
  29530. hoverCursor: string;
  29531. /** Gets the list of actions */
  29532. actions: IAction[];
  29533. /**
  29534. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29535. */
  29536. isRecursive: boolean;
  29537. /**
  29538. * Releases all associated resources
  29539. */
  29540. abstract dispose(): void;
  29541. /**
  29542. * Does this action manager has pointer triggers
  29543. */
  29544. abstract get hasPointerTriggers(): boolean;
  29545. /**
  29546. * Does this action manager has pick triggers
  29547. */
  29548. abstract get hasPickTriggers(): boolean;
  29549. /**
  29550. * Process a specific trigger
  29551. * @param trigger defines the trigger to process
  29552. * @param evt defines the event details to be processed
  29553. */
  29554. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29555. /**
  29556. * Does this action manager handles actions of any of the given triggers
  29557. * @param triggers defines the triggers to be tested
  29558. * @return a boolean indicating whether one (or more) of the triggers is handled
  29559. */
  29560. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29561. /**
  29562. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29563. * speed.
  29564. * @param triggerA defines the trigger to be tested
  29565. * @param triggerB defines the trigger to be tested
  29566. * @return a boolean indicating whether one (or more) of the triggers is handled
  29567. */
  29568. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29569. /**
  29570. * Does this action manager handles actions of a given trigger
  29571. * @param trigger defines the trigger to be tested
  29572. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29573. * @return whether the trigger is handled
  29574. */
  29575. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29576. /**
  29577. * Serialize this manager to a JSON object
  29578. * @param name defines the property name to store this manager
  29579. * @returns a JSON representation of this manager
  29580. */
  29581. abstract serialize(name: string): any;
  29582. /**
  29583. * Registers an action to this action manager
  29584. * @param action defines the action to be registered
  29585. * @return the action amended (prepared) after registration
  29586. */
  29587. abstract registerAction(action: IAction): Nullable<IAction>;
  29588. /**
  29589. * Unregisters an action to this action manager
  29590. * @param action defines the action to be unregistered
  29591. * @return a boolean indicating whether the action has been unregistered
  29592. */
  29593. abstract unregisterAction(action: IAction): Boolean;
  29594. /**
  29595. * Does exist one action manager with at least one trigger
  29596. **/
  29597. static get HasTriggers(): boolean;
  29598. /**
  29599. * Does exist one action manager with at least one pick trigger
  29600. **/
  29601. static get HasPickTriggers(): boolean;
  29602. /**
  29603. * Does exist one action manager that handles actions of a given trigger
  29604. * @param trigger defines the trigger to be tested
  29605. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29606. **/
  29607. static HasSpecificTrigger(trigger: number): boolean;
  29608. }
  29609. }
  29610. declare module "babylonjs/node" {
  29611. import { Scene } from "babylonjs/scene";
  29612. import { Nullable } from "babylonjs/types";
  29613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29614. import { Engine } from "babylonjs/Engines/engine";
  29615. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29616. import { Observable } from "babylonjs/Misc/observable";
  29617. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29618. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29619. import { Animatable } from "babylonjs/Animations/animatable";
  29620. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29621. import { Animation } from "babylonjs/Animations/animation";
  29622. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29624. /**
  29625. * Defines how a node can be built from a string name.
  29626. */
  29627. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29628. /**
  29629. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29630. */
  29631. export class Node implements IBehaviorAware<Node> {
  29632. /** @hidden */
  29633. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29634. private static _NodeConstructors;
  29635. /**
  29636. * Add a new node constructor
  29637. * @param type defines the type name of the node to construct
  29638. * @param constructorFunc defines the constructor function
  29639. */
  29640. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29641. /**
  29642. * Returns a node constructor based on type name
  29643. * @param type defines the type name
  29644. * @param name defines the new node name
  29645. * @param scene defines the hosting scene
  29646. * @param options defines optional options to transmit to constructors
  29647. * @returns the new constructor or null
  29648. */
  29649. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29650. /**
  29651. * Gets or sets the name of the node
  29652. */
  29653. name: string;
  29654. /**
  29655. * Gets or sets the id of the node
  29656. */
  29657. id: string;
  29658. /**
  29659. * Gets or sets the unique id of the node
  29660. */
  29661. uniqueId: number;
  29662. /**
  29663. * Gets or sets a string used to store user defined state for the node
  29664. */
  29665. state: string;
  29666. /**
  29667. * Gets or sets an object used to store user defined information for the node
  29668. */
  29669. metadata: any;
  29670. /**
  29671. * For internal use only. Please do not use.
  29672. */
  29673. reservedDataStore: any;
  29674. /**
  29675. * List of inspectable custom properties (used by the Inspector)
  29676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29677. */
  29678. inspectableCustomProperties: IInspectable[];
  29679. private _doNotSerialize;
  29680. /**
  29681. * Gets or sets a boolean used to define if the node must be serialized
  29682. */
  29683. get doNotSerialize(): boolean;
  29684. set doNotSerialize(value: boolean);
  29685. /** @hidden */
  29686. _isDisposed: boolean;
  29687. /**
  29688. * Gets a list of Animations associated with the node
  29689. */
  29690. animations: import("babylonjs/Animations/animation").Animation[];
  29691. protected _ranges: {
  29692. [name: string]: Nullable<AnimationRange>;
  29693. };
  29694. /**
  29695. * Callback raised when the node is ready to be used
  29696. */
  29697. onReady: Nullable<(node: Node) => void>;
  29698. private _isEnabled;
  29699. private _isParentEnabled;
  29700. private _isReady;
  29701. /** @hidden */
  29702. _currentRenderId: number;
  29703. private _parentUpdateId;
  29704. /** @hidden */
  29705. _childUpdateId: number;
  29706. /** @hidden */
  29707. _waitingParentId: Nullable<string>;
  29708. /** @hidden */
  29709. _scene: Scene;
  29710. /** @hidden */
  29711. _cache: any;
  29712. private _parentNode;
  29713. private _children;
  29714. /** @hidden */
  29715. _worldMatrix: Matrix;
  29716. /** @hidden */
  29717. _worldMatrixDeterminant: number;
  29718. /** @hidden */
  29719. _worldMatrixDeterminantIsDirty: boolean;
  29720. /** @hidden */
  29721. private _sceneRootNodesIndex;
  29722. /**
  29723. * Gets a boolean indicating if the node has been disposed
  29724. * @returns true if the node was disposed
  29725. */
  29726. isDisposed(): boolean;
  29727. /**
  29728. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29729. * @see https://doc.babylonjs.com/how_to/parenting
  29730. */
  29731. set parent(parent: Nullable<Node>);
  29732. get parent(): Nullable<Node>;
  29733. /** @hidden */
  29734. _addToSceneRootNodes(): void;
  29735. /** @hidden */
  29736. _removeFromSceneRootNodes(): void;
  29737. private _animationPropertiesOverride;
  29738. /**
  29739. * Gets or sets the animation properties override
  29740. */
  29741. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29742. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29743. /**
  29744. * Gets a string idenfifying the name of the class
  29745. * @returns "Node" string
  29746. */
  29747. getClassName(): string;
  29748. /** @hidden */
  29749. readonly _isNode: boolean;
  29750. /**
  29751. * An event triggered when the mesh is disposed
  29752. */
  29753. onDisposeObservable: Observable<Node>;
  29754. private _onDisposeObserver;
  29755. /**
  29756. * Sets a callback that will be raised when the node will be disposed
  29757. */
  29758. set onDispose(callback: () => void);
  29759. /**
  29760. * Creates a new Node
  29761. * @param name the name and id to be given to this node
  29762. * @param scene the scene this node will be added to
  29763. */
  29764. constructor(name: string, scene?: Nullable<Scene>);
  29765. /**
  29766. * Gets the scene of the node
  29767. * @returns a scene
  29768. */
  29769. getScene(): Scene;
  29770. /**
  29771. * Gets the engine of the node
  29772. * @returns a Engine
  29773. */
  29774. getEngine(): Engine;
  29775. private _behaviors;
  29776. /**
  29777. * Attach a behavior to the node
  29778. * @see http://doc.babylonjs.com/features/behaviour
  29779. * @param behavior defines the behavior to attach
  29780. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29781. * @returns the current Node
  29782. */
  29783. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29784. /**
  29785. * Remove an attached behavior
  29786. * @see http://doc.babylonjs.com/features/behaviour
  29787. * @param behavior defines the behavior to attach
  29788. * @returns the current Node
  29789. */
  29790. removeBehavior(behavior: Behavior<Node>): Node;
  29791. /**
  29792. * Gets the list of attached behaviors
  29793. * @see http://doc.babylonjs.com/features/behaviour
  29794. */
  29795. get behaviors(): Behavior<Node>[];
  29796. /**
  29797. * Gets an attached behavior by name
  29798. * @param name defines the name of the behavior to look for
  29799. * @see http://doc.babylonjs.com/features/behaviour
  29800. * @returns null if behavior was not found else the requested behavior
  29801. */
  29802. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29803. /**
  29804. * Returns the latest update of the World matrix
  29805. * @returns a Matrix
  29806. */
  29807. getWorldMatrix(): Matrix;
  29808. /** @hidden */
  29809. _getWorldMatrixDeterminant(): number;
  29810. /**
  29811. * Returns directly the latest state of the mesh World matrix.
  29812. * A Matrix is returned.
  29813. */
  29814. get worldMatrixFromCache(): Matrix;
  29815. /** @hidden */
  29816. _initCache(): void;
  29817. /** @hidden */
  29818. updateCache(force?: boolean): void;
  29819. /** @hidden */
  29820. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29821. /** @hidden */
  29822. _updateCache(ignoreParentClass?: boolean): void;
  29823. /** @hidden */
  29824. _isSynchronized(): boolean;
  29825. /** @hidden */
  29826. _markSyncedWithParent(): void;
  29827. /** @hidden */
  29828. isSynchronizedWithParent(): boolean;
  29829. /** @hidden */
  29830. isSynchronized(): boolean;
  29831. /**
  29832. * Is this node ready to be used/rendered
  29833. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29834. * @return true if the node is ready
  29835. */
  29836. isReady(completeCheck?: boolean): boolean;
  29837. /**
  29838. * Is this node enabled?
  29839. * 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
  29840. * @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
  29841. * @return whether this node (and its parent) is enabled
  29842. */
  29843. isEnabled(checkAncestors?: boolean): boolean;
  29844. /** @hidden */
  29845. protected _syncParentEnabledState(): void;
  29846. /**
  29847. * Set the enabled state of this node
  29848. * @param value defines the new enabled state
  29849. */
  29850. setEnabled(value: boolean): void;
  29851. /**
  29852. * Is this node a descendant of the given node?
  29853. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29854. * @param ancestor defines the parent node to inspect
  29855. * @returns a boolean indicating if this node is a descendant of the given node
  29856. */
  29857. isDescendantOf(ancestor: Node): boolean;
  29858. /** @hidden */
  29859. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29860. /**
  29861. * Will return all nodes that have this node as ascendant
  29862. * @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
  29863. * @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
  29864. * @return all children nodes of all types
  29865. */
  29866. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29867. /**
  29868. * Get all child-meshes of this node
  29869. * @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)
  29870. * @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
  29871. * @returns an array of AbstractMesh
  29872. */
  29873. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29874. /**
  29875. * Get all direct children of this node
  29876. * @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
  29877. * @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)
  29878. * @returns an array of Node
  29879. */
  29880. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29881. /** @hidden */
  29882. _setReady(state: boolean): void;
  29883. /**
  29884. * Get an animation by name
  29885. * @param name defines the name of the animation to look for
  29886. * @returns null if not found else the requested animation
  29887. */
  29888. getAnimationByName(name: string): Nullable<Animation>;
  29889. /**
  29890. * Creates an animation range for this node
  29891. * @param name defines the name of the range
  29892. * @param from defines the starting key
  29893. * @param to defines the end key
  29894. */
  29895. createAnimationRange(name: string, from: number, to: number): void;
  29896. /**
  29897. * Delete a specific animation range
  29898. * @param name defines the name of the range to delete
  29899. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29900. */
  29901. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29902. /**
  29903. * Get an animation range by name
  29904. * @param name defines the name of the animation range to look for
  29905. * @returns null if not found else the requested animation range
  29906. */
  29907. getAnimationRange(name: string): Nullable<AnimationRange>;
  29908. /**
  29909. * Gets the list of all animation ranges defined on this node
  29910. * @returns an array
  29911. */
  29912. getAnimationRanges(): Nullable<AnimationRange>[];
  29913. /**
  29914. * Will start the animation sequence
  29915. * @param name defines the range frames for animation sequence
  29916. * @param loop defines if the animation should loop (false by default)
  29917. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29918. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29919. * @returns the object created for this animation. If range does not exist, it will return null
  29920. */
  29921. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29922. /**
  29923. * Serialize animation ranges into a JSON compatible object
  29924. * @returns serialization object
  29925. */
  29926. serializeAnimationRanges(): any;
  29927. /**
  29928. * Computes the world matrix of the node
  29929. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29930. * @returns the world matrix
  29931. */
  29932. computeWorldMatrix(force?: boolean): Matrix;
  29933. /**
  29934. * Releases resources associated with this node.
  29935. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29936. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29937. */
  29938. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29939. /**
  29940. * Parse animation range data from a serialization object and store them into a given node
  29941. * @param node defines where to store the animation ranges
  29942. * @param parsedNode defines the serialization object to read data from
  29943. * @param scene defines the hosting scene
  29944. */
  29945. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29946. /**
  29947. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29948. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29949. * @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
  29950. * @returns the new bounding vectors
  29951. */
  29952. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29953. min: Vector3;
  29954. max: Vector3;
  29955. };
  29956. }
  29957. }
  29958. declare module "babylonjs/Animations/animation" {
  29959. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29960. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29961. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29962. import { Nullable } from "babylonjs/types";
  29963. import { Scene } from "babylonjs/scene";
  29964. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29965. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29966. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29967. import { Node } from "babylonjs/node";
  29968. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29969. import { Size } from "babylonjs/Maths/math.size";
  29970. import { Animatable } from "babylonjs/Animations/animatable";
  29971. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29972. /**
  29973. * @hidden
  29974. */
  29975. export class _IAnimationState {
  29976. key: number;
  29977. repeatCount: number;
  29978. workValue?: any;
  29979. loopMode?: number;
  29980. offsetValue?: any;
  29981. highLimitValue?: any;
  29982. }
  29983. /**
  29984. * Class used to store any kind of animation
  29985. */
  29986. export class Animation {
  29987. /**Name of the animation */
  29988. name: string;
  29989. /**Property to animate */
  29990. targetProperty: string;
  29991. /**The frames per second of the animation */
  29992. framePerSecond: number;
  29993. /**The data type of the animation */
  29994. dataType: number;
  29995. /**The loop mode of the animation */
  29996. loopMode?: number | undefined;
  29997. /**Specifies if blending should be enabled */
  29998. enableBlending?: boolean | undefined;
  29999. /**
  30000. * Use matrix interpolation instead of using direct key value when animating matrices
  30001. */
  30002. static AllowMatricesInterpolation: boolean;
  30003. /**
  30004. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30005. */
  30006. static AllowMatrixDecomposeForInterpolation: boolean;
  30007. /**
  30008. * Stores the key frames of the animation
  30009. */
  30010. private _keys;
  30011. /**
  30012. * Stores the easing function of the animation
  30013. */
  30014. private _easingFunction;
  30015. /**
  30016. * @hidden Internal use only
  30017. */
  30018. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30019. /**
  30020. * The set of event that will be linked to this animation
  30021. */
  30022. private _events;
  30023. /**
  30024. * Stores an array of target property paths
  30025. */
  30026. targetPropertyPath: string[];
  30027. /**
  30028. * Stores the blending speed of the animation
  30029. */
  30030. blendingSpeed: number;
  30031. /**
  30032. * Stores the animation ranges for the animation
  30033. */
  30034. private _ranges;
  30035. /**
  30036. * @hidden Internal use
  30037. */
  30038. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30039. /**
  30040. * Sets up an animation
  30041. * @param property The property to animate
  30042. * @param animationType The animation type to apply
  30043. * @param framePerSecond The frames per second of the animation
  30044. * @param easingFunction The easing function used in the animation
  30045. * @returns The created animation
  30046. */
  30047. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30048. /**
  30049. * Create and start an animation on a node
  30050. * @param name defines the name of the global animation that will be run on all nodes
  30051. * @param node defines the root node where the animation will take place
  30052. * @param targetProperty defines property to animate
  30053. * @param framePerSecond defines the number of frame per second yo use
  30054. * @param totalFrame defines the number of frames in total
  30055. * @param from defines the initial value
  30056. * @param to defines the final value
  30057. * @param loopMode defines which loop mode you want to use (off by default)
  30058. * @param easingFunction defines the easing function to use (linear by default)
  30059. * @param onAnimationEnd defines the callback to call when animation end
  30060. * @returns the animatable created for this animation
  30061. */
  30062. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30063. /**
  30064. * Create and start an animation on a node and its descendants
  30065. * @param name defines the name of the global animation that will be run on all nodes
  30066. * @param node defines the root node where the animation will take place
  30067. * @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
  30068. * @param targetProperty defines property to animate
  30069. * @param framePerSecond defines the number of frame per second to use
  30070. * @param totalFrame defines the number of frames in total
  30071. * @param from defines the initial value
  30072. * @param to defines the final value
  30073. * @param loopMode defines which loop mode you want to use (off by default)
  30074. * @param easingFunction defines the easing function to use (linear by default)
  30075. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30076. * @returns the list of animatables created for all nodes
  30077. * @example https://www.babylonjs-playground.com/#MH0VLI
  30078. */
  30079. 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[]>;
  30080. /**
  30081. * Creates a new animation, merges it with the existing animations and starts it
  30082. * @param name Name of the animation
  30083. * @param node Node which contains the scene that begins the animations
  30084. * @param targetProperty Specifies which property to animate
  30085. * @param framePerSecond The frames per second of the animation
  30086. * @param totalFrame The total number of frames
  30087. * @param from The frame at the beginning of the animation
  30088. * @param to The frame at the end of the animation
  30089. * @param loopMode Specifies the loop mode of the animation
  30090. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30091. * @param onAnimationEnd Callback to run once the animation is complete
  30092. * @returns Nullable animation
  30093. */
  30094. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30095. /**
  30096. * Transition property of an host to the target Value
  30097. * @param property The property to transition
  30098. * @param targetValue The target Value of the property
  30099. * @param host The object where the property to animate belongs
  30100. * @param scene Scene used to run the animation
  30101. * @param frameRate Framerate (in frame/s) to use
  30102. * @param transition The transition type we want to use
  30103. * @param duration The duration of the animation, in milliseconds
  30104. * @param onAnimationEnd Callback trigger at the end of the animation
  30105. * @returns Nullable animation
  30106. */
  30107. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30108. /**
  30109. * Return the array of runtime animations currently using this animation
  30110. */
  30111. get runtimeAnimations(): RuntimeAnimation[];
  30112. /**
  30113. * Specifies if any of the runtime animations are currently running
  30114. */
  30115. get hasRunningRuntimeAnimations(): boolean;
  30116. /**
  30117. * Initializes the animation
  30118. * @param name Name of the animation
  30119. * @param targetProperty Property to animate
  30120. * @param framePerSecond The frames per second of the animation
  30121. * @param dataType The data type of the animation
  30122. * @param loopMode The loop mode of the animation
  30123. * @param enableBlending Specifies if blending should be enabled
  30124. */
  30125. constructor(
  30126. /**Name of the animation */
  30127. name: string,
  30128. /**Property to animate */
  30129. targetProperty: string,
  30130. /**The frames per second of the animation */
  30131. framePerSecond: number,
  30132. /**The data type of the animation */
  30133. dataType: number,
  30134. /**The loop mode of the animation */
  30135. loopMode?: number | undefined,
  30136. /**Specifies if blending should be enabled */
  30137. enableBlending?: boolean | undefined);
  30138. /**
  30139. * Converts the animation to a string
  30140. * @param fullDetails support for multiple levels of logging within scene loading
  30141. * @returns String form of the animation
  30142. */
  30143. toString(fullDetails?: boolean): string;
  30144. /**
  30145. * Add an event to this animation
  30146. * @param event Event to add
  30147. */
  30148. addEvent(event: AnimationEvent): void;
  30149. /**
  30150. * Remove all events found at the given frame
  30151. * @param frame The frame to remove events from
  30152. */
  30153. removeEvents(frame: number): void;
  30154. /**
  30155. * Retrieves all the events from the animation
  30156. * @returns Events from the animation
  30157. */
  30158. getEvents(): AnimationEvent[];
  30159. /**
  30160. * Creates an animation range
  30161. * @param name Name of the animation range
  30162. * @param from Starting frame of the animation range
  30163. * @param to Ending frame of the animation
  30164. */
  30165. createRange(name: string, from: number, to: number): void;
  30166. /**
  30167. * Deletes an animation range by name
  30168. * @param name Name of the animation range to delete
  30169. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30170. */
  30171. deleteRange(name: string, deleteFrames?: boolean): void;
  30172. /**
  30173. * Gets the animation range by name, or null if not defined
  30174. * @param name Name of the animation range
  30175. * @returns Nullable animation range
  30176. */
  30177. getRange(name: string): Nullable<AnimationRange>;
  30178. /**
  30179. * Gets the key frames from the animation
  30180. * @returns The key frames of the animation
  30181. */
  30182. getKeys(): Array<IAnimationKey>;
  30183. /**
  30184. * Gets the highest frame rate of the animation
  30185. * @returns Highest frame rate of the animation
  30186. */
  30187. getHighestFrame(): number;
  30188. /**
  30189. * Gets the easing function of the animation
  30190. * @returns Easing function of the animation
  30191. */
  30192. getEasingFunction(): IEasingFunction;
  30193. /**
  30194. * Sets the easing function of the animation
  30195. * @param easingFunction A custom mathematical formula for animation
  30196. */
  30197. setEasingFunction(easingFunction: EasingFunction): void;
  30198. /**
  30199. * Interpolates a scalar linearly
  30200. * @param startValue Start value of the animation curve
  30201. * @param endValue End value of the animation curve
  30202. * @param gradient Scalar amount to interpolate
  30203. * @returns Interpolated scalar value
  30204. */
  30205. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30206. /**
  30207. * Interpolates a scalar cubically
  30208. * @param startValue Start value of the animation curve
  30209. * @param outTangent End tangent of the animation
  30210. * @param endValue End value of the animation curve
  30211. * @param inTangent Start tangent of the animation curve
  30212. * @param gradient Scalar amount to interpolate
  30213. * @returns Interpolated scalar value
  30214. */
  30215. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30216. /**
  30217. * Interpolates a quaternion using a spherical linear interpolation
  30218. * @param startValue Start value of the animation curve
  30219. * @param endValue End value of the animation curve
  30220. * @param gradient Scalar amount to interpolate
  30221. * @returns Interpolated quaternion value
  30222. */
  30223. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30224. /**
  30225. * Interpolates a quaternion cubically
  30226. * @param startValue Start value of the animation curve
  30227. * @param outTangent End tangent of the animation curve
  30228. * @param endValue End value of the animation curve
  30229. * @param inTangent Start tangent of the animation curve
  30230. * @param gradient Scalar amount to interpolate
  30231. * @returns Interpolated quaternion value
  30232. */
  30233. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30234. /**
  30235. * Interpolates a Vector3 linearl
  30236. * @param startValue Start value of the animation curve
  30237. * @param endValue End value of the animation curve
  30238. * @param gradient Scalar amount to interpolate
  30239. * @returns Interpolated scalar value
  30240. */
  30241. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30242. /**
  30243. * Interpolates a Vector3 cubically
  30244. * @param startValue Start value of the animation curve
  30245. * @param outTangent End tangent of the animation
  30246. * @param endValue End value of the animation curve
  30247. * @param inTangent Start tangent of the animation curve
  30248. * @param gradient Scalar amount to interpolate
  30249. * @returns InterpolatedVector3 value
  30250. */
  30251. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30252. /**
  30253. * Interpolates a Vector2 linearly
  30254. * @param startValue Start value of the animation curve
  30255. * @param endValue End value of the animation curve
  30256. * @param gradient Scalar amount to interpolate
  30257. * @returns Interpolated Vector2 value
  30258. */
  30259. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30260. /**
  30261. * Interpolates a Vector2 cubically
  30262. * @param startValue Start value of the animation curve
  30263. * @param outTangent End tangent of the animation
  30264. * @param endValue End value of the animation curve
  30265. * @param inTangent Start tangent of the animation curve
  30266. * @param gradient Scalar amount to interpolate
  30267. * @returns Interpolated Vector2 value
  30268. */
  30269. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30270. /**
  30271. * Interpolates a size linearly
  30272. * @param startValue Start value of the animation curve
  30273. * @param endValue End value of the animation curve
  30274. * @param gradient Scalar amount to interpolate
  30275. * @returns Interpolated Size value
  30276. */
  30277. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30278. /**
  30279. * Interpolates a Color3 linearly
  30280. * @param startValue Start value of the animation curve
  30281. * @param endValue End value of the animation curve
  30282. * @param gradient Scalar amount to interpolate
  30283. * @returns Interpolated Color3 value
  30284. */
  30285. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30286. /**
  30287. * Interpolates a Color4 linearly
  30288. * @param startValue Start value of the animation curve
  30289. * @param endValue End value of the animation curve
  30290. * @param gradient Scalar amount to interpolate
  30291. * @returns Interpolated Color3 value
  30292. */
  30293. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30294. /**
  30295. * @hidden Internal use only
  30296. */
  30297. _getKeyValue(value: any): any;
  30298. /**
  30299. * @hidden Internal use only
  30300. */
  30301. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30302. /**
  30303. * Defines the function to use to interpolate matrices
  30304. * @param startValue defines the start matrix
  30305. * @param endValue defines the end matrix
  30306. * @param gradient defines the gradient between both matrices
  30307. * @param result defines an optional target matrix where to store the interpolation
  30308. * @returns the interpolated matrix
  30309. */
  30310. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30311. /**
  30312. * Makes a copy of the animation
  30313. * @returns Cloned animation
  30314. */
  30315. clone(): Animation;
  30316. /**
  30317. * Sets the key frames of the animation
  30318. * @param values The animation key frames to set
  30319. */
  30320. setKeys(values: Array<IAnimationKey>): void;
  30321. /**
  30322. * Serializes the animation to an object
  30323. * @returns Serialized object
  30324. */
  30325. serialize(): any;
  30326. /**
  30327. * Float animation type
  30328. */
  30329. static readonly ANIMATIONTYPE_FLOAT: number;
  30330. /**
  30331. * Vector3 animation type
  30332. */
  30333. static readonly ANIMATIONTYPE_VECTOR3: number;
  30334. /**
  30335. * Quaternion animation type
  30336. */
  30337. static readonly ANIMATIONTYPE_QUATERNION: number;
  30338. /**
  30339. * Matrix animation type
  30340. */
  30341. static readonly ANIMATIONTYPE_MATRIX: number;
  30342. /**
  30343. * Color3 animation type
  30344. */
  30345. static readonly ANIMATIONTYPE_COLOR3: number;
  30346. /**
  30347. * Color3 animation type
  30348. */
  30349. static readonly ANIMATIONTYPE_COLOR4: number;
  30350. /**
  30351. * Vector2 animation type
  30352. */
  30353. static readonly ANIMATIONTYPE_VECTOR2: number;
  30354. /**
  30355. * Size animation type
  30356. */
  30357. static readonly ANIMATIONTYPE_SIZE: number;
  30358. /**
  30359. * Relative Loop Mode
  30360. */
  30361. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30362. /**
  30363. * Cycle Loop Mode
  30364. */
  30365. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30366. /**
  30367. * Constant Loop Mode
  30368. */
  30369. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30370. /** @hidden */
  30371. static _UniversalLerp(left: any, right: any, amount: number): any;
  30372. /**
  30373. * Parses an animation object and creates an animation
  30374. * @param parsedAnimation Parsed animation object
  30375. * @returns Animation object
  30376. */
  30377. static Parse(parsedAnimation: any): Animation;
  30378. /**
  30379. * Appends the serialized animations from the source animations
  30380. * @param source Source containing the animations
  30381. * @param destination Target to store the animations
  30382. */
  30383. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30384. }
  30385. }
  30386. declare module "babylonjs/Animations/animatable.interface" {
  30387. import { Nullable } from "babylonjs/types";
  30388. import { Animation } from "babylonjs/Animations/animation";
  30389. /**
  30390. * Interface containing an array of animations
  30391. */
  30392. export interface IAnimatable {
  30393. /**
  30394. * Array of animations
  30395. */
  30396. animations: Nullable<Array<Animation>>;
  30397. }
  30398. }
  30399. declare module "babylonjs/Misc/decorators" {
  30400. import { Nullable } from "babylonjs/types";
  30401. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30402. import { Scene } from "babylonjs/scene";
  30403. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30404. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30405. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30406. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30407. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30408. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30409. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. /**
  30417. * Decorator used to define property that can be serialized as reference to a camera
  30418. * @param sourceName defines the name of the property to decorate
  30419. */
  30420. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30421. /**
  30422. * Class used to help serialization objects
  30423. */
  30424. export class SerializationHelper {
  30425. /** @hidden */
  30426. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30427. /** @hidden */
  30428. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30429. /** @hidden */
  30430. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30431. /** @hidden */
  30432. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30433. /**
  30434. * Appends the serialized animations from the source animations
  30435. * @param source Source containing the animations
  30436. * @param destination Target to store the animations
  30437. */
  30438. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30439. /**
  30440. * Static function used to serialized a specific entity
  30441. * @param entity defines the entity to serialize
  30442. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30443. * @returns a JSON compatible object representing the serialization of the entity
  30444. */
  30445. static Serialize<T>(entity: T, serializationObject?: any): any;
  30446. /**
  30447. * Creates a new entity from a serialization data object
  30448. * @param creationFunction defines a function used to instanciated the new entity
  30449. * @param source defines the source serialization data
  30450. * @param scene defines the hosting scene
  30451. * @param rootUrl defines the root url for resources
  30452. * @returns a new entity
  30453. */
  30454. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30455. /**
  30456. * Clones an object
  30457. * @param creationFunction defines the function used to instanciate the new object
  30458. * @param source defines the source object
  30459. * @returns the cloned object
  30460. */
  30461. static Clone<T>(creationFunction: () => T, source: T): T;
  30462. /**
  30463. * Instanciates a new object based on a source one (some data will be shared between both object)
  30464. * @param creationFunction defines the function used to instanciate the new object
  30465. * @param source defines the source object
  30466. * @returns the new object
  30467. */
  30468. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30469. }
  30470. }
  30471. declare module "babylonjs/Misc/guid" {
  30472. /**
  30473. * Class used to manipulate GUIDs
  30474. */
  30475. export class GUID {
  30476. /**
  30477. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30478. * Be aware Math.random() could cause collisions, but:
  30479. * "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"
  30480. * @returns a pseudo random id
  30481. */
  30482. static RandomId(): string;
  30483. }
  30484. }
  30485. declare module "babylonjs/Materials/Textures/baseTexture" {
  30486. import { Observable } from "babylonjs/Misc/observable";
  30487. import { Nullable } from "babylonjs/types";
  30488. import { Scene } from "babylonjs/scene";
  30489. import { Matrix } from "babylonjs/Maths/math.vector";
  30490. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30491. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30492. import { ISize } from "babylonjs/Maths/math.size";
  30493. import "babylonjs/Misc/fileTools";
  30494. /**
  30495. * Base class of all the textures in babylon.
  30496. * It groups all the common properties the materials, post process, lights... might need
  30497. * in order to make a correct use of the texture.
  30498. */
  30499. export class BaseTexture implements IAnimatable {
  30500. /**
  30501. * Default anisotropic filtering level for the application.
  30502. * It is set to 4 as a good tradeoff between perf and quality.
  30503. */
  30504. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30505. /**
  30506. * Gets or sets the unique id of the texture
  30507. */
  30508. uniqueId: number;
  30509. /**
  30510. * Define the name of the texture.
  30511. */
  30512. name: string;
  30513. /**
  30514. * Gets or sets an object used to store user defined information.
  30515. */
  30516. metadata: any;
  30517. /**
  30518. * For internal use only. Please do not use.
  30519. */
  30520. reservedDataStore: any;
  30521. private _hasAlpha;
  30522. /**
  30523. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30524. */
  30525. set hasAlpha(value: boolean);
  30526. get hasAlpha(): boolean;
  30527. /**
  30528. * Defines if the alpha value should be determined via the rgb values.
  30529. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30530. */
  30531. getAlphaFromRGB: boolean;
  30532. /**
  30533. * Intensity or strength of the texture.
  30534. * It is commonly used by materials to fine tune the intensity of the texture
  30535. */
  30536. level: number;
  30537. /**
  30538. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30539. * This is part of the texture as textures usually maps to one uv set.
  30540. */
  30541. coordinatesIndex: number;
  30542. private _coordinatesMode;
  30543. /**
  30544. * How a texture is mapped.
  30545. *
  30546. * | Value | Type | Description |
  30547. * | ----- | ----------------------------------- | ----------- |
  30548. * | 0 | EXPLICIT_MODE | |
  30549. * | 1 | SPHERICAL_MODE | |
  30550. * | 2 | PLANAR_MODE | |
  30551. * | 3 | CUBIC_MODE | |
  30552. * | 4 | PROJECTION_MODE | |
  30553. * | 5 | SKYBOX_MODE | |
  30554. * | 6 | INVCUBIC_MODE | |
  30555. * | 7 | EQUIRECTANGULAR_MODE | |
  30556. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30557. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30558. */
  30559. set coordinatesMode(value: number);
  30560. get coordinatesMode(): number;
  30561. /**
  30562. * | Value | Type | Description |
  30563. * | ----- | ------------------ | ----------- |
  30564. * | 0 | CLAMP_ADDRESSMODE | |
  30565. * | 1 | WRAP_ADDRESSMODE | |
  30566. * | 2 | MIRROR_ADDRESSMODE | |
  30567. */
  30568. wrapU: number;
  30569. /**
  30570. * | Value | Type | Description |
  30571. * | ----- | ------------------ | ----------- |
  30572. * | 0 | CLAMP_ADDRESSMODE | |
  30573. * | 1 | WRAP_ADDRESSMODE | |
  30574. * | 2 | MIRROR_ADDRESSMODE | |
  30575. */
  30576. wrapV: number;
  30577. /**
  30578. * | Value | Type | Description |
  30579. * | ----- | ------------------ | ----------- |
  30580. * | 0 | CLAMP_ADDRESSMODE | |
  30581. * | 1 | WRAP_ADDRESSMODE | |
  30582. * | 2 | MIRROR_ADDRESSMODE | |
  30583. */
  30584. wrapR: number;
  30585. /**
  30586. * With compliant hardware and browser (supporting anisotropic filtering)
  30587. * this defines the level of anisotropic filtering in the texture.
  30588. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30589. */
  30590. anisotropicFilteringLevel: number;
  30591. /**
  30592. * Define if the texture is a cube texture or if false a 2d texture.
  30593. */
  30594. get isCube(): boolean;
  30595. set isCube(value: boolean);
  30596. /**
  30597. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30598. */
  30599. get is3D(): boolean;
  30600. set is3D(value: boolean);
  30601. /**
  30602. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30603. */
  30604. get is2DArray(): boolean;
  30605. set is2DArray(value: boolean);
  30606. /**
  30607. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30608. * HDR texture are usually stored in linear space.
  30609. * This only impacts the PBR and Background materials
  30610. */
  30611. gammaSpace: boolean;
  30612. /**
  30613. * Gets or sets whether or not the texture contains RGBD data.
  30614. */
  30615. get isRGBD(): boolean;
  30616. set isRGBD(value: boolean);
  30617. /**
  30618. * Is Z inverted in the texture (useful in a cube texture).
  30619. */
  30620. invertZ: boolean;
  30621. /**
  30622. * Are mip maps generated for this texture or not.
  30623. */
  30624. get noMipmap(): boolean;
  30625. /**
  30626. * @hidden
  30627. */
  30628. lodLevelInAlpha: boolean;
  30629. /**
  30630. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30631. */
  30632. get lodGenerationOffset(): number;
  30633. set lodGenerationOffset(value: number);
  30634. /**
  30635. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30636. */
  30637. get lodGenerationScale(): number;
  30638. set lodGenerationScale(value: number);
  30639. /**
  30640. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30641. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30642. * average roughness values.
  30643. */
  30644. get linearSpecularLOD(): boolean;
  30645. set linearSpecularLOD(value: boolean);
  30646. /**
  30647. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30648. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30649. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30650. */
  30651. get irradianceTexture(): Nullable<BaseTexture>;
  30652. set irradianceTexture(value: Nullable<BaseTexture>);
  30653. /**
  30654. * Define if the texture is a render target.
  30655. */
  30656. isRenderTarget: boolean;
  30657. /**
  30658. * Define the unique id of the texture in the scene.
  30659. */
  30660. get uid(): string;
  30661. /**
  30662. * Return a string representation of the texture.
  30663. * @returns the texture as a string
  30664. */
  30665. toString(): string;
  30666. /**
  30667. * Get the class name of the texture.
  30668. * @returns "BaseTexture"
  30669. */
  30670. getClassName(): string;
  30671. /**
  30672. * Define the list of animation attached to the texture.
  30673. */
  30674. animations: import("babylonjs/Animations/animation").Animation[];
  30675. /**
  30676. * An event triggered when the texture is disposed.
  30677. */
  30678. onDisposeObservable: Observable<BaseTexture>;
  30679. private _onDisposeObserver;
  30680. /**
  30681. * Callback triggered when the texture has been disposed.
  30682. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30683. */
  30684. set onDispose(callback: () => void);
  30685. /**
  30686. * Define the current state of the loading sequence when in delayed load mode.
  30687. */
  30688. delayLoadState: number;
  30689. private _scene;
  30690. /** @hidden */
  30691. _texture: Nullable<InternalTexture>;
  30692. private _uid;
  30693. /**
  30694. * Define if the texture is preventinga material to render or not.
  30695. * If not and the texture is not ready, the engine will use a default black texture instead.
  30696. */
  30697. get isBlocking(): boolean;
  30698. /**
  30699. * Instantiates a new BaseTexture.
  30700. * Base class of all the textures in babylon.
  30701. * It groups all the common properties the materials, post process, lights... might need
  30702. * in order to make a correct use of the texture.
  30703. * @param scene Define the scene the texture blongs to
  30704. */
  30705. constructor(scene: Nullable<Scene>);
  30706. /**
  30707. * Get the scene the texture belongs to.
  30708. * @returns the scene or null if undefined
  30709. */
  30710. getScene(): Nullable<Scene>;
  30711. /**
  30712. * Get the texture transform matrix used to offset tile the texture for istance.
  30713. * @returns the transformation matrix
  30714. */
  30715. getTextureMatrix(): Matrix;
  30716. /**
  30717. * Get the texture reflection matrix used to rotate/transform the reflection.
  30718. * @returns the reflection matrix
  30719. */
  30720. getReflectionTextureMatrix(): Matrix;
  30721. /**
  30722. * Get the underlying lower level texture from Babylon.
  30723. * @returns the insternal texture
  30724. */
  30725. getInternalTexture(): Nullable<InternalTexture>;
  30726. /**
  30727. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30728. * @returns true if ready or not blocking
  30729. */
  30730. isReadyOrNotBlocking(): boolean;
  30731. /**
  30732. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30733. * @returns true if fully ready
  30734. */
  30735. isReady(): boolean;
  30736. private _cachedSize;
  30737. /**
  30738. * Get the size of the texture.
  30739. * @returns the texture size.
  30740. */
  30741. getSize(): ISize;
  30742. /**
  30743. * Get the base size of the texture.
  30744. * It can be different from the size if the texture has been resized for POT for instance
  30745. * @returns the base size
  30746. */
  30747. getBaseSize(): ISize;
  30748. /**
  30749. * Update the sampling mode of the texture.
  30750. * Default is Trilinear mode.
  30751. *
  30752. * | Value | Type | Description |
  30753. * | ----- | ------------------ | ----------- |
  30754. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30755. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30756. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30757. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30758. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30759. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30760. * | 7 | NEAREST_LINEAR | |
  30761. * | 8 | NEAREST_NEAREST | |
  30762. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30763. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30764. * | 11 | LINEAR_LINEAR | |
  30765. * | 12 | LINEAR_NEAREST | |
  30766. *
  30767. * > _mag_: magnification filter (close to the viewer)
  30768. * > _min_: minification filter (far from the viewer)
  30769. * > _mip_: filter used between mip map levels
  30770. *@param samplingMode Define the new sampling mode of the texture
  30771. */
  30772. updateSamplingMode(samplingMode: number): void;
  30773. /**
  30774. * Scales the texture if is `canRescale()`
  30775. * @param ratio the resize factor we want to use to rescale
  30776. */
  30777. scale(ratio: number): void;
  30778. /**
  30779. * Get if the texture can rescale.
  30780. */
  30781. get canRescale(): boolean;
  30782. /** @hidden */
  30783. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30784. /** @hidden */
  30785. _rebuild(): void;
  30786. /**
  30787. * Triggers the load sequence in delayed load mode.
  30788. */
  30789. delayLoad(): void;
  30790. /**
  30791. * Clones the texture.
  30792. * @returns the cloned texture
  30793. */
  30794. clone(): Nullable<BaseTexture>;
  30795. /**
  30796. * Get the texture underlying type (INT, FLOAT...)
  30797. */
  30798. get textureType(): number;
  30799. /**
  30800. * Get the texture underlying format (RGB, RGBA...)
  30801. */
  30802. get textureFormat(): number;
  30803. /**
  30804. * Indicates that textures need to be re-calculated for all materials
  30805. */
  30806. protected _markAllSubMeshesAsTexturesDirty(): void;
  30807. /**
  30808. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30809. * This will returns an RGBA array buffer containing either in values (0-255) or
  30810. * float values (0-1) depending of the underlying buffer type.
  30811. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30812. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30813. * @param buffer defines a user defined buffer to fill with data (can be null)
  30814. * @returns The Array buffer containing the pixels data.
  30815. */
  30816. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30817. /**
  30818. * Release and destroy the underlying lower level texture aka internalTexture.
  30819. */
  30820. releaseInternalTexture(): void;
  30821. /** @hidden */
  30822. get _lodTextureHigh(): Nullable<BaseTexture>;
  30823. /** @hidden */
  30824. get _lodTextureMid(): Nullable<BaseTexture>;
  30825. /** @hidden */
  30826. get _lodTextureLow(): Nullable<BaseTexture>;
  30827. /**
  30828. * Dispose the texture and release its associated resources.
  30829. */
  30830. dispose(): void;
  30831. /**
  30832. * Serialize the texture into a JSON representation that can be parsed later on.
  30833. * @returns the JSON representation of the texture
  30834. */
  30835. serialize(): any;
  30836. /**
  30837. * Helper function to be called back once a list of texture contains only ready textures.
  30838. * @param textures Define the list of textures to wait for
  30839. * @param callback Define the callback triggered once the entire list will be ready
  30840. */
  30841. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30842. }
  30843. }
  30844. declare module "babylonjs/Materials/effect" {
  30845. import { Observable } from "babylonjs/Misc/observable";
  30846. import { Nullable } from "babylonjs/types";
  30847. import { IDisposable } from "babylonjs/scene";
  30848. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30849. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30850. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30851. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30852. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30853. import { Engine } from "babylonjs/Engines/engine";
  30854. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30855. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30857. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30858. /**
  30859. * Options to be used when creating an effect.
  30860. */
  30861. export interface IEffectCreationOptions {
  30862. /**
  30863. * Atrributes that will be used in the shader.
  30864. */
  30865. attributes: string[];
  30866. /**
  30867. * Uniform varible names that will be set in the shader.
  30868. */
  30869. uniformsNames: string[];
  30870. /**
  30871. * Uniform buffer variable names that will be set in the shader.
  30872. */
  30873. uniformBuffersNames: string[];
  30874. /**
  30875. * Sampler texture variable names that will be set in the shader.
  30876. */
  30877. samplers: string[];
  30878. /**
  30879. * Define statements that will be set in the shader.
  30880. */
  30881. defines: any;
  30882. /**
  30883. * Possible fallbacks for this effect to improve performance when needed.
  30884. */
  30885. fallbacks: Nullable<IEffectFallbacks>;
  30886. /**
  30887. * Callback that will be called when the shader is compiled.
  30888. */
  30889. onCompiled: Nullable<(effect: Effect) => void>;
  30890. /**
  30891. * Callback that will be called if an error occurs during shader compilation.
  30892. */
  30893. onError: Nullable<(effect: Effect, errors: string) => void>;
  30894. /**
  30895. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30896. */
  30897. indexParameters?: any;
  30898. /**
  30899. * Max number of lights that can be used in the shader.
  30900. */
  30901. maxSimultaneousLights?: number;
  30902. /**
  30903. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30904. */
  30905. transformFeedbackVaryings?: Nullable<string[]>;
  30906. }
  30907. /**
  30908. * Effect containing vertex and fragment shader that can be executed on an object.
  30909. */
  30910. export class Effect implements IDisposable {
  30911. /**
  30912. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30913. */
  30914. static ShadersRepository: string;
  30915. /**
  30916. * Name of the effect.
  30917. */
  30918. name: any;
  30919. /**
  30920. * String container all the define statements that should be set on the shader.
  30921. */
  30922. defines: string;
  30923. /**
  30924. * Callback that will be called when the shader is compiled.
  30925. */
  30926. onCompiled: Nullable<(effect: Effect) => void>;
  30927. /**
  30928. * Callback that will be called if an error occurs during shader compilation.
  30929. */
  30930. onError: Nullable<(effect: Effect, errors: string) => void>;
  30931. /**
  30932. * Callback that will be called when effect is bound.
  30933. */
  30934. onBind: Nullable<(effect: Effect) => void>;
  30935. /**
  30936. * Unique ID of the effect.
  30937. */
  30938. uniqueId: number;
  30939. /**
  30940. * Observable that will be called when the shader is compiled.
  30941. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30942. */
  30943. onCompileObservable: Observable<Effect>;
  30944. /**
  30945. * Observable that will be called if an error occurs during shader compilation.
  30946. */
  30947. onErrorObservable: Observable<Effect>;
  30948. /** @hidden */
  30949. _onBindObservable: Nullable<Observable<Effect>>;
  30950. /**
  30951. * @hidden
  30952. * Specifies if the effect was previously ready
  30953. */
  30954. _wasPreviouslyReady: boolean;
  30955. /**
  30956. * Observable that will be called when effect is bound.
  30957. */
  30958. get onBindObservable(): Observable<Effect>;
  30959. /** @hidden */
  30960. _bonesComputationForcedToCPU: boolean;
  30961. private static _uniqueIdSeed;
  30962. private _engine;
  30963. private _uniformBuffersNames;
  30964. private _uniformsNames;
  30965. private _samplerList;
  30966. private _samplers;
  30967. private _isReady;
  30968. private _compilationError;
  30969. private _allFallbacksProcessed;
  30970. private _attributesNames;
  30971. private _attributes;
  30972. private _attributeLocationByName;
  30973. private _uniforms;
  30974. /**
  30975. * Key for the effect.
  30976. * @hidden
  30977. */
  30978. _key: string;
  30979. private _indexParameters;
  30980. private _fallbacks;
  30981. private _vertexSourceCode;
  30982. private _fragmentSourceCode;
  30983. private _vertexSourceCodeOverride;
  30984. private _fragmentSourceCodeOverride;
  30985. private _transformFeedbackVaryings;
  30986. /**
  30987. * Compiled shader to webGL program.
  30988. * @hidden
  30989. */
  30990. _pipelineContext: Nullable<IPipelineContext>;
  30991. private _valueCache;
  30992. private static _baseCache;
  30993. /**
  30994. * Instantiates an effect.
  30995. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30996. * @param baseName Name of the effect.
  30997. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30998. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30999. * @param samplers List of sampler variables that will be passed to the shader.
  31000. * @param engine Engine to be used to render the effect
  31001. * @param defines Define statements to be added to the shader.
  31002. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31003. * @param onCompiled Callback that will be called when the shader is compiled.
  31004. * @param onError Callback that will be called if an error occurs during shader compilation.
  31005. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31006. */
  31007. 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);
  31008. private _useFinalCode;
  31009. /**
  31010. * Unique key for this effect
  31011. */
  31012. get key(): string;
  31013. /**
  31014. * If the effect has been compiled and prepared.
  31015. * @returns if the effect is compiled and prepared.
  31016. */
  31017. isReady(): boolean;
  31018. private _isReadyInternal;
  31019. /**
  31020. * The engine the effect was initialized with.
  31021. * @returns the engine.
  31022. */
  31023. getEngine(): Engine;
  31024. /**
  31025. * The pipeline context for this effect
  31026. * @returns the associated pipeline context
  31027. */
  31028. getPipelineContext(): Nullable<IPipelineContext>;
  31029. /**
  31030. * The set of names of attribute variables for the shader.
  31031. * @returns An array of attribute names.
  31032. */
  31033. getAttributesNames(): string[];
  31034. /**
  31035. * Returns the attribute at the given index.
  31036. * @param index The index of the attribute.
  31037. * @returns The location of the attribute.
  31038. */
  31039. getAttributeLocation(index: number): number;
  31040. /**
  31041. * Returns the attribute based on the name of the variable.
  31042. * @param name of the attribute to look up.
  31043. * @returns the attribute location.
  31044. */
  31045. getAttributeLocationByName(name: string): number;
  31046. /**
  31047. * The number of attributes.
  31048. * @returns the numnber of attributes.
  31049. */
  31050. getAttributesCount(): number;
  31051. /**
  31052. * Gets the index of a uniform variable.
  31053. * @param uniformName of the uniform to look up.
  31054. * @returns the index.
  31055. */
  31056. getUniformIndex(uniformName: string): number;
  31057. /**
  31058. * Returns the attribute based on the name of the variable.
  31059. * @param uniformName of the uniform to look up.
  31060. * @returns the location of the uniform.
  31061. */
  31062. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31063. /**
  31064. * Returns an array of sampler variable names
  31065. * @returns The array of sampler variable neames.
  31066. */
  31067. getSamplers(): string[];
  31068. /**
  31069. * The error from the last compilation.
  31070. * @returns the error string.
  31071. */
  31072. getCompilationError(): string;
  31073. /**
  31074. * Gets a boolean indicating that all fallbacks were used during compilation
  31075. * @returns true if all fallbacks were used
  31076. */
  31077. allFallbacksProcessed(): boolean;
  31078. /**
  31079. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31080. * @param func The callback to be used.
  31081. */
  31082. executeWhenCompiled(func: (effect: Effect) => void): void;
  31083. private _checkIsReady;
  31084. private _loadShader;
  31085. /**
  31086. * Recompiles the webGL program
  31087. * @param vertexSourceCode The source code for the vertex shader.
  31088. * @param fragmentSourceCode The source code for the fragment shader.
  31089. * @param onCompiled Callback called when completed.
  31090. * @param onError Callback called on error.
  31091. * @hidden
  31092. */
  31093. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31094. /**
  31095. * Prepares the effect
  31096. * @hidden
  31097. */
  31098. _prepareEffect(): void;
  31099. private _processCompilationErrors;
  31100. /**
  31101. * Checks if the effect is supported. (Must be called after compilation)
  31102. */
  31103. get isSupported(): boolean;
  31104. /**
  31105. * Binds a texture to the engine to be used as output of the shader.
  31106. * @param channel Name of the output variable.
  31107. * @param texture Texture to bind.
  31108. * @hidden
  31109. */
  31110. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31111. /**
  31112. * Sets a texture on the engine to be used in the shader.
  31113. * @param channel Name of the sampler variable.
  31114. * @param texture Texture to set.
  31115. */
  31116. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31117. /**
  31118. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31119. * @param channel Name of the sampler variable.
  31120. * @param texture Texture to set.
  31121. */
  31122. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31123. /**
  31124. * Sets an array of textures on the engine to be used in the shader.
  31125. * @param channel Name of the variable.
  31126. * @param textures Textures to set.
  31127. */
  31128. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31129. /**
  31130. * 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)
  31131. * @param channel Name of the sampler variable.
  31132. * @param postProcess Post process to get the input texture from.
  31133. */
  31134. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31135. /**
  31136. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31137. * 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)
  31138. * @param channel Name of the sampler variable.
  31139. * @param postProcess Post process to get the output texture from.
  31140. */
  31141. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31142. /** @hidden */
  31143. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31144. /** @hidden */
  31145. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31146. /** @hidden */
  31147. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31148. /** @hidden */
  31149. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31150. /**
  31151. * Binds a buffer to a uniform.
  31152. * @param buffer Buffer to bind.
  31153. * @param name Name of the uniform variable to bind to.
  31154. */
  31155. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31156. /**
  31157. * Binds block to a uniform.
  31158. * @param blockName Name of the block to bind.
  31159. * @param index Index to bind.
  31160. */
  31161. bindUniformBlock(blockName: string, index: number): void;
  31162. /**
  31163. * Sets an interger value on a uniform variable.
  31164. * @param uniformName Name of the variable.
  31165. * @param value Value to be set.
  31166. * @returns this effect.
  31167. */
  31168. setInt(uniformName: string, value: number): Effect;
  31169. /**
  31170. * Sets an int array on a uniform variable.
  31171. * @param uniformName Name of the variable.
  31172. * @param array array to be set.
  31173. * @returns this effect.
  31174. */
  31175. setIntArray(uniformName: string, array: Int32Array): Effect;
  31176. /**
  31177. * 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)
  31178. * @param uniformName Name of the variable.
  31179. * @param array array to be set.
  31180. * @returns this effect.
  31181. */
  31182. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31183. /**
  31184. * 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)
  31185. * @param uniformName Name of the variable.
  31186. * @param array array to be set.
  31187. * @returns this effect.
  31188. */
  31189. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31190. /**
  31191. * 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)
  31192. * @param uniformName Name of the variable.
  31193. * @param array array to be set.
  31194. * @returns this effect.
  31195. */
  31196. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31197. /**
  31198. * Sets an float array on a uniform variable.
  31199. * @param uniformName Name of the variable.
  31200. * @param array array to be set.
  31201. * @returns this effect.
  31202. */
  31203. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31204. /**
  31205. * 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)
  31206. * @param uniformName Name of the variable.
  31207. * @param array array to be set.
  31208. * @returns this effect.
  31209. */
  31210. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31211. /**
  31212. * 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)
  31213. * @param uniformName Name of the variable.
  31214. * @param array array to be set.
  31215. * @returns this effect.
  31216. */
  31217. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31218. /**
  31219. * 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)
  31220. * @param uniformName Name of the variable.
  31221. * @param array array to be set.
  31222. * @returns this effect.
  31223. */
  31224. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31225. /**
  31226. * Sets an array on a uniform variable.
  31227. * @param uniformName Name of the variable.
  31228. * @param array array to be set.
  31229. * @returns this effect.
  31230. */
  31231. setArray(uniformName: string, array: number[]): Effect;
  31232. /**
  31233. * 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)
  31234. * @param uniformName Name of the variable.
  31235. * @param array array to be set.
  31236. * @returns this effect.
  31237. */
  31238. setArray2(uniformName: string, array: number[]): Effect;
  31239. /**
  31240. * 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)
  31241. * @param uniformName Name of the variable.
  31242. * @param array array to be set.
  31243. * @returns this effect.
  31244. */
  31245. setArray3(uniformName: string, array: number[]): Effect;
  31246. /**
  31247. * 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)
  31248. * @param uniformName Name of the variable.
  31249. * @param array array to be set.
  31250. * @returns this effect.
  31251. */
  31252. setArray4(uniformName: string, array: number[]): Effect;
  31253. /**
  31254. * Sets matrices on a uniform variable.
  31255. * @param uniformName Name of the variable.
  31256. * @param matrices matrices to be set.
  31257. * @returns this effect.
  31258. */
  31259. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31260. /**
  31261. * Sets matrix on a uniform variable.
  31262. * @param uniformName Name of the variable.
  31263. * @param matrix matrix to be set.
  31264. * @returns this effect.
  31265. */
  31266. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31267. /**
  31268. * 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)
  31269. * @param uniformName Name of the variable.
  31270. * @param matrix matrix to be set.
  31271. * @returns this effect.
  31272. */
  31273. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31274. /**
  31275. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31276. * @param uniformName Name of the variable.
  31277. * @param matrix matrix to be set.
  31278. * @returns this effect.
  31279. */
  31280. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31281. /**
  31282. * Sets a float on a uniform variable.
  31283. * @param uniformName Name of the variable.
  31284. * @param value value to be set.
  31285. * @returns this effect.
  31286. */
  31287. setFloat(uniformName: string, value: number): Effect;
  31288. /**
  31289. * Sets a boolean on a uniform variable.
  31290. * @param uniformName Name of the variable.
  31291. * @param bool value to be set.
  31292. * @returns this effect.
  31293. */
  31294. setBool(uniformName: string, bool: boolean): Effect;
  31295. /**
  31296. * Sets a Vector2 on a uniform variable.
  31297. * @param uniformName Name of the variable.
  31298. * @param vector2 vector2 to be set.
  31299. * @returns this effect.
  31300. */
  31301. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31302. /**
  31303. * Sets a float2 on a uniform variable.
  31304. * @param uniformName Name of the variable.
  31305. * @param x First float in float2.
  31306. * @param y Second float in float2.
  31307. * @returns this effect.
  31308. */
  31309. setFloat2(uniformName: string, x: number, y: number): Effect;
  31310. /**
  31311. * Sets a Vector3 on a uniform variable.
  31312. * @param uniformName Name of the variable.
  31313. * @param vector3 Value to be set.
  31314. * @returns this effect.
  31315. */
  31316. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31317. /**
  31318. * Sets a float3 on a uniform variable.
  31319. * @param uniformName Name of the variable.
  31320. * @param x First float in float3.
  31321. * @param y Second float in float3.
  31322. * @param z Third float in float3.
  31323. * @returns this effect.
  31324. */
  31325. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31326. /**
  31327. * Sets a Vector4 on a uniform variable.
  31328. * @param uniformName Name of the variable.
  31329. * @param vector4 Value to be set.
  31330. * @returns this effect.
  31331. */
  31332. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31333. /**
  31334. * Sets a float4 on a uniform variable.
  31335. * @param uniformName Name of the variable.
  31336. * @param x First float in float4.
  31337. * @param y Second float in float4.
  31338. * @param z Third float in float4.
  31339. * @param w Fourth float in float4.
  31340. * @returns this effect.
  31341. */
  31342. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31343. /**
  31344. * Sets a Color3 on a uniform variable.
  31345. * @param uniformName Name of the variable.
  31346. * @param color3 Value to be set.
  31347. * @returns this effect.
  31348. */
  31349. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31350. /**
  31351. * Sets a Color4 on a uniform variable.
  31352. * @param uniformName Name of the variable.
  31353. * @param color3 Value to be set.
  31354. * @param alpha Alpha value to be set.
  31355. * @returns this effect.
  31356. */
  31357. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31358. /**
  31359. * Sets a Color4 on a uniform variable
  31360. * @param uniformName defines the name of the variable
  31361. * @param color4 defines the value to be set
  31362. * @returns this effect.
  31363. */
  31364. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31365. /** Release all associated resources */
  31366. dispose(): void;
  31367. /**
  31368. * This function will add a new shader to the shader store
  31369. * @param name the name of the shader
  31370. * @param pixelShader optional pixel shader content
  31371. * @param vertexShader optional vertex shader content
  31372. */
  31373. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31374. /**
  31375. * Store of each shader (The can be looked up using effect.key)
  31376. */
  31377. static ShadersStore: {
  31378. [key: string]: string;
  31379. };
  31380. /**
  31381. * Store of each included file for a shader (The can be looked up using effect.key)
  31382. */
  31383. static IncludesShadersStore: {
  31384. [key: string]: string;
  31385. };
  31386. /**
  31387. * Resets the cache of effects.
  31388. */
  31389. static ResetCache(): void;
  31390. }
  31391. }
  31392. declare module "babylonjs/Engines/engineCapabilities" {
  31393. /**
  31394. * Interface used to describe the capabilities of the engine relatively to the current browser
  31395. */
  31396. export interface EngineCapabilities {
  31397. /** Maximum textures units per fragment shader */
  31398. maxTexturesImageUnits: number;
  31399. /** Maximum texture units per vertex shader */
  31400. maxVertexTextureImageUnits: number;
  31401. /** Maximum textures units in the entire pipeline */
  31402. maxCombinedTexturesImageUnits: number;
  31403. /** Maximum texture size */
  31404. maxTextureSize: number;
  31405. /** Maximum texture samples */
  31406. maxSamples?: number;
  31407. /** Maximum cube texture size */
  31408. maxCubemapTextureSize: number;
  31409. /** Maximum render texture size */
  31410. maxRenderTextureSize: number;
  31411. /** Maximum number of vertex attributes */
  31412. maxVertexAttribs: number;
  31413. /** Maximum number of varyings */
  31414. maxVaryingVectors: number;
  31415. /** Maximum number of uniforms per vertex shader */
  31416. maxVertexUniformVectors: number;
  31417. /** Maximum number of uniforms per fragment shader */
  31418. maxFragmentUniformVectors: number;
  31419. /** Defines if standard derivates (dx/dy) are supported */
  31420. standardDerivatives: boolean;
  31421. /** Defines if s3tc texture compression is supported */
  31422. s3tc?: WEBGL_compressed_texture_s3tc;
  31423. /** Defines if pvrtc texture compression is supported */
  31424. pvrtc: any;
  31425. /** Defines if etc1 texture compression is supported */
  31426. etc1: any;
  31427. /** Defines if etc2 texture compression is supported */
  31428. etc2: any;
  31429. /** Defines if astc texture compression is supported */
  31430. astc: any;
  31431. /** Defines if float textures are supported */
  31432. textureFloat: boolean;
  31433. /** Defines if vertex array objects are supported */
  31434. vertexArrayObject: boolean;
  31435. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31436. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31437. /** Gets the maximum level of anisotropy supported */
  31438. maxAnisotropy: number;
  31439. /** Defines if instancing is supported */
  31440. instancedArrays: boolean;
  31441. /** Defines if 32 bits indices are supported */
  31442. uintIndices: boolean;
  31443. /** Defines if high precision shaders are supported */
  31444. highPrecisionShaderSupported: boolean;
  31445. /** Defines if depth reading in the fragment shader is supported */
  31446. fragmentDepthSupported: boolean;
  31447. /** Defines if float texture linear filtering is supported*/
  31448. textureFloatLinearFiltering: boolean;
  31449. /** Defines if rendering to float textures is supported */
  31450. textureFloatRender: boolean;
  31451. /** Defines if half float textures are supported*/
  31452. textureHalfFloat: boolean;
  31453. /** Defines if half float texture linear filtering is supported*/
  31454. textureHalfFloatLinearFiltering: boolean;
  31455. /** Defines if rendering to half float textures is supported */
  31456. textureHalfFloatRender: boolean;
  31457. /** Defines if textureLOD shader command is supported */
  31458. textureLOD: boolean;
  31459. /** Defines if draw buffers extension is supported */
  31460. drawBuffersExtension: boolean;
  31461. /** Defines if depth textures are supported */
  31462. depthTextureExtension: boolean;
  31463. /** Defines if float color buffer are supported */
  31464. colorBufferFloat: boolean;
  31465. /** Gets disjoint timer query extension (null if not supported) */
  31466. timerQuery?: EXT_disjoint_timer_query;
  31467. /** Defines if timestamp can be used with timer query */
  31468. canUseTimestampForTimerQuery: boolean;
  31469. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31470. multiview?: any;
  31471. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31472. oculusMultiview?: any;
  31473. /** Function used to let the system compiles shaders in background */
  31474. parallelShaderCompile?: {
  31475. COMPLETION_STATUS_KHR: number;
  31476. };
  31477. /** Max number of texture samples for MSAA */
  31478. maxMSAASamples: number;
  31479. /** Defines if the blend min max extension is supported */
  31480. blendMinMax: boolean;
  31481. }
  31482. }
  31483. declare module "babylonjs/States/depthCullingState" {
  31484. import { Nullable } from "babylonjs/types";
  31485. /**
  31486. * @hidden
  31487. **/
  31488. export class DepthCullingState {
  31489. private _isDepthTestDirty;
  31490. private _isDepthMaskDirty;
  31491. private _isDepthFuncDirty;
  31492. private _isCullFaceDirty;
  31493. private _isCullDirty;
  31494. private _isZOffsetDirty;
  31495. private _isFrontFaceDirty;
  31496. private _depthTest;
  31497. private _depthMask;
  31498. private _depthFunc;
  31499. private _cull;
  31500. private _cullFace;
  31501. private _zOffset;
  31502. private _frontFace;
  31503. /**
  31504. * Initializes the state.
  31505. */
  31506. constructor();
  31507. get isDirty(): boolean;
  31508. get zOffset(): number;
  31509. set zOffset(value: number);
  31510. get cullFace(): Nullable<number>;
  31511. set cullFace(value: Nullable<number>);
  31512. get cull(): Nullable<boolean>;
  31513. set cull(value: Nullable<boolean>);
  31514. get depthFunc(): Nullable<number>;
  31515. set depthFunc(value: Nullable<number>);
  31516. get depthMask(): boolean;
  31517. set depthMask(value: boolean);
  31518. get depthTest(): boolean;
  31519. set depthTest(value: boolean);
  31520. get frontFace(): Nullable<number>;
  31521. set frontFace(value: Nullable<number>);
  31522. reset(): void;
  31523. apply(gl: WebGLRenderingContext): void;
  31524. }
  31525. }
  31526. declare module "babylonjs/States/stencilState" {
  31527. /**
  31528. * @hidden
  31529. **/
  31530. export class StencilState {
  31531. /** 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 */
  31532. static readonly ALWAYS: number;
  31533. /** Passed to stencilOperation to specify that stencil value must be kept */
  31534. static readonly KEEP: number;
  31535. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31536. static readonly REPLACE: number;
  31537. private _isStencilTestDirty;
  31538. private _isStencilMaskDirty;
  31539. private _isStencilFuncDirty;
  31540. private _isStencilOpDirty;
  31541. private _stencilTest;
  31542. private _stencilMask;
  31543. private _stencilFunc;
  31544. private _stencilFuncRef;
  31545. private _stencilFuncMask;
  31546. private _stencilOpStencilFail;
  31547. private _stencilOpDepthFail;
  31548. private _stencilOpStencilDepthPass;
  31549. get isDirty(): boolean;
  31550. get stencilFunc(): number;
  31551. set stencilFunc(value: number);
  31552. get stencilFuncRef(): number;
  31553. set stencilFuncRef(value: number);
  31554. get stencilFuncMask(): number;
  31555. set stencilFuncMask(value: number);
  31556. get stencilOpStencilFail(): number;
  31557. set stencilOpStencilFail(value: number);
  31558. get stencilOpDepthFail(): number;
  31559. set stencilOpDepthFail(value: number);
  31560. get stencilOpStencilDepthPass(): number;
  31561. set stencilOpStencilDepthPass(value: number);
  31562. get stencilMask(): number;
  31563. set stencilMask(value: number);
  31564. get stencilTest(): boolean;
  31565. set stencilTest(value: boolean);
  31566. constructor();
  31567. reset(): void;
  31568. apply(gl: WebGLRenderingContext): void;
  31569. }
  31570. }
  31571. declare module "babylonjs/States/alphaCullingState" {
  31572. /**
  31573. * @hidden
  31574. **/
  31575. export class AlphaState {
  31576. private _isAlphaBlendDirty;
  31577. private _isBlendFunctionParametersDirty;
  31578. private _isBlendEquationParametersDirty;
  31579. private _isBlendConstantsDirty;
  31580. private _alphaBlend;
  31581. private _blendFunctionParameters;
  31582. private _blendEquationParameters;
  31583. private _blendConstants;
  31584. /**
  31585. * Initializes the state.
  31586. */
  31587. constructor();
  31588. get isDirty(): boolean;
  31589. get alphaBlend(): boolean;
  31590. set alphaBlend(value: boolean);
  31591. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31592. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31593. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31594. reset(): void;
  31595. apply(gl: WebGLRenderingContext): void;
  31596. }
  31597. }
  31598. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31599. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31600. /** @hidden */
  31601. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31602. attributeProcessor(attribute: string): string;
  31603. varyingProcessor(varying: string, isFragment: boolean): string;
  31604. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31605. }
  31606. }
  31607. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31608. /**
  31609. * Interface for attribute information associated with buffer instanciation
  31610. */
  31611. export interface InstancingAttributeInfo {
  31612. /**
  31613. * Name of the GLSL attribute
  31614. * if attribute index is not specified, this is used to retrieve the index from the effect
  31615. */
  31616. attributeName: string;
  31617. /**
  31618. * Index/offset of the attribute in the vertex shader
  31619. * if not specified, this will be computes from the name.
  31620. */
  31621. index?: number;
  31622. /**
  31623. * size of the attribute, 1, 2, 3 or 4
  31624. */
  31625. attributeSize: number;
  31626. /**
  31627. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31628. */
  31629. offset: number;
  31630. /**
  31631. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31632. * default to 1
  31633. */
  31634. divisor?: number;
  31635. /**
  31636. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31637. * default is FLOAT
  31638. */
  31639. attributeType?: number;
  31640. /**
  31641. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31642. */
  31643. normalized?: boolean;
  31644. }
  31645. }
  31646. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31647. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31648. import { Nullable } from "babylonjs/types";
  31649. module "babylonjs/Engines/thinEngine" {
  31650. interface ThinEngine {
  31651. /**
  31652. * Update a video texture
  31653. * @param texture defines the texture to update
  31654. * @param video defines the video element to use
  31655. * @param invertY defines if data must be stored with Y axis inverted
  31656. */
  31657. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31658. }
  31659. }
  31660. }
  31661. declare module "babylonjs/Materials/Textures/videoTexture" {
  31662. import { Observable } from "babylonjs/Misc/observable";
  31663. import { Nullable } from "babylonjs/types";
  31664. import { Scene } from "babylonjs/scene";
  31665. import { Texture } from "babylonjs/Materials/Textures/texture";
  31666. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31667. /**
  31668. * Settings for finer control over video usage
  31669. */
  31670. export interface VideoTextureSettings {
  31671. /**
  31672. * Applies `autoplay` to video, if specified
  31673. */
  31674. autoPlay?: boolean;
  31675. /**
  31676. * Applies `loop` to video, if specified
  31677. */
  31678. loop?: boolean;
  31679. /**
  31680. * Automatically updates internal texture from video at every frame in the render loop
  31681. */
  31682. autoUpdateTexture: boolean;
  31683. /**
  31684. * Image src displayed during the video loading or until the user interacts with the video.
  31685. */
  31686. poster?: string;
  31687. }
  31688. /**
  31689. * If you want to display a video in your scene, this is the special texture for that.
  31690. * This special texture works similar to other textures, with the exception of a few parameters.
  31691. * @see https://doc.babylonjs.com/how_to/video_texture
  31692. */
  31693. export class VideoTexture extends Texture {
  31694. /**
  31695. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31696. */
  31697. readonly autoUpdateTexture: boolean;
  31698. /**
  31699. * The video instance used by the texture internally
  31700. */
  31701. readonly video: HTMLVideoElement;
  31702. private _onUserActionRequestedObservable;
  31703. /**
  31704. * Event triggerd when a dom action is required by the user to play the video.
  31705. * This happens due to recent changes in browser policies preventing video to auto start.
  31706. */
  31707. get onUserActionRequestedObservable(): Observable<Texture>;
  31708. private _generateMipMaps;
  31709. private _engine;
  31710. private _stillImageCaptured;
  31711. private _displayingPosterTexture;
  31712. private _settings;
  31713. private _createInternalTextureOnEvent;
  31714. private _frameId;
  31715. private _currentSrc;
  31716. /**
  31717. * Creates a video texture.
  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. * @param name optional name, will detect from video source, if not defined
  31722. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31723. * @param scene is obviously the current scene.
  31724. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31725. * @param invertY is false by default but can be used to invert video on Y axis
  31726. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31727. * @param settings allows finer control over video usage
  31728. */
  31729. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31730. private _getName;
  31731. private _getVideo;
  31732. private _createInternalTexture;
  31733. private reset;
  31734. /**
  31735. * @hidden Internal method to initiate `update`.
  31736. */
  31737. _rebuild(): void;
  31738. /**
  31739. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31740. */
  31741. update(): void;
  31742. /**
  31743. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31744. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31745. */
  31746. updateTexture(isVisible: boolean): void;
  31747. protected _updateInternalTexture: () => void;
  31748. /**
  31749. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31750. * @param url New url.
  31751. */
  31752. updateURL(url: string): void;
  31753. /**
  31754. * Clones the texture.
  31755. * @returns the cloned texture
  31756. */
  31757. clone(): VideoTexture;
  31758. /**
  31759. * Dispose the texture and release its associated resources.
  31760. */
  31761. dispose(): void;
  31762. /**
  31763. * Creates a video texture straight from a stream.
  31764. * @param scene Define the scene the texture should be created in
  31765. * @param stream Define the stream the texture should be created from
  31766. * @returns The created video texture as a promise
  31767. */
  31768. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31769. /**
  31770. * Creates a video texture straight from your WebCam video feed.
  31771. * @param scene Define the scene the texture should be created in
  31772. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31773. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31774. * @returns The created video texture as a promise
  31775. */
  31776. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31777. minWidth: number;
  31778. maxWidth: number;
  31779. minHeight: number;
  31780. maxHeight: number;
  31781. deviceId: string;
  31782. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31783. /**
  31784. * Creates a video texture straight from your WebCam video feed.
  31785. * @param scene Define the scene the texture should be created in
  31786. * @param onReady Define a callback to triggered once the texture will be ready
  31787. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31788. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31789. */
  31790. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31791. minWidth: number;
  31792. maxWidth: number;
  31793. minHeight: number;
  31794. maxHeight: number;
  31795. deviceId: string;
  31796. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31797. }
  31798. }
  31799. declare module "babylonjs/Engines/thinEngine" {
  31800. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31801. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31802. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31803. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31804. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31805. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31806. import { Observable } from "babylonjs/Misc/observable";
  31807. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31808. import { StencilState } from "babylonjs/States/stencilState";
  31809. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31810. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31811. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31812. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31813. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31814. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31815. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31816. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31817. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31819. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31820. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31821. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31822. import { WebRequest } from "babylonjs/Misc/webRequest";
  31823. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31824. /**
  31825. * Defines the interface used by objects working like Scene
  31826. * @hidden
  31827. */
  31828. interface ISceneLike {
  31829. _addPendingData(data: any): void;
  31830. _removePendingData(data: any): void;
  31831. offlineProvider: IOfflineProvider;
  31832. }
  31833. /** Interface defining initialization parameters for Engine class */
  31834. export interface EngineOptions extends WebGLContextAttributes {
  31835. /**
  31836. * Defines if the engine should no exceed a specified device ratio
  31837. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31838. */
  31839. limitDeviceRatio?: number;
  31840. /**
  31841. * Defines if webvr should be enabled automatically
  31842. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31843. */
  31844. autoEnableWebVR?: boolean;
  31845. /**
  31846. * Defines if webgl2 should be turned off even if supported
  31847. * @see http://doc.babylonjs.com/features/webgl2
  31848. */
  31849. disableWebGL2Support?: boolean;
  31850. /**
  31851. * Defines if webaudio should be initialized as well
  31852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31853. */
  31854. audioEngine?: boolean;
  31855. /**
  31856. * Defines if animations should run using a deterministic lock step
  31857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31858. */
  31859. deterministicLockstep?: boolean;
  31860. /** Defines the maximum steps to use with deterministic lock step mode */
  31861. lockstepMaxSteps?: number;
  31862. /** Defines the seconds between each deterministic lock step */
  31863. timeStep?: number;
  31864. /**
  31865. * Defines that engine should ignore context lost events
  31866. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31867. */
  31868. doNotHandleContextLost?: boolean;
  31869. /**
  31870. * Defines that engine should ignore modifying touch action attribute and style
  31871. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31872. */
  31873. doNotHandleTouchAction?: boolean;
  31874. /**
  31875. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31876. */
  31877. useHighPrecisionFloats?: boolean;
  31878. }
  31879. /**
  31880. * The base engine class (root of all engines)
  31881. */
  31882. export class ThinEngine {
  31883. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31884. static ExceptionList: ({
  31885. key: string;
  31886. capture: string;
  31887. captureConstraint: number;
  31888. targets: string[];
  31889. } | {
  31890. key: string;
  31891. capture: null;
  31892. captureConstraint: null;
  31893. targets: string[];
  31894. })[];
  31895. /** @hidden */
  31896. static _TextureLoaders: IInternalTextureLoader[];
  31897. /**
  31898. * Returns the current npm package of the sdk
  31899. */
  31900. static get NpmPackage(): string;
  31901. /**
  31902. * Returns the current version of the framework
  31903. */
  31904. static get Version(): string;
  31905. /**
  31906. * Returns a string describing the current engine
  31907. */
  31908. get description(): string;
  31909. /**
  31910. * Gets or sets the epsilon value used by collision engine
  31911. */
  31912. static CollisionsEpsilon: number;
  31913. /**
  31914. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31915. */
  31916. static get ShadersRepository(): string;
  31917. static set ShadersRepository(value: string);
  31918. /**
  31919. * Gets or sets the textures that the engine should not attempt to load as compressed
  31920. */
  31921. protected _excludedCompressedTextures: string[];
  31922. /**
  31923. * Filters the compressed texture formats to only include
  31924. * files that are not included in the skippable list
  31925. *
  31926. * @param url the current extension
  31927. * @param textureFormatInUse the current compressed texture format
  31928. * @returns "format" string
  31929. */
  31930. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31931. /** @hidden */
  31932. _shaderProcessor: IShaderProcessor;
  31933. /**
  31934. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31935. */
  31936. forcePOTTextures: boolean;
  31937. /**
  31938. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31939. */
  31940. isFullscreen: boolean;
  31941. /**
  31942. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31943. */
  31944. cullBackFaces: boolean;
  31945. /**
  31946. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31947. */
  31948. renderEvenInBackground: boolean;
  31949. /**
  31950. * Gets or sets a boolean indicating that cache can be kept between frames
  31951. */
  31952. preventCacheWipeBetweenFrames: boolean;
  31953. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31954. validateShaderPrograms: boolean;
  31955. /**
  31956. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31957. * This can provide greater z depth for distant objects.
  31958. */
  31959. useReverseDepthBuffer: boolean;
  31960. /**
  31961. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31962. */
  31963. disableUniformBuffers: boolean;
  31964. /** @hidden */
  31965. _uniformBuffers: UniformBuffer[];
  31966. /**
  31967. * Gets a boolean indicating that the engine supports uniform buffers
  31968. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31969. */
  31970. get supportsUniformBuffers(): boolean;
  31971. /** @hidden */
  31972. _gl: WebGLRenderingContext;
  31973. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31974. protected _windowIsBackground: boolean;
  31975. protected _webGLVersion: number;
  31976. protected _creationOptions: EngineOptions;
  31977. protected _highPrecisionShadersAllowed: boolean;
  31978. /** @hidden */
  31979. get _shouldUseHighPrecisionShader(): boolean;
  31980. /**
  31981. * Gets a boolean indicating that only power of 2 textures are supported
  31982. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31983. */
  31984. get needPOTTextures(): boolean;
  31985. /** @hidden */
  31986. _badOS: boolean;
  31987. /** @hidden */
  31988. _badDesktopOS: boolean;
  31989. private _hardwareScalingLevel;
  31990. /** @hidden */
  31991. _caps: EngineCapabilities;
  31992. private _isStencilEnable;
  31993. private _glVersion;
  31994. private _glRenderer;
  31995. private _glVendor;
  31996. /** @hidden */
  31997. _videoTextureSupported: boolean;
  31998. protected _renderingQueueLaunched: boolean;
  31999. protected _activeRenderLoops: (() => void)[];
  32000. /**
  32001. * Observable signaled when a context lost event is raised
  32002. */
  32003. onContextLostObservable: Observable<ThinEngine>;
  32004. /**
  32005. * Observable signaled when a context restored event is raised
  32006. */
  32007. onContextRestoredObservable: Observable<ThinEngine>;
  32008. private _onContextLost;
  32009. private _onContextRestored;
  32010. protected _contextWasLost: boolean;
  32011. /** @hidden */
  32012. _doNotHandleContextLost: boolean;
  32013. /**
  32014. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32016. */
  32017. get doNotHandleContextLost(): boolean;
  32018. set doNotHandleContextLost(value: boolean);
  32019. /**
  32020. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32021. */
  32022. disableVertexArrayObjects: boolean;
  32023. /** @hidden */
  32024. protected _colorWrite: boolean;
  32025. /** @hidden */
  32026. protected _colorWriteChanged: boolean;
  32027. /** @hidden */
  32028. protected _depthCullingState: DepthCullingState;
  32029. /** @hidden */
  32030. protected _stencilState: StencilState;
  32031. /** @hidden */
  32032. _alphaState: AlphaState;
  32033. /** @hidden */
  32034. _alphaMode: number;
  32035. /** @hidden */
  32036. _alphaEquation: number;
  32037. /** @hidden */
  32038. _internalTexturesCache: InternalTexture[];
  32039. /** @hidden */
  32040. protected _activeChannel: number;
  32041. private _currentTextureChannel;
  32042. /** @hidden */
  32043. protected _boundTexturesCache: {
  32044. [key: string]: Nullable<InternalTexture>;
  32045. };
  32046. /** @hidden */
  32047. protected _currentEffect: Nullable<Effect>;
  32048. /** @hidden */
  32049. protected _currentProgram: Nullable<WebGLProgram>;
  32050. private _compiledEffects;
  32051. private _vertexAttribArraysEnabled;
  32052. /** @hidden */
  32053. protected _cachedViewport: Nullable<IViewportLike>;
  32054. private _cachedVertexArrayObject;
  32055. /** @hidden */
  32056. protected _cachedVertexBuffers: any;
  32057. /** @hidden */
  32058. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32059. /** @hidden */
  32060. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32061. /** @hidden */
  32062. _currentRenderTarget: Nullable<InternalTexture>;
  32063. private _uintIndicesCurrentlySet;
  32064. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32065. /** @hidden */
  32066. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32067. private _currentBufferPointers;
  32068. private _currentInstanceLocations;
  32069. private _currentInstanceBuffers;
  32070. private _textureUnits;
  32071. /** @hidden */
  32072. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32073. /** @hidden */
  32074. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32075. /** @hidden */
  32076. _boundRenderFunction: any;
  32077. private _vaoRecordInProgress;
  32078. private _mustWipeVertexAttributes;
  32079. private _emptyTexture;
  32080. private _emptyCubeTexture;
  32081. private _emptyTexture3D;
  32082. private _emptyTexture2DArray;
  32083. /** @hidden */
  32084. _frameHandler: number;
  32085. private _nextFreeTextureSlots;
  32086. private _maxSimultaneousTextures;
  32087. private _activeRequests;
  32088. protected _texturesSupported: string[];
  32089. /** @hidden */
  32090. _textureFormatInUse: Nullable<string>;
  32091. protected get _supportsHardwareTextureRescaling(): boolean;
  32092. /**
  32093. * Gets the list of texture formats supported
  32094. */
  32095. get texturesSupported(): Array<string>;
  32096. /**
  32097. * Gets the list of texture formats in use
  32098. */
  32099. get textureFormatInUse(): Nullable<string>;
  32100. /**
  32101. * Gets the current viewport
  32102. */
  32103. get currentViewport(): Nullable<IViewportLike>;
  32104. /**
  32105. * Gets the default empty texture
  32106. */
  32107. get emptyTexture(): InternalTexture;
  32108. /**
  32109. * Gets the default empty 3D texture
  32110. */
  32111. get emptyTexture3D(): InternalTexture;
  32112. /**
  32113. * Gets the default empty 2D array texture
  32114. */
  32115. get emptyTexture2DArray(): InternalTexture;
  32116. /**
  32117. * Gets the default empty cube texture
  32118. */
  32119. get emptyCubeTexture(): InternalTexture;
  32120. /**
  32121. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32122. */
  32123. readonly premultipliedAlpha: boolean;
  32124. /**
  32125. * Observable event triggered before each texture is initialized
  32126. */
  32127. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32128. /**
  32129. * Creates a new engine
  32130. * @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
  32131. * @param antialias defines enable antialiasing (default: false)
  32132. * @param options defines further options to be sent to the getContext() function
  32133. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32134. */
  32135. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32136. private _rebuildInternalTextures;
  32137. private _rebuildEffects;
  32138. /**
  32139. * Gets a boolean indicating if all created effects are ready
  32140. * @returns true if all effects are ready
  32141. */
  32142. areAllEffectsReady(): boolean;
  32143. protected _rebuildBuffers(): void;
  32144. private _initGLContext;
  32145. /**
  32146. * Gets version of the current webGL context
  32147. */
  32148. get webGLVersion(): number;
  32149. /**
  32150. * Gets a string idenfifying the name of the class
  32151. * @returns "Engine" string
  32152. */
  32153. getClassName(): string;
  32154. /**
  32155. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32156. */
  32157. get isStencilEnable(): boolean;
  32158. /** @hidden */
  32159. _prepareWorkingCanvas(): void;
  32160. /**
  32161. * Reset the texture cache to empty state
  32162. */
  32163. resetTextureCache(): void;
  32164. /**
  32165. * Gets an object containing information about the current webGL context
  32166. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32167. */
  32168. getGlInfo(): {
  32169. vendor: string;
  32170. renderer: string;
  32171. version: string;
  32172. };
  32173. /**
  32174. * Defines the hardware scaling level.
  32175. * By default the hardware scaling level is computed from the window device ratio.
  32176. * 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.
  32177. * @param level defines the level to use
  32178. */
  32179. setHardwareScalingLevel(level: number): void;
  32180. /**
  32181. * Gets the current hardware scaling level.
  32182. * By default the hardware scaling level is computed from the window device ratio.
  32183. * 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.
  32184. * @returns a number indicating the current hardware scaling level
  32185. */
  32186. getHardwareScalingLevel(): number;
  32187. /**
  32188. * Gets the list of loaded textures
  32189. * @returns an array containing all loaded textures
  32190. */
  32191. getLoadedTexturesCache(): InternalTexture[];
  32192. /**
  32193. * Gets the object containing all engine capabilities
  32194. * @returns the EngineCapabilities object
  32195. */
  32196. getCaps(): EngineCapabilities;
  32197. /**
  32198. * stop executing a render loop function and remove it from the execution array
  32199. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32200. */
  32201. stopRenderLoop(renderFunction?: () => void): void;
  32202. /** @hidden */
  32203. _renderLoop(): void;
  32204. /**
  32205. * Gets the HTML canvas attached with the current webGL context
  32206. * @returns a HTML canvas
  32207. */
  32208. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32209. /**
  32210. * Gets host window
  32211. * @returns the host window object
  32212. */
  32213. getHostWindow(): Nullable<Window>;
  32214. /**
  32215. * Gets the current render width
  32216. * @param useScreen defines if screen size must be used (or the current render target if any)
  32217. * @returns a number defining the current render width
  32218. */
  32219. getRenderWidth(useScreen?: boolean): number;
  32220. /**
  32221. * Gets the current render height
  32222. * @param useScreen defines if screen size must be used (or the current render target if any)
  32223. * @returns a number defining the current render height
  32224. */
  32225. getRenderHeight(useScreen?: boolean): number;
  32226. /**
  32227. * Can be used to override the current requestAnimationFrame requester.
  32228. * @hidden
  32229. */
  32230. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32231. /**
  32232. * Register and execute a render loop. The engine can have more than one render function
  32233. * @param renderFunction defines the function to continuously execute
  32234. */
  32235. runRenderLoop(renderFunction: () => void): void;
  32236. /**
  32237. * Clear the current render buffer or the current render target (if any is set up)
  32238. * @param color defines the color to use
  32239. * @param backBuffer defines if the back buffer must be cleared
  32240. * @param depth defines if the depth buffer must be cleared
  32241. * @param stencil defines if the stencil buffer must be cleared
  32242. */
  32243. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32244. private _viewportCached;
  32245. /** @hidden */
  32246. _viewport(x: number, y: number, width: number, height: number): void;
  32247. /**
  32248. * Set the WebGL's viewport
  32249. * @param viewport defines the viewport element to be used
  32250. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32251. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32252. */
  32253. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32254. /**
  32255. * Begin a new frame
  32256. */
  32257. beginFrame(): void;
  32258. /**
  32259. * Enf the current frame
  32260. */
  32261. endFrame(): void;
  32262. /**
  32263. * Resize the view according to the canvas' size
  32264. */
  32265. resize(): void;
  32266. /**
  32267. * Force a specific size of the canvas
  32268. * @param width defines the new canvas' width
  32269. * @param height defines the new canvas' height
  32270. */
  32271. setSize(width: number, height: number): void;
  32272. /**
  32273. * Binds the frame buffer to the specified texture.
  32274. * @param texture The texture to render to or null for the default canvas
  32275. * @param faceIndex The face of the texture to render to in case of cube texture
  32276. * @param requiredWidth The width of the target to render to
  32277. * @param requiredHeight The height of the target to render to
  32278. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32279. * @param lodLevel defines the lod level to bind to the frame buffer
  32280. * @param layer defines the 2d array index to bind to frame buffer to
  32281. */
  32282. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32283. /** @hidden */
  32284. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32285. /**
  32286. * Unbind the current render target texture from the webGL context
  32287. * @param texture defines the render target texture to unbind
  32288. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32289. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32290. */
  32291. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32292. /**
  32293. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32294. */
  32295. flushFramebuffer(): void;
  32296. /**
  32297. * Unbind the current render target and bind the default framebuffer
  32298. */
  32299. restoreDefaultFramebuffer(): void;
  32300. /** @hidden */
  32301. protected _resetVertexBufferBinding(): void;
  32302. /**
  32303. * Creates a vertex buffer
  32304. * @param data the data for the vertex buffer
  32305. * @returns the new WebGL static buffer
  32306. */
  32307. createVertexBuffer(data: DataArray): DataBuffer;
  32308. private _createVertexBuffer;
  32309. /**
  32310. * Creates a dynamic vertex buffer
  32311. * @param data the data for the dynamic vertex buffer
  32312. * @returns the new WebGL dynamic buffer
  32313. */
  32314. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32315. protected _resetIndexBufferBinding(): void;
  32316. /**
  32317. * Creates a new index buffer
  32318. * @param indices defines the content of the index buffer
  32319. * @param updatable defines if the index buffer must be updatable
  32320. * @returns a new webGL buffer
  32321. */
  32322. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32323. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32324. /**
  32325. * Bind a webGL buffer to the webGL context
  32326. * @param buffer defines the buffer to bind
  32327. */
  32328. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32329. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32330. private bindBuffer;
  32331. /**
  32332. * update the bound buffer with the given data
  32333. * @param data defines the data to update
  32334. */
  32335. updateArrayBuffer(data: Float32Array): void;
  32336. private _vertexAttribPointer;
  32337. /** @hidden */
  32338. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32339. private _bindVertexBuffersAttributes;
  32340. /**
  32341. * Records a vertex array object
  32342. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32343. * @param vertexBuffers defines the list of vertex buffers to store
  32344. * @param indexBuffer defines the index buffer to store
  32345. * @param effect defines the effect to store
  32346. * @returns the new vertex array object
  32347. */
  32348. recordVertexArrayObject(vertexBuffers: {
  32349. [key: string]: VertexBuffer;
  32350. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32351. /**
  32352. * Bind a specific vertex array object
  32353. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32354. * @param vertexArrayObject defines the vertex array object to bind
  32355. * @param indexBuffer defines the index buffer to bind
  32356. */
  32357. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32358. /**
  32359. * Bind webGl buffers directly to the webGL context
  32360. * @param vertexBuffer defines the vertex buffer to bind
  32361. * @param indexBuffer defines the index buffer to bind
  32362. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32363. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32364. * @param effect defines the effect associated with the vertex buffer
  32365. */
  32366. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32367. private _unbindVertexArrayObject;
  32368. /**
  32369. * Bind a list of vertex buffers to the webGL context
  32370. * @param vertexBuffers defines the list of vertex buffers to bind
  32371. * @param indexBuffer defines the index buffer to bind
  32372. * @param effect defines the effect associated with the vertex buffers
  32373. */
  32374. bindBuffers(vertexBuffers: {
  32375. [key: string]: Nullable<VertexBuffer>;
  32376. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32377. /**
  32378. * Unbind all instance attributes
  32379. */
  32380. unbindInstanceAttributes(): void;
  32381. /**
  32382. * Release and free the memory of a vertex array object
  32383. * @param vao defines the vertex array object to delete
  32384. */
  32385. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32386. /** @hidden */
  32387. _releaseBuffer(buffer: DataBuffer): boolean;
  32388. protected _deleteBuffer(buffer: DataBuffer): void;
  32389. /**
  32390. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32391. * @param instancesBuffer defines the webGL buffer to update and bind
  32392. * @param data defines the data to store in the buffer
  32393. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32394. */
  32395. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32396. /**
  32397. * Bind the content of a webGL buffer used with instantiation
  32398. * @param instancesBuffer defines the webGL buffer to bind
  32399. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32400. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32401. */
  32402. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32403. /**
  32404. * Disable the instance attribute corresponding to the name in parameter
  32405. * @param name defines the name of the attribute to disable
  32406. */
  32407. disableInstanceAttributeByName(name: string): void;
  32408. /**
  32409. * Disable the instance attribute corresponding to the location in parameter
  32410. * @param attributeLocation defines the attribute location of the attribute to disable
  32411. */
  32412. disableInstanceAttribute(attributeLocation: number): void;
  32413. /**
  32414. * Disable the attribute corresponding to the location in parameter
  32415. * @param attributeLocation defines the attribute location of the attribute to disable
  32416. */
  32417. disableAttributeByIndex(attributeLocation: number): void;
  32418. /**
  32419. * Send a draw order
  32420. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32421. * @param indexStart defines the starting index
  32422. * @param indexCount defines the number of index to draw
  32423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32424. */
  32425. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32426. /**
  32427. * Draw a list of points
  32428. * @param verticesStart defines the index of first vertex to draw
  32429. * @param verticesCount defines the count of vertices to draw
  32430. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32431. */
  32432. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32433. /**
  32434. * Draw a list of unindexed primitives
  32435. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32436. * @param verticesStart defines the index of first vertex to draw
  32437. * @param verticesCount defines the count of vertices to draw
  32438. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32439. */
  32440. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32441. /**
  32442. * Draw a list of indexed primitives
  32443. * @param fillMode defines the primitive to use
  32444. * @param indexStart defines the starting index
  32445. * @param indexCount defines the number of index to draw
  32446. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32447. */
  32448. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32449. /**
  32450. * Draw a list of unindexed primitives
  32451. * @param fillMode defines the primitive to use
  32452. * @param verticesStart defines the index of first vertex to draw
  32453. * @param verticesCount defines the count of vertices to draw
  32454. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32455. */
  32456. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32457. private _drawMode;
  32458. /** @hidden */
  32459. protected _reportDrawCall(): void;
  32460. /** @hidden */
  32461. _releaseEffect(effect: Effect): void;
  32462. /** @hidden */
  32463. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32464. /**
  32465. * Create a new effect (used to store vertex/fragment shaders)
  32466. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32467. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32468. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32469. * @param samplers defines an array of string used to represent textures
  32470. * @param defines defines the string containing the defines to use to compile the shaders
  32471. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32472. * @param onCompiled defines a function to call when the effect creation is successful
  32473. * @param onError defines a function to call when the effect creation has failed
  32474. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32475. * @returns the new Effect
  32476. */
  32477. 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;
  32478. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32479. private _compileShader;
  32480. private _compileRawShader;
  32481. /**
  32482. * Directly creates a webGL program
  32483. * @param pipelineContext defines the pipeline context to attach to
  32484. * @param vertexCode defines the vertex shader code to use
  32485. * @param fragmentCode defines the fragment shader code to use
  32486. * @param context defines the webGL context to use (if not set, the current one will be used)
  32487. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32488. * @returns the new webGL program
  32489. */
  32490. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32491. /**
  32492. * Creates a webGL program
  32493. * @param pipelineContext defines the pipeline context to attach to
  32494. * @param vertexCode defines the vertex shader code to use
  32495. * @param fragmentCode defines the fragment shader code to use
  32496. * @param defines defines the string containing the defines to use to compile the shaders
  32497. * @param context defines the webGL context to use (if not set, the current one will be used)
  32498. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32499. * @returns the new webGL program
  32500. */
  32501. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32502. /**
  32503. * Creates a new pipeline context
  32504. * @returns the new pipeline
  32505. */
  32506. createPipelineContext(): IPipelineContext;
  32507. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32508. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32509. /** @hidden */
  32510. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32511. /** @hidden */
  32512. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32513. /** @hidden */
  32514. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32515. /**
  32516. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32517. * @param pipelineContext defines the pipeline context to use
  32518. * @param uniformsNames defines the list of uniform names
  32519. * @returns an array of webGL uniform locations
  32520. */
  32521. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32522. /**
  32523. * Gets the lsit of active attributes for a given webGL program
  32524. * @param pipelineContext defines the pipeline context to use
  32525. * @param attributesNames defines the list of attribute names to get
  32526. * @returns an array of indices indicating the offset of each attribute
  32527. */
  32528. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32529. /**
  32530. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32531. * @param effect defines the effect to activate
  32532. */
  32533. enableEffect(effect: Nullable<Effect>): void;
  32534. /**
  32535. * Set the value of an uniform to a number (int)
  32536. * @param uniform defines the webGL uniform location where to store the value
  32537. * @param value defines the int number to store
  32538. */
  32539. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32540. /**
  32541. * Set the value of an uniform to an array of int32
  32542. * @param uniform defines the webGL uniform location where to store the value
  32543. * @param array defines the array of int32 to store
  32544. */
  32545. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32546. /**
  32547. * Set the value of an uniform to an array of int32 (stored as vec2)
  32548. * @param uniform defines the webGL uniform location where to store the value
  32549. * @param array defines the array of int32 to store
  32550. */
  32551. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32552. /**
  32553. * Set the value of an uniform to an array of int32 (stored as vec3)
  32554. * @param uniform defines the webGL uniform location where to store the value
  32555. * @param array defines the array of int32 to store
  32556. */
  32557. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32558. /**
  32559. * Set the value of an uniform to an array of int32 (stored as vec4)
  32560. * @param uniform defines the webGL uniform location where to store the value
  32561. * @param array defines the array of int32 to store
  32562. */
  32563. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32564. /**
  32565. * Set the value of an uniform to an array of number
  32566. * @param uniform defines the webGL uniform location where to store the value
  32567. * @param array defines the array of number to store
  32568. */
  32569. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32570. /**
  32571. * Set the value of an uniform to an array of number (stored as vec2)
  32572. * @param uniform defines the webGL uniform location where to store the value
  32573. * @param array defines the array of number to store
  32574. */
  32575. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32576. /**
  32577. * Set the value of an uniform to an array of number (stored as vec3)
  32578. * @param uniform defines the webGL uniform location where to store the value
  32579. * @param array defines the array of number to store
  32580. */
  32581. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32582. /**
  32583. * Set the value of an uniform to an array of number (stored as vec4)
  32584. * @param uniform defines the webGL uniform location where to store the value
  32585. * @param array defines the array of number to store
  32586. */
  32587. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32588. /**
  32589. * Set the value of an uniform to an array of float32 (stored as matrices)
  32590. * @param uniform defines the webGL uniform location where to store the value
  32591. * @param matrices defines the array of float32 to store
  32592. */
  32593. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32594. /**
  32595. * Set the value of an uniform to a matrix (3x3)
  32596. * @param uniform defines the webGL uniform location where to store the value
  32597. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32598. */
  32599. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32600. /**
  32601. * Set the value of an uniform to a matrix (2x2)
  32602. * @param uniform defines the webGL uniform location where to store the value
  32603. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32604. */
  32605. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32606. /**
  32607. * Set the value of an uniform to a number (float)
  32608. * @param uniform defines the webGL uniform location where to store the value
  32609. * @param value defines the float number to store
  32610. */
  32611. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32612. /**
  32613. * Set the value of an uniform to a vec2
  32614. * @param uniform defines the webGL uniform location where to store the value
  32615. * @param x defines the 1st component of the value
  32616. * @param y defines the 2nd component of the value
  32617. */
  32618. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32619. /**
  32620. * Set the value of an uniform to a vec3
  32621. * @param uniform defines the webGL uniform location where to store the value
  32622. * @param x defines the 1st component of the value
  32623. * @param y defines the 2nd component of the value
  32624. * @param z defines the 3rd component of the value
  32625. */
  32626. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32627. /**
  32628. * Set the value of an uniform to a vec4
  32629. * @param uniform defines the webGL uniform location where to store the value
  32630. * @param x defines the 1st component of the value
  32631. * @param y defines the 2nd component of the value
  32632. * @param z defines the 3rd component of the value
  32633. * @param w defines the 4th component of the value
  32634. */
  32635. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32636. /**
  32637. * Apply all cached states (depth, culling, stencil and alpha)
  32638. */
  32639. applyStates(): void;
  32640. /**
  32641. * Enable or disable color writing
  32642. * @param enable defines the state to set
  32643. */
  32644. setColorWrite(enable: boolean): void;
  32645. /**
  32646. * Gets a boolean indicating if color writing is enabled
  32647. * @returns the current color writing state
  32648. */
  32649. getColorWrite(): boolean;
  32650. /**
  32651. * Gets the depth culling state manager
  32652. */
  32653. get depthCullingState(): DepthCullingState;
  32654. /**
  32655. * Gets the alpha state manager
  32656. */
  32657. get alphaState(): AlphaState;
  32658. /**
  32659. * Gets the stencil state manager
  32660. */
  32661. get stencilState(): StencilState;
  32662. /**
  32663. * Clears the list of texture accessible through engine.
  32664. * This can help preventing texture load conflict due to name collision.
  32665. */
  32666. clearInternalTexturesCache(): void;
  32667. /**
  32668. * Force the entire cache to be cleared
  32669. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32670. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32671. */
  32672. wipeCaches(bruteForce?: boolean): void;
  32673. /** @hidden */
  32674. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32675. min: number;
  32676. mag: number;
  32677. };
  32678. /** @hidden */
  32679. _createTexture(): WebGLTexture;
  32680. /**
  32681. * Usually called from Texture.ts.
  32682. * Passed information to create a WebGLTexture
  32683. * @param urlArg defines a value which contains one of the following:
  32684. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32685. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32686. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32687. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32688. * @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)
  32689. * @param scene needed for loading to the correct scene
  32690. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32691. * @param onLoad optional callback to be called upon successful completion
  32692. * @param onError optional callback to be called upon failure
  32693. * @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
  32694. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32695. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32696. * @param forcedExtension defines the extension to use to pick the right loader
  32697. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32698. * @param mimeType defines an optional mime type
  32699. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32700. */
  32701. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32702. /**
  32703. * Loads an image as an HTMLImageElement.
  32704. * @param input url string, ArrayBuffer, or Blob to load
  32705. * @param onLoad callback called when the image successfully loads
  32706. * @param onError callback called when the image fails to load
  32707. * @param offlineProvider offline provider for caching
  32708. * @param mimeType optional mime type
  32709. * @returns the HTMLImageElement of the loaded image
  32710. * @hidden
  32711. */
  32712. 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>;
  32713. /**
  32714. * @hidden
  32715. */
  32716. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32717. /**
  32718. * Creates a raw texture
  32719. * @param data defines the data to store in the texture
  32720. * @param width defines the width of the texture
  32721. * @param height defines the height of the texture
  32722. * @param format defines the format of the data
  32723. * @param generateMipMaps defines if the engine should generate the mip levels
  32724. * @param invertY defines if data must be stored with Y axis inverted
  32725. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32726. * @param compression defines the compression used (null by default)
  32727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32728. * @returns the raw texture inside an InternalTexture
  32729. */
  32730. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32731. /**
  32732. * Creates a new raw cube texture
  32733. * @param data defines the array of data to use to create each face
  32734. * @param size defines the size of the textures
  32735. * @param format defines the format of the data
  32736. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32737. * @param generateMipMaps defines if the engine should generate the mip levels
  32738. * @param invertY defines if data must be stored with Y axis inverted
  32739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32740. * @param compression defines the compression used (null by default)
  32741. * @returns the cube texture as an InternalTexture
  32742. */
  32743. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32744. /**
  32745. * Creates a new raw 3D texture
  32746. * @param data defines the data used to create the texture
  32747. * @param width defines the width of the texture
  32748. * @param height defines the height of the texture
  32749. * @param depth defines the depth of the texture
  32750. * @param format defines the format of the texture
  32751. * @param generateMipMaps defines if the engine must generate mip levels
  32752. * @param invertY defines if data must be stored with Y axis inverted
  32753. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32754. * @param compression defines the compressed used (can be null)
  32755. * @param textureType defines the compressed used (can be null)
  32756. * @returns a new raw 3D texture (stored in an InternalTexture)
  32757. */
  32758. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32759. /**
  32760. * Creates a new raw 2D array texture
  32761. * @param data defines the data used to create the texture
  32762. * @param width defines the width of the texture
  32763. * @param height defines the height of the texture
  32764. * @param depth defines the number of layers of the texture
  32765. * @param format defines the format of the texture
  32766. * @param generateMipMaps defines if the engine must generate mip levels
  32767. * @param invertY defines if data must be stored with Y axis inverted
  32768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32769. * @param compression defines the compressed used (can be null)
  32770. * @param textureType defines the compressed used (can be null)
  32771. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32772. */
  32773. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32774. private _unpackFlipYCached;
  32775. /**
  32776. * In case you are sharing the context with other applications, it might
  32777. * be interested to not cache the unpack flip y state to ensure a consistent
  32778. * value would be set.
  32779. */
  32780. enableUnpackFlipYCached: boolean;
  32781. /** @hidden */
  32782. _unpackFlipY(value: boolean): void;
  32783. /** @hidden */
  32784. _getUnpackAlignement(): number;
  32785. private _getTextureTarget;
  32786. /**
  32787. * Update the sampling mode of a given texture
  32788. * @param samplingMode defines the required sampling mode
  32789. * @param texture defines the texture to update
  32790. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32791. */
  32792. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32793. /**
  32794. * Update the sampling mode of a given texture
  32795. * @param texture defines the texture to update
  32796. * @param wrapU defines the texture wrap mode of the u coordinates
  32797. * @param wrapV defines the texture wrap mode of the v coordinates
  32798. * @param wrapR defines the texture wrap mode of the r coordinates
  32799. */
  32800. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32801. /** @hidden */
  32802. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32803. width: number;
  32804. height: number;
  32805. layers?: number;
  32806. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32807. /** @hidden */
  32808. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32809. /** @hidden */
  32810. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32811. /**
  32812. * Update a portion of an internal texture
  32813. * @param texture defines the texture to update
  32814. * @param imageData defines the data to store into the texture
  32815. * @param xOffset defines the x coordinates of the update rectangle
  32816. * @param yOffset defines the y coordinates of the update rectangle
  32817. * @param width defines the width of the update rectangle
  32818. * @param height defines the height of the update rectangle
  32819. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32820. * @param lod defines the lod level to update (0 by default)
  32821. */
  32822. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32823. /** @hidden */
  32824. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32825. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32826. private _prepareWebGLTexture;
  32827. /** @hidden */
  32828. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32829. private _getDepthStencilBuffer;
  32830. /** @hidden */
  32831. _releaseFramebufferObjects(texture: InternalTexture): void;
  32832. /** @hidden */
  32833. _releaseTexture(texture: InternalTexture): void;
  32834. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32835. protected _setProgram(program: WebGLProgram): void;
  32836. protected _boundUniforms: {
  32837. [key: number]: WebGLUniformLocation;
  32838. };
  32839. /**
  32840. * Binds an effect to the webGL context
  32841. * @param effect defines the effect to bind
  32842. */
  32843. bindSamplers(effect: Effect): void;
  32844. private _activateCurrentTexture;
  32845. /** @hidden */
  32846. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32847. /** @hidden */
  32848. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32849. /**
  32850. * Unbind all textures from the webGL context
  32851. */
  32852. unbindAllTextures(): void;
  32853. /**
  32854. * Sets a texture to the according uniform.
  32855. * @param channel The texture channel
  32856. * @param uniform The uniform to set
  32857. * @param texture The texture to apply
  32858. */
  32859. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32860. private _bindSamplerUniformToChannel;
  32861. private _getTextureWrapMode;
  32862. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32863. /**
  32864. * Sets an array of texture to the webGL context
  32865. * @param channel defines the channel where the texture array must be set
  32866. * @param uniform defines the associated uniform location
  32867. * @param textures defines the array of textures to bind
  32868. */
  32869. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32870. /** @hidden */
  32871. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32872. private _setTextureParameterFloat;
  32873. private _setTextureParameterInteger;
  32874. /**
  32875. * Unbind all vertex attributes from the webGL context
  32876. */
  32877. unbindAllAttributes(): void;
  32878. /**
  32879. * 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
  32880. */
  32881. releaseEffects(): void;
  32882. /**
  32883. * Dispose and release all associated resources
  32884. */
  32885. dispose(): void;
  32886. /**
  32887. * Attach a new callback raised when context lost event is fired
  32888. * @param callback defines the callback to call
  32889. */
  32890. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32891. /**
  32892. * Attach a new callback raised when context restored event is fired
  32893. * @param callback defines the callback to call
  32894. */
  32895. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32896. /**
  32897. * Get the current error code of the webGL context
  32898. * @returns the error code
  32899. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32900. */
  32901. getError(): number;
  32902. private _canRenderToFloatFramebuffer;
  32903. private _canRenderToHalfFloatFramebuffer;
  32904. private _canRenderToFramebuffer;
  32905. /** @hidden */
  32906. _getWebGLTextureType(type: number): number;
  32907. /** @hidden */
  32908. _getInternalFormat(format: number): number;
  32909. /** @hidden */
  32910. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32911. /** @hidden */
  32912. _getRGBAMultiSampleBufferFormat(type: number): number;
  32913. /** @hidden */
  32914. _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;
  32915. /**
  32916. * Loads a file from a url
  32917. * @param url url to load
  32918. * @param onSuccess callback called when the file successfully loads
  32919. * @param onProgress callback called while file is loading (if the server supports this mode)
  32920. * @param offlineProvider defines the offline provider for caching
  32921. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32922. * @param onError callback called when the file fails to load
  32923. * @returns a file request object
  32924. * @hidden
  32925. */
  32926. 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;
  32927. /**
  32928. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32929. * @param x defines the x coordinate of the rectangle where pixels must be read
  32930. * @param y defines the y coordinate of the rectangle where pixels must be read
  32931. * @param width defines the width of the rectangle where pixels must be read
  32932. * @param height defines the height of the rectangle where pixels must be read
  32933. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32934. * @returns a Uint8Array containing RGBA colors
  32935. */
  32936. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32937. private static _isSupported;
  32938. /**
  32939. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32940. * @returns true if the engine can be created
  32941. * @ignorenaming
  32942. */
  32943. static isSupported(): boolean;
  32944. /**
  32945. * Find the next highest power of two.
  32946. * @param x Number to start search from.
  32947. * @return Next highest power of two.
  32948. */
  32949. static CeilingPOT(x: number): number;
  32950. /**
  32951. * Find the next lowest power of two.
  32952. * @param x Number to start search from.
  32953. * @return Next lowest power of two.
  32954. */
  32955. static FloorPOT(x: number): number;
  32956. /**
  32957. * Find the nearest power of two.
  32958. * @param x Number to start search from.
  32959. * @return Next nearest power of two.
  32960. */
  32961. static NearestPOT(x: number): number;
  32962. /**
  32963. * Get the closest exponent of two
  32964. * @param value defines the value to approximate
  32965. * @param max defines the maximum value to return
  32966. * @param mode defines how to define the closest value
  32967. * @returns closest exponent of two of the given value
  32968. */
  32969. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32970. /**
  32971. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32972. * @param func - the function to be called
  32973. * @param requester - the object that will request the next frame. Falls back to window.
  32974. * @returns frame number
  32975. */
  32976. static QueueNewFrame(func: () => void, requester?: any): number;
  32977. /**
  32978. * Gets host document
  32979. * @returns the host document object
  32980. */
  32981. getHostDocument(): Nullable<Document>;
  32982. }
  32983. }
  32984. declare module "babylonjs/Maths/sphericalPolynomial" {
  32985. import { Vector3 } from "babylonjs/Maths/math.vector";
  32986. import { Color3 } from "babylonjs/Maths/math.color";
  32987. /**
  32988. * Class representing spherical harmonics coefficients to the 3rd degree
  32989. */
  32990. export class SphericalHarmonics {
  32991. /**
  32992. * Defines whether or not the harmonics have been prescaled for rendering.
  32993. */
  32994. preScaled: boolean;
  32995. /**
  32996. * The l0,0 coefficients of the spherical harmonics
  32997. */
  32998. l00: Vector3;
  32999. /**
  33000. * The l1,-1 coefficients of the spherical harmonics
  33001. */
  33002. l1_1: Vector3;
  33003. /**
  33004. * The l1,0 coefficients of the spherical harmonics
  33005. */
  33006. l10: Vector3;
  33007. /**
  33008. * The l1,1 coefficients of the spherical harmonics
  33009. */
  33010. l11: Vector3;
  33011. /**
  33012. * The l2,-2 coefficients of the spherical harmonics
  33013. */
  33014. l2_2: Vector3;
  33015. /**
  33016. * The l2,-1 coefficients of the spherical harmonics
  33017. */
  33018. l2_1: Vector3;
  33019. /**
  33020. * The l2,0 coefficients of the spherical harmonics
  33021. */
  33022. l20: Vector3;
  33023. /**
  33024. * The l2,1 coefficients of the spherical harmonics
  33025. */
  33026. l21: Vector3;
  33027. /**
  33028. * The l2,2 coefficients of the spherical harmonics
  33029. */
  33030. l22: Vector3;
  33031. /**
  33032. * Adds a light to the spherical harmonics
  33033. * @param direction the direction of the light
  33034. * @param color the color of the light
  33035. * @param deltaSolidAngle the delta solid angle of the light
  33036. */
  33037. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33038. /**
  33039. * Scales the spherical harmonics by the given amount
  33040. * @param scale the amount to scale
  33041. */
  33042. scaleInPlace(scale: number): void;
  33043. /**
  33044. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33045. *
  33046. * ```
  33047. * E_lm = A_l * L_lm
  33048. * ```
  33049. *
  33050. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33051. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33052. * the scaling factors are given in equation 9.
  33053. */
  33054. convertIncidentRadianceToIrradiance(): void;
  33055. /**
  33056. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33057. *
  33058. * ```
  33059. * L = (1/pi) * E * rho
  33060. * ```
  33061. *
  33062. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33063. */
  33064. convertIrradianceToLambertianRadiance(): void;
  33065. /**
  33066. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33067. * required operations at run time.
  33068. *
  33069. * This is simply done by scaling back the SH with Ylm constants parameter.
  33070. * The trigonometric part being applied by the shader at run time.
  33071. */
  33072. preScaleForRendering(): void;
  33073. /**
  33074. * Constructs a spherical harmonics from an array.
  33075. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33076. * @returns the spherical harmonics
  33077. */
  33078. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33079. /**
  33080. * Gets the spherical harmonics from polynomial
  33081. * @param polynomial the spherical polynomial
  33082. * @returns the spherical harmonics
  33083. */
  33084. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33085. }
  33086. /**
  33087. * Class representing spherical polynomial coefficients to the 3rd degree
  33088. */
  33089. export class SphericalPolynomial {
  33090. private _harmonics;
  33091. /**
  33092. * The spherical harmonics used to create the polynomials.
  33093. */
  33094. get preScaledHarmonics(): SphericalHarmonics;
  33095. /**
  33096. * The x coefficients of the spherical polynomial
  33097. */
  33098. x: Vector3;
  33099. /**
  33100. * The y coefficients of the spherical polynomial
  33101. */
  33102. y: Vector3;
  33103. /**
  33104. * The z coefficients of the spherical polynomial
  33105. */
  33106. z: Vector3;
  33107. /**
  33108. * The xx coefficients of the spherical polynomial
  33109. */
  33110. xx: Vector3;
  33111. /**
  33112. * The yy coefficients of the spherical polynomial
  33113. */
  33114. yy: Vector3;
  33115. /**
  33116. * The zz coefficients of the spherical polynomial
  33117. */
  33118. zz: Vector3;
  33119. /**
  33120. * The xy coefficients of the spherical polynomial
  33121. */
  33122. xy: Vector3;
  33123. /**
  33124. * The yz coefficients of the spherical polynomial
  33125. */
  33126. yz: Vector3;
  33127. /**
  33128. * The zx coefficients of the spherical polynomial
  33129. */
  33130. zx: Vector3;
  33131. /**
  33132. * Adds an ambient color to the spherical polynomial
  33133. * @param color the color to add
  33134. */
  33135. addAmbient(color: Color3): void;
  33136. /**
  33137. * Scales the spherical polynomial by the given amount
  33138. * @param scale the amount to scale
  33139. */
  33140. scaleInPlace(scale: number): void;
  33141. /**
  33142. * Gets the spherical polynomial from harmonics
  33143. * @param harmonics the spherical harmonics
  33144. * @returns the spherical polynomial
  33145. */
  33146. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33147. /**
  33148. * Constructs a spherical polynomial from an array.
  33149. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33150. * @returns the spherical polynomial
  33151. */
  33152. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33153. }
  33154. }
  33155. declare module "babylonjs/Materials/Textures/internalTexture" {
  33156. import { Observable } from "babylonjs/Misc/observable";
  33157. import { Nullable, int } from "babylonjs/types";
  33158. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33160. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33161. /**
  33162. * Defines the source of the internal texture
  33163. */
  33164. export enum InternalTextureSource {
  33165. /**
  33166. * The source of the texture data is unknown
  33167. */
  33168. Unknown = 0,
  33169. /**
  33170. * Texture data comes from an URL
  33171. */
  33172. Url = 1,
  33173. /**
  33174. * Texture data is only used for temporary storage
  33175. */
  33176. Temp = 2,
  33177. /**
  33178. * Texture data comes from raw data (ArrayBuffer)
  33179. */
  33180. Raw = 3,
  33181. /**
  33182. * Texture content is dynamic (video or dynamic texture)
  33183. */
  33184. Dynamic = 4,
  33185. /**
  33186. * Texture content is generated by rendering to it
  33187. */
  33188. RenderTarget = 5,
  33189. /**
  33190. * Texture content is part of a multi render target process
  33191. */
  33192. MultiRenderTarget = 6,
  33193. /**
  33194. * Texture data comes from a cube data file
  33195. */
  33196. Cube = 7,
  33197. /**
  33198. * Texture data comes from a raw cube data
  33199. */
  33200. CubeRaw = 8,
  33201. /**
  33202. * Texture data come from a prefiltered cube data file
  33203. */
  33204. CubePrefiltered = 9,
  33205. /**
  33206. * Texture content is raw 3D data
  33207. */
  33208. Raw3D = 10,
  33209. /**
  33210. * Texture content is raw 2D array data
  33211. */
  33212. Raw2DArray = 11,
  33213. /**
  33214. * Texture content is a depth texture
  33215. */
  33216. Depth = 12,
  33217. /**
  33218. * Texture data comes from a raw cube data encoded with RGBD
  33219. */
  33220. CubeRawRGBD = 13
  33221. }
  33222. /**
  33223. * Class used to store data associated with WebGL texture data for the engine
  33224. * This class should not be used directly
  33225. */
  33226. export class InternalTexture {
  33227. /** @hidden */
  33228. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33229. /**
  33230. * Defines if the texture is ready
  33231. */
  33232. isReady: boolean;
  33233. /**
  33234. * Defines if the texture is a cube texture
  33235. */
  33236. isCube: boolean;
  33237. /**
  33238. * Defines if the texture contains 3D data
  33239. */
  33240. is3D: boolean;
  33241. /**
  33242. * Defines if the texture contains 2D array data
  33243. */
  33244. is2DArray: boolean;
  33245. /**
  33246. * Defines if the texture contains multiview data
  33247. */
  33248. isMultiview: boolean;
  33249. /**
  33250. * Gets the URL used to load this texture
  33251. */
  33252. url: string;
  33253. /**
  33254. * Gets the sampling mode of the texture
  33255. */
  33256. samplingMode: number;
  33257. /**
  33258. * Gets a boolean indicating if the texture needs mipmaps generation
  33259. */
  33260. generateMipMaps: boolean;
  33261. /**
  33262. * Gets the number of samples used by the texture (WebGL2+ only)
  33263. */
  33264. samples: number;
  33265. /**
  33266. * Gets the type of the texture (int, float...)
  33267. */
  33268. type: number;
  33269. /**
  33270. * Gets the format of the texture (RGB, RGBA...)
  33271. */
  33272. format: number;
  33273. /**
  33274. * Observable called when the texture is loaded
  33275. */
  33276. onLoadedObservable: Observable<InternalTexture>;
  33277. /**
  33278. * Gets the width of the texture
  33279. */
  33280. width: number;
  33281. /**
  33282. * Gets the height of the texture
  33283. */
  33284. height: number;
  33285. /**
  33286. * Gets the depth of the texture
  33287. */
  33288. depth: number;
  33289. /**
  33290. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33291. */
  33292. baseWidth: number;
  33293. /**
  33294. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33295. */
  33296. baseHeight: number;
  33297. /**
  33298. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33299. */
  33300. baseDepth: number;
  33301. /**
  33302. * Gets a boolean indicating if the texture is inverted on Y axis
  33303. */
  33304. invertY: boolean;
  33305. /** @hidden */
  33306. _invertVScale: boolean;
  33307. /** @hidden */
  33308. _associatedChannel: number;
  33309. /** @hidden */
  33310. _source: InternalTextureSource;
  33311. /** @hidden */
  33312. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33313. /** @hidden */
  33314. _bufferView: Nullable<ArrayBufferView>;
  33315. /** @hidden */
  33316. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33317. /** @hidden */
  33318. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33319. /** @hidden */
  33320. _size: number;
  33321. /** @hidden */
  33322. _extension: string;
  33323. /** @hidden */
  33324. _files: Nullable<string[]>;
  33325. /** @hidden */
  33326. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33327. /** @hidden */
  33328. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33329. /** @hidden */
  33330. _framebuffer: Nullable<WebGLFramebuffer>;
  33331. /** @hidden */
  33332. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33333. /** @hidden */
  33334. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33335. /** @hidden */
  33336. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33337. /** @hidden */
  33338. _attachments: Nullable<number[]>;
  33339. /** @hidden */
  33340. _cachedCoordinatesMode: Nullable<number>;
  33341. /** @hidden */
  33342. _cachedWrapU: Nullable<number>;
  33343. /** @hidden */
  33344. _cachedWrapV: Nullable<number>;
  33345. /** @hidden */
  33346. _cachedWrapR: Nullable<number>;
  33347. /** @hidden */
  33348. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33349. /** @hidden */
  33350. _isDisabled: boolean;
  33351. /** @hidden */
  33352. _compression: Nullable<string>;
  33353. /** @hidden */
  33354. _generateStencilBuffer: boolean;
  33355. /** @hidden */
  33356. _generateDepthBuffer: boolean;
  33357. /** @hidden */
  33358. _comparisonFunction: number;
  33359. /** @hidden */
  33360. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33361. /** @hidden */
  33362. _lodGenerationScale: number;
  33363. /** @hidden */
  33364. _lodGenerationOffset: number;
  33365. /** @hidden */
  33366. _depthStencilTexture: Nullable<InternalTexture>;
  33367. /** @hidden */
  33368. _colorTextureArray: Nullable<WebGLTexture>;
  33369. /** @hidden */
  33370. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33371. /** @hidden */
  33372. _lodTextureHigh: Nullable<BaseTexture>;
  33373. /** @hidden */
  33374. _lodTextureMid: Nullable<BaseTexture>;
  33375. /** @hidden */
  33376. _lodTextureLow: Nullable<BaseTexture>;
  33377. /** @hidden */
  33378. _isRGBD: boolean;
  33379. /** @hidden */
  33380. _linearSpecularLOD: boolean;
  33381. /** @hidden */
  33382. _irradianceTexture: Nullable<BaseTexture>;
  33383. /** @hidden */
  33384. _webGLTexture: Nullable<WebGLTexture>;
  33385. /** @hidden */
  33386. _references: number;
  33387. private _engine;
  33388. /**
  33389. * Gets the Engine the texture belongs to.
  33390. * @returns The babylon engine
  33391. */
  33392. getEngine(): ThinEngine;
  33393. /**
  33394. * Gets the data source type of the texture
  33395. */
  33396. get source(): InternalTextureSource;
  33397. /**
  33398. * Creates a new InternalTexture
  33399. * @param engine defines the engine to use
  33400. * @param source defines the type of data that will be used
  33401. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33402. */
  33403. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33404. /**
  33405. * Increments the number of references (ie. the number of Texture that point to it)
  33406. */
  33407. incrementReferences(): void;
  33408. /**
  33409. * Change the size of the texture (not the size of the content)
  33410. * @param width defines the new width
  33411. * @param height defines the new height
  33412. * @param depth defines the new depth (1 by default)
  33413. */
  33414. updateSize(width: int, height: int, depth?: int): void;
  33415. /** @hidden */
  33416. _rebuild(): void;
  33417. /** @hidden */
  33418. _swapAndDie(target: InternalTexture): void;
  33419. /**
  33420. * Dispose the current allocated resources
  33421. */
  33422. dispose(): void;
  33423. }
  33424. }
  33425. declare module "babylonjs/Audio/analyser" {
  33426. import { Scene } from "babylonjs/scene";
  33427. /**
  33428. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33430. */
  33431. export class Analyser {
  33432. /**
  33433. * Gets or sets the smoothing
  33434. * @ignorenaming
  33435. */
  33436. SMOOTHING: number;
  33437. /**
  33438. * Gets or sets the FFT table size
  33439. * @ignorenaming
  33440. */
  33441. FFT_SIZE: number;
  33442. /**
  33443. * Gets or sets the bar graph amplitude
  33444. * @ignorenaming
  33445. */
  33446. BARGRAPHAMPLITUDE: number;
  33447. /**
  33448. * Gets or sets the position of the debug canvas
  33449. * @ignorenaming
  33450. */
  33451. DEBUGCANVASPOS: {
  33452. x: number;
  33453. y: number;
  33454. };
  33455. /**
  33456. * Gets or sets the debug canvas size
  33457. * @ignorenaming
  33458. */
  33459. DEBUGCANVASSIZE: {
  33460. width: number;
  33461. height: number;
  33462. };
  33463. private _byteFreqs;
  33464. private _byteTime;
  33465. private _floatFreqs;
  33466. private _webAudioAnalyser;
  33467. private _debugCanvas;
  33468. private _debugCanvasContext;
  33469. private _scene;
  33470. private _registerFunc;
  33471. private _audioEngine;
  33472. /**
  33473. * Creates a new analyser
  33474. * @param scene defines hosting scene
  33475. */
  33476. constructor(scene: Scene);
  33477. /**
  33478. * Get the number of data values you will have to play with for the visualization
  33479. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33480. * @returns a number
  33481. */
  33482. getFrequencyBinCount(): number;
  33483. /**
  33484. * Gets the current frequency data as a byte array
  33485. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33486. * @returns a Uint8Array
  33487. */
  33488. getByteFrequencyData(): Uint8Array;
  33489. /**
  33490. * Gets the current waveform as a byte array
  33491. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33492. * @returns a Uint8Array
  33493. */
  33494. getByteTimeDomainData(): Uint8Array;
  33495. /**
  33496. * Gets the current frequency data as a float array
  33497. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33498. * @returns a Float32Array
  33499. */
  33500. getFloatFrequencyData(): Float32Array;
  33501. /**
  33502. * Renders the debug canvas
  33503. */
  33504. drawDebugCanvas(): void;
  33505. /**
  33506. * Stops rendering the debug canvas and removes it
  33507. */
  33508. stopDebugCanvas(): void;
  33509. /**
  33510. * Connects two audio nodes
  33511. * @param inputAudioNode defines first node to connect
  33512. * @param outputAudioNode defines second node to connect
  33513. */
  33514. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33515. /**
  33516. * Releases all associated resources
  33517. */
  33518. dispose(): void;
  33519. }
  33520. }
  33521. declare module "babylonjs/Audio/audioEngine" {
  33522. import { IDisposable } from "babylonjs/scene";
  33523. import { Analyser } from "babylonjs/Audio/analyser";
  33524. import { Nullable } from "babylonjs/types";
  33525. import { Observable } from "babylonjs/Misc/observable";
  33526. /**
  33527. * This represents an audio engine and it is responsible
  33528. * to play, synchronize and analyse sounds throughout the application.
  33529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33530. */
  33531. export interface IAudioEngine extends IDisposable {
  33532. /**
  33533. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33534. */
  33535. readonly canUseWebAudio: boolean;
  33536. /**
  33537. * Gets the current AudioContext if available.
  33538. */
  33539. readonly audioContext: Nullable<AudioContext>;
  33540. /**
  33541. * The master gain node defines the global audio volume of your audio engine.
  33542. */
  33543. readonly masterGain: GainNode;
  33544. /**
  33545. * Gets whether or not mp3 are supported by your browser.
  33546. */
  33547. readonly isMP3supported: boolean;
  33548. /**
  33549. * Gets whether or not ogg are supported by your browser.
  33550. */
  33551. readonly isOGGsupported: boolean;
  33552. /**
  33553. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33554. * @ignoreNaming
  33555. */
  33556. WarnedWebAudioUnsupported: boolean;
  33557. /**
  33558. * Defines if the audio engine relies on a custom unlocked button.
  33559. * In this case, the embedded button will not be displayed.
  33560. */
  33561. useCustomUnlockedButton: boolean;
  33562. /**
  33563. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33564. */
  33565. readonly unlocked: boolean;
  33566. /**
  33567. * Event raised when audio has been unlocked on the browser.
  33568. */
  33569. onAudioUnlockedObservable: Observable<AudioEngine>;
  33570. /**
  33571. * Event raised when audio has been locked on the browser.
  33572. */
  33573. onAudioLockedObservable: Observable<AudioEngine>;
  33574. /**
  33575. * Flags the audio engine in Locked state.
  33576. * This happens due to new browser policies preventing audio to autoplay.
  33577. */
  33578. lock(): void;
  33579. /**
  33580. * Unlocks the audio engine once a user action has been done on the dom.
  33581. * This is helpful to resume play once browser policies have been satisfied.
  33582. */
  33583. unlock(): void;
  33584. }
  33585. /**
  33586. * This represents the default audio engine used in babylon.
  33587. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33589. */
  33590. export class AudioEngine implements IAudioEngine {
  33591. private _audioContext;
  33592. private _audioContextInitialized;
  33593. private _muteButton;
  33594. private _hostElement;
  33595. /**
  33596. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33597. */
  33598. canUseWebAudio: boolean;
  33599. /**
  33600. * The master gain node defines the global audio volume of your audio engine.
  33601. */
  33602. masterGain: GainNode;
  33603. /**
  33604. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33605. * @ignoreNaming
  33606. */
  33607. WarnedWebAudioUnsupported: boolean;
  33608. /**
  33609. * Gets whether or not mp3 are supported by your browser.
  33610. */
  33611. isMP3supported: boolean;
  33612. /**
  33613. * Gets whether or not ogg are supported by your browser.
  33614. */
  33615. isOGGsupported: boolean;
  33616. /**
  33617. * Gets whether audio has been unlocked on the device.
  33618. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33619. * a user interaction has happened.
  33620. */
  33621. unlocked: boolean;
  33622. /**
  33623. * Defines if the audio engine relies on a custom unlocked button.
  33624. * In this case, the embedded button will not be displayed.
  33625. */
  33626. useCustomUnlockedButton: boolean;
  33627. /**
  33628. * Event raised when audio has been unlocked on the browser.
  33629. */
  33630. onAudioUnlockedObservable: Observable<AudioEngine>;
  33631. /**
  33632. * Event raised when audio has been locked on the browser.
  33633. */
  33634. onAudioLockedObservable: Observable<AudioEngine>;
  33635. /**
  33636. * Gets the current AudioContext if available.
  33637. */
  33638. get audioContext(): Nullable<AudioContext>;
  33639. private _connectedAnalyser;
  33640. /**
  33641. * Instantiates a new audio engine.
  33642. *
  33643. * There should be only one per page as some browsers restrict the number
  33644. * of audio contexts you can create.
  33645. * @param hostElement defines the host element where to display the mute icon if necessary
  33646. */
  33647. constructor(hostElement?: Nullable<HTMLElement>);
  33648. /**
  33649. * Flags the audio engine in Locked state.
  33650. * This happens due to new browser policies preventing audio to autoplay.
  33651. */
  33652. lock(): void;
  33653. /**
  33654. * Unlocks the audio engine once a user action has been done on the dom.
  33655. * This is helpful to resume play once browser policies have been satisfied.
  33656. */
  33657. unlock(): void;
  33658. private _resumeAudioContext;
  33659. private _initializeAudioContext;
  33660. private _tryToRun;
  33661. private _triggerRunningState;
  33662. private _triggerSuspendedState;
  33663. private _displayMuteButton;
  33664. private _moveButtonToTopLeft;
  33665. private _onResize;
  33666. private _hideMuteButton;
  33667. /**
  33668. * Destroy and release the resources associated with the audio ccontext.
  33669. */
  33670. dispose(): void;
  33671. /**
  33672. * Gets the global volume sets on the master gain.
  33673. * @returns the global volume if set or -1 otherwise
  33674. */
  33675. getGlobalVolume(): number;
  33676. /**
  33677. * Sets the global volume of your experience (sets on the master gain).
  33678. * @param newVolume Defines the new global volume of the application
  33679. */
  33680. setGlobalVolume(newVolume: number): void;
  33681. /**
  33682. * Connect the audio engine to an audio analyser allowing some amazing
  33683. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33685. * @param analyser The analyser to connect to the engine
  33686. */
  33687. connectToAnalyser(analyser: Analyser): void;
  33688. }
  33689. }
  33690. declare module "babylonjs/Loading/loadingScreen" {
  33691. /**
  33692. * Interface used to present a loading screen while loading a scene
  33693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33694. */
  33695. export interface ILoadingScreen {
  33696. /**
  33697. * Function called to display the loading screen
  33698. */
  33699. displayLoadingUI: () => void;
  33700. /**
  33701. * Function called to hide the loading screen
  33702. */
  33703. hideLoadingUI: () => void;
  33704. /**
  33705. * Gets or sets the color to use for the background
  33706. */
  33707. loadingUIBackgroundColor: string;
  33708. /**
  33709. * Gets or sets the text to display while loading
  33710. */
  33711. loadingUIText: string;
  33712. }
  33713. /**
  33714. * Class used for the default loading screen
  33715. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33716. */
  33717. export class DefaultLoadingScreen implements ILoadingScreen {
  33718. private _renderingCanvas;
  33719. private _loadingText;
  33720. private _loadingDivBackgroundColor;
  33721. private _loadingDiv;
  33722. private _loadingTextDiv;
  33723. /** Gets or sets the logo url to use for the default loading screen */
  33724. static DefaultLogoUrl: string;
  33725. /** Gets or sets the spinner url to use for the default loading screen */
  33726. static DefaultSpinnerUrl: string;
  33727. /**
  33728. * Creates a new default loading screen
  33729. * @param _renderingCanvas defines the canvas used to render the scene
  33730. * @param _loadingText defines the default text to display
  33731. * @param _loadingDivBackgroundColor defines the default background color
  33732. */
  33733. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33734. /**
  33735. * Function called to display the loading screen
  33736. */
  33737. displayLoadingUI(): void;
  33738. /**
  33739. * Function called to hide the loading screen
  33740. */
  33741. hideLoadingUI(): void;
  33742. /**
  33743. * Gets or sets the text to display while loading
  33744. */
  33745. set loadingUIText(text: string);
  33746. get loadingUIText(): string;
  33747. /**
  33748. * Gets or sets the color to use for the background
  33749. */
  33750. get loadingUIBackgroundColor(): string;
  33751. set loadingUIBackgroundColor(color: string);
  33752. private _resizeLoadingUI;
  33753. }
  33754. }
  33755. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33756. /**
  33757. * Interface for any object that can request an animation frame
  33758. */
  33759. export interface ICustomAnimationFrameRequester {
  33760. /**
  33761. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33762. */
  33763. renderFunction?: Function;
  33764. /**
  33765. * Called to request the next frame to render to
  33766. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33767. */
  33768. requestAnimationFrame: Function;
  33769. /**
  33770. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33771. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33772. */
  33773. requestID?: number;
  33774. }
  33775. }
  33776. declare module "babylonjs/Misc/performanceMonitor" {
  33777. /**
  33778. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33779. */
  33780. export class PerformanceMonitor {
  33781. private _enabled;
  33782. private _rollingFrameTime;
  33783. private _lastFrameTimeMs;
  33784. /**
  33785. * constructor
  33786. * @param frameSampleSize The number of samples required to saturate the sliding window
  33787. */
  33788. constructor(frameSampleSize?: number);
  33789. /**
  33790. * Samples current frame
  33791. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33792. */
  33793. sampleFrame(timeMs?: number): void;
  33794. /**
  33795. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33796. */
  33797. get averageFrameTime(): number;
  33798. /**
  33799. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33800. */
  33801. get averageFrameTimeVariance(): number;
  33802. /**
  33803. * Returns the frame time of the most recent frame
  33804. */
  33805. get instantaneousFrameTime(): number;
  33806. /**
  33807. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33808. */
  33809. get averageFPS(): number;
  33810. /**
  33811. * Returns the average framerate in frames per second using the most recent frame time
  33812. */
  33813. get instantaneousFPS(): number;
  33814. /**
  33815. * Returns true if enough samples have been taken to completely fill the sliding window
  33816. */
  33817. get isSaturated(): boolean;
  33818. /**
  33819. * Enables contributions to the sliding window sample set
  33820. */
  33821. enable(): void;
  33822. /**
  33823. * Disables contributions to the sliding window sample set
  33824. * Samples will not be interpolated over the disabled period
  33825. */
  33826. disable(): void;
  33827. /**
  33828. * Returns true if sampling is enabled
  33829. */
  33830. get isEnabled(): boolean;
  33831. /**
  33832. * Resets performance monitor
  33833. */
  33834. reset(): void;
  33835. }
  33836. /**
  33837. * RollingAverage
  33838. *
  33839. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33840. */
  33841. export class RollingAverage {
  33842. /**
  33843. * Current average
  33844. */
  33845. average: number;
  33846. /**
  33847. * Current variance
  33848. */
  33849. variance: number;
  33850. protected _samples: Array<number>;
  33851. protected _sampleCount: number;
  33852. protected _pos: number;
  33853. protected _m2: number;
  33854. /**
  33855. * constructor
  33856. * @param length The number of samples required to saturate the sliding window
  33857. */
  33858. constructor(length: number);
  33859. /**
  33860. * Adds a sample to the sample set
  33861. * @param v The sample value
  33862. */
  33863. add(v: number): void;
  33864. /**
  33865. * Returns previously added values or null if outside of history or outside the sliding window domain
  33866. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33867. * @return Value previously recorded with add() or null if outside of range
  33868. */
  33869. history(i: number): number;
  33870. /**
  33871. * Returns true if enough samples have been taken to completely fill the sliding window
  33872. * @return true if sample-set saturated
  33873. */
  33874. isSaturated(): boolean;
  33875. /**
  33876. * Resets the rolling average (equivalent to 0 samples taken so far)
  33877. */
  33878. reset(): void;
  33879. /**
  33880. * Wraps a value around the sample range boundaries
  33881. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33882. * @return Wrapped position in sample range
  33883. */
  33884. protected _wrapPosition(i: number): number;
  33885. }
  33886. }
  33887. declare module "babylonjs/Misc/perfCounter" {
  33888. /**
  33889. * This class is used to track a performance counter which is number based.
  33890. * The user has access to many properties which give statistics of different nature.
  33891. *
  33892. * The implementer can track two kinds of Performance Counter: time and count.
  33893. * 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.
  33894. * 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.
  33895. */
  33896. export class PerfCounter {
  33897. /**
  33898. * Gets or sets a global boolean to turn on and off all the counters
  33899. */
  33900. static Enabled: boolean;
  33901. /**
  33902. * Returns the smallest value ever
  33903. */
  33904. get min(): number;
  33905. /**
  33906. * Returns the biggest value ever
  33907. */
  33908. get max(): number;
  33909. /**
  33910. * Returns the average value since the performance counter is running
  33911. */
  33912. get average(): number;
  33913. /**
  33914. * Returns the average value of the last second the counter was monitored
  33915. */
  33916. get lastSecAverage(): number;
  33917. /**
  33918. * Returns the current value
  33919. */
  33920. get current(): number;
  33921. /**
  33922. * Gets the accumulated total
  33923. */
  33924. get total(): number;
  33925. /**
  33926. * Gets the total value count
  33927. */
  33928. get count(): number;
  33929. /**
  33930. * Creates a new counter
  33931. */
  33932. constructor();
  33933. /**
  33934. * Call this method to start monitoring a new frame.
  33935. * 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.
  33936. */
  33937. fetchNewFrame(): void;
  33938. /**
  33939. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33940. * @param newCount the count value to add to the monitored count
  33941. * @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.
  33942. */
  33943. addCount(newCount: number, fetchResult: boolean): void;
  33944. /**
  33945. * Start monitoring this performance counter
  33946. */
  33947. beginMonitoring(): void;
  33948. /**
  33949. * Compute the time lapsed since the previous beginMonitoring() call.
  33950. * @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
  33951. */
  33952. endMonitoring(newFrame?: boolean): void;
  33953. private _fetchResult;
  33954. private _startMonitoringTime;
  33955. private _min;
  33956. private _max;
  33957. private _average;
  33958. private _current;
  33959. private _totalValueCount;
  33960. private _totalAccumulated;
  33961. private _lastSecAverage;
  33962. private _lastSecAccumulated;
  33963. private _lastSecTime;
  33964. private _lastSecValueCount;
  33965. }
  33966. }
  33967. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33968. module "babylonjs/Engines/thinEngine" {
  33969. interface ThinEngine {
  33970. /**
  33971. * Sets alpha constants used by some alpha blending modes
  33972. * @param r defines the red component
  33973. * @param g defines the green component
  33974. * @param b defines the blue component
  33975. * @param a defines the alpha component
  33976. */
  33977. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33978. /**
  33979. * Sets the current alpha mode
  33980. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33981. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33982. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33983. */
  33984. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33985. /**
  33986. * Gets the current alpha mode
  33987. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33988. * @returns the current alpha mode
  33989. */
  33990. getAlphaMode(): number;
  33991. /**
  33992. * Sets the current alpha equation
  33993. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33994. */
  33995. setAlphaEquation(equation: number): void;
  33996. /**
  33997. * Gets the current alpha equation.
  33998. * @returns the current alpha equation
  33999. */
  34000. getAlphaEquation(): number;
  34001. }
  34002. }
  34003. }
  34004. declare module "babylonjs/Engines/engine" {
  34005. import { Observable } from "babylonjs/Misc/observable";
  34006. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34007. import { Scene } from "babylonjs/scene";
  34008. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34009. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34010. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34011. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34012. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34013. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34014. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34015. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34016. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34017. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34018. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34019. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34020. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34021. import "babylonjs/Engines/Extensions/engine.alpha";
  34022. import { Material } from "babylonjs/Materials/material";
  34023. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34024. /**
  34025. * Defines the interface used by display changed events
  34026. */
  34027. export interface IDisplayChangedEventArgs {
  34028. /** Gets the vrDisplay object (if any) */
  34029. vrDisplay: Nullable<any>;
  34030. /** Gets a boolean indicating if webVR is supported */
  34031. vrSupported: boolean;
  34032. }
  34033. /**
  34034. * Defines the interface used by objects containing a viewport (like a camera)
  34035. */
  34036. interface IViewportOwnerLike {
  34037. /**
  34038. * Gets or sets the viewport
  34039. */
  34040. viewport: IViewportLike;
  34041. }
  34042. /**
  34043. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34044. */
  34045. export class Engine extends ThinEngine {
  34046. /** Defines that alpha blending is disabled */
  34047. static readonly ALPHA_DISABLE: number;
  34048. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34049. static readonly ALPHA_ADD: number;
  34050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34051. static readonly ALPHA_COMBINE: number;
  34052. /** Defines that alpha blending to DEST - SRC * DEST */
  34053. static readonly ALPHA_SUBTRACT: number;
  34054. /** Defines that alpha blending to SRC * DEST */
  34055. static readonly ALPHA_MULTIPLY: number;
  34056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34057. static readonly ALPHA_MAXIMIZED: number;
  34058. /** Defines that alpha blending to SRC + DEST */
  34059. static readonly ALPHA_ONEONE: number;
  34060. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34061. static readonly ALPHA_PREMULTIPLIED: number;
  34062. /**
  34063. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34064. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34065. */
  34066. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34067. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34068. static readonly ALPHA_INTERPOLATE: number;
  34069. /**
  34070. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34071. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34072. */
  34073. static readonly ALPHA_SCREENMODE: number;
  34074. /** Defines that the ressource is not delayed*/
  34075. static readonly DELAYLOADSTATE_NONE: number;
  34076. /** Defines that the ressource was successfully delay loaded */
  34077. static readonly DELAYLOADSTATE_LOADED: number;
  34078. /** Defines that the ressource is currently delay loading */
  34079. static readonly DELAYLOADSTATE_LOADING: number;
  34080. /** Defines that the ressource is delayed and has not started loading */
  34081. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34083. static readonly NEVER: number;
  34084. /** 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 */
  34085. static readonly ALWAYS: number;
  34086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34087. static readonly LESS: number;
  34088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34089. static readonly EQUAL: number;
  34090. /** 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 */
  34091. static readonly LEQUAL: number;
  34092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34093. static readonly GREATER: number;
  34094. /** 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 */
  34095. static readonly GEQUAL: number;
  34096. /** 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 */
  34097. static readonly NOTEQUAL: number;
  34098. /** Passed to stencilOperation to specify that stencil value must be kept */
  34099. static readonly KEEP: number;
  34100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34101. static readonly REPLACE: number;
  34102. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34103. static readonly INCR: number;
  34104. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34105. static readonly DECR: number;
  34106. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34107. static readonly INVERT: number;
  34108. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34109. static readonly INCR_WRAP: number;
  34110. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34111. static readonly DECR_WRAP: number;
  34112. /** Texture is not repeating outside of 0..1 UVs */
  34113. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34114. /** Texture is repeating outside of 0..1 UVs */
  34115. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34116. /** Texture is repeating and mirrored */
  34117. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34118. /** ALPHA */
  34119. static readonly TEXTUREFORMAT_ALPHA: number;
  34120. /** LUMINANCE */
  34121. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34122. /** LUMINANCE_ALPHA */
  34123. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34124. /** RGB */
  34125. static readonly TEXTUREFORMAT_RGB: number;
  34126. /** RGBA */
  34127. static readonly TEXTUREFORMAT_RGBA: number;
  34128. /** RED */
  34129. static readonly TEXTUREFORMAT_RED: number;
  34130. /** RED (2nd reference) */
  34131. static readonly TEXTUREFORMAT_R: number;
  34132. /** RG */
  34133. static readonly TEXTUREFORMAT_RG: number;
  34134. /** RED_INTEGER */
  34135. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34136. /** RED_INTEGER (2nd reference) */
  34137. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34138. /** RG_INTEGER */
  34139. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34140. /** RGB_INTEGER */
  34141. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34142. /** RGBA_INTEGER */
  34143. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34144. /** UNSIGNED_BYTE */
  34145. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34146. /** UNSIGNED_BYTE (2nd reference) */
  34147. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34148. /** FLOAT */
  34149. static readonly TEXTURETYPE_FLOAT: number;
  34150. /** HALF_FLOAT */
  34151. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34152. /** BYTE */
  34153. static readonly TEXTURETYPE_BYTE: number;
  34154. /** SHORT */
  34155. static readonly TEXTURETYPE_SHORT: number;
  34156. /** UNSIGNED_SHORT */
  34157. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34158. /** INT */
  34159. static readonly TEXTURETYPE_INT: number;
  34160. /** UNSIGNED_INT */
  34161. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34162. /** UNSIGNED_SHORT_4_4_4_4 */
  34163. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34164. /** UNSIGNED_SHORT_5_5_5_1 */
  34165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34166. /** UNSIGNED_SHORT_5_6_5 */
  34167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34168. /** UNSIGNED_INT_2_10_10_10_REV */
  34169. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34170. /** UNSIGNED_INT_24_8 */
  34171. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34172. /** UNSIGNED_INT_10F_11F_11F_REV */
  34173. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34174. /** UNSIGNED_INT_5_9_9_9_REV */
  34175. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34176. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34177. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34178. /** nearest is mag = nearest and min = nearest and mip = linear */
  34179. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34181. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34182. /** Trilinear is mag = linear and min = linear and mip = linear */
  34183. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34184. /** nearest is mag = nearest and min = nearest and mip = linear */
  34185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34187. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34188. /** Trilinear is mag = linear and min = linear and mip = linear */
  34189. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34190. /** mag = nearest and min = nearest and mip = nearest */
  34191. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34192. /** mag = nearest and min = linear and mip = nearest */
  34193. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34194. /** mag = nearest and min = linear and mip = linear */
  34195. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34196. /** mag = nearest and min = linear and mip = none */
  34197. static readonly TEXTURE_NEAREST_LINEAR: number;
  34198. /** mag = nearest and min = nearest and mip = none */
  34199. static readonly TEXTURE_NEAREST_NEAREST: number;
  34200. /** mag = linear and min = nearest and mip = nearest */
  34201. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34202. /** mag = linear and min = nearest and mip = linear */
  34203. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34204. /** mag = linear and min = linear and mip = none */
  34205. static readonly TEXTURE_LINEAR_LINEAR: number;
  34206. /** mag = linear and min = nearest and mip = none */
  34207. static readonly TEXTURE_LINEAR_NEAREST: number;
  34208. /** Explicit coordinates mode */
  34209. static readonly TEXTURE_EXPLICIT_MODE: number;
  34210. /** Spherical coordinates mode */
  34211. static readonly TEXTURE_SPHERICAL_MODE: number;
  34212. /** Planar coordinates mode */
  34213. static readonly TEXTURE_PLANAR_MODE: number;
  34214. /** Cubic coordinates mode */
  34215. static readonly TEXTURE_CUBIC_MODE: number;
  34216. /** Projection coordinates mode */
  34217. static readonly TEXTURE_PROJECTION_MODE: number;
  34218. /** Skybox coordinates mode */
  34219. static readonly TEXTURE_SKYBOX_MODE: number;
  34220. /** Inverse Cubic coordinates mode */
  34221. static readonly TEXTURE_INVCUBIC_MODE: number;
  34222. /** Equirectangular coordinates mode */
  34223. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34224. /** Equirectangular Fixed coordinates mode */
  34225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34226. /** Equirectangular Fixed Mirrored coordinates mode */
  34227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34228. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34229. static readonly SCALEMODE_FLOOR: number;
  34230. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34231. static readonly SCALEMODE_NEAREST: number;
  34232. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34233. static readonly SCALEMODE_CEILING: number;
  34234. /**
  34235. * Returns the current npm package of the sdk
  34236. */
  34237. static get NpmPackage(): string;
  34238. /**
  34239. * Returns the current version of the framework
  34240. */
  34241. static get Version(): string;
  34242. /** Gets the list of created engines */
  34243. static get Instances(): Engine[];
  34244. /**
  34245. * Gets the latest created engine
  34246. */
  34247. static get LastCreatedEngine(): Nullable<Engine>;
  34248. /**
  34249. * Gets the latest created scene
  34250. */
  34251. static get LastCreatedScene(): Nullable<Scene>;
  34252. /**
  34253. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34254. * @param flag defines which part of the materials must be marked as dirty
  34255. * @param predicate defines a predicate used to filter which materials should be affected
  34256. */
  34257. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34258. /**
  34259. * Method called to create the default loading screen.
  34260. * This can be overriden in your own app.
  34261. * @param canvas The rendering canvas element
  34262. * @returns The loading screen
  34263. */
  34264. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34265. /**
  34266. * Method called to create the default rescale post process on each engine.
  34267. */
  34268. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34269. /**
  34270. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34271. **/
  34272. enableOfflineSupport: boolean;
  34273. /**
  34274. * 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)
  34275. **/
  34276. disableManifestCheck: boolean;
  34277. /**
  34278. * Gets the list of created scenes
  34279. */
  34280. scenes: Scene[];
  34281. /**
  34282. * Event raised when a new scene is created
  34283. */
  34284. onNewSceneAddedObservable: Observable<Scene>;
  34285. /**
  34286. * Gets the list of created postprocesses
  34287. */
  34288. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34289. /**
  34290. * Gets a boolean indicating if the pointer is currently locked
  34291. */
  34292. isPointerLock: boolean;
  34293. /**
  34294. * Observable event triggered each time the rendering canvas is resized
  34295. */
  34296. onResizeObservable: Observable<Engine>;
  34297. /**
  34298. * Observable event triggered each time the canvas loses focus
  34299. */
  34300. onCanvasBlurObservable: Observable<Engine>;
  34301. /**
  34302. * Observable event triggered each time the canvas gains focus
  34303. */
  34304. onCanvasFocusObservable: Observable<Engine>;
  34305. /**
  34306. * Observable event triggered each time the canvas receives pointerout event
  34307. */
  34308. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34309. /**
  34310. * Observable raised when the engine begins a new frame
  34311. */
  34312. onBeginFrameObservable: Observable<Engine>;
  34313. /**
  34314. * If set, will be used to request the next animation frame for the render loop
  34315. */
  34316. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34317. /**
  34318. * Observable raised when the engine ends the current frame
  34319. */
  34320. onEndFrameObservable: Observable<Engine>;
  34321. /**
  34322. * Observable raised when the engine is about to compile a shader
  34323. */
  34324. onBeforeShaderCompilationObservable: Observable<Engine>;
  34325. /**
  34326. * Observable raised when the engine has jsut compiled a shader
  34327. */
  34328. onAfterShaderCompilationObservable: Observable<Engine>;
  34329. /**
  34330. * Gets the audio engine
  34331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34332. * @ignorenaming
  34333. */
  34334. static audioEngine: IAudioEngine;
  34335. /**
  34336. * Default AudioEngine factory responsible of creating the Audio Engine.
  34337. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34338. */
  34339. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34340. /**
  34341. * Default offline support factory responsible of creating a tool used to store data locally.
  34342. * By default, this will create a Database object if the workload has been embedded.
  34343. */
  34344. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34345. private _loadingScreen;
  34346. private _pointerLockRequested;
  34347. private _dummyFramebuffer;
  34348. private _rescalePostProcess;
  34349. private _deterministicLockstep;
  34350. private _lockstepMaxSteps;
  34351. private _timeStep;
  34352. protected get _supportsHardwareTextureRescaling(): boolean;
  34353. private _fps;
  34354. private _deltaTime;
  34355. /** @hidden */
  34356. _drawCalls: PerfCounter;
  34357. /** 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 */
  34358. canvasTabIndex: number;
  34359. /**
  34360. * Turn this value on if you want to pause FPS computation when in background
  34361. */
  34362. disablePerformanceMonitorInBackground: boolean;
  34363. private _performanceMonitor;
  34364. /**
  34365. * Gets the performance monitor attached to this engine
  34366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34367. */
  34368. get performanceMonitor(): PerformanceMonitor;
  34369. private _onFocus;
  34370. private _onBlur;
  34371. private _onCanvasPointerOut;
  34372. private _onCanvasBlur;
  34373. private _onCanvasFocus;
  34374. private _onFullscreenChange;
  34375. private _onPointerLockChange;
  34376. /**
  34377. * Gets the HTML element used to attach event listeners
  34378. * @returns a HTML element
  34379. */
  34380. getInputElement(): Nullable<HTMLElement>;
  34381. /**
  34382. * Creates a new engine
  34383. * @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
  34384. * @param antialias defines enable antialiasing (default: false)
  34385. * @param options defines further options to be sent to the getContext() function
  34386. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34387. */
  34388. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34389. /**
  34390. * Gets current aspect ratio
  34391. * @param viewportOwner defines the camera to use to get the aspect ratio
  34392. * @param useScreen defines if screen size must be used (or the current render target if any)
  34393. * @returns a number defining the aspect ratio
  34394. */
  34395. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34396. /**
  34397. * Gets current screen aspect ratio
  34398. * @returns a number defining the aspect ratio
  34399. */
  34400. getScreenAspectRatio(): number;
  34401. /**
  34402. * Gets the client rect of the HTML canvas attached with the current webGL context
  34403. * @returns a client rectanglee
  34404. */
  34405. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34406. /**
  34407. * Gets the client rect of the HTML element used for events
  34408. * @returns a client rectanglee
  34409. */
  34410. getInputElementClientRect(): Nullable<ClientRect>;
  34411. /**
  34412. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34413. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34414. * @returns true if engine is in deterministic lock step mode
  34415. */
  34416. isDeterministicLockStep(): boolean;
  34417. /**
  34418. * Gets the max steps when engine is running in deterministic lock step
  34419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34420. * @returns the max steps
  34421. */
  34422. getLockstepMaxSteps(): number;
  34423. /**
  34424. * Returns the time in ms between steps when using deterministic lock step.
  34425. * @returns time step in (ms)
  34426. */
  34427. getTimeStep(): number;
  34428. /**
  34429. * Force the mipmap generation for the given render target texture
  34430. * @param texture defines the render target texture to use
  34431. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34432. */
  34433. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34434. /** States */
  34435. /**
  34436. * Set various states to the webGL context
  34437. * @param culling defines backface culling state
  34438. * @param zOffset defines the value to apply to zOffset (0 by default)
  34439. * @param force defines if states must be applied even if cache is up to date
  34440. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34441. */
  34442. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34443. /**
  34444. * Set the z offset to apply to current rendering
  34445. * @param value defines the offset to apply
  34446. */
  34447. setZOffset(value: number): void;
  34448. /**
  34449. * Gets the current value of the zOffset
  34450. * @returns the current zOffset state
  34451. */
  34452. getZOffset(): number;
  34453. /**
  34454. * Enable or disable depth buffering
  34455. * @param enable defines the state to set
  34456. */
  34457. setDepthBuffer(enable: boolean): void;
  34458. /**
  34459. * Gets a boolean indicating if depth writing is enabled
  34460. * @returns the current depth writing state
  34461. */
  34462. getDepthWrite(): boolean;
  34463. /**
  34464. * Enable or disable depth writing
  34465. * @param enable defines the state to set
  34466. */
  34467. setDepthWrite(enable: boolean): void;
  34468. /**
  34469. * Gets a boolean indicating if stencil buffer is enabled
  34470. * @returns the current stencil buffer state
  34471. */
  34472. getStencilBuffer(): boolean;
  34473. /**
  34474. * Enable or disable the stencil buffer
  34475. * @param enable defines if the stencil buffer must be enabled or disabled
  34476. */
  34477. setStencilBuffer(enable: boolean): void;
  34478. /**
  34479. * Gets the current stencil mask
  34480. * @returns a number defining the new stencil mask to use
  34481. */
  34482. getStencilMask(): number;
  34483. /**
  34484. * Sets the current stencil mask
  34485. * @param mask defines the new stencil mask to use
  34486. */
  34487. setStencilMask(mask: number): void;
  34488. /**
  34489. * Gets the current stencil function
  34490. * @returns a number defining the stencil function to use
  34491. */
  34492. getStencilFunction(): number;
  34493. /**
  34494. * Gets the current stencil reference value
  34495. * @returns a number defining the stencil reference value to use
  34496. */
  34497. getStencilFunctionReference(): number;
  34498. /**
  34499. * Gets the current stencil mask
  34500. * @returns a number defining the stencil mask to use
  34501. */
  34502. getStencilFunctionMask(): number;
  34503. /**
  34504. * Sets the current stencil function
  34505. * @param stencilFunc defines the new stencil function to use
  34506. */
  34507. setStencilFunction(stencilFunc: number): void;
  34508. /**
  34509. * Sets the current stencil reference
  34510. * @param reference defines the new stencil reference to use
  34511. */
  34512. setStencilFunctionReference(reference: number): void;
  34513. /**
  34514. * Sets the current stencil mask
  34515. * @param mask defines the new stencil mask to use
  34516. */
  34517. setStencilFunctionMask(mask: number): void;
  34518. /**
  34519. * Gets the current stencil operation when stencil fails
  34520. * @returns a number defining stencil operation to use when stencil fails
  34521. */
  34522. getStencilOperationFail(): number;
  34523. /**
  34524. * Gets the current stencil operation when depth fails
  34525. * @returns a number defining stencil operation to use when depth fails
  34526. */
  34527. getStencilOperationDepthFail(): number;
  34528. /**
  34529. * Gets the current stencil operation when stencil passes
  34530. * @returns a number defining stencil operation to use when stencil passes
  34531. */
  34532. getStencilOperationPass(): number;
  34533. /**
  34534. * Sets the stencil operation to use when stencil fails
  34535. * @param operation defines the stencil operation to use when stencil fails
  34536. */
  34537. setStencilOperationFail(operation: number): void;
  34538. /**
  34539. * Sets the stencil operation to use when depth fails
  34540. * @param operation defines the stencil operation to use when depth fails
  34541. */
  34542. setStencilOperationDepthFail(operation: number): void;
  34543. /**
  34544. * Sets the stencil operation to use when stencil passes
  34545. * @param operation defines the stencil operation to use when stencil passes
  34546. */
  34547. setStencilOperationPass(operation: number): void;
  34548. /**
  34549. * Sets a boolean indicating if the dithering state is enabled or disabled
  34550. * @param value defines the dithering state
  34551. */
  34552. setDitheringState(value: boolean): void;
  34553. /**
  34554. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34555. * @param value defines the rasterizer state
  34556. */
  34557. setRasterizerState(value: boolean): void;
  34558. /**
  34559. * Gets the current depth function
  34560. * @returns a number defining the depth function
  34561. */
  34562. getDepthFunction(): Nullable<number>;
  34563. /**
  34564. * Sets the current depth function
  34565. * @param depthFunc defines the function to use
  34566. */
  34567. setDepthFunction(depthFunc: number): void;
  34568. /**
  34569. * Sets the current depth function to GREATER
  34570. */
  34571. setDepthFunctionToGreater(): void;
  34572. /**
  34573. * Sets the current depth function to GEQUAL
  34574. */
  34575. setDepthFunctionToGreaterOrEqual(): void;
  34576. /**
  34577. * Sets the current depth function to LESS
  34578. */
  34579. setDepthFunctionToLess(): void;
  34580. /**
  34581. * Sets the current depth function to LEQUAL
  34582. */
  34583. setDepthFunctionToLessOrEqual(): void;
  34584. private _cachedStencilBuffer;
  34585. private _cachedStencilFunction;
  34586. private _cachedStencilMask;
  34587. private _cachedStencilOperationPass;
  34588. private _cachedStencilOperationFail;
  34589. private _cachedStencilOperationDepthFail;
  34590. private _cachedStencilReference;
  34591. /**
  34592. * Caches the the state of the stencil buffer
  34593. */
  34594. cacheStencilState(): void;
  34595. /**
  34596. * Restores the state of the stencil buffer
  34597. */
  34598. restoreStencilState(): void;
  34599. /**
  34600. * Directly set the WebGL Viewport
  34601. * @param x defines the x coordinate of the viewport (in screen space)
  34602. * @param y defines the y coordinate of the viewport (in screen space)
  34603. * @param width defines the width of the viewport (in screen space)
  34604. * @param height defines the height of the viewport (in screen space)
  34605. * @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
  34606. */
  34607. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34608. /**
  34609. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34610. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34611. * @param y defines the y-coordinate of the corner of the clear rectangle
  34612. * @param width defines the width of the clear rectangle
  34613. * @param height defines the height of the clear rectangle
  34614. * @param clearColor defines the clear color
  34615. */
  34616. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34617. /**
  34618. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34619. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34620. * @param y defines the y-coordinate of the corner of the clear rectangle
  34621. * @param width defines the width of the clear rectangle
  34622. * @param height defines the height of the clear rectangle
  34623. */
  34624. enableScissor(x: number, y: number, width: number, height: number): void;
  34625. /**
  34626. * Disable previously set scissor test rectangle
  34627. */
  34628. disableScissor(): void;
  34629. protected _reportDrawCall(): void;
  34630. /**
  34631. * Initializes a webVR display and starts listening to display change events
  34632. * The onVRDisplayChangedObservable will be notified upon these changes
  34633. * @returns The onVRDisplayChangedObservable
  34634. */
  34635. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34636. /** @hidden */
  34637. _prepareVRComponent(): void;
  34638. /** @hidden */
  34639. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34640. /** @hidden */
  34641. _submitVRFrame(): void;
  34642. /**
  34643. * Call this function to leave webVR mode
  34644. * Will do nothing if webVR is not supported or if there is no webVR device
  34645. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34646. */
  34647. disableVR(): void;
  34648. /**
  34649. * Gets a boolean indicating that the system is in VR mode and is presenting
  34650. * @returns true if VR mode is engaged
  34651. */
  34652. isVRPresenting(): boolean;
  34653. /** @hidden */
  34654. _requestVRFrame(): void;
  34655. /** @hidden */
  34656. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34657. /**
  34658. * Gets the source code of the vertex shader associated with a specific webGL program
  34659. * @param program defines the program to use
  34660. * @returns a string containing the source code of the vertex shader associated with the program
  34661. */
  34662. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34663. /**
  34664. * Gets the source code of the fragment shader associated with a specific webGL program
  34665. * @param program defines the program to use
  34666. * @returns a string containing the source code of the fragment shader associated with the program
  34667. */
  34668. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34669. /**
  34670. * Sets a depth stencil texture from a render target to the according uniform.
  34671. * @param channel The texture channel
  34672. * @param uniform The uniform to set
  34673. * @param texture The render target texture containing the depth stencil texture to apply
  34674. */
  34675. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34676. /**
  34677. * Sets a texture to the webGL context from a postprocess
  34678. * @param channel defines the channel to use
  34679. * @param postProcess defines the source postprocess
  34680. */
  34681. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34682. /**
  34683. * Binds the output of the passed in post process to the texture channel specified
  34684. * @param channel The channel the texture should be bound to
  34685. * @param postProcess The post process which's output should be bound
  34686. */
  34687. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34688. /** @hidden */
  34689. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34690. protected _rebuildBuffers(): void;
  34691. /** @hidden */
  34692. _renderFrame(): void;
  34693. _renderLoop(): void;
  34694. /** @hidden */
  34695. _renderViews(): boolean;
  34696. /**
  34697. * Toggle full screen mode
  34698. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34699. */
  34700. switchFullscreen(requestPointerLock: boolean): void;
  34701. /**
  34702. * Enters full screen mode
  34703. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34704. */
  34705. enterFullscreen(requestPointerLock: boolean): void;
  34706. /**
  34707. * Exits full screen mode
  34708. */
  34709. exitFullscreen(): void;
  34710. /**
  34711. * Enters Pointerlock mode
  34712. */
  34713. enterPointerlock(): void;
  34714. /**
  34715. * Exits Pointerlock mode
  34716. */
  34717. exitPointerlock(): void;
  34718. /**
  34719. * Begin a new frame
  34720. */
  34721. beginFrame(): void;
  34722. /**
  34723. * Enf the current frame
  34724. */
  34725. endFrame(): void;
  34726. resize(): void;
  34727. /**
  34728. * Set the compressed texture format to use, based on the formats you have, and the formats
  34729. * supported by the hardware / browser.
  34730. *
  34731. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34732. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34733. * to API arguments needed to compressed textures. This puts the burden on the container
  34734. * generator to house the arcane code for determining these for current & future formats.
  34735. *
  34736. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34737. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34738. *
  34739. * Note: The result of this call is not taken into account when a texture is base64.
  34740. *
  34741. * @param formatsAvailable defines the list of those format families you have created
  34742. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34743. *
  34744. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34745. * @returns The extension selected.
  34746. */
  34747. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34748. /**
  34749. * Set the compressed texture extensions or file names to skip.
  34750. *
  34751. * @param skippedFiles defines the list of those texture files you want to skip
  34752. * Example: [".dds", ".env", "myfile.png"]
  34753. */
  34754. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34755. /**
  34756. * Force a specific size of the canvas
  34757. * @param width defines the new canvas' width
  34758. * @param height defines the new canvas' height
  34759. */
  34760. setSize(width: number, height: number): void;
  34761. /**
  34762. * Updates a dynamic vertex buffer.
  34763. * @param vertexBuffer the vertex buffer to update
  34764. * @param data the data used to update the vertex buffer
  34765. * @param byteOffset the byte offset of the data
  34766. * @param byteLength the byte length of the data
  34767. */
  34768. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34769. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34770. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34771. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34772. _releaseTexture(texture: InternalTexture): void;
  34773. /**
  34774. * @hidden
  34775. * Rescales a texture
  34776. * @param source input texutre
  34777. * @param destination destination texture
  34778. * @param scene scene to use to render the resize
  34779. * @param internalFormat format to use when resizing
  34780. * @param onComplete callback to be called when resize has completed
  34781. */
  34782. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34783. /**
  34784. * Gets the current framerate
  34785. * @returns a number representing the framerate
  34786. */
  34787. getFps(): number;
  34788. /**
  34789. * Gets the time spent between current and previous frame
  34790. * @returns a number representing the delta time in ms
  34791. */
  34792. getDeltaTime(): number;
  34793. private _measureFps;
  34794. /** @hidden */
  34795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34796. /**
  34797. * Update a dynamic index buffer
  34798. * @param indexBuffer defines the target index buffer
  34799. * @param indices defines the data to update
  34800. * @param offset defines the offset in the target index buffer where update should start
  34801. */
  34802. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34803. /**
  34804. * Updates the sample count of a render target texture
  34805. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34806. * @param texture defines the texture to update
  34807. * @param samples defines the sample count to set
  34808. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34809. */
  34810. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34811. /**
  34812. * Updates a depth texture Comparison Mode and Function.
  34813. * If the comparison Function is equal to 0, the mode will be set to none.
  34814. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34815. * @param texture The texture to set the comparison function for
  34816. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34817. */
  34818. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34819. /**
  34820. * Creates a webGL buffer to use with instanciation
  34821. * @param capacity defines the size of the buffer
  34822. * @returns the webGL buffer
  34823. */
  34824. createInstancesBuffer(capacity: number): DataBuffer;
  34825. /**
  34826. * Delete a webGL buffer used with instanciation
  34827. * @param buffer defines the webGL buffer to delete
  34828. */
  34829. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34830. /** @hidden */
  34831. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34832. dispose(): void;
  34833. private _disableTouchAction;
  34834. /**
  34835. * Display the loading screen
  34836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34837. */
  34838. displayLoadingUI(): void;
  34839. /**
  34840. * Hide the loading screen
  34841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34842. */
  34843. hideLoadingUI(): void;
  34844. /**
  34845. * Gets the current loading screen object
  34846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34847. */
  34848. get loadingScreen(): ILoadingScreen;
  34849. /**
  34850. * Sets the current loading screen object
  34851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34852. */
  34853. set loadingScreen(loadingScreen: ILoadingScreen);
  34854. /**
  34855. * Sets the current loading screen text
  34856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34857. */
  34858. set loadingUIText(text: string);
  34859. /**
  34860. * Sets the current loading screen background color
  34861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34862. */
  34863. set loadingUIBackgroundColor(color: string);
  34864. /** Pointerlock and fullscreen */
  34865. /**
  34866. * Ask the browser to promote the current element to pointerlock mode
  34867. * @param element defines the DOM element to promote
  34868. */
  34869. static _RequestPointerlock(element: HTMLElement): void;
  34870. /**
  34871. * Asks the browser to exit pointerlock mode
  34872. */
  34873. static _ExitPointerlock(): void;
  34874. /**
  34875. * Ask the browser to promote the current element to fullscreen rendering mode
  34876. * @param element defines the DOM element to promote
  34877. */
  34878. static _RequestFullscreen(element: HTMLElement): void;
  34879. /**
  34880. * Asks the browser to exit fullscreen mode
  34881. */
  34882. static _ExitFullscreen(): void;
  34883. }
  34884. }
  34885. declare module "babylonjs/Engines/engineStore" {
  34886. import { Nullable } from "babylonjs/types";
  34887. import { Engine } from "babylonjs/Engines/engine";
  34888. import { Scene } from "babylonjs/scene";
  34889. /**
  34890. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34891. * during the life time of the application.
  34892. */
  34893. export class EngineStore {
  34894. /** Gets the list of created engines */
  34895. static Instances: import("babylonjs/Engines/engine").Engine[];
  34896. /** @hidden */
  34897. static _LastCreatedScene: Nullable<Scene>;
  34898. /**
  34899. * Gets the latest created engine
  34900. */
  34901. static get LastCreatedEngine(): Nullable<Engine>;
  34902. /**
  34903. * Gets the latest created scene
  34904. */
  34905. static get LastCreatedScene(): Nullable<Scene>;
  34906. /**
  34907. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34908. * @ignorenaming
  34909. */
  34910. static UseFallbackTexture: boolean;
  34911. /**
  34912. * Texture content used if a texture cannot loaded
  34913. * @ignorenaming
  34914. */
  34915. static FallbackTexture: string;
  34916. }
  34917. }
  34918. declare module "babylonjs/Misc/promise" {
  34919. /**
  34920. * Helper class that provides a small promise polyfill
  34921. */
  34922. export class PromisePolyfill {
  34923. /**
  34924. * Static function used to check if the polyfill is required
  34925. * If this is the case then the function will inject the polyfill to window.Promise
  34926. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34927. */
  34928. static Apply(force?: boolean): void;
  34929. }
  34930. }
  34931. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34932. /**
  34933. * Interface for screenshot methods with describe argument called `size` as object with options
  34934. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34935. */
  34936. export interface IScreenshotSize {
  34937. /**
  34938. * number in pixels for canvas height
  34939. */
  34940. height?: number;
  34941. /**
  34942. * multiplier allowing render at a higher or lower resolution
  34943. * If value is defined then height and width will be ignored and taken from camera
  34944. */
  34945. precision?: number;
  34946. /**
  34947. * number in pixels for canvas width
  34948. */
  34949. width?: number;
  34950. }
  34951. }
  34952. declare module "babylonjs/Misc/tools" {
  34953. import { Nullable, float } from "babylonjs/types";
  34954. import { DomManagement } from "babylonjs/Misc/domManagement";
  34955. import { WebRequest } from "babylonjs/Misc/webRequest";
  34956. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34957. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34958. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34959. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34960. import { Camera } from "babylonjs/Cameras/camera";
  34961. import { Engine } from "babylonjs/Engines/engine";
  34962. interface IColor4Like {
  34963. r: float;
  34964. g: float;
  34965. b: float;
  34966. a: float;
  34967. }
  34968. /**
  34969. * Class containing a set of static utilities functions
  34970. */
  34971. export class Tools {
  34972. /**
  34973. * Gets or sets the base URL to use to load assets
  34974. */
  34975. static get BaseUrl(): string;
  34976. static set BaseUrl(value: string);
  34977. /**
  34978. * Enable/Disable Custom HTTP Request Headers globally.
  34979. * default = false
  34980. * @see CustomRequestHeaders
  34981. */
  34982. static UseCustomRequestHeaders: boolean;
  34983. /**
  34984. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34985. * i.e. when loading files, where the server/service expects an Authorization header
  34986. */
  34987. static CustomRequestHeaders: {
  34988. [key: string]: string;
  34989. };
  34990. /**
  34991. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34992. */
  34993. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34994. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34995. /**
  34996. * Default behaviour for cors in the application.
  34997. * It can be a string if the expected behavior is identical in the entire app.
  34998. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34999. */
  35000. static CorsBehavior: string | ((url: string | string[]) => string);
  35001. /**
  35002. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35003. * @ignorenaming
  35004. */
  35005. static get UseFallbackTexture(): boolean;
  35006. static set UseFallbackTexture(value: boolean);
  35007. /**
  35008. * Use this object to register external classes like custom textures or material
  35009. * to allow the laoders to instantiate them
  35010. */
  35011. static get RegisteredExternalClasses(): {
  35012. [key: string]: Object;
  35013. };
  35014. static set RegisteredExternalClasses(classes: {
  35015. [key: string]: Object;
  35016. });
  35017. /**
  35018. * Texture content used if a texture cannot loaded
  35019. * @ignorenaming
  35020. */
  35021. static get fallbackTexture(): string;
  35022. static set fallbackTexture(value: string);
  35023. /**
  35024. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35025. * @param u defines the coordinate on X axis
  35026. * @param v defines the coordinate on Y axis
  35027. * @param width defines the width of the source data
  35028. * @param height defines the height of the source data
  35029. * @param pixels defines the source byte array
  35030. * @param color defines the output color
  35031. */
  35032. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35033. /**
  35034. * Interpolates between a and b via alpha
  35035. * @param a The lower value (returned when alpha = 0)
  35036. * @param b The upper value (returned when alpha = 1)
  35037. * @param alpha The interpolation-factor
  35038. * @return The mixed value
  35039. */
  35040. static Mix(a: number, b: number, alpha: number): number;
  35041. /**
  35042. * Tries to instantiate a new object from a given class name
  35043. * @param className defines the class name to instantiate
  35044. * @returns the new object or null if the system was not able to do the instantiation
  35045. */
  35046. static Instantiate(className: string): any;
  35047. /**
  35048. * Provides a slice function that will work even on IE
  35049. * @param data defines the array to slice
  35050. * @param start defines the start of the data (optional)
  35051. * @param end defines the end of the data (optional)
  35052. * @returns the new sliced array
  35053. */
  35054. static Slice<T>(data: T, start?: number, end?: number): T;
  35055. /**
  35056. * Polyfill for setImmediate
  35057. * @param action defines the action to execute after the current execution block
  35058. */
  35059. static SetImmediate(action: () => void): void;
  35060. /**
  35061. * Function indicating if a number is an exponent of 2
  35062. * @param value defines the value to test
  35063. * @returns true if the value is an exponent of 2
  35064. */
  35065. static IsExponentOfTwo(value: number): boolean;
  35066. private static _tmpFloatArray;
  35067. /**
  35068. * Returns the nearest 32-bit single precision float representation of a Number
  35069. * @param value A Number. If the parameter is of a different type, it will get converted
  35070. * to a number or to NaN if it cannot be converted
  35071. * @returns number
  35072. */
  35073. static FloatRound(value: number): number;
  35074. /**
  35075. * Extracts the filename from a path
  35076. * @param path defines the path to use
  35077. * @returns the filename
  35078. */
  35079. static GetFilename(path: string): string;
  35080. /**
  35081. * Extracts the "folder" part of a path (everything before the filename).
  35082. * @param uri The URI to extract the info from
  35083. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35084. * @returns The "folder" part of the path
  35085. */
  35086. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35087. /**
  35088. * Extracts text content from a DOM element hierarchy
  35089. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35090. */
  35091. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35092. /**
  35093. * Convert an angle in radians to degrees
  35094. * @param angle defines the angle to convert
  35095. * @returns the angle in degrees
  35096. */
  35097. static ToDegrees(angle: number): number;
  35098. /**
  35099. * Convert an angle in degrees to radians
  35100. * @param angle defines the angle to convert
  35101. * @returns the angle in radians
  35102. */
  35103. static ToRadians(angle: number): number;
  35104. /**
  35105. * Returns an array if obj is not an array
  35106. * @param obj defines the object to evaluate as an array
  35107. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35108. * @returns either obj directly if obj is an array or a new array containing obj
  35109. */
  35110. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35111. /**
  35112. * Gets the pointer prefix to use
  35113. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35114. */
  35115. static GetPointerPrefix(): string;
  35116. /**
  35117. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35118. * @param url define the url we are trying
  35119. * @param element define the dom element where to configure the cors policy
  35120. */
  35121. static SetCorsBehavior(url: string | string[], element: {
  35122. crossOrigin: string | null;
  35123. }): void;
  35124. /**
  35125. * Removes unwanted characters from an url
  35126. * @param url defines the url to clean
  35127. * @returns the cleaned url
  35128. */
  35129. static CleanUrl(url: string): string;
  35130. /**
  35131. * Gets or sets a function used to pre-process url before using them to load assets
  35132. */
  35133. static get PreprocessUrl(): (url: string) => string;
  35134. static set PreprocessUrl(processor: (url: string) => string);
  35135. /**
  35136. * Loads an image as an HTMLImageElement.
  35137. * @param input url string, ArrayBuffer, or Blob to load
  35138. * @param onLoad callback called when the image successfully loads
  35139. * @param onError callback called when the image fails to load
  35140. * @param offlineProvider offline provider for caching
  35141. * @param mimeType optional mime type
  35142. * @returns the HTMLImageElement of the loaded image
  35143. */
  35144. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35145. /**
  35146. * Loads a file from a url
  35147. * @param url url string, ArrayBuffer, or Blob to load
  35148. * @param onSuccess callback called when the file successfully loads
  35149. * @param onProgress callback called while file is loading (if the server supports this mode)
  35150. * @param offlineProvider defines the offline provider for caching
  35151. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35152. * @param onError callback called when the file fails to load
  35153. * @returns a file request object
  35154. */
  35155. 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;
  35156. /**
  35157. * Loads a file from a url
  35158. * @param url the file url to load
  35159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35160. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35161. */
  35162. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35163. /**
  35164. * Load a script (identified by an url). When the url returns, the
  35165. * content of this file is added into a new script element, attached to the DOM (body element)
  35166. * @param scriptUrl defines the url of the script to laod
  35167. * @param onSuccess defines the callback called when the script is loaded
  35168. * @param onError defines the callback to call if an error occurs
  35169. * @param scriptId defines the id of the script element
  35170. */
  35171. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35172. /**
  35173. * Load an asynchronous script (identified by an url). When the url returns, the
  35174. * content of this file is added into a new script element, attached to the DOM (body element)
  35175. * @param scriptUrl defines the url of the script to laod
  35176. * @param scriptId defines the id of the script element
  35177. * @returns a promise request object
  35178. */
  35179. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35180. /**
  35181. * Loads a file from a blob
  35182. * @param fileToLoad defines the blob to use
  35183. * @param callback defines the callback to call when data is loaded
  35184. * @param progressCallback defines the callback to call during loading process
  35185. * @returns a file request object
  35186. */
  35187. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35188. /**
  35189. * Reads a file from a File object
  35190. * @param file defines the file to load
  35191. * @param onSuccess defines the callback to call when data is loaded
  35192. * @param onProgress defines the callback to call during loading process
  35193. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35194. * @param onError defines the callback to call when an error occurs
  35195. * @returns a file request object
  35196. */
  35197. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35198. /**
  35199. * Creates a data url from a given string content
  35200. * @param content defines the content to convert
  35201. * @returns the new data url link
  35202. */
  35203. static FileAsURL(content: string): string;
  35204. /**
  35205. * Format the given number to a specific decimal format
  35206. * @param value defines the number to format
  35207. * @param decimals defines the number of decimals to use
  35208. * @returns the formatted string
  35209. */
  35210. static Format(value: number, decimals?: number): string;
  35211. /**
  35212. * Tries to copy an object by duplicating every property
  35213. * @param source defines the source object
  35214. * @param destination defines the target object
  35215. * @param doNotCopyList defines a list of properties to avoid
  35216. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35217. */
  35218. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35219. /**
  35220. * Gets a boolean indicating if the given object has no own property
  35221. * @param obj defines the object to test
  35222. * @returns true if object has no own property
  35223. */
  35224. static IsEmpty(obj: any): boolean;
  35225. /**
  35226. * Function used to register events at window level
  35227. * @param windowElement defines the Window object to use
  35228. * @param events defines the events to register
  35229. */
  35230. static RegisterTopRootEvents(windowElement: Window, events: {
  35231. name: string;
  35232. handler: Nullable<(e: FocusEvent) => any>;
  35233. }[]): void;
  35234. /**
  35235. * Function used to unregister events from window level
  35236. * @param windowElement defines the Window object to use
  35237. * @param events defines the events to unregister
  35238. */
  35239. static UnregisterTopRootEvents(windowElement: Window, events: {
  35240. name: string;
  35241. handler: Nullable<(e: FocusEvent) => any>;
  35242. }[]): void;
  35243. /**
  35244. * @ignore
  35245. */
  35246. static _ScreenshotCanvas: HTMLCanvasElement;
  35247. /**
  35248. * Dumps the current bound framebuffer
  35249. * @param width defines the rendering width
  35250. * @param height defines the rendering height
  35251. * @param engine defines the hosting engine
  35252. * @param successCallback defines the callback triggered once the data are available
  35253. * @param mimeType defines the mime type of the result
  35254. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35255. */
  35256. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35257. /**
  35258. * Converts the canvas data to blob.
  35259. * This acts as a polyfill for browsers not supporting the to blob function.
  35260. * @param canvas Defines the canvas to extract the data from
  35261. * @param successCallback Defines the callback triggered once the data are available
  35262. * @param mimeType Defines the mime type of the result
  35263. */
  35264. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35265. /**
  35266. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35267. * @param successCallback defines the callback triggered once the data are available
  35268. * @param mimeType defines the mime type of the result
  35269. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35270. */
  35271. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35272. /**
  35273. * Downloads a blob in the browser
  35274. * @param blob defines the blob to download
  35275. * @param fileName defines the name of the downloaded file
  35276. */
  35277. static Download(blob: Blob, fileName: string): void;
  35278. /**
  35279. * Captures a screenshot of the current rendering
  35280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35281. * @param engine defines the rendering engine
  35282. * @param camera defines the source camera
  35283. * @param size This parameter can be set to a single number or to an object with the
  35284. * following (optional) properties: precision, width, height. If a single number is passed,
  35285. * it will be used for both width and height. If an object is passed, the screenshot size
  35286. * will be derived from the parameters. The precision property is a multiplier allowing
  35287. * rendering at a higher or lower resolution
  35288. * @param successCallback defines the callback receives a single parameter which contains the
  35289. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35290. * src parameter of an <img> to display it
  35291. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35292. * Check your browser for supported MIME types
  35293. */
  35294. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35295. /**
  35296. * Captures a screenshot of the current rendering
  35297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35298. * @param engine defines the rendering engine
  35299. * @param camera defines the source camera
  35300. * @param size This parameter can be set to a single number or to an object with the
  35301. * following (optional) properties: precision, width, height. If a single number is passed,
  35302. * it will be used for both width and height. If an object is passed, the screenshot size
  35303. * will be derived from the parameters. The precision property is a multiplier allowing
  35304. * rendering at a higher or lower resolution
  35305. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35306. * Check your browser for supported MIME types
  35307. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35308. * to the src parameter of an <img> to display it
  35309. */
  35310. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35311. /**
  35312. * Generates an image screenshot from the specified camera.
  35313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35314. * @param engine The engine to use for rendering
  35315. * @param camera The camera to use for rendering
  35316. * @param size This parameter can be set to a single number or to an object with the
  35317. * following (optional) properties: precision, width, height. If a single number is passed,
  35318. * it will be used for both width and height. If an object is passed, the screenshot size
  35319. * will be derived from the parameters. The precision property is a multiplier allowing
  35320. * rendering at a higher or lower resolution
  35321. * @param successCallback The callback receives a single parameter which contains the
  35322. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35323. * src parameter of an <img> to display it
  35324. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35325. * Check your browser for supported MIME types
  35326. * @param samples Texture samples (default: 1)
  35327. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35328. * @param fileName A name for for the downloaded file.
  35329. */
  35330. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35331. /**
  35332. * Generates an image screenshot from the specified camera.
  35333. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35334. * @param engine The engine to use for rendering
  35335. * @param camera The camera to use for rendering
  35336. * @param size This parameter can be set to a single number or to an object with the
  35337. * following (optional) properties: precision, width, height. If a single number is passed,
  35338. * it will be used for both width and height. If an object is passed, the screenshot size
  35339. * will be derived from the parameters. The precision property is a multiplier allowing
  35340. * rendering at a higher or lower resolution
  35341. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35342. * Check your browser for supported MIME types
  35343. * @param samples Texture samples (default: 1)
  35344. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35345. * @param fileName A name for for the downloaded file.
  35346. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35347. * to the src parameter of an <img> to display it
  35348. */
  35349. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35350. /**
  35351. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35352. * Be aware Math.random() could cause collisions, but:
  35353. * "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"
  35354. * @returns a pseudo random id
  35355. */
  35356. static RandomId(): string;
  35357. /**
  35358. * Test if the given uri is a base64 string
  35359. * @param uri The uri to test
  35360. * @return True if the uri is a base64 string or false otherwise
  35361. */
  35362. static IsBase64(uri: string): boolean;
  35363. /**
  35364. * Decode the given base64 uri.
  35365. * @param uri The uri to decode
  35366. * @return The decoded base64 data.
  35367. */
  35368. static DecodeBase64(uri: string): ArrayBuffer;
  35369. /**
  35370. * Gets the absolute url.
  35371. * @param url the input url
  35372. * @return the absolute url
  35373. */
  35374. static GetAbsoluteUrl(url: string): string;
  35375. /**
  35376. * No log
  35377. */
  35378. static readonly NoneLogLevel: number;
  35379. /**
  35380. * Only message logs
  35381. */
  35382. static readonly MessageLogLevel: number;
  35383. /**
  35384. * Only warning logs
  35385. */
  35386. static readonly WarningLogLevel: number;
  35387. /**
  35388. * Only error logs
  35389. */
  35390. static readonly ErrorLogLevel: number;
  35391. /**
  35392. * All logs
  35393. */
  35394. static readonly AllLogLevel: number;
  35395. /**
  35396. * Gets a value indicating the number of loading errors
  35397. * @ignorenaming
  35398. */
  35399. static get errorsCount(): number;
  35400. /**
  35401. * Callback called when a new log is added
  35402. */
  35403. static OnNewCacheEntry: (entry: string) => void;
  35404. /**
  35405. * Log a message to the console
  35406. * @param message defines the message to log
  35407. */
  35408. static Log(message: string): void;
  35409. /**
  35410. * Write a warning message to the console
  35411. * @param message defines the message to log
  35412. */
  35413. static Warn(message: string): void;
  35414. /**
  35415. * Write an error message to the console
  35416. * @param message defines the message to log
  35417. */
  35418. static Error(message: string): void;
  35419. /**
  35420. * Gets current log cache (list of logs)
  35421. */
  35422. static get LogCache(): string;
  35423. /**
  35424. * Clears the log cache
  35425. */
  35426. static ClearLogCache(): void;
  35427. /**
  35428. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35429. */
  35430. static set LogLevels(level: number);
  35431. /**
  35432. * Checks if the window object exists
  35433. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35434. */
  35435. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35436. /**
  35437. * No performance log
  35438. */
  35439. static readonly PerformanceNoneLogLevel: number;
  35440. /**
  35441. * Use user marks to log performance
  35442. */
  35443. static readonly PerformanceUserMarkLogLevel: number;
  35444. /**
  35445. * Log performance to the console
  35446. */
  35447. static readonly PerformanceConsoleLogLevel: number;
  35448. private static _performance;
  35449. /**
  35450. * Sets the current performance log level
  35451. */
  35452. static set PerformanceLogLevel(level: number);
  35453. private static _StartPerformanceCounterDisabled;
  35454. private static _EndPerformanceCounterDisabled;
  35455. private static _StartUserMark;
  35456. private static _EndUserMark;
  35457. private static _StartPerformanceConsole;
  35458. private static _EndPerformanceConsole;
  35459. /**
  35460. * Starts a performance counter
  35461. */
  35462. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35463. /**
  35464. * Ends a specific performance coutner
  35465. */
  35466. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35467. /**
  35468. * Gets either window.performance.now() if supported or Date.now() else
  35469. */
  35470. static get Now(): number;
  35471. /**
  35472. * This method will return the name of the class used to create the instance of the given object.
  35473. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35474. * @param object the object to get the class name from
  35475. * @param isType defines if the object is actually a type
  35476. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35477. */
  35478. static GetClassName(object: any, isType?: boolean): string;
  35479. /**
  35480. * Gets the first element of an array satisfying a given predicate
  35481. * @param array defines the array to browse
  35482. * @param predicate defines the predicate to use
  35483. * @returns null if not found or the element
  35484. */
  35485. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35486. /**
  35487. * This method will return the name of the full name of the class, including its owning module (if any).
  35488. * 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).
  35489. * @param object the object to get the class name from
  35490. * @param isType defines if the object is actually a type
  35491. * @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.
  35492. * @ignorenaming
  35493. */
  35494. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35495. /**
  35496. * Returns a promise that resolves after the given amount of time.
  35497. * @param delay Number of milliseconds to delay
  35498. * @returns Promise that resolves after the given amount of time
  35499. */
  35500. static DelayAsync(delay: number): Promise<void>;
  35501. /**
  35502. * Utility function to detect if the current user agent is Safari
  35503. * @returns whether or not the current user agent is safari
  35504. */
  35505. static IsSafari(): boolean;
  35506. }
  35507. /**
  35508. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35509. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35510. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35511. * @param name The name of the class, case should be preserved
  35512. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35513. */
  35514. export function className(name: string, module?: string): (target: Object) => void;
  35515. /**
  35516. * An implementation of a loop for asynchronous functions.
  35517. */
  35518. export class AsyncLoop {
  35519. /**
  35520. * Defines the number of iterations for the loop
  35521. */
  35522. iterations: number;
  35523. /**
  35524. * Defines the current index of the loop.
  35525. */
  35526. index: number;
  35527. private _done;
  35528. private _fn;
  35529. private _successCallback;
  35530. /**
  35531. * Constructor.
  35532. * @param iterations the number of iterations.
  35533. * @param func the function to run each iteration
  35534. * @param successCallback the callback that will be called upon succesful execution
  35535. * @param offset starting offset.
  35536. */
  35537. constructor(
  35538. /**
  35539. * Defines the number of iterations for the loop
  35540. */
  35541. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35542. /**
  35543. * Execute the next iteration. Must be called after the last iteration was finished.
  35544. */
  35545. executeNext(): void;
  35546. /**
  35547. * Break the loop and run the success callback.
  35548. */
  35549. breakLoop(): void;
  35550. /**
  35551. * Create and run an async loop.
  35552. * @param iterations the number of iterations.
  35553. * @param fn the function to run each iteration
  35554. * @param successCallback the callback that will be called upon succesful execution
  35555. * @param offset starting offset.
  35556. * @returns the created async loop object
  35557. */
  35558. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35559. /**
  35560. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35561. * @param iterations total number of iterations
  35562. * @param syncedIterations number of synchronous iterations in each async iteration.
  35563. * @param fn the function to call each iteration.
  35564. * @param callback a success call back that will be called when iterating stops.
  35565. * @param breakFunction a break condition (optional)
  35566. * @param timeout timeout settings for the setTimeout function. default - 0.
  35567. * @returns the created async loop object
  35568. */
  35569. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35570. }
  35571. }
  35572. declare module "babylonjs/Misc/stringDictionary" {
  35573. import { Nullable } from "babylonjs/types";
  35574. /**
  35575. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35576. * The underlying implementation relies on an associative array to ensure the best performances.
  35577. * The value can be anything including 'null' but except 'undefined'
  35578. */
  35579. export class StringDictionary<T> {
  35580. /**
  35581. * This will clear this dictionary and copy the content from the 'source' one.
  35582. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35583. * @param source the dictionary to take the content from and copy to this dictionary
  35584. */
  35585. copyFrom(source: StringDictionary<T>): void;
  35586. /**
  35587. * Get a value based from its key
  35588. * @param key the given key to get the matching value from
  35589. * @return the value if found, otherwise undefined is returned
  35590. */
  35591. get(key: string): T | undefined;
  35592. /**
  35593. * Get a value from its key or add it if it doesn't exist.
  35594. * This method will ensure you that a given key/data will be present in the dictionary.
  35595. * @param key the given key to get the matching value from
  35596. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35597. * The factory will only be invoked if there's no data for the given key.
  35598. * @return the value corresponding to the key.
  35599. */
  35600. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35601. /**
  35602. * Get a value from its key if present in the dictionary otherwise add it
  35603. * @param key the key to get the value from
  35604. * @param val if there's no such key/value pair in the dictionary add it with this value
  35605. * @return the value corresponding to the key
  35606. */
  35607. getOrAdd(key: string, val: T): T;
  35608. /**
  35609. * Check if there's a given key in the dictionary
  35610. * @param key the key to check for
  35611. * @return true if the key is present, false otherwise
  35612. */
  35613. contains(key: string): boolean;
  35614. /**
  35615. * Add a new key and its corresponding value
  35616. * @param key the key to add
  35617. * @param value the value corresponding to the key
  35618. * @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
  35619. */
  35620. add(key: string, value: T): boolean;
  35621. /**
  35622. * Update a specific value associated to a key
  35623. * @param key defines the key to use
  35624. * @param value defines the value to store
  35625. * @returns true if the value was updated (or false if the key was not found)
  35626. */
  35627. set(key: string, value: T): boolean;
  35628. /**
  35629. * Get the element of the given key and remove it from the dictionary
  35630. * @param key defines the key to search
  35631. * @returns the value associated with the key or null if not found
  35632. */
  35633. getAndRemove(key: string): Nullable<T>;
  35634. /**
  35635. * Remove a key/value from the dictionary.
  35636. * @param key the key to remove
  35637. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35638. */
  35639. remove(key: string): boolean;
  35640. /**
  35641. * Clear the whole content of the dictionary
  35642. */
  35643. clear(): void;
  35644. /**
  35645. * Gets the current count
  35646. */
  35647. get count(): number;
  35648. /**
  35649. * Execute a callback on each key/val of the dictionary.
  35650. * Note that you can remove any element in this dictionary in the callback implementation
  35651. * @param callback the callback to execute on a given key/value pair
  35652. */
  35653. forEach(callback: (key: string, val: T) => void): void;
  35654. /**
  35655. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35656. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35657. * Note that you can remove any element in this dictionary in the callback implementation
  35658. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35659. * @returns the first item
  35660. */
  35661. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35662. private _count;
  35663. private _data;
  35664. }
  35665. }
  35666. declare module "babylonjs/Collisions/collisionCoordinator" {
  35667. import { Nullable } from "babylonjs/types";
  35668. import { Scene } from "babylonjs/scene";
  35669. import { Vector3 } from "babylonjs/Maths/math.vector";
  35670. import { Collider } from "babylonjs/Collisions/collider";
  35671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35672. /** @hidden */
  35673. export interface ICollisionCoordinator {
  35674. createCollider(): Collider;
  35675. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35676. init(scene: Scene): void;
  35677. }
  35678. /** @hidden */
  35679. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35680. private _scene;
  35681. private _scaledPosition;
  35682. private _scaledVelocity;
  35683. private _finalPosition;
  35684. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35685. createCollider(): Collider;
  35686. init(scene: Scene): void;
  35687. private _collideWithWorld;
  35688. }
  35689. }
  35690. declare module "babylonjs/Inputs/scene.inputManager" {
  35691. import { Nullable } from "babylonjs/types";
  35692. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35693. import { Vector2 } from "babylonjs/Maths/math.vector";
  35694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35695. import { Scene } from "babylonjs/scene";
  35696. /**
  35697. * Class used to manage all inputs for the scene.
  35698. */
  35699. export class InputManager {
  35700. /** The distance in pixel that you have to move to prevent some events */
  35701. static DragMovementThreshold: number;
  35702. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35703. static LongPressDelay: number;
  35704. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35705. static DoubleClickDelay: number;
  35706. /** If you need to check double click without raising a single click at first click, enable this flag */
  35707. static ExclusiveDoubleClickMode: boolean;
  35708. private _wheelEventName;
  35709. private _onPointerMove;
  35710. private _onPointerDown;
  35711. private _onPointerUp;
  35712. private _initClickEvent;
  35713. private _initActionManager;
  35714. private _delayedSimpleClick;
  35715. private _delayedSimpleClickTimeout;
  35716. private _previousDelayedSimpleClickTimeout;
  35717. private _meshPickProceed;
  35718. private _previousButtonPressed;
  35719. private _currentPickResult;
  35720. private _previousPickResult;
  35721. private _totalPointersPressed;
  35722. private _doubleClickOccured;
  35723. private _pointerOverMesh;
  35724. private _pickedDownMesh;
  35725. private _pickedUpMesh;
  35726. private _pointerX;
  35727. private _pointerY;
  35728. private _unTranslatedPointerX;
  35729. private _unTranslatedPointerY;
  35730. private _startingPointerPosition;
  35731. private _previousStartingPointerPosition;
  35732. private _startingPointerTime;
  35733. private _previousStartingPointerTime;
  35734. private _pointerCaptures;
  35735. private _onKeyDown;
  35736. private _onKeyUp;
  35737. private _onCanvasFocusObserver;
  35738. private _onCanvasBlurObserver;
  35739. private _scene;
  35740. /**
  35741. * Creates a new InputManager
  35742. * @param scene defines the hosting scene
  35743. */
  35744. constructor(scene: Scene);
  35745. /**
  35746. * Gets the mesh that is currently under the pointer
  35747. */
  35748. get meshUnderPointer(): Nullable<AbstractMesh>;
  35749. /**
  35750. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35751. */
  35752. get unTranslatedPointer(): Vector2;
  35753. /**
  35754. * Gets or sets the current on-screen X position of the pointer
  35755. */
  35756. get pointerX(): number;
  35757. set pointerX(value: number);
  35758. /**
  35759. * Gets or sets the current on-screen Y position of the pointer
  35760. */
  35761. get pointerY(): number;
  35762. set pointerY(value: number);
  35763. private _updatePointerPosition;
  35764. private _processPointerMove;
  35765. private _setRayOnPointerInfo;
  35766. private _checkPrePointerObservable;
  35767. /**
  35768. * Use this method to simulate a pointer move on a mesh
  35769. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35770. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35771. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35772. */
  35773. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35774. /**
  35775. * Use this method to simulate a pointer down on a mesh
  35776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35779. */
  35780. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35781. private _processPointerDown;
  35782. /** @hidden */
  35783. _isPointerSwiping(): boolean;
  35784. /**
  35785. * Use this method to simulate a pointer up on a mesh
  35786. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35787. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35788. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35789. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35790. */
  35791. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35792. private _processPointerUp;
  35793. /**
  35794. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35795. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35796. * @returns true if the pointer was captured
  35797. */
  35798. isPointerCaptured(pointerId?: number): boolean;
  35799. /**
  35800. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35801. * @param attachUp defines if you want to attach events to pointerup
  35802. * @param attachDown defines if you want to attach events to pointerdown
  35803. * @param attachMove defines if you want to attach events to pointermove
  35804. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35805. */
  35806. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35807. /**
  35808. * Detaches all event handlers
  35809. */
  35810. detachControl(): void;
  35811. /**
  35812. * Force the value of meshUnderPointer
  35813. * @param mesh defines the mesh to use
  35814. */
  35815. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35816. /**
  35817. * Gets the mesh under the pointer
  35818. * @returns a Mesh or null if no mesh is under the pointer
  35819. */
  35820. getPointerOverMesh(): Nullable<AbstractMesh>;
  35821. }
  35822. }
  35823. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35824. /**
  35825. * Helper class used to generate session unique ID
  35826. */
  35827. export class UniqueIdGenerator {
  35828. private static _UniqueIdCounter;
  35829. /**
  35830. * Gets an unique (relatively to the current scene) Id
  35831. */
  35832. static get UniqueId(): number;
  35833. }
  35834. }
  35835. declare module "babylonjs/Animations/animationGroup" {
  35836. import { Animatable } from "babylonjs/Animations/animatable";
  35837. import { Animation } from "babylonjs/Animations/animation";
  35838. import { Scene, IDisposable } from "babylonjs/scene";
  35839. import { Observable } from "babylonjs/Misc/observable";
  35840. import { Nullable } from "babylonjs/types";
  35841. import "babylonjs/Animations/animatable";
  35842. /**
  35843. * This class defines the direct association between an animation and a target
  35844. */
  35845. export class TargetedAnimation {
  35846. /**
  35847. * Animation to perform
  35848. */
  35849. animation: Animation;
  35850. /**
  35851. * Target to animate
  35852. */
  35853. target: any;
  35854. /**
  35855. * Serialize the object
  35856. * @returns the JSON object representing the current entity
  35857. */
  35858. serialize(): any;
  35859. }
  35860. /**
  35861. * Use this class to create coordinated animations on multiple targets
  35862. */
  35863. export class AnimationGroup implements IDisposable {
  35864. /** The name of the animation group */
  35865. name: string;
  35866. private _scene;
  35867. private _targetedAnimations;
  35868. private _animatables;
  35869. private _from;
  35870. private _to;
  35871. private _isStarted;
  35872. private _isPaused;
  35873. private _speedRatio;
  35874. private _loopAnimation;
  35875. /**
  35876. * Gets or sets the unique id of the node
  35877. */
  35878. uniqueId: number;
  35879. /**
  35880. * This observable will notify when one animation have ended
  35881. */
  35882. onAnimationEndObservable: Observable<TargetedAnimation>;
  35883. /**
  35884. * Observer raised when one animation loops
  35885. */
  35886. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35887. /**
  35888. * Observer raised when all animations have looped
  35889. */
  35890. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35891. /**
  35892. * This observable will notify when all animations have ended.
  35893. */
  35894. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35895. /**
  35896. * This observable will notify when all animations have paused.
  35897. */
  35898. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35899. /**
  35900. * This observable will notify when all animations are playing.
  35901. */
  35902. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35903. /**
  35904. * Gets the first frame
  35905. */
  35906. get from(): number;
  35907. /**
  35908. * Gets the last frame
  35909. */
  35910. get to(): number;
  35911. /**
  35912. * Define if the animations are started
  35913. */
  35914. get isStarted(): boolean;
  35915. /**
  35916. * Gets a value indicating that the current group is playing
  35917. */
  35918. get isPlaying(): boolean;
  35919. /**
  35920. * Gets or sets the speed ratio to use for all animations
  35921. */
  35922. get speedRatio(): number;
  35923. /**
  35924. * Gets or sets the speed ratio to use for all animations
  35925. */
  35926. set speedRatio(value: number);
  35927. /**
  35928. * Gets or sets if all animations should loop or not
  35929. */
  35930. get loopAnimation(): boolean;
  35931. set loopAnimation(value: boolean);
  35932. /**
  35933. * Gets the targeted animations for this animation group
  35934. */
  35935. get targetedAnimations(): Array<TargetedAnimation>;
  35936. /**
  35937. * returning the list of animatables controlled by this animation group.
  35938. */
  35939. get animatables(): Array<Animatable>;
  35940. /**
  35941. * Instantiates a new Animation Group.
  35942. * This helps managing several animations at once.
  35943. * @see http://doc.babylonjs.com/how_to/group
  35944. * @param name Defines the name of the group
  35945. * @param scene Defines the scene the group belongs to
  35946. */
  35947. constructor(
  35948. /** The name of the animation group */
  35949. name: string, scene?: Nullable<Scene>);
  35950. /**
  35951. * Add an animation (with its target) in the group
  35952. * @param animation defines the animation we want to add
  35953. * @param target defines the target of the animation
  35954. * @returns the TargetedAnimation object
  35955. */
  35956. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35957. /**
  35958. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35959. * It can add constant keys at begin or end
  35960. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35961. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35962. * @returns the animation group
  35963. */
  35964. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35965. private _animationLoopCount;
  35966. private _animationLoopFlags;
  35967. private _processLoop;
  35968. /**
  35969. * Start all animations on given targets
  35970. * @param loop defines if animations must loop
  35971. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35972. * @param from defines the from key (optional)
  35973. * @param to defines the to key (optional)
  35974. * @returns the current animation group
  35975. */
  35976. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35977. /**
  35978. * Pause all animations
  35979. * @returns the animation group
  35980. */
  35981. pause(): AnimationGroup;
  35982. /**
  35983. * Play all animations to initial state
  35984. * This function will start() the animations if they were not started or will restart() them if they were paused
  35985. * @param loop defines if animations must loop
  35986. * @returns the animation group
  35987. */
  35988. play(loop?: boolean): AnimationGroup;
  35989. /**
  35990. * Reset all animations to initial state
  35991. * @returns the animation group
  35992. */
  35993. reset(): AnimationGroup;
  35994. /**
  35995. * Restart animations from key 0
  35996. * @returns the animation group
  35997. */
  35998. restart(): AnimationGroup;
  35999. /**
  36000. * Stop all animations
  36001. * @returns the animation group
  36002. */
  36003. stop(): AnimationGroup;
  36004. /**
  36005. * Set animation weight for all animatables
  36006. * @param weight defines the weight to use
  36007. * @return the animationGroup
  36008. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36009. */
  36010. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36011. /**
  36012. * Synchronize and normalize all animatables with a source animatable
  36013. * @param root defines the root animatable to synchronize with
  36014. * @return the animationGroup
  36015. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36016. */
  36017. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36018. /**
  36019. * Goes to a specific frame in this animation group
  36020. * @param frame the frame number to go to
  36021. * @return the animationGroup
  36022. */
  36023. goToFrame(frame: number): AnimationGroup;
  36024. /**
  36025. * Dispose all associated resources
  36026. */
  36027. dispose(): void;
  36028. private _checkAnimationGroupEnded;
  36029. /**
  36030. * Clone the current animation group and returns a copy
  36031. * @param newName defines the name of the new group
  36032. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36033. * @returns the new aniamtion group
  36034. */
  36035. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36036. /**
  36037. * Serializes the animationGroup to an object
  36038. * @returns Serialized object
  36039. */
  36040. serialize(): any;
  36041. /**
  36042. * Returns a new AnimationGroup object parsed from the source provided.
  36043. * @param parsedAnimationGroup defines the source
  36044. * @param scene defines the scene that will receive the animationGroup
  36045. * @returns a new AnimationGroup
  36046. */
  36047. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36048. /**
  36049. * Returns the string "AnimationGroup"
  36050. * @returns "AnimationGroup"
  36051. */
  36052. getClassName(): string;
  36053. /**
  36054. * Creates a detailled string about the object
  36055. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36056. * @returns a string representing the object
  36057. */
  36058. toString(fullDetails?: boolean): string;
  36059. }
  36060. }
  36061. declare module "babylonjs/scene" {
  36062. import { Nullable } from "babylonjs/types";
  36063. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36064. import { Observable } from "babylonjs/Misc/observable";
  36065. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36066. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36067. import { Geometry } from "babylonjs/Meshes/geometry";
  36068. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36071. import { Mesh } from "babylonjs/Meshes/mesh";
  36072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36073. import { Bone } from "babylonjs/Bones/bone";
  36074. import { Skeleton } from "babylonjs/Bones/skeleton";
  36075. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36076. import { Camera } from "babylonjs/Cameras/camera";
  36077. import { AbstractScene } from "babylonjs/abstractScene";
  36078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36080. import { Material } from "babylonjs/Materials/material";
  36081. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36082. import { Effect } from "babylonjs/Materials/effect";
  36083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36084. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36085. import { Light } from "babylonjs/Lights/light";
  36086. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36087. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36088. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36089. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36090. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36091. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36092. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36093. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36094. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36095. import { Engine } from "babylonjs/Engines/engine";
  36096. import { Node } from "babylonjs/node";
  36097. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36098. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36099. import { WebRequest } from "babylonjs/Misc/webRequest";
  36100. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36101. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36102. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36103. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36104. import { Plane } from "babylonjs/Maths/math.plane";
  36105. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36106. import { Ray } from "babylonjs/Culling/ray";
  36107. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36108. import { Animation } from "babylonjs/Animations/animation";
  36109. import { Animatable } from "babylonjs/Animations/animatable";
  36110. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36111. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36112. import { Collider } from "babylonjs/Collisions/collider";
  36113. /**
  36114. * Define an interface for all classes that will hold resources
  36115. */
  36116. export interface IDisposable {
  36117. /**
  36118. * Releases all held resources
  36119. */
  36120. dispose(): void;
  36121. }
  36122. /** Interface defining initialization parameters for Scene class */
  36123. export interface SceneOptions {
  36124. /**
  36125. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36126. * It will improve performance when the number of geometries becomes important.
  36127. */
  36128. useGeometryUniqueIdsMap?: boolean;
  36129. /**
  36130. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36131. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36132. */
  36133. useMaterialMeshMap?: boolean;
  36134. /**
  36135. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36136. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36137. */
  36138. useClonedMeshMap?: boolean;
  36139. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36140. virtual?: boolean;
  36141. }
  36142. /**
  36143. * Represents a scene to be rendered by the engine.
  36144. * @see http://doc.babylonjs.com/features/scene
  36145. */
  36146. export class Scene extends AbstractScene implements IAnimatable {
  36147. /** The fog is deactivated */
  36148. static readonly FOGMODE_NONE: number;
  36149. /** The fog density is following an exponential function */
  36150. static readonly FOGMODE_EXP: number;
  36151. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36152. static readonly FOGMODE_EXP2: number;
  36153. /** The fog density is following a linear function. */
  36154. static readonly FOGMODE_LINEAR: number;
  36155. /**
  36156. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36157. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36158. */
  36159. static MinDeltaTime: number;
  36160. /**
  36161. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36163. */
  36164. static MaxDeltaTime: number;
  36165. /**
  36166. * Factory used to create the default material.
  36167. * @param name The name of the material to create
  36168. * @param scene The scene to create the material for
  36169. * @returns The default material
  36170. */
  36171. static DefaultMaterialFactory(scene: Scene): Material;
  36172. /**
  36173. * Factory used to create the a collision coordinator.
  36174. * @returns The collision coordinator
  36175. */
  36176. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36177. /** @hidden */
  36178. _inputManager: InputManager;
  36179. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36180. cameraToUseForPointers: Nullable<Camera>;
  36181. /** @hidden */
  36182. readonly _isScene: boolean;
  36183. /**
  36184. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36185. */
  36186. autoClear: boolean;
  36187. /**
  36188. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36189. */
  36190. autoClearDepthAndStencil: boolean;
  36191. /**
  36192. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36193. */
  36194. clearColor: Color4;
  36195. /**
  36196. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36197. */
  36198. ambientColor: Color3;
  36199. /**
  36200. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36201. * It should only be one of the following (if not the default embedded one):
  36202. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36203. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36204. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36205. * The material properties need to be setup according to the type of texture in use.
  36206. */
  36207. environmentBRDFTexture: BaseTexture;
  36208. /** @hidden */
  36209. protected _environmentTexture: Nullable<BaseTexture>;
  36210. /**
  36211. * Texture used in all pbr material as the reflection texture.
  36212. * As in the majority of the scene they are the same (exception for multi room and so on),
  36213. * this is easier to reference from here than from all the materials.
  36214. */
  36215. get environmentTexture(): Nullable<BaseTexture>;
  36216. /**
  36217. * Texture used in all pbr material as the reflection texture.
  36218. * As in the majority of the scene they are the same (exception for multi room and so on),
  36219. * this is easier to set here than in all the materials.
  36220. */
  36221. set environmentTexture(value: Nullable<BaseTexture>);
  36222. /** @hidden */
  36223. protected _environmentIntensity: number;
  36224. /**
  36225. * Intensity of the environment in all pbr material.
  36226. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36227. * As in the majority of the scene they are the same (exception for multi room and so on),
  36228. * this is easier to reference from here than from all the materials.
  36229. */
  36230. get environmentIntensity(): number;
  36231. /**
  36232. * Intensity of the environment in all pbr material.
  36233. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36234. * As in the majority of the scene they are the same (exception for multi room and so on),
  36235. * this is easier to set here than in all the materials.
  36236. */
  36237. set environmentIntensity(value: number);
  36238. /** @hidden */
  36239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36240. /**
  36241. * Default image processing configuration used either in the rendering
  36242. * Forward main pass or through the imageProcessingPostProcess if present.
  36243. * As in the majority of the scene they are the same (exception for multi camera),
  36244. * this is easier to reference from here than from all the materials and post process.
  36245. *
  36246. * No setter as we it is a shared configuration, you can set the values instead.
  36247. */
  36248. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36249. private _forceWireframe;
  36250. /**
  36251. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36252. */
  36253. set forceWireframe(value: boolean);
  36254. get forceWireframe(): boolean;
  36255. private _skipFrustumClipping;
  36256. /**
  36257. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36258. */
  36259. set skipFrustumClipping(value: boolean);
  36260. get skipFrustumClipping(): boolean;
  36261. private _forcePointsCloud;
  36262. /**
  36263. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36264. */
  36265. set forcePointsCloud(value: boolean);
  36266. get forcePointsCloud(): boolean;
  36267. /**
  36268. * Gets or sets the active clipplane 1
  36269. */
  36270. clipPlane: Nullable<Plane>;
  36271. /**
  36272. * Gets or sets the active clipplane 2
  36273. */
  36274. clipPlane2: Nullable<Plane>;
  36275. /**
  36276. * Gets or sets the active clipplane 3
  36277. */
  36278. clipPlane3: Nullable<Plane>;
  36279. /**
  36280. * Gets or sets the active clipplane 4
  36281. */
  36282. clipPlane4: Nullable<Plane>;
  36283. /**
  36284. * Gets or sets the active clipplane 5
  36285. */
  36286. clipPlane5: Nullable<Plane>;
  36287. /**
  36288. * Gets or sets the active clipplane 6
  36289. */
  36290. clipPlane6: Nullable<Plane>;
  36291. /**
  36292. * Gets or sets a boolean indicating if animations are enabled
  36293. */
  36294. animationsEnabled: boolean;
  36295. private _animationPropertiesOverride;
  36296. /**
  36297. * Gets or sets the animation properties override
  36298. */
  36299. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36300. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36301. /**
  36302. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36303. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36304. */
  36305. useConstantAnimationDeltaTime: boolean;
  36306. /**
  36307. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36308. * Please note that it requires to run a ray cast through the scene on every frame
  36309. */
  36310. constantlyUpdateMeshUnderPointer: boolean;
  36311. /**
  36312. * Defines the HTML cursor to use when hovering over interactive elements
  36313. */
  36314. hoverCursor: string;
  36315. /**
  36316. * Defines the HTML default cursor to use (empty by default)
  36317. */
  36318. defaultCursor: string;
  36319. /**
  36320. * Defines whether cursors are handled by the scene.
  36321. */
  36322. doNotHandleCursors: boolean;
  36323. /**
  36324. * This is used to call preventDefault() on pointer down
  36325. * in order to block unwanted artifacts like system double clicks
  36326. */
  36327. preventDefaultOnPointerDown: boolean;
  36328. /**
  36329. * This is used to call preventDefault() on pointer up
  36330. * in order to block unwanted artifacts like system double clicks
  36331. */
  36332. preventDefaultOnPointerUp: boolean;
  36333. /**
  36334. * Gets or sets user defined metadata
  36335. */
  36336. metadata: any;
  36337. /**
  36338. * For internal use only. Please do not use.
  36339. */
  36340. reservedDataStore: any;
  36341. /**
  36342. * Gets the name of the plugin used to load this scene (null by default)
  36343. */
  36344. loadingPluginName: string;
  36345. /**
  36346. * Use this array to add regular expressions used to disable offline support for specific urls
  36347. */
  36348. disableOfflineSupportExceptionRules: RegExp[];
  36349. /**
  36350. * An event triggered when the scene is disposed.
  36351. */
  36352. onDisposeObservable: Observable<Scene>;
  36353. private _onDisposeObserver;
  36354. /** Sets a function to be executed when this scene is disposed. */
  36355. set onDispose(callback: () => void);
  36356. /**
  36357. * An event triggered before rendering the scene (right after animations and physics)
  36358. */
  36359. onBeforeRenderObservable: Observable<Scene>;
  36360. private _onBeforeRenderObserver;
  36361. /** Sets a function to be executed before rendering this scene */
  36362. set beforeRender(callback: Nullable<() => void>);
  36363. /**
  36364. * An event triggered after rendering the scene
  36365. */
  36366. onAfterRenderObservable: Observable<Scene>;
  36367. /**
  36368. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36369. */
  36370. onAfterRenderCameraObservable: Observable<Camera>;
  36371. private _onAfterRenderObserver;
  36372. /** Sets a function to be executed after rendering this scene */
  36373. set afterRender(callback: Nullable<() => void>);
  36374. /**
  36375. * An event triggered before animating the scene
  36376. */
  36377. onBeforeAnimationsObservable: Observable<Scene>;
  36378. /**
  36379. * An event triggered after animations processing
  36380. */
  36381. onAfterAnimationsObservable: Observable<Scene>;
  36382. /**
  36383. * An event triggered before draw calls are ready to be sent
  36384. */
  36385. onBeforeDrawPhaseObservable: Observable<Scene>;
  36386. /**
  36387. * An event triggered after draw calls have been sent
  36388. */
  36389. onAfterDrawPhaseObservable: Observable<Scene>;
  36390. /**
  36391. * An event triggered when the scene is ready
  36392. */
  36393. onReadyObservable: Observable<Scene>;
  36394. /**
  36395. * An event triggered before rendering a camera
  36396. */
  36397. onBeforeCameraRenderObservable: Observable<Camera>;
  36398. private _onBeforeCameraRenderObserver;
  36399. /** Sets a function to be executed before rendering a camera*/
  36400. set beforeCameraRender(callback: () => void);
  36401. /**
  36402. * An event triggered after rendering a camera
  36403. */
  36404. onAfterCameraRenderObservable: Observable<Camera>;
  36405. private _onAfterCameraRenderObserver;
  36406. /** Sets a function to be executed after rendering a camera*/
  36407. set afterCameraRender(callback: () => void);
  36408. /**
  36409. * An event triggered when active meshes evaluation is about to start
  36410. */
  36411. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36412. /**
  36413. * An event triggered when active meshes evaluation is done
  36414. */
  36415. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36416. /**
  36417. * An event triggered when particles rendering is about to start
  36418. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36419. */
  36420. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36421. /**
  36422. * An event triggered when particles rendering is done
  36423. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36424. */
  36425. onAfterParticlesRenderingObservable: Observable<Scene>;
  36426. /**
  36427. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36428. */
  36429. onDataLoadedObservable: Observable<Scene>;
  36430. /**
  36431. * An event triggered when a camera is created
  36432. */
  36433. onNewCameraAddedObservable: Observable<Camera>;
  36434. /**
  36435. * An event triggered when a camera is removed
  36436. */
  36437. onCameraRemovedObservable: Observable<Camera>;
  36438. /**
  36439. * An event triggered when a light is created
  36440. */
  36441. onNewLightAddedObservable: Observable<Light>;
  36442. /**
  36443. * An event triggered when a light is removed
  36444. */
  36445. onLightRemovedObservable: Observable<Light>;
  36446. /**
  36447. * An event triggered when a geometry is created
  36448. */
  36449. onNewGeometryAddedObservable: Observable<Geometry>;
  36450. /**
  36451. * An event triggered when a geometry is removed
  36452. */
  36453. onGeometryRemovedObservable: Observable<Geometry>;
  36454. /**
  36455. * An event triggered when a transform node is created
  36456. */
  36457. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36458. /**
  36459. * An event triggered when a transform node is removed
  36460. */
  36461. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36462. /**
  36463. * An event triggered when a mesh is created
  36464. */
  36465. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36466. /**
  36467. * An event triggered when a mesh is removed
  36468. */
  36469. onMeshRemovedObservable: Observable<AbstractMesh>;
  36470. /**
  36471. * An event triggered when a skeleton is created
  36472. */
  36473. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36474. /**
  36475. * An event triggered when a skeleton is removed
  36476. */
  36477. onSkeletonRemovedObservable: Observable<Skeleton>;
  36478. /**
  36479. * An event triggered when a material is created
  36480. */
  36481. onNewMaterialAddedObservable: Observable<Material>;
  36482. /**
  36483. * An event triggered when a material is removed
  36484. */
  36485. onMaterialRemovedObservable: Observable<Material>;
  36486. /**
  36487. * An event triggered when a texture is created
  36488. */
  36489. onNewTextureAddedObservable: Observable<BaseTexture>;
  36490. /**
  36491. * An event triggered when a texture is removed
  36492. */
  36493. onTextureRemovedObservable: Observable<BaseTexture>;
  36494. /**
  36495. * An event triggered when render targets are about to be rendered
  36496. * Can happen multiple times per frame.
  36497. */
  36498. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36499. /**
  36500. * An event triggered when render targets were rendered.
  36501. * Can happen multiple times per frame.
  36502. */
  36503. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36504. /**
  36505. * An event triggered before calculating deterministic simulation step
  36506. */
  36507. onBeforeStepObservable: Observable<Scene>;
  36508. /**
  36509. * An event triggered after calculating deterministic simulation step
  36510. */
  36511. onAfterStepObservable: Observable<Scene>;
  36512. /**
  36513. * An event triggered when the activeCamera property is updated
  36514. */
  36515. onActiveCameraChanged: Observable<Scene>;
  36516. /**
  36517. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36518. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36519. * 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)
  36520. */
  36521. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36522. /**
  36523. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36524. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36525. * 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)
  36526. */
  36527. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36528. /**
  36529. * This Observable will when a mesh has been imported into the scene.
  36530. */
  36531. onMeshImportedObservable: Observable<AbstractMesh>;
  36532. /**
  36533. * This Observable will when an animation file has been imported into the scene.
  36534. */
  36535. onAnimationFileImportedObservable: Observable<Scene>;
  36536. /**
  36537. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36538. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36539. */
  36540. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36541. /** @hidden */
  36542. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36543. /**
  36544. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36545. */
  36546. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36547. /**
  36548. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36549. */
  36550. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36551. /**
  36552. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36553. */
  36554. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36555. /** Callback called when a pointer move is detected */
  36556. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36557. /** Callback called when a pointer down is detected */
  36558. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36559. /** Callback called when a pointer up is detected */
  36560. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36561. /** Callback called when a pointer pick is detected */
  36562. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36563. /**
  36564. * 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).
  36565. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36566. */
  36567. onPrePointerObservable: Observable<PointerInfoPre>;
  36568. /**
  36569. * Observable event triggered each time an input event is received from the rendering canvas
  36570. */
  36571. onPointerObservable: Observable<PointerInfo>;
  36572. /**
  36573. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36574. */
  36575. get unTranslatedPointer(): Vector2;
  36576. /**
  36577. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36578. */
  36579. static get DragMovementThreshold(): number;
  36580. static set DragMovementThreshold(value: number);
  36581. /**
  36582. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36583. */
  36584. static get LongPressDelay(): number;
  36585. static set LongPressDelay(value: number);
  36586. /**
  36587. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36588. */
  36589. static get DoubleClickDelay(): number;
  36590. static set DoubleClickDelay(value: number);
  36591. /** If you need to check double click without raising a single click at first click, enable this flag */
  36592. static get ExclusiveDoubleClickMode(): boolean;
  36593. static set ExclusiveDoubleClickMode(value: boolean);
  36594. /** @hidden */
  36595. _mirroredCameraPosition: Nullable<Vector3>;
  36596. /**
  36597. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36598. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36599. */
  36600. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36601. /**
  36602. * Observable event triggered each time an keyboard event is received from the hosting window
  36603. */
  36604. onKeyboardObservable: Observable<KeyboardInfo>;
  36605. private _useRightHandedSystem;
  36606. /**
  36607. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36608. */
  36609. set useRightHandedSystem(value: boolean);
  36610. get useRightHandedSystem(): boolean;
  36611. private _timeAccumulator;
  36612. private _currentStepId;
  36613. private _currentInternalStep;
  36614. /**
  36615. * Sets the step Id used by deterministic lock step
  36616. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36617. * @param newStepId defines the step Id
  36618. */
  36619. setStepId(newStepId: number): void;
  36620. /**
  36621. * Gets the step Id used by deterministic lock step
  36622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36623. * @returns the step Id
  36624. */
  36625. getStepId(): number;
  36626. /**
  36627. * Gets the internal step used by deterministic lock step
  36628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36629. * @returns the internal step
  36630. */
  36631. getInternalStep(): number;
  36632. private _fogEnabled;
  36633. /**
  36634. * Gets or sets a boolean indicating if fog is enabled on this scene
  36635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36636. * (Default is true)
  36637. */
  36638. set fogEnabled(value: boolean);
  36639. get fogEnabled(): boolean;
  36640. private _fogMode;
  36641. /**
  36642. * Gets or sets the fog mode to use
  36643. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36644. * | mode | value |
  36645. * | --- | --- |
  36646. * | FOGMODE_NONE | 0 |
  36647. * | FOGMODE_EXP | 1 |
  36648. * | FOGMODE_EXP2 | 2 |
  36649. * | FOGMODE_LINEAR | 3 |
  36650. */
  36651. set fogMode(value: number);
  36652. get fogMode(): number;
  36653. /**
  36654. * Gets or sets the fog color to use
  36655. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36656. * (Default is Color3(0.2, 0.2, 0.3))
  36657. */
  36658. fogColor: Color3;
  36659. /**
  36660. * Gets or sets the fog density to use
  36661. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36662. * (Default is 0.1)
  36663. */
  36664. fogDensity: number;
  36665. /**
  36666. * Gets or sets the fog start distance to use
  36667. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36668. * (Default is 0)
  36669. */
  36670. fogStart: number;
  36671. /**
  36672. * Gets or sets the fog end distance to use
  36673. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36674. * (Default is 1000)
  36675. */
  36676. fogEnd: number;
  36677. private _shadowsEnabled;
  36678. /**
  36679. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36680. */
  36681. set shadowsEnabled(value: boolean);
  36682. get shadowsEnabled(): boolean;
  36683. private _lightsEnabled;
  36684. /**
  36685. * Gets or sets a boolean indicating if lights are enabled on this scene
  36686. */
  36687. set lightsEnabled(value: boolean);
  36688. get lightsEnabled(): boolean;
  36689. /** All of the active cameras added to this scene. */
  36690. activeCameras: Camera[];
  36691. /** @hidden */
  36692. _activeCamera: Nullable<Camera>;
  36693. /** Gets or sets the current active camera */
  36694. get activeCamera(): Nullable<Camera>;
  36695. set activeCamera(value: Nullable<Camera>);
  36696. private _defaultMaterial;
  36697. /** The default material used on meshes when no material is affected */
  36698. get defaultMaterial(): Material;
  36699. /** The default material used on meshes when no material is affected */
  36700. set defaultMaterial(value: Material);
  36701. private _texturesEnabled;
  36702. /**
  36703. * Gets or sets a boolean indicating if textures are enabled on this scene
  36704. */
  36705. set texturesEnabled(value: boolean);
  36706. get texturesEnabled(): boolean;
  36707. /**
  36708. * Gets or sets a boolean indicating if particles are enabled on this scene
  36709. */
  36710. particlesEnabled: boolean;
  36711. /**
  36712. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36713. */
  36714. spritesEnabled: boolean;
  36715. private _skeletonsEnabled;
  36716. /**
  36717. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36718. */
  36719. set skeletonsEnabled(value: boolean);
  36720. get skeletonsEnabled(): boolean;
  36721. /**
  36722. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36723. */
  36724. lensFlaresEnabled: boolean;
  36725. /**
  36726. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36728. */
  36729. collisionsEnabled: boolean;
  36730. private _collisionCoordinator;
  36731. /** @hidden */
  36732. get collisionCoordinator(): ICollisionCoordinator;
  36733. /**
  36734. * Defines the gravity applied to this scene (used only for collisions)
  36735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36736. */
  36737. gravity: Vector3;
  36738. /**
  36739. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36740. */
  36741. postProcessesEnabled: boolean;
  36742. /**
  36743. * The list of postprocesses added to the scene
  36744. */
  36745. postProcesses: PostProcess[];
  36746. /**
  36747. * Gets the current postprocess manager
  36748. */
  36749. postProcessManager: PostProcessManager;
  36750. /**
  36751. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36752. */
  36753. renderTargetsEnabled: boolean;
  36754. /**
  36755. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36756. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36757. */
  36758. dumpNextRenderTargets: boolean;
  36759. /**
  36760. * The list of user defined render targets added to the scene
  36761. */
  36762. customRenderTargets: RenderTargetTexture[];
  36763. /**
  36764. * Defines if texture loading must be delayed
  36765. * If true, textures will only be loaded when they need to be rendered
  36766. */
  36767. useDelayedTextureLoading: boolean;
  36768. /**
  36769. * Gets the list of meshes imported to the scene through SceneLoader
  36770. */
  36771. importedMeshesFiles: String[];
  36772. /**
  36773. * Gets or sets a boolean indicating if probes are enabled on this scene
  36774. */
  36775. probesEnabled: boolean;
  36776. /**
  36777. * Gets or sets the current offline provider to use to store scene data
  36778. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36779. */
  36780. offlineProvider: IOfflineProvider;
  36781. /**
  36782. * Gets or sets the action manager associated with the scene
  36783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36784. */
  36785. actionManager: AbstractActionManager;
  36786. private _meshesForIntersections;
  36787. /**
  36788. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36789. */
  36790. proceduralTexturesEnabled: boolean;
  36791. private _engine;
  36792. private _totalVertices;
  36793. /** @hidden */
  36794. _activeIndices: PerfCounter;
  36795. /** @hidden */
  36796. _activeParticles: PerfCounter;
  36797. /** @hidden */
  36798. _activeBones: PerfCounter;
  36799. private _animationRatio;
  36800. /** @hidden */
  36801. _animationTimeLast: number;
  36802. /** @hidden */
  36803. _animationTime: number;
  36804. /**
  36805. * Gets or sets a general scale for animation speed
  36806. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36807. */
  36808. animationTimeScale: number;
  36809. /** @hidden */
  36810. _cachedMaterial: Nullable<Material>;
  36811. /** @hidden */
  36812. _cachedEffect: Nullable<Effect>;
  36813. /** @hidden */
  36814. _cachedVisibility: Nullable<number>;
  36815. private _renderId;
  36816. private _frameId;
  36817. private _executeWhenReadyTimeoutId;
  36818. private _intermediateRendering;
  36819. private _viewUpdateFlag;
  36820. private _projectionUpdateFlag;
  36821. /** @hidden */
  36822. _toBeDisposed: Nullable<IDisposable>[];
  36823. private _activeRequests;
  36824. /** @hidden */
  36825. _pendingData: any[];
  36826. private _isDisposed;
  36827. /**
  36828. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36829. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36830. */
  36831. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36832. private _activeMeshes;
  36833. private _processedMaterials;
  36834. private _renderTargets;
  36835. /** @hidden */
  36836. _activeParticleSystems: SmartArray<IParticleSystem>;
  36837. private _activeSkeletons;
  36838. private _softwareSkinnedMeshes;
  36839. private _renderingManager;
  36840. /** @hidden */
  36841. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36842. private _transformMatrix;
  36843. private _sceneUbo;
  36844. /** @hidden */
  36845. _viewMatrix: Matrix;
  36846. private _projectionMatrix;
  36847. /** @hidden */
  36848. _forcedViewPosition: Nullable<Vector3>;
  36849. /** @hidden */
  36850. _frustumPlanes: Plane[];
  36851. /**
  36852. * Gets the list of frustum planes (built from the active camera)
  36853. */
  36854. get frustumPlanes(): Plane[];
  36855. /**
  36856. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36857. * This is useful if there are more lights that the maximum simulteanous authorized
  36858. */
  36859. requireLightSorting: boolean;
  36860. /** @hidden */
  36861. readonly useMaterialMeshMap: boolean;
  36862. /** @hidden */
  36863. readonly useClonedMeshMap: boolean;
  36864. private _externalData;
  36865. private _uid;
  36866. /**
  36867. * @hidden
  36868. * Backing store of defined scene components.
  36869. */
  36870. _components: ISceneComponent[];
  36871. /**
  36872. * @hidden
  36873. * Backing store of defined scene components.
  36874. */
  36875. _serializableComponents: ISceneSerializableComponent[];
  36876. /**
  36877. * List of components to register on the next registration step.
  36878. */
  36879. private _transientComponents;
  36880. /**
  36881. * Registers the transient components if needed.
  36882. */
  36883. private _registerTransientComponents;
  36884. /**
  36885. * @hidden
  36886. * Add a component to the scene.
  36887. * Note that the ccomponent could be registered on th next frame if this is called after
  36888. * the register component stage.
  36889. * @param component Defines the component to add to the scene
  36890. */
  36891. _addComponent(component: ISceneComponent): void;
  36892. /**
  36893. * @hidden
  36894. * Gets a component from the scene.
  36895. * @param name defines the name of the component to retrieve
  36896. * @returns the component or null if not present
  36897. */
  36898. _getComponent(name: string): Nullable<ISceneComponent>;
  36899. /**
  36900. * @hidden
  36901. * Defines the actions happening before camera updates.
  36902. */
  36903. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36904. /**
  36905. * @hidden
  36906. * Defines the actions happening before clear the canvas.
  36907. */
  36908. _beforeClearStage: Stage<SimpleStageAction>;
  36909. /**
  36910. * @hidden
  36911. * Defines the actions when collecting render targets for the frame.
  36912. */
  36913. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36914. /**
  36915. * @hidden
  36916. * Defines the actions happening for one camera in the frame.
  36917. */
  36918. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36919. /**
  36920. * @hidden
  36921. * Defines the actions happening during the per mesh ready checks.
  36922. */
  36923. _isReadyForMeshStage: Stage<MeshStageAction>;
  36924. /**
  36925. * @hidden
  36926. * Defines the actions happening before evaluate active mesh checks.
  36927. */
  36928. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36929. /**
  36930. * @hidden
  36931. * Defines the actions happening during the evaluate sub mesh checks.
  36932. */
  36933. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36934. /**
  36935. * @hidden
  36936. * Defines the actions happening during the active mesh stage.
  36937. */
  36938. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36939. /**
  36940. * @hidden
  36941. * Defines the actions happening during the per camera render target step.
  36942. */
  36943. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36944. /**
  36945. * @hidden
  36946. * Defines the actions happening just before the active camera is drawing.
  36947. */
  36948. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36949. /**
  36950. * @hidden
  36951. * Defines the actions happening just before a render target is drawing.
  36952. */
  36953. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36954. /**
  36955. * @hidden
  36956. * Defines the actions happening just before a rendering group is drawing.
  36957. */
  36958. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36959. /**
  36960. * @hidden
  36961. * Defines the actions happening just before a mesh is drawing.
  36962. */
  36963. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36964. /**
  36965. * @hidden
  36966. * Defines the actions happening just after a mesh has been drawn.
  36967. */
  36968. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36969. /**
  36970. * @hidden
  36971. * Defines the actions happening just after a rendering group has been drawn.
  36972. */
  36973. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36974. /**
  36975. * @hidden
  36976. * Defines the actions happening just after the active camera has been drawn.
  36977. */
  36978. _afterCameraDrawStage: Stage<CameraStageAction>;
  36979. /**
  36980. * @hidden
  36981. * Defines the actions happening just after a render target has been drawn.
  36982. */
  36983. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36984. /**
  36985. * @hidden
  36986. * Defines the actions happening just after rendering all cameras and computing intersections.
  36987. */
  36988. _afterRenderStage: Stage<SimpleStageAction>;
  36989. /**
  36990. * @hidden
  36991. * Defines the actions happening when a pointer move event happens.
  36992. */
  36993. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36994. /**
  36995. * @hidden
  36996. * Defines the actions happening when a pointer down event happens.
  36997. */
  36998. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36999. /**
  37000. * @hidden
  37001. * Defines the actions happening when a pointer up event happens.
  37002. */
  37003. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37004. /**
  37005. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37006. */
  37007. private geometriesByUniqueId;
  37008. /**
  37009. * Creates a new Scene
  37010. * @param engine defines the engine to use to render this scene
  37011. * @param options defines the scene options
  37012. */
  37013. constructor(engine: Engine, options?: SceneOptions);
  37014. /**
  37015. * Gets a string idenfifying the name of the class
  37016. * @returns "Scene" string
  37017. */
  37018. getClassName(): string;
  37019. private _defaultMeshCandidates;
  37020. /**
  37021. * @hidden
  37022. */
  37023. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37024. private _defaultSubMeshCandidates;
  37025. /**
  37026. * @hidden
  37027. */
  37028. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37029. /**
  37030. * Sets the default candidate providers for the scene.
  37031. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37032. * and getCollidingSubMeshCandidates to their default function
  37033. */
  37034. setDefaultCandidateProviders(): void;
  37035. /**
  37036. * Gets the mesh that is currently under the pointer
  37037. */
  37038. get meshUnderPointer(): Nullable<AbstractMesh>;
  37039. /**
  37040. * Gets or sets the current on-screen X position of the pointer
  37041. */
  37042. get pointerX(): number;
  37043. set pointerX(value: number);
  37044. /**
  37045. * Gets or sets the current on-screen Y position of the pointer
  37046. */
  37047. get pointerY(): number;
  37048. set pointerY(value: number);
  37049. /**
  37050. * Gets the cached material (ie. the latest rendered one)
  37051. * @returns the cached material
  37052. */
  37053. getCachedMaterial(): Nullable<Material>;
  37054. /**
  37055. * Gets the cached effect (ie. the latest rendered one)
  37056. * @returns the cached effect
  37057. */
  37058. getCachedEffect(): Nullable<Effect>;
  37059. /**
  37060. * Gets the cached visibility state (ie. the latest rendered one)
  37061. * @returns the cached visibility state
  37062. */
  37063. getCachedVisibility(): Nullable<number>;
  37064. /**
  37065. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37066. * @param material defines the current material
  37067. * @param effect defines the current effect
  37068. * @param visibility defines the current visibility state
  37069. * @returns true if one parameter is not cached
  37070. */
  37071. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37072. /**
  37073. * Gets the engine associated with the scene
  37074. * @returns an Engine
  37075. */
  37076. getEngine(): Engine;
  37077. /**
  37078. * Gets the total number of vertices rendered per frame
  37079. * @returns the total number of vertices rendered per frame
  37080. */
  37081. getTotalVertices(): number;
  37082. /**
  37083. * Gets the performance counter for total vertices
  37084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37085. */
  37086. get totalVerticesPerfCounter(): PerfCounter;
  37087. /**
  37088. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37089. * @returns the total number of active indices rendered per frame
  37090. */
  37091. getActiveIndices(): number;
  37092. /**
  37093. * Gets the performance counter for active indices
  37094. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37095. */
  37096. get totalActiveIndicesPerfCounter(): PerfCounter;
  37097. /**
  37098. * Gets the total number of active particles rendered per frame
  37099. * @returns the total number of active particles rendered per frame
  37100. */
  37101. getActiveParticles(): number;
  37102. /**
  37103. * Gets the performance counter for active particles
  37104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37105. */
  37106. get activeParticlesPerfCounter(): PerfCounter;
  37107. /**
  37108. * Gets the total number of active bones rendered per frame
  37109. * @returns the total number of active bones rendered per frame
  37110. */
  37111. getActiveBones(): number;
  37112. /**
  37113. * Gets the performance counter for active bones
  37114. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37115. */
  37116. get activeBonesPerfCounter(): PerfCounter;
  37117. /**
  37118. * Gets the array of active meshes
  37119. * @returns an array of AbstractMesh
  37120. */
  37121. getActiveMeshes(): SmartArray<AbstractMesh>;
  37122. /**
  37123. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37124. * @returns a number
  37125. */
  37126. getAnimationRatio(): number;
  37127. /**
  37128. * Gets an unique Id for the current render phase
  37129. * @returns a number
  37130. */
  37131. getRenderId(): number;
  37132. /**
  37133. * Gets an unique Id for the current frame
  37134. * @returns a number
  37135. */
  37136. getFrameId(): number;
  37137. /** Call this function if you want to manually increment the render Id*/
  37138. incrementRenderId(): void;
  37139. private _createUbo;
  37140. /**
  37141. * Use this method to simulate a pointer move on a mesh
  37142. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37143. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37144. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37145. * @returns the current scene
  37146. */
  37147. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37148. /**
  37149. * Use this method to simulate a pointer down on a mesh
  37150. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37151. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37152. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37153. * @returns the current scene
  37154. */
  37155. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37156. /**
  37157. * Use this method to simulate a pointer up on a mesh
  37158. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37159. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37160. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37161. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37162. * @returns the current scene
  37163. */
  37164. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37165. /**
  37166. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37167. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37168. * @returns true if the pointer was captured
  37169. */
  37170. isPointerCaptured(pointerId?: number): boolean;
  37171. /**
  37172. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37173. * @param attachUp defines if you want to attach events to pointerup
  37174. * @param attachDown defines if you want to attach events to pointerdown
  37175. * @param attachMove defines if you want to attach events to pointermove
  37176. */
  37177. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37178. /** Detaches all event handlers*/
  37179. detachControl(): void;
  37180. /**
  37181. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37182. * Delay loaded resources are not taking in account
  37183. * @return true if all required resources are ready
  37184. */
  37185. isReady(): boolean;
  37186. /** Resets all cached information relative to material (including effect and visibility) */
  37187. resetCachedMaterial(): void;
  37188. /**
  37189. * Registers a function to be called before every frame render
  37190. * @param func defines the function to register
  37191. */
  37192. registerBeforeRender(func: () => void): void;
  37193. /**
  37194. * Unregisters a function called before every frame render
  37195. * @param func defines the function to unregister
  37196. */
  37197. unregisterBeforeRender(func: () => void): void;
  37198. /**
  37199. * Registers a function to be called after every frame render
  37200. * @param func defines the function to register
  37201. */
  37202. registerAfterRender(func: () => void): void;
  37203. /**
  37204. * Unregisters a function called after every frame render
  37205. * @param func defines the function to unregister
  37206. */
  37207. unregisterAfterRender(func: () => void): void;
  37208. private _executeOnceBeforeRender;
  37209. /**
  37210. * The provided function will run before render once and will be disposed afterwards.
  37211. * A timeout delay can be provided so that the function will be executed in N ms.
  37212. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37213. * @param func The function to be executed.
  37214. * @param timeout optional delay in ms
  37215. */
  37216. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37217. /** @hidden */
  37218. _addPendingData(data: any): void;
  37219. /** @hidden */
  37220. _removePendingData(data: any): void;
  37221. /**
  37222. * Returns the number of items waiting to be loaded
  37223. * @returns the number of items waiting to be loaded
  37224. */
  37225. getWaitingItemsCount(): number;
  37226. /**
  37227. * Returns a boolean indicating if the scene is still loading data
  37228. */
  37229. get isLoading(): boolean;
  37230. /**
  37231. * Registers a function to be executed when the scene is ready
  37232. * @param {Function} func - the function to be executed
  37233. */
  37234. executeWhenReady(func: () => void): void;
  37235. /**
  37236. * Returns a promise that resolves when the scene is ready
  37237. * @returns A promise that resolves when the scene is ready
  37238. */
  37239. whenReadyAsync(): Promise<void>;
  37240. /** @hidden */
  37241. _checkIsReady(): void;
  37242. /**
  37243. * Gets all animatable attached to the scene
  37244. */
  37245. get animatables(): Animatable[];
  37246. /**
  37247. * Resets the last animation time frame.
  37248. * Useful to override when animations start running when loading a scene for the first time.
  37249. */
  37250. resetLastAnimationTimeFrame(): void;
  37251. /**
  37252. * Gets the current view matrix
  37253. * @returns a Matrix
  37254. */
  37255. getViewMatrix(): Matrix;
  37256. /**
  37257. * Gets the current projection matrix
  37258. * @returns a Matrix
  37259. */
  37260. getProjectionMatrix(): Matrix;
  37261. /**
  37262. * Gets the current transform matrix
  37263. * @returns a Matrix made of View * Projection
  37264. */
  37265. getTransformMatrix(): Matrix;
  37266. /**
  37267. * Sets the current transform matrix
  37268. * @param viewL defines the View matrix to use
  37269. * @param projectionL defines the Projection matrix to use
  37270. * @param viewR defines the right View matrix to use (if provided)
  37271. * @param projectionR defines the right Projection matrix to use (if provided)
  37272. */
  37273. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37274. /**
  37275. * Gets the uniform buffer used to store scene data
  37276. * @returns a UniformBuffer
  37277. */
  37278. getSceneUniformBuffer(): UniformBuffer;
  37279. /**
  37280. * Gets an unique (relatively to the current scene) Id
  37281. * @returns an unique number for the scene
  37282. */
  37283. getUniqueId(): number;
  37284. /**
  37285. * Add a mesh to the list of scene's meshes
  37286. * @param newMesh defines the mesh to add
  37287. * @param recursive if all child meshes should also be added to the scene
  37288. */
  37289. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37290. /**
  37291. * Remove a mesh for the list of scene's meshes
  37292. * @param toRemove defines the mesh to remove
  37293. * @param recursive if all child meshes should also be removed from the scene
  37294. * @returns the index where the mesh was in the mesh list
  37295. */
  37296. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37297. /**
  37298. * Add a transform node to the list of scene's transform nodes
  37299. * @param newTransformNode defines the transform node to add
  37300. */
  37301. addTransformNode(newTransformNode: TransformNode): void;
  37302. /**
  37303. * Remove a transform node for the list of scene's transform nodes
  37304. * @param toRemove defines the transform node to remove
  37305. * @returns the index where the transform node was in the transform node list
  37306. */
  37307. removeTransformNode(toRemove: TransformNode): number;
  37308. /**
  37309. * Remove a skeleton for the list of scene's skeletons
  37310. * @param toRemove defines the skeleton to remove
  37311. * @returns the index where the skeleton was in the skeleton list
  37312. */
  37313. removeSkeleton(toRemove: Skeleton): number;
  37314. /**
  37315. * Remove a morph target for the list of scene's morph targets
  37316. * @param toRemove defines the morph target to remove
  37317. * @returns the index where the morph target was in the morph target list
  37318. */
  37319. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37320. /**
  37321. * Remove a light for the list of scene's lights
  37322. * @param toRemove defines the light to remove
  37323. * @returns the index where the light was in the light list
  37324. */
  37325. removeLight(toRemove: Light): number;
  37326. /**
  37327. * Remove a camera for the list of scene's cameras
  37328. * @param toRemove defines the camera to remove
  37329. * @returns the index where the camera was in the camera list
  37330. */
  37331. removeCamera(toRemove: Camera): number;
  37332. /**
  37333. * Remove a particle system for the list of scene's particle systems
  37334. * @param toRemove defines the particle system to remove
  37335. * @returns the index where the particle system was in the particle system list
  37336. */
  37337. removeParticleSystem(toRemove: IParticleSystem): number;
  37338. /**
  37339. * Remove a animation for the list of scene's animations
  37340. * @param toRemove defines the animation to remove
  37341. * @returns the index where the animation was in the animation list
  37342. */
  37343. removeAnimation(toRemove: Animation): number;
  37344. /**
  37345. * Will stop the animation of the given target
  37346. * @param target - the target
  37347. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37348. * @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)
  37349. */
  37350. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37351. /**
  37352. * Removes the given animation group from this scene.
  37353. * @param toRemove The animation group to remove
  37354. * @returns The index of the removed animation group
  37355. */
  37356. removeAnimationGroup(toRemove: AnimationGroup): number;
  37357. /**
  37358. * Removes the given multi-material from this scene.
  37359. * @param toRemove The multi-material to remove
  37360. * @returns The index of the removed multi-material
  37361. */
  37362. removeMultiMaterial(toRemove: MultiMaterial): number;
  37363. /**
  37364. * Removes the given material from this scene.
  37365. * @param toRemove The material to remove
  37366. * @returns The index of the removed material
  37367. */
  37368. removeMaterial(toRemove: Material): number;
  37369. /**
  37370. * Removes the given action manager from this scene.
  37371. * @param toRemove The action manager to remove
  37372. * @returns The index of the removed action manager
  37373. */
  37374. removeActionManager(toRemove: AbstractActionManager): number;
  37375. /**
  37376. * Removes the given texture from this scene.
  37377. * @param toRemove The texture to remove
  37378. * @returns The index of the removed texture
  37379. */
  37380. removeTexture(toRemove: BaseTexture): number;
  37381. /**
  37382. * Adds the given light to this scene
  37383. * @param newLight The light to add
  37384. */
  37385. addLight(newLight: Light): void;
  37386. /**
  37387. * Sorts the list list based on light priorities
  37388. */
  37389. sortLightsByPriority(): void;
  37390. /**
  37391. * Adds the given camera to this scene
  37392. * @param newCamera The camera to add
  37393. */
  37394. addCamera(newCamera: Camera): void;
  37395. /**
  37396. * Adds the given skeleton to this scene
  37397. * @param newSkeleton The skeleton to add
  37398. */
  37399. addSkeleton(newSkeleton: Skeleton): void;
  37400. /**
  37401. * Adds the given particle system to this scene
  37402. * @param newParticleSystem The particle system to add
  37403. */
  37404. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37405. /**
  37406. * Adds the given animation to this scene
  37407. * @param newAnimation The animation to add
  37408. */
  37409. addAnimation(newAnimation: Animation): void;
  37410. /**
  37411. * Adds the given animation group to this scene.
  37412. * @param newAnimationGroup The animation group to add
  37413. */
  37414. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37415. /**
  37416. * Adds the given multi-material to this scene
  37417. * @param newMultiMaterial The multi-material to add
  37418. */
  37419. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37420. /**
  37421. * Adds the given material to this scene
  37422. * @param newMaterial The material to add
  37423. */
  37424. addMaterial(newMaterial: Material): void;
  37425. /**
  37426. * Adds the given morph target to this scene
  37427. * @param newMorphTargetManager The morph target to add
  37428. */
  37429. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37430. /**
  37431. * Adds the given geometry to this scene
  37432. * @param newGeometry The geometry to add
  37433. */
  37434. addGeometry(newGeometry: Geometry): void;
  37435. /**
  37436. * Adds the given action manager to this scene
  37437. * @param newActionManager The action manager to add
  37438. */
  37439. addActionManager(newActionManager: AbstractActionManager): void;
  37440. /**
  37441. * Adds the given texture to this scene.
  37442. * @param newTexture The texture to add
  37443. */
  37444. addTexture(newTexture: BaseTexture): void;
  37445. /**
  37446. * Switch active camera
  37447. * @param newCamera defines the new active camera
  37448. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37449. */
  37450. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37451. /**
  37452. * sets the active camera of the scene using its ID
  37453. * @param id defines the camera's ID
  37454. * @return the new active camera or null if none found.
  37455. */
  37456. setActiveCameraByID(id: string): Nullable<Camera>;
  37457. /**
  37458. * sets the active camera of the scene using its name
  37459. * @param name defines the camera's name
  37460. * @returns the new active camera or null if none found.
  37461. */
  37462. setActiveCameraByName(name: string): Nullable<Camera>;
  37463. /**
  37464. * get an animation group using its name
  37465. * @param name defines the material's name
  37466. * @return the animation group or null if none found.
  37467. */
  37468. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37469. /**
  37470. * Get a material using its unique id
  37471. * @param uniqueId defines the material's unique id
  37472. * @return the material or null if none found.
  37473. */
  37474. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37475. /**
  37476. * get a material using its id
  37477. * @param id defines the material's ID
  37478. * @return the material or null if none found.
  37479. */
  37480. getMaterialByID(id: string): Nullable<Material>;
  37481. /**
  37482. * Gets a the last added material using a given id
  37483. * @param id defines the material's ID
  37484. * @return the last material with the given id or null if none found.
  37485. */
  37486. getLastMaterialByID(id: string): Nullable<Material>;
  37487. /**
  37488. * Gets a material using its name
  37489. * @param name defines the material's name
  37490. * @return the material or null if none found.
  37491. */
  37492. getMaterialByName(name: string): Nullable<Material>;
  37493. /**
  37494. * Get a texture using its unique id
  37495. * @param uniqueId defines the texture's unique id
  37496. * @return the texture or null if none found.
  37497. */
  37498. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37499. /**
  37500. * Gets a camera using its id
  37501. * @param id defines the id to look for
  37502. * @returns the camera or null if not found
  37503. */
  37504. getCameraByID(id: string): Nullable<Camera>;
  37505. /**
  37506. * Gets a camera using its unique id
  37507. * @param uniqueId defines the unique id to look for
  37508. * @returns the camera or null if not found
  37509. */
  37510. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37511. /**
  37512. * Gets a camera using its name
  37513. * @param name defines the camera's name
  37514. * @return the camera or null if none found.
  37515. */
  37516. getCameraByName(name: string): Nullable<Camera>;
  37517. /**
  37518. * Gets a bone using its id
  37519. * @param id defines the bone's id
  37520. * @return the bone or null if not found
  37521. */
  37522. getBoneByID(id: string): Nullable<Bone>;
  37523. /**
  37524. * Gets a bone using its id
  37525. * @param name defines the bone's name
  37526. * @return the bone or null if not found
  37527. */
  37528. getBoneByName(name: string): Nullable<Bone>;
  37529. /**
  37530. * Gets a light node using its name
  37531. * @param name defines the the light's name
  37532. * @return the light or null if none found.
  37533. */
  37534. getLightByName(name: string): Nullable<Light>;
  37535. /**
  37536. * Gets a light node using its id
  37537. * @param id defines the light's id
  37538. * @return the light or null if none found.
  37539. */
  37540. getLightByID(id: string): Nullable<Light>;
  37541. /**
  37542. * Gets a light node using its scene-generated unique ID
  37543. * @param uniqueId defines the light's unique id
  37544. * @return the light or null if none found.
  37545. */
  37546. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37547. /**
  37548. * Gets a particle system by id
  37549. * @param id defines the particle system id
  37550. * @return the corresponding system or null if none found
  37551. */
  37552. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37553. /**
  37554. * Gets a geometry using its ID
  37555. * @param id defines the geometry's id
  37556. * @return the geometry or null if none found.
  37557. */
  37558. getGeometryByID(id: string): Nullable<Geometry>;
  37559. private _getGeometryByUniqueID;
  37560. /**
  37561. * Add a new geometry to this scene
  37562. * @param geometry defines the geometry to be added to the scene.
  37563. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37564. * @return a boolean defining if the geometry was added or not
  37565. */
  37566. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37567. /**
  37568. * Removes an existing geometry
  37569. * @param geometry defines the geometry to be removed from the scene
  37570. * @return a boolean defining if the geometry was removed or not
  37571. */
  37572. removeGeometry(geometry: Geometry): boolean;
  37573. /**
  37574. * Gets the list of geometries attached to the scene
  37575. * @returns an array of Geometry
  37576. */
  37577. getGeometries(): Geometry[];
  37578. /**
  37579. * Gets the first added mesh found of a given ID
  37580. * @param id defines the id to search for
  37581. * @return the mesh found or null if not found at all
  37582. */
  37583. getMeshByID(id: string): Nullable<AbstractMesh>;
  37584. /**
  37585. * Gets a list of meshes using their id
  37586. * @param id defines the id to search for
  37587. * @returns a list of meshes
  37588. */
  37589. getMeshesByID(id: string): Array<AbstractMesh>;
  37590. /**
  37591. * Gets the first added transform node found of a given ID
  37592. * @param id defines the id to search for
  37593. * @return the found transform node or null if not found at all.
  37594. */
  37595. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37596. /**
  37597. * Gets a transform node with its auto-generated unique id
  37598. * @param uniqueId efines the unique id to search for
  37599. * @return the found transform node or null if not found at all.
  37600. */
  37601. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37602. /**
  37603. * Gets a list of transform nodes using their id
  37604. * @param id defines the id to search for
  37605. * @returns a list of transform nodes
  37606. */
  37607. getTransformNodesByID(id: string): Array<TransformNode>;
  37608. /**
  37609. * Gets a mesh with its auto-generated unique id
  37610. * @param uniqueId defines the unique id to search for
  37611. * @return the found mesh or null if not found at all.
  37612. */
  37613. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37614. /**
  37615. * Gets a the last added mesh using a given id
  37616. * @param id defines the id to search for
  37617. * @return the found mesh or null if not found at all.
  37618. */
  37619. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37620. /**
  37621. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37622. * @param id defines the id to search for
  37623. * @return the found node or null if not found at all
  37624. */
  37625. getLastEntryByID(id: string): Nullable<Node>;
  37626. /**
  37627. * Gets a node (Mesh, Camera, Light) using a given id
  37628. * @param id defines the id to search for
  37629. * @return the found node or null if not found at all
  37630. */
  37631. getNodeByID(id: string): Nullable<Node>;
  37632. /**
  37633. * Gets a node (Mesh, Camera, Light) using a given name
  37634. * @param name defines the name to search for
  37635. * @return the found node or null if not found at all.
  37636. */
  37637. getNodeByName(name: string): Nullable<Node>;
  37638. /**
  37639. * Gets a mesh using a given name
  37640. * @param name defines the name to search for
  37641. * @return the found mesh or null if not found at all.
  37642. */
  37643. getMeshByName(name: string): Nullable<AbstractMesh>;
  37644. /**
  37645. * Gets a transform node using a given name
  37646. * @param name defines the name to search for
  37647. * @return the found transform node or null if not found at all.
  37648. */
  37649. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37650. /**
  37651. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37652. * @param id defines the id to search for
  37653. * @return the found skeleton or null if not found at all.
  37654. */
  37655. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37656. /**
  37657. * Gets a skeleton using a given auto generated unique id
  37658. * @param uniqueId defines the unique id to search for
  37659. * @return the found skeleton or null if not found at all.
  37660. */
  37661. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37662. /**
  37663. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37664. * @param id defines the id to search for
  37665. * @return the found skeleton or null if not found at all.
  37666. */
  37667. getSkeletonById(id: string): Nullable<Skeleton>;
  37668. /**
  37669. * Gets a skeleton using a given name
  37670. * @param name defines the name to search for
  37671. * @return the found skeleton or null if not found at all.
  37672. */
  37673. getSkeletonByName(name: string): Nullable<Skeleton>;
  37674. /**
  37675. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37676. * @param id defines the id to search for
  37677. * @return the found morph target manager or null if not found at all.
  37678. */
  37679. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37680. /**
  37681. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37682. * @param id defines the id to search for
  37683. * @return the found morph target or null if not found at all.
  37684. */
  37685. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37686. /**
  37687. * Gets a boolean indicating if the given mesh is active
  37688. * @param mesh defines the mesh to look for
  37689. * @returns true if the mesh is in the active list
  37690. */
  37691. isActiveMesh(mesh: AbstractMesh): boolean;
  37692. /**
  37693. * Return a unique id as a string which can serve as an identifier for the scene
  37694. */
  37695. get uid(): string;
  37696. /**
  37697. * Add an externaly attached data from its key.
  37698. * This method call will fail and return false, if such key already exists.
  37699. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37700. * @param key the unique key that identifies the data
  37701. * @param data the data object to associate to the key for this Engine instance
  37702. * @return true if no such key were already present and the data was added successfully, false otherwise
  37703. */
  37704. addExternalData<T>(key: string, data: T): boolean;
  37705. /**
  37706. * Get an externaly attached data from its key
  37707. * @param key the unique key that identifies the data
  37708. * @return the associated data, if present (can be null), or undefined if not present
  37709. */
  37710. getExternalData<T>(key: string): Nullable<T>;
  37711. /**
  37712. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37713. * @param key the unique key that identifies the data
  37714. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37715. * @return the associated data, can be null if the factory returned null.
  37716. */
  37717. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37718. /**
  37719. * Remove an externaly attached data from the Engine instance
  37720. * @param key the unique key that identifies the data
  37721. * @return true if the data was successfully removed, false if it doesn't exist
  37722. */
  37723. removeExternalData(key: string): boolean;
  37724. private _evaluateSubMesh;
  37725. /**
  37726. * Clear the processed materials smart array preventing retention point in material dispose.
  37727. */
  37728. freeProcessedMaterials(): void;
  37729. private _preventFreeActiveMeshesAndRenderingGroups;
  37730. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37731. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37732. * when disposing several meshes in a row or a hierarchy of meshes.
  37733. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37734. */
  37735. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37736. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37737. /**
  37738. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37739. */
  37740. freeActiveMeshes(): void;
  37741. /**
  37742. * Clear the info related to rendering groups preventing retention points during dispose.
  37743. */
  37744. freeRenderingGroups(): void;
  37745. /** @hidden */
  37746. _isInIntermediateRendering(): boolean;
  37747. /**
  37748. * Lambda returning the list of potentially active meshes.
  37749. */
  37750. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37751. /**
  37752. * Lambda returning the list of potentially active sub meshes.
  37753. */
  37754. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37755. /**
  37756. * Lambda returning the list of potentially intersecting sub meshes.
  37757. */
  37758. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37759. /**
  37760. * Lambda returning the list of potentially colliding sub meshes.
  37761. */
  37762. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37763. private _activeMeshesFrozen;
  37764. private _skipEvaluateActiveMeshesCompletely;
  37765. /**
  37766. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37767. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37768. * @returns the current scene
  37769. */
  37770. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37771. /**
  37772. * Use this function to restart evaluating active meshes on every frame
  37773. * @returns the current scene
  37774. */
  37775. unfreezeActiveMeshes(): Scene;
  37776. private _evaluateActiveMeshes;
  37777. private _activeMesh;
  37778. /**
  37779. * Update the transform matrix to update from the current active camera
  37780. * @param force defines a boolean used to force the update even if cache is up to date
  37781. */
  37782. updateTransformMatrix(force?: boolean): void;
  37783. private _bindFrameBuffer;
  37784. /** @hidden */
  37785. _allowPostProcessClearColor: boolean;
  37786. /** @hidden */
  37787. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37788. private _processSubCameras;
  37789. private _checkIntersections;
  37790. /** @hidden */
  37791. _advancePhysicsEngineStep(step: number): void;
  37792. /**
  37793. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37794. */
  37795. getDeterministicFrameTime: () => number;
  37796. /** @hidden */
  37797. _animate(): void;
  37798. /** Execute all animations (for a frame) */
  37799. animate(): void;
  37800. /**
  37801. * Render the scene
  37802. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37803. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37804. */
  37805. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37806. /**
  37807. * Freeze all materials
  37808. * A frozen material will not be updatable but should be faster to render
  37809. */
  37810. freezeMaterials(): void;
  37811. /**
  37812. * Unfreeze all materials
  37813. * A frozen material will not be updatable but should be faster to render
  37814. */
  37815. unfreezeMaterials(): void;
  37816. /**
  37817. * Releases all held ressources
  37818. */
  37819. dispose(): void;
  37820. /**
  37821. * Gets if the scene is already disposed
  37822. */
  37823. get isDisposed(): boolean;
  37824. /**
  37825. * Call this function to reduce memory footprint of the scene.
  37826. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37827. */
  37828. clearCachedVertexData(): void;
  37829. /**
  37830. * This function will remove the local cached buffer data from texture.
  37831. * It will save memory but will prevent the texture from being rebuilt
  37832. */
  37833. cleanCachedTextureBuffer(): void;
  37834. /**
  37835. * Get the world extend vectors with an optional filter
  37836. *
  37837. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37838. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37839. */
  37840. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37841. min: Vector3;
  37842. max: Vector3;
  37843. };
  37844. /**
  37845. * Creates a ray that can be used to pick in the scene
  37846. * @param x defines the x coordinate of the origin (on-screen)
  37847. * @param y defines the y coordinate of the origin (on-screen)
  37848. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37849. * @param camera defines the camera to use for the picking
  37850. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37851. * @returns a Ray
  37852. */
  37853. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37854. /**
  37855. * Creates a ray that can be used to pick in the scene
  37856. * @param x defines the x coordinate of the origin (on-screen)
  37857. * @param y defines the y coordinate of the origin (on-screen)
  37858. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37859. * @param result defines the ray where to store the picking ray
  37860. * @param camera defines the camera to use for the picking
  37861. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37862. * @returns the current scene
  37863. */
  37864. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37865. /**
  37866. * Creates a ray that can be used to pick in the scene
  37867. * @param x defines the x coordinate of the origin (on-screen)
  37868. * @param y defines the y coordinate of the origin (on-screen)
  37869. * @param camera defines the camera to use for the picking
  37870. * @returns a Ray
  37871. */
  37872. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37873. /**
  37874. * Creates a ray that can be used to pick in the scene
  37875. * @param x defines the x coordinate of the origin (on-screen)
  37876. * @param y defines the y coordinate of the origin (on-screen)
  37877. * @param result defines the ray where to store the picking ray
  37878. * @param camera defines the camera to use for the picking
  37879. * @returns the current scene
  37880. */
  37881. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37882. /** Launch a ray to try to pick a mesh in the scene
  37883. * @param x position on screen
  37884. * @param y position on screen
  37885. * @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
  37886. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37887. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37888. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37889. * @returns a PickingInfo
  37890. */
  37891. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37892. /** Use the given ray to pick a mesh in the scene
  37893. * @param ray The ray to use to pick meshes
  37894. * @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
  37895. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37896. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37897. * @returns a PickingInfo
  37898. */
  37899. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37900. /**
  37901. * Launch a ray to try to pick a mesh in the scene
  37902. * @param x X position on screen
  37903. * @param y Y position on screen
  37904. * @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
  37905. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37906. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37907. * @returns an array of PickingInfo
  37908. */
  37909. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37910. /**
  37911. * Launch a ray to try to pick a mesh in the scene
  37912. * @param ray Ray to use
  37913. * @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
  37914. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37915. * @returns an array of PickingInfo
  37916. */
  37917. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37918. /**
  37919. * Force the value of meshUnderPointer
  37920. * @param mesh defines the mesh to use
  37921. */
  37922. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37923. /**
  37924. * Gets the mesh under the pointer
  37925. * @returns a Mesh or null if no mesh is under the pointer
  37926. */
  37927. getPointerOverMesh(): Nullable<AbstractMesh>;
  37928. /** @hidden */
  37929. _rebuildGeometries(): void;
  37930. /** @hidden */
  37931. _rebuildTextures(): void;
  37932. private _getByTags;
  37933. /**
  37934. * Get a list of meshes by tags
  37935. * @param tagsQuery defines the tags query to use
  37936. * @param forEach defines a predicate used to filter results
  37937. * @returns an array of Mesh
  37938. */
  37939. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37940. /**
  37941. * Get a list of cameras by tags
  37942. * @param tagsQuery defines the tags query to use
  37943. * @param forEach defines a predicate used to filter results
  37944. * @returns an array of Camera
  37945. */
  37946. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37947. /**
  37948. * Get a list of lights by tags
  37949. * @param tagsQuery defines the tags query to use
  37950. * @param forEach defines a predicate used to filter results
  37951. * @returns an array of Light
  37952. */
  37953. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37954. /**
  37955. * Get a list of materials by tags
  37956. * @param tagsQuery defines the tags query to use
  37957. * @param forEach defines a predicate used to filter results
  37958. * @returns an array of Material
  37959. */
  37960. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37961. /**
  37962. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37963. * This allowed control for front to back rendering or reversly depending of the special needs.
  37964. *
  37965. * @param renderingGroupId The rendering group id corresponding to its index
  37966. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37967. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37968. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37969. */
  37970. 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;
  37971. /**
  37972. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37973. *
  37974. * @param renderingGroupId The rendering group id corresponding to its index
  37975. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37976. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37977. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37978. */
  37979. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37980. /**
  37981. * Gets the current auto clear configuration for one rendering group of the rendering
  37982. * manager.
  37983. * @param index the rendering group index to get the information for
  37984. * @returns The auto clear setup for the requested rendering group
  37985. */
  37986. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37987. private _blockMaterialDirtyMechanism;
  37988. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37989. get blockMaterialDirtyMechanism(): boolean;
  37990. set blockMaterialDirtyMechanism(value: boolean);
  37991. /**
  37992. * Will flag all materials as dirty to trigger new shader compilation
  37993. * @param flag defines the flag used to specify which material part must be marked as dirty
  37994. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37995. */
  37996. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37997. /** @hidden */
  37998. _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;
  37999. /** @hidden */
  38000. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38001. /** @hidden */
  38002. _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;
  38003. /** @hidden */
  38004. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38005. /** @hidden */
  38006. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38007. /** @hidden */
  38008. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38009. }
  38010. }
  38011. declare module "babylonjs/assetContainer" {
  38012. import { AbstractScene } from "babylonjs/abstractScene";
  38013. import { Scene } from "babylonjs/scene";
  38014. import { Mesh } from "babylonjs/Meshes/mesh";
  38015. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38016. import { Skeleton } from "babylonjs/Bones/skeleton";
  38017. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38018. import { Animatable } from "babylonjs/Animations/animatable";
  38019. import { Nullable } from "babylonjs/types";
  38020. import { Node } from "babylonjs/node";
  38021. /**
  38022. * Set of assets to keep when moving a scene into an asset container.
  38023. */
  38024. export class KeepAssets extends AbstractScene {
  38025. }
  38026. /**
  38027. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38028. */
  38029. export class InstantiatedEntries {
  38030. /**
  38031. * List of new root nodes (eg. nodes with no parent)
  38032. */
  38033. rootNodes: TransformNode[];
  38034. /**
  38035. * List of new skeletons
  38036. */
  38037. skeletons: Skeleton[];
  38038. /**
  38039. * List of new animation groups
  38040. */
  38041. animationGroups: AnimationGroup[];
  38042. }
  38043. /**
  38044. * Container with a set of assets that can be added or removed from a scene.
  38045. */
  38046. export class AssetContainer extends AbstractScene {
  38047. /**
  38048. * The scene the AssetContainer belongs to.
  38049. */
  38050. scene: Scene;
  38051. /**
  38052. * Instantiates an AssetContainer.
  38053. * @param scene The scene the AssetContainer belongs to.
  38054. */
  38055. constructor(scene: Scene);
  38056. /**
  38057. * Instantiate or clone all meshes and add the new ones to the scene.
  38058. * Skeletons and animation groups will all be cloned
  38059. * @param nameFunction defines an optional function used to get new names for clones
  38060. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38061. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38062. */
  38063. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38064. /**
  38065. * Adds all the assets from the container to the scene.
  38066. */
  38067. addAllToScene(): void;
  38068. /**
  38069. * Removes all the assets in the container from the scene
  38070. */
  38071. removeAllFromScene(): void;
  38072. /**
  38073. * Disposes all the assets in the container
  38074. */
  38075. dispose(): void;
  38076. private _moveAssets;
  38077. /**
  38078. * Removes all the assets contained in the scene and adds them to the container.
  38079. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38080. */
  38081. moveAllFromScene(keepAssets?: KeepAssets): void;
  38082. /**
  38083. * 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.
  38084. * @returns the root mesh
  38085. */
  38086. createRootMesh(): Mesh;
  38087. /**
  38088. * Merge animations from this asset container into a scene
  38089. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38090. * @param animatables set of animatables to retarget to a node from the scene
  38091. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38092. */
  38093. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38094. }
  38095. }
  38096. declare module "babylonjs/abstractScene" {
  38097. import { Scene } from "babylonjs/scene";
  38098. import { Nullable } from "babylonjs/types";
  38099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38100. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38101. import { Geometry } from "babylonjs/Meshes/geometry";
  38102. import { Skeleton } from "babylonjs/Bones/skeleton";
  38103. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38104. import { AssetContainer } from "babylonjs/assetContainer";
  38105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38106. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38107. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38108. import { Material } from "babylonjs/Materials/material";
  38109. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38110. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38111. import { Camera } from "babylonjs/Cameras/camera";
  38112. import { Light } from "babylonjs/Lights/light";
  38113. import { Node } from "babylonjs/node";
  38114. import { Animation } from "babylonjs/Animations/animation";
  38115. /**
  38116. * Defines how the parser contract is defined.
  38117. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38118. */
  38119. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38120. /**
  38121. * Defines how the individual parser contract is defined.
  38122. * These parser can parse an individual asset
  38123. */
  38124. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38125. /**
  38126. * Base class of the scene acting as a container for the different elements composing a scene.
  38127. * This class is dynamically extended by the different components of the scene increasing
  38128. * flexibility and reducing coupling
  38129. */
  38130. export abstract class AbstractScene {
  38131. /**
  38132. * Stores the list of available parsers in the application.
  38133. */
  38134. private static _BabylonFileParsers;
  38135. /**
  38136. * Stores the list of available individual parsers in the application.
  38137. */
  38138. private static _IndividualBabylonFileParsers;
  38139. /**
  38140. * Adds a parser in the list of available ones
  38141. * @param name Defines the name of the parser
  38142. * @param parser Defines the parser to add
  38143. */
  38144. static AddParser(name: string, parser: BabylonFileParser): void;
  38145. /**
  38146. * Gets a general parser from the list of avaialble ones
  38147. * @param name Defines the name of the parser
  38148. * @returns the requested parser or null
  38149. */
  38150. static GetParser(name: string): Nullable<BabylonFileParser>;
  38151. /**
  38152. * Adds n individual parser in the list of available ones
  38153. * @param name Defines the name of the parser
  38154. * @param parser Defines the parser to add
  38155. */
  38156. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38157. /**
  38158. * Gets an individual parser from the list of avaialble ones
  38159. * @param name Defines the name of the parser
  38160. * @returns the requested parser or null
  38161. */
  38162. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38163. /**
  38164. * Parser json data and populate both a scene and its associated container object
  38165. * @param jsonData Defines the data to parse
  38166. * @param scene Defines the scene to parse the data for
  38167. * @param container Defines the container attached to the parsing sequence
  38168. * @param rootUrl Defines the root url of the data
  38169. */
  38170. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38171. /**
  38172. * Gets the list of root nodes (ie. nodes with no parent)
  38173. */
  38174. rootNodes: Node[];
  38175. /** All of the cameras added to this scene
  38176. * @see http://doc.babylonjs.com/babylon101/cameras
  38177. */
  38178. cameras: Camera[];
  38179. /**
  38180. * All of the lights added to this scene
  38181. * @see http://doc.babylonjs.com/babylon101/lights
  38182. */
  38183. lights: Light[];
  38184. /**
  38185. * All of the (abstract) meshes added to this scene
  38186. */
  38187. meshes: AbstractMesh[];
  38188. /**
  38189. * The list of skeletons added to the scene
  38190. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38191. */
  38192. skeletons: Skeleton[];
  38193. /**
  38194. * All of the particle systems added to this scene
  38195. * @see http://doc.babylonjs.com/babylon101/particles
  38196. */
  38197. particleSystems: IParticleSystem[];
  38198. /**
  38199. * Gets a list of Animations associated with the scene
  38200. */
  38201. animations: Animation[];
  38202. /**
  38203. * All of the animation groups added to this scene
  38204. * @see http://doc.babylonjs.com/how_to/group
  38205. */
  38206. animationGroups: AnimationGroup[];
  38207. /**
  38208. * All of the multi-materials added to this scene
  38209. * @see http://doc.babylonjs.com/how_to/multi_materials
  38210. */
  38211. multiMaterials: MultiMaterial[];
  38212. /**
  38213. * All of the materials added to this scene
  38214. * In the context of a Scene, it is not supposed to be modified manually.
  38215. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38216. * Note also that the order of the Material within the array is not significant and might change.
  38217. * @see http://doc.babylonjs.com/babylon101/materials
  38218. */
  38219. materials: Material[];
  38220. /**
  38221. * The list of morph target managers added to the scene
  38222. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38223. */
  38224. morphTargetManagers: MorphTargetManager[];
  38225. /**
  38226. * The list of geometries used in the scene.
  38227. */
  38228. geometries: Geometry[];
  38229. /**
  38230. * All of the tranform nodes added to this scene
  38231. * In the context of a Scene, it is not supposed to be modified manually.
  38232. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38233. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38234. * @see http://doc.babylonjs.com/how_to/transformnode
  38235. */
  38236. transformNodes: TransformNode[];
  38237. /**
  38238. * ActionManagers available on the scene.
  38239. */
  38240. actionManagers: AbstractActionManager[];
  38241. /**
  38242. * Textures to keep.
  38243. */
  38244. textures: BaseTexture[];
  38245. /**
  38246. * Environment texture for the scene
  38247. */
  38248. environmentTexture: Nullable<BaseTexture>;
  38249. /**
  38250. * @returns all meshes, lights, cameras, transformNodes and bones
  38251. */
  38252. getNodes(): Array<Node>;
  38253. }
  38254. }
  38255. declare module "babylonjs/Audio/sound" {
  38256. import { Observable } from "babylonjs/Misc/observable";
  38257. import { Vector3 } from "babylonjs/Maths/math.vector";
  38258. import { Nullable } from "babylonjs/types";
  38259. import { Scene } from "babylonjs/scene";
  38260. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38261. /**
  38262. * Interface used to define options for Sound class
  38263. */
  38264. export interface ISoundOptions {
  38265. /**
  38266. * Does the sound autoplay once loaded.
  38267. */
  38268. autoplay?: boolean;
  38269. /**
  38270. * Does the sound loop after it finishes playing once.
  38271. */
  38272. loop?: boolean;
  38273. /**
  38274. * Sound's volume
  38275. */
  38276. volume?: number;
  38277. /**
  38278. * Is it a spatial sound?
  38279. */
  38280. spatialSound?: boolean;
  38281. /**
  38282. * Maximum distance to hear that sound
  38283. */
  38284. maxDistance?: number;
  38285. /**
  38286. * Uses user defined attenuation function
  38287. */
  38288. useCustomAttenuation?: boolean;
  38289. /**
  38290. * Define the roll off factor of spatial sounds.
  38291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38292. */
  38293. rolloffFactor?: number;
  38294. /**
  38295. * Define the reference distance the sound should be heard perfectly.
  38296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38297. */
  38298. refDistance?: number;
  38299. /**
  38300. * Define the distance attenuation model the sound will follow.
  38301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38302. */
  38303. distanceModel?: string;
  38304. /**
  38305. * Defines the playback speed (1 by default)
  38306. */
  38307. playbackRate?: number;
  38308. /**
  38309. * Defines if the sound is from a streaming source
  38310. */
  38311. streaming?: boolean;
  38312. /**
  38313. * Defines an optional length (in seconds) inside the sound file
  38314. */
  38315. length?: number;
  38316. /**
  38317. * Defines an optional offset (in seconds) inside the sound file
  38318. */
  38319. offset?: number;
  38320. /**
  38321. * If true, URLs will not be required to state the audio file codec to use.
  38322. */
  38323. skipCodecCheck?: boolean;
  38324. }
  38325. /**
  38326. * Defines a sound that can be played in the application.
  38327. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38329. */
  38330. export class Sound {
  38331. /**
  38332. * The name of the sound in the scene.
  38333. */
  38334. name: string;
  38335. /**
  38336. * Does the sound autoplay once loaded.
  38337. */
  38338. autoplay: boolean;
  38339. /**
  38340. * Does the sound loop after it finishes playing once.
  38341. */
  38342. loop: boolean;
  38343. /**
  38344. * Does the sound use a custom attenuation curve to simulate the falloff
  38345. * happening when the source gets further away from the camera.
  38346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38347. */
  38348. useCustomAttenuation: boolean;
  38349. /**
  38350. * The sound track id this sound belongs to.
  38351. */
  38352. soundTrackId: number;
  38353. /**
  38354. * Is this sound currently played.
  38355. */
  38356. isPlaying: boolean;
  38357. /**
  38358. * Is this sound currently paused.
  38359. */
  38360. isPaused: boolean;
  38361. /**
  38362. * Does this sound enables spatial sound.
  38363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38364. */
  38365. spatialSound: boolean;
  38366. /**
  38367. * Define the reference distance the sound should be heard perfectly.
  38368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38369. */
  38370. refDistance: number;
  38371. /**
  38372. * Define the roll off factor of spatial sounds.
  38373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38374. */
  38375. rolloffFactor: number;
  38376. /**
  38377. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38379. */
  38380. maxDistance: number;
  38381. /**
  38382. * Define the distance attenuation model the sound will follow.
  38383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38384. */
  38385. distanceModel: string;
  38386. /**
  38387. * @hidden
  38388. * Back Compat
  38389. **/
  38390. onended: () => any;
  38391. /**
  38392. * Observable event when the current playing sound finishes.
  38393. */
  38394. onEndedObservable: Observable<Sound>;
  38395. private _panningModel;
  38396. private _playbackRate;
  38397. private _streaming;
  38398. private _startTime;
  38399. private _startOffset;
  38400. private _position;
  38401. /** @hidden */
  38402. _positionInEmitterSpace: boolean;
  38403. private _localDirection;
  38404. private _volume;
  38405. private _isReadyToPlay;
  38406. private _isDirectional;
  38407. private _readyToPlayCallback;
  38408. private _audioBuffer;
  38409. private _soundSource;
  38410. private _streamingSource;
  38411. private _soundPanner;
  38412. private _soundGain;
  38413. private _inputAudioNode;
  38414. private _outputAudioNode;
  38415. private _coneInnerAngle;
  38416. private _coneOuterAngle;
  38417. private _coneOuterGain;
  38418. private _scene;
  38419. private _connectedTransformNode;
  38420. private _customAttenuationFunction;
  38421. private _registerFunc;
  38422. private _isOutputConnected;
  38423. private _htmlAudioElement;
  38424. private _urlType;
  38425. private _length?;
  38426. private _offset?;
  38427. /** @hidden */
  38428. static _SceneComponentInitialization: (scene: Scene) => void;
  38429. /**
  38430. * Create a sound and attach it to a scene
  38431. * @param name Name of your sound
  38432. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38433. * @param scene defines the scene the sound belongs to
  38434. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38435. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38436. */
  38437. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38438. /**
  38439. * Release the sound and its associated resources
  38440. */
  38441. dispose(): void;
  38442. /**
  38443. * Gets if the sounds is ready to be played or not.
  38444. * @returns true if ready, otherwise false
  38445. */
  38446. isReady(): boolean;
  38447. private _soundLoaded;
  38448. /**
  38449. * Sets the data of the sound from an audiobuffer
  38450. * @param audioBuffer The audioBuffer containing the data
  38451. */
  38452. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38453. /**
  38454. * Updates the current sounds options such as maxdistance, loop...
  38455. * @param options A JSON object containing values named as the object properties
  38456. */
  38457. updateOptions(options: ISoundOptions): void;
  38458. private _createSpatialParameters;
  38459. private _updateSpatialParameters;
  38460. /**
  38461. * Switch the panning model to HRTF:
  38462. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38464. */
  38465. switchPanningModelToHRTF(): void;
  38466. /**
  38467. * Switch the panning model to Equal Power:
  38468. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38470. */
  38471. switchPanningModelToEqualPower(): void;
  38472. private _switchPanningModel;
  38473. /**
  38474. * Connect this sound to a sound track audio node like gain...
  38475. * @param soundTrackAudioNode the sound track audio node to connect to
  38476. */
  38477. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38478. /**
  38479. * Transform this sound into a directional source
  38480. * @param coneInnerAngle Size of the inner cone in degree
  38481. * @param coneOuterAngle Size of the outer cone in degree
  38482. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38483. */
  38484. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38485. /**
  38486. * Gets or sets the inner angle for the directional cone.
  38487. */
  38488. get directionalConeInnerAngle(): number;
  38489. /**
  38490. * Gets or sets the inner angle for the directional cone.
  38491. */
  38492. set directionalConeInnerAngle(value: number);
  38493. /**
  38494. * Gets or sets the outer angle for the directional cone.
  38495. */
  38496. get directionalConeOuterAngle(): number;
  38497. /**
  38498. * Gets or sets the outer angle for the directional cone.
  38499. */
  38500. set directionalConeOuterAngle(value: number);
  38501. /**
  38502. * Sets the position of the emitter if spatial sound is enabled
  38503. * @param newPosition Defines the new posisiton
  38504. */
  38505. setPosition(newPosition: Vector3): void;
  38506. /**
  38507. * Sets the local direction of the emitter if spatial sound is enabled
  38508. * @param newLocalDirection Defines the new local direction
  38509. */
  38510. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38511. private _updateDirection;
  38512. /** @hidden */
  38513. updateDistanceFromListener(): void;
  38514. /**
  38515. * Sets a new custom attenuation function for the sound.
  38516. * @param callback Defines the function used for the attenuation
  38517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38518. */
  38519. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38520. /**
  38521. * Play the sound
  38522. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38523. * @param offset (optional) Start the sound at a specific time in seconds
  38524. * @param length (optional) Sound duration (in seconds)
  38525. */
  38526. play(time?: number, offset?: number, length?: number): void;
  38527. private _onended;
  38528. /**
  38529. * Stop the sound
  38530. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38531. */
  38532. stop(time?: number): void;
  38533. /**
  38534. * Put the sound in pause
  38535. */
  38536. pause(): void;
  38537. /**
  38538. * Sets a dedicated volume for this sounds
  38539. * @param newVolume Define the new volume of the sound
  38540. * @param time Define time for gradual change to new volume
  38541. */
  38542. setVolume(newVolume: number, time?: number): void;
  38543. /**
  38544. * Set the sound play back rate
  38545. * @param newPlaybackRate Define the playback rate the sound should be played at
  38546. */
  38547. setPlaybackRate(newPlaybackRate: number): void;
  38548. /**
  38549. * Gets the volume of the sound.
  38550. * @returns the volume of the sound
  38551. */
  38552. getVolume(): number;
  38553. /**
  38554. * Attach the sound to a dedicated mesh
  38555. * @param transformNode The transform node to connect the sound with
  38556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38557. */
  38558. attachToMesh(transformNode: TransformNode): void;
  38559. /**
  38560. * Detach the sound from the previously attached mesh
  38561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38562. */
  38563. detachFromMesh(): void;
  38564. private _onRegisterAfterWorldMatrixUpdate;
  38565. /**
  38566. * Clone the current sound in the scene.
  38567. * @returns the new sound clone
  38568. */
  38569. clone(): Nullable<Sound>;
  38570. /**
  38571. * Gets the current underlying audio buffer containing the data
  38572. * @returns the audio buffer
  38573. */
  38574. getAudioBuffer(): Nullable<AudioBuffer>;
  38575. /**
  38576. * Serializes the Sound in a JSON representation
  38577. * @returns the JSON representation of the sound
  38578. */
  38579. serialize(): any;
  38580. /**
  38581. * Parse a JSON representation of a sound to innstantiate in a given scene
  38582. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38583. * @param scene Define the scene the new parsed sound should be created in
  38584. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38585. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38586. * @returns the newly parsed sound
  38587. */
  38588. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38589. }
  38590. }
  38591. declare module "babylonjs/Actions/directAudioActions" {
  38592. import { Action } from "babylonjs/Actions/action";
  38593. import { Condition } from "babylonjs/Actions/condition";
  38594. import { Sound } from "babylonjs/Audio/sound";
  38595. /**
  38596. * This defines an action helpful to play a defined sound on a triggered action.
  38597. */
  38598. export class PlaySoundAction extends Action {
  38599. private _sound;
  38600. /**
  38601. * Instantiate the action
  38602. * @param triggerOptions defines the trigger options
  38603. * @param sound defines the sound to play
  38604. * @param condition defines the trigger related conditions
  38605. */
  38606. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38607. /** @hidden */
  38608. _prepare(): void;
  38609. /**
  38610. * Execute the action and play the sound.
  38611. */
  38612. execute(): void;
  38613. /**
  38614. * Serializes the actions and its related information.
  38615. * @param parent defines the object to serialize in
  38616. * @returns the serialized object
  38617. */
  38618. serialize(parent: any): any;
  38619. }
  38620. /**
  38621. * This defines an action helpful to stop a defined sound on a triggered action.
  38622. */
  38623. export class StopSoundAction extends Action {
  38624. private _sound;
  38625. /**
  38626. * Instantiate the action
  38627. * @param triggerOptions defines the trigger options
  38628. * @param sound defines the sound to stop
  38629. * @param condition defines the trigger related conditions
  38630. */
  38631. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38632. /** @hidden */
  38633. _prepare(): void;
  38634. /**
  38635. * Execute the action and stop the sound.
  38636. */
  38637. execute(): void;
  38638. /**
  38639. * Serializes the actions and its related information.
  38640. * @param parent defines the object to serialize in
  38641. * @returns the serialized object
  38642. */
  38643. serialize(parent: any): any;
  38644. }
  38645. }
  38646. declare module "babylonjs/Actions/interpolateValueAction" {
  38647. import { Action } from "babylonjs/Actions/action";
  38648. import { Condition } from "babylonjs/Actions/condition";
  38649. import { Observable } from "babylonjs/Misc/observable";
  38650. /**
  38651. * This defines an action responsible to change the value of a property
  38652. * by interpolating between its current value and the newly set one once triggered.
  38653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38654. */
  38655. export class InterpolateValueAction extends Action {
  38656. /**
  38657. * Defines the path of the property where the value should be interpolated
  38658. */
  38659. propertyPath: string;
  38660. /**
  38661. * Defines the target value at the end of the interpolation.
  38662. */
  38663. value: any;
  38664. /**
  38665. * Defines the time it will take for the property to interpolate to the value.
  38666. */
  38667. duration: number;
  38668. /**
  38669. * Defines if the other scene animations should be stopped when the action has been triggered
  38670. */
  38671. stopOtherAnimations?: boolean;
  38672. /**
  38673. * Defines a callback raised once the interpolation animation has been done.
  38674. */
  38675. onInterpolationDone?: () => void;
  38676. /**
  38677. * Observable triggered once the interpolation animation has been done.
  38678. */
  38679. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38680. private _target;
  38681. private _effectiveTarget;
  38682. private _property;
  38683. /**
  38684. * Instantiate the action
  38685. * @param triggerOptions defines the trigger options
  38686. * @param target defines the object containing the value to interpolate
  38687. * @param propertyPath defines the path to the property in the target object
  38688. * @param value defines the target value at the end of the interpolation
  38689. * @param duration deines the time it will take for the property to interpolate to the value.
  38690. * @param condition defines the trigger related conditions
  38691. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38692. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38693. */
  38694. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38695. /** @hidden */
  38696. _prepare(): void;
  38697. /**
  38698. * Execute the action starts the value interpolation.
  38699. */
  38700. execute(): void;
  38701. /**
  38702. * Serializes the actions and its related information.
  38703. * @param parent defines the object to serialize in
  38704. * @returns the serialized object
  38705. */
  38706. serialize(parent: any): any;
  38707. }
  38708. }
  38709. declare module "babylonjs/Actions/index" {
  38710. export * from "babylonjs/Actions/abstractActionManager";
  38711. export * from "babylonjs/Actions/action";
  38712. export * from "babylonjs/Actions/actionEvent";
  38713. export * from "babylonjs/Actions/actionManager";
  38714. export * from "babylonjs/Actions/condition";
  38715. export * from "babylonjs/Actions/directActions";
  38716. export * from "babylonjs/Actions/directAudioActions";
  38717. export * from "babylonjs/Actions/interpolateValueAction";
  38718. }
  38719. declare module "babylonjs/Animations/index" {
  38720. export * from "babylonjs/Animations/animatable";
  38721. export * from "babylonjs/Animations/animation";
  38722. export * from "babylonjs/Animations/animationGroup";
  38723. export * from "babylonjs/Animations/animationPropertiesOverride";
  38724. export * from "babylonjs/Animations/easing";
  38725. export * from "babylonjs/Animations/runtimeAnimation";
  38726. export * from "babylonjs/Animations/animationEvent";
  38727. export * from "babylonjs/Animations/animationGroup";
  38728. export * from "babylonjs/Animations/animationKey";
  38729. export * from "babylonjs/Animations/animationRange";
  38730. export * from "babylonjs/Animations/animatable.interface";
  38731. }
  38732. declare module "babylonjs/Audio/soundTrack" {
  38733. import { Sound } from "babylonjs/Audio/sound";
  38734. import { Analyser } from "babylonjs/Audio/analyser";
  38735. import { Scene } from "babylonjs/scene";
  38736. /**
  38737. * Options allowed during the creation of a sound track.
  38738. */
  38739. export interface ISoundTrackOptions {
  38740. /**
  38741. * The volume the sound track should take during creation
  38742. */
  38743. volume?: number;
  38744. /**
  38745. * Define if the sound track is the main sound track of the scene
  38746. */
  38747. mainTrack?: boolean;
  38748. }
  38749. /**
  38750. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38751. * It will be also used in a future release to apply effects on a specific track.
  38752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38753. */
  38754. export class SoundTrack {
  38755. /**
  38756. * The unique identifier of the sound track in the scene.
  38757. */
  38758. id: number;
  38759. /**
  38760. * The list of sounds included in the sound track.
  38761. */
  38762. soundCollection: Array<Sound>;
  38763. private _outputAudioNode;
  38764. private _scene;
  38765. private _connectedAnalyser;
  38766. private _options;
  38767. private _isInitialized;
  38768. /**
  38769. * Creates a new sound track.
  38770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38771. * @param scene Define the scene the sound track belongs to
  38772. * @param options
  38773. */
  38774. constructor(scene: Scene, options?: ISoundTrackOptions);
  38775. private _initializeSoundTrackAudioGraph;
  38776. /**
  38777. * Release the sound track and its associated resources
  38778. */
  38779. dispose(): void;
  38780. /**
  38781. * Adds a sound to this sound track
  38782. * @param sound define the cound to add
  38783. * @ignoreNaming
  38784. */
  38785. AddSound(sound: Sound): void;
  38786. /**
  38787. * Removes a sound to this sound track
  38788. * @param sound define the cound to remove
  38789. * @ignoreNaming
  38790. */
  38791. RemoveSound(sound: Sound): void;
  38792. /**
  38793. * Set a global volume for the full sound track.
  38794. * @param newVolume Define the new volume of the sound track
  38795. */
  38796. setVolume(newVolume: number): void;
  38797. /**
  38798. * Switch the panning model to HRTF:
  38799. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38801. */
  38802. switchPanningModelToHRTF(): void;
  38803. /**
  38804. * Switch the panning model to Equal Power:
  38805. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38807. */
  38808. switchPanningModelToEqualPower(): void;
  38809. /**
  38810. * Connect the sound track to an audio analyser allowing some amazing
  38811. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38813. * @param analyser The analyser to connect to the engine
  38814. */
  38815. connectToAnalyser(analyser: Analyser): void;
  38816. }
  38817. }
  38818. declare module "babylonjs/Audio/audioSceneComponent" {
  38819. import { Sound } from "babylonjs/Audio/sound";
  38820. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38821. import { Nullable } from "babylonjs/types";
  38822. import { Vector3 } from "babylonjs/Maths/math.vector";
  38823. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38824. import { Scene } from "babylonjs/scene";
  38825. import { AbstractScene } from "babylonjs/abstractScene";
  38826. import "babylonjs/Audio/audioEngine";
  38827. module "babylonjs/abstractScene" {
  38828. interface AbstractScene {
  38829. /**
  38830. * The list of sounds used in the scene.
  38831. */
  38832. sounds: Nullable<Array<Sound>>;
  38833. }
  38834. }
  38835. module "babylonjs/scene" {
  38836. interface Scene {
  38837. /**
  38838. * @hidden
  38839. * Backing field
  38840. */
  38841. _mainSoundTrack: SoundTrack;
  38842. /**
  38843. * The main sound track played by the scene.
  38844. * It cotains your primary collection of sounds.
  38845. */
  38846. mainSoundTrack: SoundTrack;
  38847. /**
  38848. * The list of sound tracks added to the scene
  38849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38850. */
  38851. soundTracks: Nullable<Array<SoundTrack>>;
  38852. /**
  38853. * Gets a sound using a given name
  38854. * @param name defines the name to search for
  38855. * @return the found sound or null if not found at all.
  38856. */
  38857. getSoundByName(name: string): Nullable<Sound>;
  38858. /**
  38859. * Gets or sets if audio support is enabled
  38860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38861. */
  38862. audioEnabled: boolean;
  38863. /**
  38864. * Gets or sets if audio will be output to headphones
  38865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38866. */
  38867. headphone: boolean;
  38868. /**
  38869. * Gets or sets custom audio listener position provider
  38870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38871. */
  38872. audioListenerPositionProvider: Nullable<() => Vector3>;
  38873. /**
  38874. * Gets or sets a refresh rate when using 3D audio positioning
  38875. */
  38876. audioPositioningRefreshRate: number;
  38877. }
  38878. }
  38879. /**
  38880. * Defines the sound scene component responsible to manage any sounds
  38881. * in a given scene.
  38882. */
  38883. export class AudioSceneComponent implements ISceneSerializableComponent {
  38884. /**
  38885. * The component name helpfull to identify the component in the list of scene components.
  38886. */
  38887. readonly name: string;
  38888. /**
  38889. * The scene the component belongs to.
  38890. */
  38891. scene: Scene;
  38892. private _audioEnabled;
  38893. /**
  38894. * Gets whether audio is enabled or not.
  38895. * Please use related enable/disable method to switch state.
  38896. */
  38897. get audioEnabled(): boolean;
  38898. private _headphone;
  38899. /**
  38900. * Gets whether audio is outputing to headphone or not.
  38901. * Please use the according Switch methods to change output.
  38902. */
  38903. get headphone(): boolean;
  38904. /**
  38905. * Gets or sets a refresh rate when using 3D audio positioning
  38906. */
  38907. audioPositioningRefreshRate: number;
  38908. private _audioListenerPositionProvider;
  38909. /**
  38910. * Gets the current audio listener position provider
  38911. */
  38912. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38913. /**
  38914. * Sets a custom listener position for all sounds in the scene
  38915. * By default, this is the position of the first active camera
  38916. */
  38917. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38918. /**
  38919. * Creates a new instance of the component for the given scene
  38920. * @param scene Defines the scene to register the component in
  38921. */
  38922. constructor(scene: Scene);
  38923. /**
  38924. * Registers the component in a given scene
  38925. */
  38926. register(): void;
  38927. /**
  38928. * Rebuilds the elements related to this component in case of
  38929. * context lost for instance.
  38930. */
  38931. rebuild(): void;
  38932. /**
  38933. * Serializes the component data to the specified json object
  38934. * @param serializationObject The object to serialize to
  38935. */
  38936. serialize(serializationObject: any): void;
  38937. /**
  38938. * Adds all the elements from the container to the scene
  38939. * @param container the container holding the elements
  38940. */
  38941. addFromContainer(container: AbstractScene): void;
  38942. /**
  38943. * Removes all the elements in the container from the scene
  38944. * @param container contains the elements to remove
  38945. * @param dispose if the removed element should be disposed (default: false)
  38946. */
  38947. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38948. /**
  38949. * Disposes the component and the associated ressources.
  38950. */
  38951. dispose(): void;
  38952. /**
  38953. * Disables audio in the associated scene.
  38954. */
  38955. disableAudio(): void;
  38956. /**
  38957. * Enables audio in the associated scene.
  38958. */
  38959. enableAudio(): void;
  38960. /**
  38961. * Switch audio to headphone output.
  38962. */
  38963. switchAudioModeForHeadphones(): void;
  38964. /**
  38965. * Switch audio to normal speakers.
  38966. */
  38967. switchAudioModeForNormalSpeakers(): void;
  38968. private _cachedCameraDirection;
  38969. private _cachedCameraPosition;
  38970. private _lastCheck;
  38971. private _afterRender;
  38972. }
  38973. }
  38974. declare module "babylonjs/Audio/weightedsound" {
  38975. import { Sound } from "babylonjs/Audio/sound";
  38976. /**
  38977. * Wraps one or more Sound objects and selects one with random weight for playback.
  38978. */
  38979. export class WeightedSound {
  38980. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38981. loop: boolean;
  38982. private _coneInnerAngle;
  38983. private _coneOuterAngle;
  38984. private _volume;
  38985. /** A Sound is currently playing. */
  38986. isPlaying: boolean;
  38987. /** A Sound is currently paused. */
  38988. isPaused: boolean;
  38989. private _sounds;
  38990. private _weights;
  38991. private _currentIndex?;
  38992. /**
  38993. * Creates a new WeightedSound from the list of sounds given.
  38994. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38995. * @param sounds Array of Sounds that will be selected from.
  38996. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38997. */
  38998. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38999. /**
  39000. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39001. */
  39002. get directionalConeInnerAngle(): number;
  39003. /**
  39004. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39005. */
  39006. set directionalConeInnerAngle(value: number);
  39007. /**
  39008. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39009. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39010. */
  39011. get directionalConeOuterAngle(): number;
  39012. /**
  39013. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39014. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39015. */
  39016. set directionalConeOuterAngle(value: number);
  39017. /**
  39018. * Playback volume.
  39019. */
  39020. get volume(): number;
  39021. /**
  39022. * Playback volume.
  39023. */
  39024. set volume(value: number);
  39025. private _onended;
  39026. /**
  39027. * Suspend playback
  39028. */
  39029. pause(): void;
  39030. /**
  39031. * Stop playback
  39032. */
  39033. stop(): void;
  39034. /**
  39035. * Start playback.
  39036. * @param startOffset Position the clip head at a specific time in seconds.
  39037. */
  39038. play(startOffset?: number): void;
  39039. }
  39040. }
  39041. declare module "babylonjs/Audio/index" {
  39042. export * from "babylonjs/Audio/analyser";
  39043. export * from "babylonjs/Audio/audioEngine";
  39044. export * from "babylonjs/Audio/audioSceneComponent";
  39045. export * from "babylonjs/Audio/sound";
  39046. export * from "babylonjs/Audio/soundTrack";
  39047. export * from "babylonjs/Audio/weightedsound";
  39048. }
  39049. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39050. import { Behavior } from "babylonjs/Behaviors/behavior";
  39051. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39052. import { BackEase } from "babylonjs/Animations/easing";
  39053. /**
  39054. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39056. */
  39057. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39058. /**
  39059. * Gets the name of the behavior.
  39060. */
  39061. get name(): string;
  39062. /**
  39063. * The easing function used by animations
  39064. */
  39065. static EasingFunction: BackEase;
  39066. /**
  39067. * The easing mode used by animations
  39068. */
  39069. static EasingMode: number;
  39070. /**
  39071. * The duration of the animation, in milliseconds
  39072. */
  39073. transitionDuration: number;
  39074. /**
  39075. * Length of the distance animated by the transition when lower radius is reached
  39076. */
  39077. lowerRadiusTransitionRange: number;
  39078. /**
  39079. * Length of the distance animated by the transition when upper radius is reached
  39080. */
  39081. upperRadiusTransitionRange: number;
  39082. private _autoTransitionRange;
  39083. /**
  39084. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39085. */
  39086. get autoTransitionRange(): boolean;
  39087. /**
  39088. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39089. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39090. */
  39091. set autoTransitionRange(value: boolean);
  39092. private _attachedCamera;
  39093. private _onAfterCheckInputsObserver;
  39094. private _onMeshTargetChangedObserver;
  39095. /**
  39096. * Initializes the behavior.
  39097. */
  39098. init(): void;
  39099. /**
  39100. * Attaches the behavior to its arc rotate camera.
  39101. * @param camera Defines the camera to attach the behavior to
  39102. */
  39103. attach(camera: ArcRotateCamera): void;
  39104. /**
  39105. * Detaches the behavior from its current arc rotate camera.
  39106. */
  39107. detach(): void;
  39108. private _radiusIsAnimating;
  39109. private _radiusBounceTransition;
  39110. private _animatables;
  39111. private _cachedWheelPrecision;
  39112. /**
  39113. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39114. * @param radiusLimit The limit to check against.
  39115. * @return Bool to indicate if at limit.
  39116. */
  39117. private _isRadiusAtLimit;
  39118. /**
  39119. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39120. * @param radiusDelta The delta by which to animate to. Can be negative.
  39121. */
  39122. private _applyBoundRadiusAnimation;
  39123. /**
  39124. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39125. */
  39126. protected _clearAnimationLocks(): void;
  39127. /**
  39128. * Stops and removes all animations that have been applied to the camera
  39129. */
  39130. stopAllAnimations(): void;
  39131. }
  39132. }
  39133. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39134. import { Behavior } from "babylonjs/Behaviors/behavior";
  39135. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39136. import { ExponentialEase } from "babylonjs/Animations/easing";
  39137. import { Nullable } from "babylonjs/types";
  39138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39139. import { Vector3 } from "babylonjs/Maths/math.vector";
  39140. /**
  39141. * 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.
  39142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39143. */
  39144. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39145. /**
  39146. * Gets the name of the behavior.
  39147. */
  39148. get name(): string;
  39149. private _mode;
  39150. private _radiusScale;
  39151. private _positionScale;
  39152. private _defaultElevation;
  39153. private _elevationReturnTime;
  39154. private _elevationReturnWaitTime;
  39155. private _zoomStopsAnimation;
  39156. private _framingTime;
  39157. /**
  39158. * The easing function used by animations
  39159. */
  39160. static EasingFunction: ExponentialEase;
  39161. /**
  39162. * The easing mode used by animations
  39163. */
  39164. static EasingMode: number;
  39165. /**
  39166. * Sets the current mode used by the behavior
  39167. */
  39168. set mode(mode: number);
  39169. /**
  39170. * Gets current mode used by the behavior.
  39171. */
  39172. get mode(): number;
  39173. /**
  39174. * Sets the scale applied to the radius (1 by default)
  39175. */
  39176. set radiusScale(radius: number);
  39177. /**
  39178. * Gets the scale applied to the radius
  39179. */
  39180. get radiusScale(): number;
  39181. /**
  39182. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39183. */
  39184. set positionScale(scale: number);
  39185. /**
  39186. * Gets 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. get positionScale(): number;
  39189. /**
  39190. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39191. * behaviour is triggered, in radians.
  39192. */
  39193. set defaultElevation(elevation: number);
  39194. /**
  39195. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39196. * behaviour is triggered, in radians.
  39197. */
  39198. get defaultElevation(): number;
  39199. /**
  39200. * Sets the time (in milliseconds) taken to return to the default beta position.
  39201. * Negative value indicates camera should not return to default.
  39202. */
  39203. set elevationReturnTime(speed: number);
  39204. /**
  39205. * Gets the time (in milliseconds) taken to return to the default beta position.
  39206. * Negative value indicates camera should not return to default.
  39207. */
  39208. get elevationReturnTime(): number;
  39209. /**
  39210. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39211. */
  39212. set elevationReturnWaitTime(time: number);
  39213. /**
  39214. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39215. */
  39216. get elevationReturnWaitTime(): number;
  39217. /**
  39218. * Sets the flag that indicates if user zooming should stop animation.
  39219. */
  39220. set zoomStopsAnimation(flag: boolean);
  39221. /**
  39222. * Gets the flag that indicates if user zooming should stop animation.
  39223. */
  39224. get zoomStopsAnimation(): boolean;
  39225. /**
  39226. * Sets the transition time when framing the mesh, in milliseconds
  39227. */
  39228. set framingTime(time: number);
  39229. /**
  39230. * Gets the transition time when framing the mesh, in milliseconds
  39231. */
  39232. get framingTime(): number;
  39233. /**
  39234. * Define if the behavior should automatically change the configured
  39235. * camera limits and sensibilities.
  39236. */
  39237. autoCorrectCameraLimitsAndSensibility: boolean;
  39238. private _onPrePointerObservableObserver;
  39239. private _onAfterCheckInputsObserver;
  39240. private _onMeshTargetChangedObserver;
  39241. private _attachedCamera;
  39242. private _isPointerDown;
  39243. private _lastInteractionTime;
  39244. /**
  39245. * Initializes the behavior.
  39246. */
  39247. init(): void;
  39248. /**
  39249. * Attaches the behavior to its arc rotate camera.
  39250. * @param camera Defines the camera to attach the behavior to
  39251. */
  39252. attach(camera: ArcRotateCamera): void;
  39253. /**
  39254. * Detaches the behavior from its current arc rotate camera.
  39255. */
  39256. detach(): void;
  39257. private _animatables;
  39258. private _betaIsAnimating;
  39259. private _betaTransition;
  39260. private _radiusTransition;
  39261. private _vectorTransition;
  39262. /**
  39263. * Targets the given mesh and updates zoom level accordingly.
  39264. * @param mesh The mesh to target.
  39265. * @param radius Optional. If a cached radius position already exists, overrides default.
  39266. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39267. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39268. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39269. */
  39270. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39271. /**
  39272. * Targets the given mesh with its children and updates zoom level accordingly.
  39273. * @param mesh The mesh to target.
  39274. * @param radius Optional. If a cached radius position already exists, overrides default.
  39275. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  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 radius Optional. If a cached radius position already exists, overrides default.
  39284. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39285. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39286. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39287. */
  39288. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39289. /**
  39290. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39291. * @param minimumWorld Determines the smaller position of the bounding box extend
  39292. * @param maximumWorld Determines the bigger position of the bounding box extend
  39293. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39294. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39295. */
  39296. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39297. /**
  39298. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39299. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39300. * frustum width.
  39301. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39302. * to fully enclose the mesh in the viewing frustum.
  39303. */
  39304. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39305. /**
  39306. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39307. * is automatically returned to its default position (expected to be above ground plane).
  39308. */
  39309. private _maintainCameraAboveGround;
  39310. /**
  39311. * Returns the frustum slope based on the canvas ratio and camera FOV
  39312. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39313. */
  39314. private _getFrustumSlope;
  39315. /**
  39316. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39317. */
  39318. private _clearAnimationLocks;
  39319. /**
  39320. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39321. */
  39322. private _applyUserInteraction;
  39323. /**
  39324. * Stops and removes all animations that have been applied to the camera
  39325. */
  39326. stopAllAnimations(): void;
  39327. /**
  39328. * Gets a value indicating if the user is moving the camera
  39329. */
  39330. get isUserIsMoving(): boolean;
  39331. /**
  39332. * The camera can move all the way towards the mesh.
  39333. */
  39334. static IgnoreBoundsSizeMode: number;
  39335. /**
  39336. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39337. */
  39338. static FitFrustumSidesMode: number;
  39339. }
  39340. }
  39341. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39342. import { Nullable } from "babylonjs/types";
  39343. import { Camera } from "babylonjs/Cameras/camera";
  39344. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39345. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39346. /**
  39347. * Base class for Camera Pointer Inputs.
  39348. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39349. * for example usage.
  39350. */
  39351. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39352. /**
  39353. * Defines the camera the input is attached to.
  39354. */
  39355. abstract camera: Camera;
  39356. /**
  39357. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39358. */
  39359. protected _altKey: boolean;
  39360. protected _ctrlKey: boolean;
  39361. protected _metaKey: boolean;
  39362. protected _shiftKey: boolean;
  39363. /**
  39364. * Which mouse buttons were pressed at time of last mouse event.
  39365. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39366. */
  39367. protected _buttonsPressed: number;
  39368. /**
  39369. * Defines the buttons associated with the input to handle camera move.
  39370. */
  39371. buttons: number[];
  39372. /**
  39373. * Attach the input controls to a specific dom element to get the input from.
  39374. * @param element Defines the element the controls should be listened from
  39375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39376. */
  39377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39378. /**
  39379. * Detach the current controls from the specified dom element.
  39380. * @param element Defines the element to stop listening the inputs from
  39381. */
  39382. detachControl(element: Nullable<HTMLElement>): void;
  39383. /**
  39384. * Gets the class name of the current input.
  39385. * @returns the class name
  39386. */
  39387. getClassName(): string;
  39388. /**
  39389. * Get the friendly name associated with the input class.
  39390. * @returns the input friendly name
  39391. */
  39392. getSimpleName(): string;
  39393. /**
  39394. * Called on pointer POINTERDOUBLETAP event.
  39395. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39396. */
  39397. protected onDoubleTap(type: string): void;
  39398. /**
  39399. * Called on pointer POINTERMOVE event if only a single touch is active.
  39400. * Override this method to provide functionality.
  39401. */
  39402. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39403. /**
  39404. * Called on pointer POINTERMOVE event if multiple touches are active.
  39405. * Override this method to provide functionality.
  39406. */
  39407. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39408. /**
  39409. * Called on JS contextmenu event.
  39410. * Override this method to provide functionality.
  39411. */
  39412. protected onContextMenu(evt: PointerEvent): void;
  39413. /**
  39414. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39415. * press.
  39416. * Override this method to provide functionality.
  39417. */
  39418. protected onButtonDown(evt: PointerEvent): void;
  39419. /**
  39420. * Called each time a new POINTERUP event occurs. Ie, for each button
  39421. * release.
  39422. * Override this method to provide functionality.
  39423. */
  39424. protected onButtonUp(evt: PointerEvent): void;
  39425. /**
  39426. * Called when window becomes inactive.
  39427. * Override this method to provide functionality.
  39428. */
  39429. protected onLostFocus(): void;
  39430. private _pointerInput;
  39431. private _observer;
  39432. private _onLostFocus;
  39433. private pointA;
  39434. private pointB;
  39435. }
  39436. }
  39437. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39438. import { Nullable } from "babylonjs/types";
  39439. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39440. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39441. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39442. /**
  39443. * Manage the pointers inputs to control an arc rotate camera.
  39444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39445. */
  39446. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39447. /**
  39448. * Defines the camera the input is attached to.
  39449. */
  39450. camera: ArcRotateCamera;
  39451. /**
  39452. * Gets the class name of the current input.
  39453. * @returns the class name
  39454. */
  39455. getClassName(): string;
  39456. /**
  39457. * Defines the buttons associated with the input to handle camera move.
  39458. */
  39459. buttons: number[];
  39460. /**
  39461. * Defines the pointer angular sensibility along the X axis or how fast is
  39462. * the camera rotating.
  39463. */
  39464. angularSensibilityX: number;
  39465. /**
  39466. * Defines the pointer angular sensibility along the Y axis or how fast is
  39467. * the camera rotating.
  39468. */
  39469. angularSensibilityY: number;
  39470. /**
  39471. * Defines the pointer pinch precision or how fast is the camera zooming.
  39472. */
  39473. pinchPrecision: number;
  39474. /**
  39475. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39476. * from 0.
  39477. * It defines the percentage of current camera.radius to use as delta when
  39478. * pinch zoom is used.
  39479. */
  39480. pinchDeltaPercentage: number;
  39481. /**
  39482. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39483. * that any object in the plane at the camera's target point will scale
  39484. * perfectly with finger motion.
  39485. * Overrides pinchDeltaPercentage and pinchPrecision.
  39486. */
  39487. useNaturalPinchZoom: boolean;
  39488. /**
  39489. * Defines the pointer panning sensibility or how fast is the camera moving.
  39490. */
  39491. panningSensibility: number;
  39492. /**
  39493. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39494. */
  39495. multiTouchPanning: boolean;
  39496. /**
  39497. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39498. * zoom (pinch) through multitouch.
  39499. */
  39500. multiTouchPanAndZoom: boolean;
  39501. /**
  39502. * Revers pinch action direction.
  39503. */
  39504. pinchInwards: boolean;
  39505. private _isPanClick;
  39506. private _twoFingerActivityCount;
  39507. private _isPinching;
  39508. /**
  39509. * Called on pointer POINTERMOVE event if only a single touch is active.
  39510. */
  39511. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39512. /**
  39513. * Called on pointer POINTERDOUBLETAP event.
  39514. */
  39515. protected onDoubleTap(type: string): void;
  39516. /**
  39517. * Called on pointer POINTERMOVE event if multiple touches are active.
  39518. */
  39519. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39520. /**
  39521. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39522. * press.
  39523. */
  39524. protected onButtonDown(evt: PointerEvent): void;
  39525. /**
  39526. * Called each time a new POINTERUP event occurs. Ie, for each button
  39527. * release.
  39528. */
  39529. protected onButtonUp(evt: PointerEvent): void;
  39530. /**
  39531. * Called when window becomes inactive.
  39532. */
  39533. protected onLostFocus(): void;
  39534. }
  39535. }
  39536. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39537. import { Nullable } from "babylonjs/types";
  39538. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39539. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39540. /**
  39541. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39543. */
  39544. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39545. /**
  39546. * Defines the camera the input is attached to.
  39547. */
  39548. camera: ArcRotateCamera;
  39549. /**
  39550. * Defines the list of key codes associated with the up action (increase alpha)
  39551. */
  39552. keysUp: number[];
  39553. /**
  39554. * Defines the list of key codes associated with the down action (decrease alpha)
  39555. */
  39556. keysDown: number[];
  39557. /**
  39558. * Defines the list of key codes associated with the left action (increase beta)
  39559. */
  39560. keysLeft: number[];
  39561. /**
  39562. * Defines the list of key codes associated with the right action (decrease beta)
  39563. */
  39564. keysRight: number[];
  39565. /**
  39566. * Defines the list of key codes associated with the reset action.
  39567. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39568. */
  39569. keysReset: number[];
  39570. /**
  39571. * Defines the panning sensibility of the inputs.
  39572. * (How fast is the camera panning)
  39573. */
  39574. panningSensibility: number;
  39575. /**
  39576. * Defines the zooming sensibility of the inputs.
  39577. * (How fast is the camera zooming)
  39578. */
  39579. zoomingSensibility: number;
  39580. /**
  39581. * Defines whether maintaining the alt key down switch the movement mode from
  39582. * orientation to zoom.
  39583. */
  39584. useAltToZoom: boolean;
  39585. /**
  39586. * Rotation speed of the camera
  39587. */
  39588. angularSpeed: number;
  39589. private _keys;
  39590. private _ctrlPressed;
  39591. private _altPressed;
  39592. private _onCanvasBlurObserver;
  39593. private _onKeyboardObserver;
  39594. private _engine;
  39595. private _scene;
  39596. /**
  39597. * Attach the input controls to a specific dom element to get the input from.
  39598. * @param element Defines the element the controls should be listened from
  39599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39600. */
  39601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39602. /**
  39603. * Detach the current controls from the specified dom element.
  39604. * @param element Defines the element to stop listening the inputs from
  39605. */
  39606. detachControl(element: Nullable<HTMLElement>): void;
  39607. /**
  39608. * Update the current camera state depending on the inputs that have been used this frame.
  39609. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39610. */
  39611. checkInputs(): void;
  39612. /**
  39613. * Gets the class name of the current intput.
  39614. * @returns the class name
  39615. */
  39616. getClassName(): string;
  39617. /**
  39618. * Get the friendly name associated with the input class.
  39619. * @returns the input friendly name
  39620. */
  39621. getSimpleName(): string;
  39622. }
  39623. }
  39624. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39625. import { Nullable } from "babylonjs/types";
  39626. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39627. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39628. /**
  39629. * Manage the mouse wheel inputs to control an arc rotate camera.
  39630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39631. */
  39632. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39633. /**
  39634. * Defines the camera the input is attached to.
  39635. */
  39636. camera: ArcRotateCamera;
  39637. /**
  39638. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39639. */
  39640. wheelPrecision: number;
  39641. /**
  39642. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39643. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39644. */
  39645. wheelDeltaPercentage: number;
  39646. private _wheel;
  39647. private _observer;
  39648. private computeDeltaFromMouseWheelLegacyEvent;
  39649. /**
  39650. * Attach the input controls to a specific dom element to get the input from.
  39651. * @param element Defines the element the controls should be listened from
  39652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39653. */
  39654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39655. /**
  39656. * Detach the current controls from the specified dom element.
  39657. * @param element Defines the element to stop listening the inputs from
  39658. */
  39659. detachControl(element: Nullable<HTMLElement>): void;
  39660. /**
  39661. * Gets the class name of the current intput.
  39662. * @returns the class name
  39663. */
  39664. getClassName(): string;
  39665. /**
  39666. * Get the friendly name associated with the input class.
  39667. * @returns the input friendly name
  39668. */
  39669. getSimpleName(): string;
  39670. }
  39671. }
  39672. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39673. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39674. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39675. /**
  39676. * Default Inputs manager for the ArcRotateCamera.
  39677. * It groups all the default supported inputs for ease of use.
  39678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39679. */
  39680. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39681. /**
  39682. * Instantiates a new ArcRotateCameraInputsManager.
  39683. * @param camera Defines the camera the inputs belong to
  39684. */
  39685. constructor(camera: ArcRotateCamera);
  39686. /**
  39687. * Add mouse wheel input support to the input manager.
  39688. * @returns the current input manager
  39689. */
  39690. addMouseWheel(): ArcRotateCameraInputsManager;
  39691. /**
  39692. * Add pointers input support to the input manager.
  39693. * @returns the current input manager
  39694. */
  39695. addPointers(): ArcRotateCameraInputsManager;
  39696. /**
  39697. * Add keyboard input support to the input manager.
  39698. * @returns the current input manager
  39699. */
  39700. addKeyboard(): ArcRotateCameraInputsManager;
  39701. }
  39702. }
  39703. declare module "babylonjs/Cameras/arcRotateCamera" {
  39704. import { Observable } from "babylonjs/Misc/observable";
  39705. import { Nullable } from "babylonjs/types";
  39706. import { Scene } from "babylonjs/scene";
  39707. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39709. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39710. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39711. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39712. import { Camera } from "babylonjs/Cameras/camera";
  39713. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39714. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39715. import { Collider } from "babylonjs/Collisions/collider";
  39716. /**
  39717. * This represents an orbital type of camera.
  39718. *
  39719. * 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.
  39720. * 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.
  39721. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39722. */
  39723. export class ArcRotateCamera extends TargetCamera {
  39724. /**
  39725. * Defines the rotation angle of the camera along the longitudinal axis.
  39726. */
  39727. alpha: number;
  39728. /**
  39729. * Defines the rotation angle of the camera along the latitudinal axis.
  39730. */
  39731. beta: number;
  39732. /**
  39733. * Defines the radius of the camera from it s target point.
  39734. */
  39735. radius: number;
  39736. protected _target: Vector3;
  39737. protected _targetHost: Nullable<AbstractMesh>;
  39738. /**
  39739. * Defines the target point of the camera.
  39740. * The camera looks towards it form the radius distance.
  39741. */
  39742. get target(): Vector3;
  39743. set target(value: Vector3);
  39744. /**
  39745. * Define the current local position of the camera in the scene
  39746. */
  39747. get position(): Vector3;
  39748. set position(newPosition: Vector3);
  39749. protected _upVector: Vector3;
  39750. protected _upToYMatrix: Matrix;
  39751. protected _YToUpMatrix: Matrix;
  39752. /**
  39753. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39754. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39755. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39756. */
  39757. set upVector(vec: Vector3);
  39758. get upVector(): Vector3;
  39759. /**
  39760. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39761. */
  39762. setMatUp(): void;
  39763. /**
  39764. * Current inertia value on the longitudinal axis.
  39765. * The bigger this number the longer it will take for the camera to stop.
  39766. */
  39767. inertialAlphaOffset: number;
  39768. /**
  39769. * Current inertia value on the latitudinal axis.
  39770. * The bigger this number the longer it will take for the camera to stop.
  39771. */
  39772. inertialBetaOffset: number;
  39773. /**
  39774. * Current inertia value on the radius axis.
  39775. * The bigger this number the longer it will take for the camera to stop.
  39776. */
  39777. inertialRadiusOffset: number;
  39778. /**
  39779. * Minimum allowed angle on the longitudinal axis.
  39780. * This can help limiting how the Camera is able to move in the scene.
  39781. */
  39782. lowerAlphaLimit: Nullable<number>;
  39783. /**
  39784. * Maximum allowed angle on the longitudinal axis.
  39785. * This can help limiting how the Camera is able to move in the scene.
  39786. */
  39787. upperAlphaLimit: Nullable<number>;
  39788. /**
  39789. * Minimum allowed angle on the latitudinal axis.
  39790. * This can help limiting how the Camera is able to move in the scene.
  39791. */
  39792. lowerBetaLimit: number;
  39793. /**
  39794. * Maximum allowed angle on the latitudinal axis.
  39795. * This can help limiting how the Camera is able to move in the scene.
  39796. */
  39797. upperBetaLimit: number;
  39798. /**
  39799. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39800. * This can help limiting how the Camera is able to move in the scene.
  39801. */
  39802. lowerRadiusLimit: Nullable<number>;
  39803. /**
  39804. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39805. * This can help limiting how the Camera is able to move in the scene.
  39806. */
  39807. upperRadiusLimit: Nullable<number>;
  39808. /**
  39809. * Defines the current inertia value used during panning of the camera along the X axis.
  39810. */
  39811. inertialPanningX: number;
  39812. /**
  39813. * Defines the current inertia value used during panning of the camera along the Y axis.
  39814. */
  39815. inertialPanningY: number;
  39816. /**
  39817. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39818. * Basically if your fingers moves away from more than this distance you will be considered
  39819. * in pinch mode.
  39820. */
  39821. pinchToPanMaxDistance: number;
  39822. /**
  39823. * Defines the maximum distance the camera can pan.
  39824. * This could help keeping the cammera always in your scene.
  39825. */
  39826. panningDistanceLimit: Nullable<number>;
  39827. /**
  39828. * Defines the target of the camera before paning.
  39829. */
  39830. panningOriginTarget: Vector3;
  39831. /**
  39832. * Defines the value of the inertia used during panning.
  39833. * 0 would mean stop inertia and one would mean no decelleration at all.
  39834. */
  39835. panningInertia: number;
  39836. /**
  39837. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39838. */
  39839. get angularSensibilityX(): number;
  39840. set angularSensibilityX(value: number);
  39841. /**
  39842. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39843. */
  39844. get angularSensibilityY(): number;
  39845. set angularSensibilityY(value: number);
  39846. /**
  39847. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39848. */
  39849. get pinchPrecision(): number;
  39850. set pinchPrecision(value: number);
  39851. /**
  39852. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39853. * It will be used instead of pinchDeltaPrecision if different from 0.
  39854. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39855. */
  39856. get pinchDeltaPercentage(): number;
  39857. set pinchDeltaPercentage(value: number);
  39858. /**
  39859. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39860. * and pinch delta percentage.
  39861. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39862. * that any object in the plane at the camera's target point will scale
  39863. * perfectly with finger motion.
  39864. */
  39865. get useNaturalPinchZoom(): boolean;
  39866. set useNaturalPinchZoom(value: boolean);
  39867. /**
  39868. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39869. */
  39870. get panningSensibility(): number;
  39871. set panningSensibility(value: number);
  39872. /**
  39873. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39874. */
  39875. get keysUp(): number[];
  39876. set keysUp(value: number[]);
  39877. /**
  39878. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39879. */
  39880. get keysDown(): number[];
  39881. set keysDown(value: number[]);
  39882. /**
  39883. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39884. */
  39885. get keysLeft(): number[];
  39886. set keysLeft(value: number[]);
  39887. /**
  39888. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39889. */
  39890. get keysRight(): number[];
  39891. set keysRight(value: number[]);
  39892. /**
  39893. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39894. */
  39895. get wheelPrecision(): number;
  39896. set wheelPrecision(value: number);
  39897. /**
  39898. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39899. * It will be used instead of pinchDeltaPrecision if different from 0.
  39900. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39901. */
  39902. get wheelDeltaPercentage(): number;
  39903. set wheelDeltaPercentage(value: number);
  39904. /**
  39905. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39906. */
  39907. zoomOnFactor: number;
  39908. /**
  39909. * Defines a screen offset for the camera position.
  39910. */
  39911. targetScreenOffset: Vector2;
  39912. /**
  39913. * Allows the camera to be completely reversed.
  39914. * If false the camera can not arrive upside down.
  39915. */
  39916. allowUpsideDown: boolean;
  39917. /**
  39918. * Define if double tap/click is used to restore the previously saved state of the camera.
  39919. */
  39920. useInputToRestoreState: boolean;
  39921. /** @hidden */
  39922. _viewMatrix: Matrix;
  39923. /** @hidden */
  39924. _useCtrlForPanning: boolean;
  39925. /** @hidden */
  39926. _panningMouseButton: number;
  39927. /**
  39928. * Defines the input associated to the camera.
  39929. */
  39930. inputs: ArcRotateCameraInputsManager;
  39931. /** @hidden */
  39932. _reset: () => void;
  39933. /**
  39934. * Defines the allowed panning axis.
  39935. */
  39936. panningAxis: Vector3;
  39937. protected _localDirection: Vector3;
  39938. protected _transformedDirection: Vector3;
  39939. private _bouncingBehavior;
  39940. /**
  39941. * Gets the bouncing behavior of the camera if it has been enabled.
  39942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39943. */
  39944. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39945. /**
  39946. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39948. */
  39949. get useBouncingBehavior(): boolean;
  39950. set useBouncingBehavior(value: boolean);
  39951. private _framingBehavior;
  39952. /**
  39953. * Gets the framing behavior of the camera if it has been enabled.
  39954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39955. */
  39956. get framingBehavior(): Nullable<FramingBehavior>;
  39957. /**
  39958. * Defines if the framing behavior of the camera is enabled on the camera.
  39959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39960. */
  39961. get useFramingBehavior(): boolean;
  39962. set useFramingBehavior(value: boolean);
  39963. private _autoRotationBehavior;
  39964. /**
  39965. * Gets the auto rotation behavior of the camera if it has been enabled.
  39966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39967. */
  39968. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39969. /**
  39970. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39972. */
  39973. get useAutoRotationBehavior(): boolean;
  39974. set useAutoRotationBehavior(value: boolean);
  39975. /**
  39976. * Observable triggered when the mesh target has been changed on the camera.
  39977. */
  39978. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39979. /**
  39980. * Event raised when the camera is colliding with a mesh.
  39981. */
  39982. onCollide: (collidedMesh: AbstractMesh) => void;
  39983. /**
  39984. * Defines whether the camera should check collision with the objects oh the scene.
  39985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39986. */
  39987. checkCollisions: boolean;
  39988. /**
  39989. * Defines the collision radius of the camera.
  39990. * This simulates a sphere around the camera.
  39991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39992. */
  39993. collisionRadius: Vector3;
  39994. protected _collider: Collider;
  39995. protected _previousPosition: Vector3;
  39996. protected _collisionVelocity: Vector3;
  39997. protected _newPosition: Vector3;
  39998. protected _previousAlpha: number;
  39999. protected _previousBeta: number;
  40000. protected _previousRadius: number;
  40001. protected _collisionTriggered: boolean;
  40002. protected _targetBoundingCenter: Nullable<Vector3>;
  40003. private _computationVector;
  40004. /**
  40005. * Instantiates a new ArcRotateCamera in a given scene
  40006. * @param name Defines the name of the camera
  40007. * @param alpha Defines the camera rotation along the logitudinal axis
  40008. * @param beta Defines the camera rotation along the latitudinal axis
  40009. * @param radius Defines the camera distance from its target
  40010. * @param target Defines the camera target
  40011. * @param scene Defines the scene the camera belongs to
  40012. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40013. */
  40014. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40015. /** @hidden */
  40016. _initCache(): void;
  40017. /** @hidden */
  40018. _updateCache(ignoreParentClass?: boolean): void;
  40019. protected _getTargetPosition(): Vector3;
  40020. private _storedAlpha;
  40021. private _storedBeta;
  40022. private _storedRadius;
  40023. private _storedTarget;
  40024. private _storedTargetScreenOffset;
  40025. /**
  40026. * Stores the current state of the camera (alpha, beta, radius and target)
  40027. * @returns the camera itself
  40028. */
  40029. storeState(): Camera;
  40030. /**
  40031. * @hidden
  40032. * Restored camera state. You must call storeState() first
  40033. */
  40034. _restoreStateValues(): boolean;
  40035. /** @hidden */
  40036. _isSynchronizedViewMatrix(): boolean;
  40037. /**
  40038. * Attached controls to the current camera.
  40039. * @param element Defines the element the controls should be listened from
  40040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40041. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40042. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40043. */
  40044. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40045. /**
  40046. * Detach the current controls from the camera.
  40047. * The camera will stop reacting to inputs.
  40048. * @param element Defines the element to stop listening the inputs from
  40049. */
  40050. detachControl(element: HTMLElement): void;
  40051. /** @hidden */
  40052. _checkInputs(): void;
  40053. protected _checkLimits(): void;
  40054. /**
  40055. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40056. */
  40057. rebuildAnglesAndRadius(): void;
  40058. /**
  40059. * Use a position to define the current camera related information like alpha, beta and radius
  40060. * @param position Defines the position to set the camera at
  40061. */
  40062. setPosition(position: Vector3): void;
  40063. /**
  40064. * Defines the target the camera should look at.
  40065. * This will automatically adapt alpha beta and radius to fit within the new target.
  40066. * @param target Defines the new target as a Vector or a mesh
  40067. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40068. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40069. */
  40070. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40071. /** @hidden */
  40072. _getViewMatrix(): Matrix;
  40073. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40074. /**
  40075. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40076. * @param meshes Defines the mesh to zoom on
  40077. * @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)
  40078. */
  40079. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40080. /**
  40081. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40082. * The target will be changed but the radius
  40083. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40084. * @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)
  40085. */
  40086. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40087. min: Vector3;
  40088. max: Vector3;
  40089. distance: number;
  40090. }, doNotUpdateMaxZ?: boolean): void;
  40091. /**
  40092. * @override
  40093. * Override Camera.createRigCamera
  40094. */
  40095. createRigCamera(name: string, cameraIndex: number): Camera;
  40096. /**
  40097. * @hidden
  40098. * @override
  40099. * Override Camera._updateRigCameras
  40100. */
  40101. _updateRigCameras(): void;
  40102. /**
  40103. * Destroy the camera and release the current resources hold by it.
  40104. */
  40105. dispose(): void;
  40106. /**
  40107. * Gets the current object class name.
  40108. * @return the class name
  40109. */
  40110. getClassName(): string;
  40111. }
  40112. }
  40113. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40114. import { Behavior } from "babylonjs/Behaviors/behavior";
  40115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40116. /**
  40117. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40119. */
  40120. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40121. /**
  40122. * Gets the name of the behavior.
  40123. */
  40124. get name(): string;
  40125. private _zoomStopsAnimation;
  40126. private _idleRotationSpeed;
  40127. private _idleRotationWaitTime;
  40128. private _idleRotationSpinupTime;
  40129. /**
  40130. * Sets the flag that indicates if user zooming should stop animation.
  40131. */
  40132. set zoomStopsAnimation(flag: boolean);
  40133. /**
  40134. * Gets the flag that indicates if user zooming should stop animation.
  40135. */
  40136. get zoomStopsAnimation(): boolean;
  40137. /**
  40138. * Sets the default speed at which the camera rotates around the model.
  40139. */
  40140. set idleRotationSpeed(speed: number);
  40141. /**
  40142. * Gets the default speed at which the camera rotates around the model.
  40143. */
  40144. get idleRotationSpeed(): number;
  40145. /**
  40146. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40147. */
  40148. set idleRotationWaitTime(time: number);
  40149. /**
  40150. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40151. */
  40152. get idleRotationWaitTime(): number;
  40153. /**
  40154. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40155. */
  40156. set idleRotationSpinupTime(time: number);
  40157. /**
  40158. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40159. */
  40160. get idleRotationSpinupTime(): number;
  40161. /**
  40162. * Gets a value indicating if the camera is currently rotating because of this behavior
  40163. */
  40164. get rotationInProgress(): boolean;
  40165. private _onPrePointerObservableObserver;
  40166. private _onAfterCheckInputsObserver;
  40167. private _attachedCamera;
  40168. private _isPointerDown;
  40169. private _lastFrameTime;
  40170. private _lastInteractionTime;
  40171. private _cameraRotationSpeed;
  40172. /**
  40173. * Initializes the behavior.
  40174. */
  40175. init(): void;
  40176. /**
  40177. * Attaches the behavior to its arc rotate camera.
  40178. * @param camera Defines the camera to attach the behavior to
  40179. */
  40180. attach(camera: ArcRotateCamera): void;
  40181. /**
  40182. * Detaches the behavior from its current arc rotate camera.
  40183. */
  40184. detach(): void;
  40185. /**
  40186. * Returns true if user is scrolling.
  40187. * @return true if user is scrolling.
  40188. */
  40189. private _userIsZooming;
  40190. private _lastFrameRadius;
  40191. private _shouldAnimationStopForInteraction;
  40192. /**
  40193. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40194. */
  40195. private _applyUserInteraction;
  40196. private _userIsMoving;
  40197. }
  40198. }
  40199. declare module "babylonjs/Behaviors/Cameras/index" {
  40200. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40201. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40202. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40203. }
  40204. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40205. import { Mesh } from "babylonjs/Meshes/mesh";
  40206. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40207. import { Behavior } from "babylonjs/Behaviors/behavior";
  40208. /**
  40209. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40210. */
  40211. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40212. private ui;
  40213. /**
  40214. * The name of the behavior
  40215. */
  40216. name: string;
  40217. /**
  40218. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40219. */
  40220. distanceAwayFromFace: number;
  40221. /**
  40222. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40223. */
  40224. distanceAwayFromBottomOfFace: number;
  40225. private _faceVectors;
  40226. private _target;
  40227. private _scene;
  40228. private _onRenderObserver;
  40229. private _tmpMatrix;
  40230. private _tmpVector;
  40231. /**
  40232. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40233. * @param ui The transform node that should be attched to the mesh
  40234. */
  40235. constructor(ui: TransformNode);
  40236. /**
  40237. * Initializes the behavior
  40238. */
  40239. init(): void;
  40240. private _closestFace;
  40241. private _zeroVector;
  40242. private _lookAtTmpMatrix;
  40243. private _lookAtToRef;
  40244. /**
  40245. * Attaches the AttachToBoxBehavior to the passed in mesh
  40246. * @param target The mesh that the specified node will be attached to
  40247. */
  40248. attach(target: Mesh): void;
  40249. /**
  40250. * Detaches the behavior from the mesh
  40251. */
  40252. detach(): void;
  40253. }
  40254. }
  40255. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40256. import { Behavior } from "babylonjs/Behaviors/behavior";
  40257. import { Mesh } from "babylonjs/Meshes/mesh";
  40258. /**
  40259. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40260. */
  40261. export class FadeInOutBehavior implements Behavior<Mesh> {
  40262. /**
  40263. * Time in milliseconds to delay before fading in (Default: 0)
  40264. */
  40265. delay: number;
  40266. /**
  40267. * Time in milliseconds for the mesh to fade in (Default: 300)
  40268. */
  40269. fadeInTime: number;
  40270. private _millisecondsPerFrame;
  40271. private _hovered;
  40272. private _hoverValue;
  40273. private _ownerNode;
  40274. /**
  40275. * Instatiates the FadeInOutBehavior
  40276. */
  40277. constructor();
  40278. /**
  40279. * The name of the behavior
  40280. */
  40281. get name(): string;
  40282. /**
  40283. * Initializes the behavior
  40284. */
  40285. init(): void;
  40286. /**
  40287. * Attaches the fade behavior on the passed in mesh
  40288. * @param ownerNode The mesh that will be faded in/out once attached
  40289. */
  40290. attach(ownerNode: Mesh): void;
  40291. /**
  40292. * Detaches the behavior from the mesh
  40293. */
  40294. detach(): void;
  40295. /**
  40296. * Triggers the mesh to begin fading in or out
  40297. * @param value if the object should fade in or out (true to fade in)
  40298. */
  40299. fadeIn(value: boolean): void;
  40300. private _update;
  40301. private _setAllVisibility;
  40302. }
  40303. }
  40304. declare module "babylonjs/Misc/pivotTools" {
  40305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40306. /**
  40307. * Class containing a set of static utilities functions for managing Pivots
  40308. * @hidden
  40309. */
  40310. export class PivotTools {
  40311. private static _PivotCached;
  40312. private static _OldPivotPoint;
  40313. private static _PivotTranslation;
  40314. private static _PivotTmpVector;
  40315. /** @hidden */
  40316. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40317. /** @hidden */
  40318. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40319. }
  40320. }
  40321. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40322. import { Scene } from "babylonjs/scene";
  40323. import { Vector4 } from "babylonjs/Maths/math.vector";
  40324. import { Mesh } from "babylonjs/Meshes/mesh";
  40325. import { Nullable } from "babylonjs/types";
  40326. import { Plane } from "babylonjs/Maths/math.plane";
  40327. /**
  40328. * Class containing static functions to help procedurally build meshes
  40329. */
  40330. export class PlaneBuilder {
  40331. /**
  40332. * Creates a plane mesh
  40333. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40334. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40335. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40339. * @param name defines the name of the mesh
  40340. * @param options defines the options used to create the mesh
  40341. * @param scene defines the hosting scene
  40342. * @returns the plane mesh
  40343. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40344. */
  40345. static CreatePlane(name: string, options: {
  40346. size?: number;
  40347. width?: number;
  40348. height?: number;
  40349. sideOrientation?: number;
  40350. frontUVs?: Vector4;
  40351. backUVs?: Vector4;
  40352. updatable?: boolean;
  40353. sourcePlane?: Plane;
  40354. }, scene?: Nullable<Scene>): Mesh;
  40355. }
  40356. }
  40357. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40358. import { Behavior } from "babylonjs/Behaviors/behavior";
  40359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40360. import { Observable } from "babylonjs/Misc/observable";
  40361. import { Vector3 } from "babylonjs/Maths/math.vector";
  40362. import { Ray } from "babylonjs/Culling/ray";
  40363. import "babylonjs/Meshes/Builders/planeBuilder";
  40364. /**
  40365. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40366. */
  40367. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40368. private static _AnyMouseID;
  40369. /**
  40370. * Abstract mesh the behavior is set on
  40371. */
  40372. attachedNode: AbstractMesh;
  40373. private _dragPlane;
  40374. private _scene;
  40375. private _pointerObserver;
  40376. private _beforeRenderObserver;
  40377. private static _planeScene;
  40378. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40379. /**
  40380. * 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)
  40381. */
  40382. maxDragAngle: number;
  40383. /**
  40384. * @hidden
  40385. */
  40386. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40387. /**
  40388. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40389. */
  40390. currentDraggingPointerID: number;
  40391. /**
  40392. * The last position where the pointer hit the drag plane in world space
  40393. */
  40394. lastDragPosition: Vector3;
  40395. /**
  40396. * If the behavior is currently in a dragging state
  40397. */
  40398. dragging: boolean;
  40399. /**
  40400. * 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)
  40401. */
  40402. dragDeltaRatio: number;
  40403. /**
  40404. * If the drag plane orientation should be updated during the dragging (Default: true)
  40405. */
  40406. updateDragPlane: boolean;
  40407. private _debugMode;
  40408. private _moving;
  40409. /**
  40410. * Fires each time the attached mesh is dragged with the pointer
  40411. * * delta between last drag position and current drag position in world space
  40412. * * dragDistance along the drag axis
  40413. * * dragPlaneNormal normal of the current drag plane used during the drag
  40414. * * dragPlanePoint in world space where the drag intersects the drag plane
  40415. */
  40416. onDragObservable: Observable<{
  40417. delta: Vector3;
  40418. dragPlanePoint: Vector3;
  40419. dragPlaneNormal: Vector3;
  40420. dragDistance: number;
  40421. pointerId: number;
  40422. }>;
  40423. /**
  40424. * Fires each time a drag begins (eg. mouse down on mesh)
  40425. */
  40426. onDragStartObservable: Observable<{
  40427. dragPlanePoint: Vector3;
  40428. pointerId: number;
  40429. }>;
  40430. /**
  40431. * Fires each time a drag ends (eg. mouse release after drag)
  40432. */
  40433. onDragEndObservable: Observable<{
  40434. dragPlanePoint: Vector3;
  40435. pointerId: number;
  40436. }>;
  40437. /**
  40438. * If the attached mesh should be moved when dragged
  40439. */
  40440. moveAttached: boolean;
  40441. /**
  40442. * If the drag behavior will react to drag events (Default: true)
  40443. */
  40444. enabled: boolean;
  40445. /**
  40446. * If pointer events should start and release the drag (Default: true)
  40447. */
  40448. startAndReleaseDragOnPointerEvents: boolean;
  40449. /**
  40450. * If camera controls should be detached during the drag
  40451. */
  40452. detachCameraControls: boolean;
  40453. /**
  40454. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40455. */
  40456. useObjectOrientationForDragging: boolean;
  40457. private _options;
  40458. /**
  40459. * Gets the options used by the behavior
  40460. */
  40461. get options(): {
  40462. dragAxis?: Vector3;
  40463. dragPlaneNormal?: Vector3;
  40464. };
  40465. /**
  40466. * Sets the options used by the behavior
  40467. */
  40468. set options(options: {
  40469. dragAxis?: Vector3;
  40470. dragPlaneNormal?: Vector3;
  40471. });
  40472. /**
  40473. * Creates a pointer drag behavior that can be attached to a mesh
  40474. * @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)
  40475. */
  40476. constructor(options?: {
  40477. dragAxis?: Vector3;
  40478. dragPlaneNormal?: Vector3;
  40479. });
  40480. /**
  40481. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40482. */
  40483. validateDrag: (targetPosition: Vector3) => boolean;
  40484. /**
  40485. * The name of the behavior
  40486. */
  40487. get name(): string;
  40488. /**
  40489. * Initializes the behavior
  40490. */
  40491. init(): void;
  40492. private _tmpVector;
  40493. private _alternatePickedPoint;
  40494. private _worldDragAxis;
  40495. private _targetPosition;
  40496. private _attachedElement;
  40497. /**
  40498. * Attaches the drag behavior the passed in mesh
  40499. * @param ownerNode The mesh that will be dragged around once attached
  40500. * @param predicate Predicate to use for pick filtering
  40501. */
  40502. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40503. /**
  40504. * Force relase the drag action by code.
  40505. */
  40506. releaseDrag(): void;
  40507. private _startDragRay;
  40508. private _lastPointerRay;
  40509. /**
  40510. * Simulates the start of a pointer drag event on the behavior
  40511. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40512. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40513. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40514. */
  40515. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40516. private _startDrag;
  40517. private _dragDelta;
  40518. private _moveDrag;
  40519. private _pickWithRayOnDragPlane;
  40520. private _pointA;
  40521. private _pointB;
  40522. private _pointC;
  40523. private _lineA;
  40524. private _lineB;
  40525. private _localAxis;
  40526. private _lookAt;
  40527. private _updateDragPlanePosition;
  40528. /**
  40529. * Detaches the behavior from the mesh
  40530. */
  40531. detach(): void;
  40532. }
  40533. }
  40534. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40535. import { Mesh } from "babylonjs/Meshes/mesh";
  40536. import { Behavior } from "babylonjs/Behaviors/behavior";
  40537. /**
  40538. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40539. */
  40540. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40541. private _dragBehaviorA;
  40542. private _dragBehaviorB;
  40543. private _startDistance;
  40544. private _initialScale;
  40545. private _targetScale;
  40546. private _ownerNode;
  40547. private _sceneRenderObserver;
  40548. /**
  40549. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40550. */
  40551. constructor();
  40552. /**
  40553. * The name of the behavior
  40554. */
  40555. get name(): string;
  40556. /**
  40557. * Initializes the behavior
  40558. */
  40559. init(): void;
  40560. private _getCurrentDistance;
  40561. /**
  40562. * Attaches the scale behavior the passed in mesh
  40563. * @param ownerNode The mesh that will be scaled around once attached
  40564. */
  40565. attach(ownerNode: Mesh): void;
  40566. /**
  40567. * Detaches the behavior from the mesh
  40568. */
  40569. detach(): void;
  40570. }
  40571. }
  40572. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40573. import { Behavior } from "babylonjs/Behaviors/behavior";
  40574. import { Mesh } from "babylonjs/Meshes/mesh";
  40575. import { Observable } from "babylonjs/Misc/observable";
  40576. /**
  40577. * 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
  40578. */
  40579. export class SixDofDragBehavior implements Behavior<Mesh> {
  40580. private static _virtualScene;
  40581. private _ownerNode;
  40582. private _sceneRenderObserver;
  40583. private _scene;
  40584. private _targetPosition;
  40585. private _virtualOriginMesh;
  40586. private _virtualDragMesh;
  40587. private _pointerObserver;
  40588. private _moving;
  40589. private _startingOrientation;
  40590. /**
  40591. * 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)
  40592. */
  40593. private zDragFactor;
  40594. /**
  40595. * If the object should rotate to face the drag origin
  40596. */
  40597. rotateDraggedObject: boolean;
  40598. /**
  40599. * If the behavior is currently in a dragging state
  40600. */
  40601. dragging: boolean;
  40602. /**
  40603. * 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)
  40604. */
  40605. dragDeltaRatio: number;
  40606. /**
  40607. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40608. */
  40609. currentDraggingPointerID: number;
  40610. /**
  40611. * If camera controls should be detached during the drag
  40612. */
  40613. detachCameraControls: boolean;
  40614. /**
  40615. * Fires each time a drag starts
  40616. */
  40617. onDragStartObservable: Observable<{}>;
  40618. /**
  40619. * Fires each time a drag ends (eg. mouse release after drag)
  40620. */
  40621. onDragEndObservable: Observable<{}>;
  40622. /**
  40623. * 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
  40624. */
  40625. constructor();
  40626. /**
  40627. * The name of the behavior
  40628. */
  40629. get name(): string;
  40630. /**
  40631. * Initializes the behavior
  40632. */
  40633. init(): void;
  40634. /**
  40635. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40636. */
  40637. private get _pointerCamera();
  40638. /**
  40639. * Attaches the scale behavior the passed in mesh
  40640. * @param ownerNode The mesh that will be scaled around once attached
  40641. */
  40642. attach(ownerNode: Mesh): void;
  40643. /**
  40644. * Detaches the behavior from the mesh
  40645. */
  40646. detach(): void;
  40647. }
  40648. }
  40649. declare module "babylonjs/Behaviors/Meshes/index" {
  40650. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40651. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40652. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40653. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40654. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40655. }
  40656. declare module "babylonjs/Behaviors/index" {
  40657. export * from "babylonjs/Behaviors/behavior";
  40658. export * from "babylonjs/Behaviors/Cameras/index";
  40659. export * from "babylonjs/Behaviors/Meshes/index";
  40660. }
  40661. declare module "babylonjs/Bones/boneIKController" {
  40662. import { Bone } from "babylonjs/Bones/bone";
  40663. import { Vector3 } from "babylonjs/Maths/math.vector";
  40664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40665. import { Nullable } from "babylonjs/types";
  40666. /**
  40667. * Class used to apply inverse kinematics to bones
  40668. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40669. */
  40670. export class BoneIKController {
  40671. private static _tmpVecs;
  40672. private static _tmpQuat;
  40673. private static _tmpMats;
  40674. /**
  40675. * Gets or sets the target mesh
  40676. */
  40677. targetMesh: AbstractMesh;
  40678. /** Gets or sets the mesh used as pole */
  40679. poleTargetMesh: AbstractMesh;
  40680. /**
  40681. * Gets or sets the bone used as pole
  40682. */
  40683. poleTargetBone: Nullable<Bone>;
  40684. /**
  40685. * Gets or sets the target position
  40686. */
  40687. targetPosition: Vector3;
  40688. /**
  40689. * Gets or sets the pole target position
  40690. */
  40691. poleTargetPosition: Vector3;
  40692. /**
  40693. * Gets or sets the pole target local offset
  40694. */
  40695. poleTargetLocalOffset: Vector3;
  40696. /**
  40697. * Gets or sets the pole angle
  40698. */
  40699. poleAngle: number;
  40700. /**
  40701. * Gets or sets the mesh associated with the controller
  40702. */
  40703. mesh: AbstractMesh;
  40704. /**
  40705. * 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)
  40706. */
  40707. slerpAmount: number;
  40708. private _bone1Quat;
  40709. private _bone1Mat;
  40710. private _bone2Ang;
  40711. private _bone1;
  40712. private _bone2;
  40713. private _bone1Length;
  40714. private _bone2Length;
  40715. private _maxAngle;
  40716. private _maxReach;
  40717. private _rightHandedSystem;
  40718. private _bendAxis;
  40719. private _slerping;
  40720. private _adjustRoll;
  40721. /**
  40722. * Gets or sets maximum allowed angle
  40723. */
  40724. get maxAngle(): number;
  40725. set maxAngle(value: number);
  40726. /**
  40727. * Creates a new BoneIKController
  40728. * @param mesh defines the mesh to control
  40729. * @param bone defines the bone to control
  40730. * @param options defines options to set up the controller
  40731. */
  40732. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40733. targetMesh?: AbstractMesh;
  40734. poleTargetMesh?: AbstractMesh;
  40735. poleTargetBone?: Bone;
  40736. poleTargetLocalOffset?: Vector3;
  40737. poleAngle?: number;
  40738. bendAxis?: Vector3;
  40739. maxAngle?: number;
  40740. slerpAmount?: number;
  40741. });
  40742. private _setMaxAngle;
  40743. /**
  40744. * Force the controller to update the bones
  40745. */
  40746. update(): void;
  40747. }
  40748. }
  40749. declare module "babylonjs/Bones/boneLookController" {
  40750. import { Vector3 } from "babylonjs/Maths/math.vector";
  40751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40752. import { Bone } from "babylonjs/Bones/bone";
  40753. import { Space } from "babylonjs/Maths/math.axis";
  40754. /**
  40755. * Class used to make a bone look toward a point in space
  40756. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40757. */
  40758. export class BoneLookController {
  40759. private static _tmpVecs;
  40760. private static _tmpQuat;
  40761. private static _tmpMats;
  40762. /**
  40763. * The target Vector3 that the bone will look at
  40764. */
  40765. target: Vector3;
  40766. /**
  40767. * The mesh that the bone is attached to
  40768. */
  40769. mesh: AbstractMesh;
  40770. /**
  40771. * The bone that will be looking to the target
  40772. */
  40773. bone: Bone;
  40774. /**
  40775. * The up axis of the coordinate system that is used when the bone is rotated
  40776. */
  40777. upAxis: Vector3;
  40778. /**
  40779. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40780. */
  40781. upAxisSpace: Space;
  40782. /**
  40783. * Used to make an adjustment to the yaw of the bone
  40784. */
  40785. adjustYaw: number;
  40786. /**
  40787. * Used to make an adjustment to the pitch of the bone
  40788. */
  40789. adjustPitch: number;
  40790. /**
  40791. * Used to make an adjustment to the roll of the bone
  40792. */
  40793. adjustRoll: number;
  40794. /**
  40795. * 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)
  40796. */
  40797. slerpAmount: number;
  40798. private _minYaw;
  40799. private _maxYaw;
  40800. private _minPitch;
  40801. private _maxPitch;
  40802. private _minYawSin;
  40803. private _minYawCos;
  40804. private _maxYawSin;
  40805. private _maxYawCos;
  40806. private _midYawConstraint;
  40807. private _minPitchTan;
  40808. private _maxPitchTan;
  40809. private _boneQuat;
  40810. private _slerping;
  40811. private _transformYawPitch;
  40812. private _transformYawPitchInv;
  40813. private _firstFrameSkipped;
  40814. private _yawRange;
  40815. private _fowardAxis;
  40816. /**
  40817. * Gets or sets the minimum yaw angle that the bone can look to
  40818. */
  40819. get minYaw(): number;
  40820. set minYaw(value: number);
  40821. /**
  40822. * Gets or sets the maximum yaw angle that the bone can look to
  40823. */
  40824. get maxYaw(): number;
  40825. set maxYaw(value: number);
  40826. /**
  40827. * Gets or sets the minimum pitch angle that the bone can look to
  40828. */
  40829. get minPitch(): number;
  40830. set minPitch(value: number);
  40831. /**
  40832. * Gets or sets the maximum pitch angle that the bone can look to
  40833. */
  40834. get maxPitch(): number;
  40835. set maxPitch(value: number);
  40836. /**
  40837. * Create a BoneLookController
  40838. * @param mesh the mesh that the bone belongs to
  40839. * @param bone the bone that will be looking to the target
  40840. * @param target the target Vector3 to look at
  40841. * @param options optional settings:
  40842. * * maxYaw: the maximum angle the bone will yaw to
  40843. * * minYaw: the minimum angle the bone will yaw to
  40844. * * maxPitch: the maximum angle the bone will pitch to
  40845. * * minPitch: the minimum angle the bone will yaw to
  40846. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40847. * * upAxis: the up axis of the coordinate system
  40848. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40849. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40850. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40851. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40852. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40853. * * adjustRoll: used to make an adjustment to the roll of the bone
  40854. **/
  40855. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40856. maxYaw?: number;
  40857. minYaw?: number;
  40858. maxPitch?: number;
  40859. minPitch?: number;
  40860. slerpAmount?: number;
  40861. upAxis?: Vector3;
  40862. upAxisSpace?: Space;
  40863. yawAxis?: Vector3;
  40864. pitchAxis?: Vector3;
  40865. adjustYaw?: number;
  40866. adjustPitch?: number;
  40867. adjustRoll?: number;
  40868. });
  40869. /**
  40870. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40871. */
  40872. update(): void;
  40873. private _getAngleDiff;
  40874. private _getAngleBetween;
  40875. private _isAngleBetween;
  40876. }
  40877. }
  40878. declare module "babylonjs/Bones/index" {
  40879. export * from "babylonjs/Bones/bone";
  40880. export * from "babylonjs/Bones/boneIKController";
  40881. export * from "babylonjs/Bones/boneLookController";
  40882. export * from "babylonjs/Bones/skeleton";
  40883. }
  40884. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40885. import { Nullable } from "babylonjs/types";
  40886. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40887. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40888. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40889. /**
  40890. * Manage the gamepad inputs to control an arc rotate camera.
  40891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40892. */
  40893. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40894. /**
  40895. * Defines the camera the input is attached to.
  40896. */
  40897. camera: ArcRotateCamera;
  40898. /**
  40899. * Defines the gamepad the input is gathering event from.
  40900. */
  40901. gamepad: Nullable<Gamepad>;
  40902. /**
  40903. * Defines the gamepad rotation sensiblity.
  40904. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40905. */
  40906. gamepadRotationSensibility: number;
  40907. /**
  40908. * Defines the gamepad move sensiblity.
  40909. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40910. */
  40911. gamepadMoveSensibility: number;
  40912. private _yAxisScale;
  40913. /**
  40914. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40915. */
  40916. get invertYAxis(): boolean;
  40917. set invertYAxis(value: boolean);
  40918. private _onGamepadConnectedObserver;
  40919. private _onGamepadDisconnectedObserver;
  40920. /**
  40921. * Attach the input controls to a specific dom element to get the input from.
  40922. * @param element Defines the element the controls should be listened from
  40923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40924. */
  40925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40926. /**
  40927. * Detach the current controls from the specified dom element.
  40928. * @param element Defines the element to stop listening the inputs from
  40929. */
  40930. detachControl(element: Nullable<HTMLElement>): void;
  40931. /**
  40932. * Update the current camera state depending on the inputs that have been used this frame.
  40933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40934. */
  40935. checkInputs(): void;
  40936. /**
  40937. * Gets the class name of the current intput.
  40938. * @returns the class name
  40939. */
  40940. getClassName(): string;
  40941. /**
  40942. * Get the friendly name associated with the input class.
  40943. * @returns the input friendly name
  40944. */
  40945. getSimpleName(): string;
  40946. }
  40947. }
  40948. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40949. import { Nullable } from "babylonjs/types";
  40950. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40951. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40952. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40953. interface ArcRotateCameraInputsManager {
  40954. /**
  40955. * Add orientation input support to the input manager.
  40956. * @returns the current input manager
  40957. */
  40958. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40959. }
  40960. }
  40961. /**
  40962. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40964. */
  40965. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40966. /**
  40967. * Defines the camera the input is attached to.
  40968. */
  40969. camera: ArcRotateCamera;
  40970. /**
  40971. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40972. */
  40973. alphaCorrection: number;
  40974. /**
  40975. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40976. */
  40977. gammaCorrection: number;
  40978. private _alpha;
  40979. private _gamma;
  40980. private _dirty;
  40981. private _deviceOrientationHandler;
  40982. /**
  40983. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40984. */
  40985. constructor();
  40986. /**
  40987. * Attach the input controls to a specific dom element to get the input from.
  40988. * @param element Defines the element the controls should be listened from
  40989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40990. */
  40991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40992. /** @hidden */
  40993. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40994. /**
  40995. * Update the current camera state depending on the inputs that have been used this frame.
  40996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40997. */
  40998. checkInputs(): void;
  40999. /**
  41000. * Detach the current controls from the specified dom element.
  41001. * @param element Defines the element to stop listening the inputs from
  41002. */
  41003. detachControl(element: Nullable<HTMLElement>): void;
  41004. /**
  41005. * Gets the class name of the current intput.
  41006. * @returns the class name
  41007. */
  41008. getClassName(): string;
  41009. /**
  41010. * Get the friendly name associated with the input class.
  41011. * @returns the input friendly name
  41012. */
  41013. getSimpleName(): string;
  41014. }
  41015. }
  41016. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41017. import { Nullable } from "babylonjs/types";
  41018. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41019. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41020. /**
  41021. * Listen to mouse events to control the camera.
  41022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41023. */
  41024. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41025. /**
  41026. * Defines the camera the input is attached to.
  41027. */
  41028. camera: FlyCamera;
  41029. /**
  41030. * Defines if touch is enabled. (Default is true.)
  41031. */
  41032. touchEnabled: boolean;
  41033. /**
  41034. * Defines the buttons associated with the input to handle camera rotation.
  41035. */
  41036. buttons: number[];
  41037. /**
  41038. * Assign buttons for Yaw control.
  41039. */
  41040. buttonsYaw: number[];
  41041. /**
  41042. * Assign buttons for Pitch control.
  41043. */
  41044. buttonsPitch: number[];
  41045. /**
  41046. * Assign buttons for Roll control.
  41047. */
  41048. buttonsRoll: number[];
  41049. /**
  41050. * Detect if any button is being pressed while mouse is moved.
  41051. * -1 = Mouse locked.
  41052. * 0 = Left button.
  41053. * 1 = Middle Button.
  41054. * 2 = Right Button.
  41055. */
  41056. activeButton: number;
  41057. /**
  41058. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41059. * Higher values reduce its sensitivity.
  41060. */
  41061. angularSensibility: number;
  41062. private _mousemoveCallback;
  41063. private _observer;
  41064. private _rollObserver;
  41065. private previousPosition;
  41066. private noPreventDefault;
  41067. private element;
  41068. /**
  41069. * Listen to mouse events to control the camera.
  41070. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41072. */
  41073. constructor(touchEnabled?: boolean);
  41074. /**
  41075. * Attach the mouse control to the HTML DOM element.
  41076. * @param element Defines the element that listens to the input events.
  41077. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41078. */
  41079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41080. /**
  41081. * Detach the current controls from the specified dom element.
  41082. * @param element Defines the element to stop listening the inputs from
  41083. */
  41084. detachControl(element: Nullable<HTMLElement>): void;
  41085. /**
  41086. * Gets the class name of the current input.
  41087. * @returns the class name.
  41088. */
  41089. getClassName(): string;
  41090. /**
  41091. * Get the friendly name associated with the input class.
  41092. * @returns the input's friendly name.
  41093. */
  41094. getSimpleName(): string;
  41095. private _pointerInput;
  41096. private _onMouseMove;
  41097. /**
  41098. * Rotate camera by mouse offset.
  41099. */
  41100. private rotateCamera;
  41101. }
  41102. }
  41103. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41104. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41105. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41106. /**
  41107. * Default Inputs manager for the FlyCamera.
  41108. * It groups all the default supported inputs for ease of use.
  41109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41110. */
  41111. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41112. /**
  41113. * Instantiates a new FlyCameraInputsManager.
  41114. * @param camera Defines the camera the inputs belong to.
  41115. */
  41116. constructor(camera: FlyCamera);
  41117. /**
  41118. * Add keyboard input support to the input manager.
  41119. * @returns the new FlyCameraKeyboardMoveInput().
  41120. */
  41121. addKeyboard(): FlyCameraInputsManager;
  41122. /**
  41123. * Add mouse input support to the input manager.
  41124. * @param touchEnabled Enable touch screen support.
  41125. * @returns the new FlyCameraMouseInput().
  41126. */
  41127. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41128. }
  41129. }
  41130. declare module "babylonjs/Cameras/flyCamera" {
  41131. import { Scene } from "babylonjs/scene";
  41132. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41134. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41135. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41136. /**
  41137. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41138. * such as in a 3D Space Shooter or a Flight Simulator.
  41139. */
  41140. export class FlyCamera extends TargetCamera {
  41141. /**
  41142. * Define the collision ellipsoid of the camera.
  41143. * This is helpful for simulating a camera body, like a player's body.
  41144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41145. */
  41146. ellipsoid: Vector3;
  41147. /**
  41148. * Define an offset for the position of the ellipsoid around the camera.
  41149. * This can be helpful if the camera is attached away from the player's body center,
  41150. * such as at its head.
  41151. */
  41152. ellipsoidOffset: Vector3;
  41153. /**
  41154. * Enable or disable collisions of the camera with the rest of the scene objects.
  41155. */
  41156. checkCollisions: boolean;
  41157. /**
  41158. * Enable or disable gravity on the camera.
  41159. */
  41160. applyGravity: boolean;
  41161. /**
  41162. * Define the current direction the camera is moving to.
  41163. */
  41164. cameraDirection: Vector3;
  41165. /**
  41166. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41167. * This overrides and empties cameraRotation.
  41168. */
  41169. rotationQuaternion: Quaternion;
  41170. /**
  41171. * Track Roll to maintain the wanted Rolling when looking around.
  41172. */
  41173. _trackRoll: number;
  41174. /**
  41175. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41176. */
  41177. rollCorrect: number;
  41178. /**
  41179. * Mimic a banked turn, Rolling the camera when Yawing.
  41180. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41181. */
  41182. bankedTurn: boolean;
  41183. /**
  41184. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41185. */
  41186. bankedTurnLimit: number;
  41187. /**
  41188. * Value of 0 disables the banked Roll.
  41189. * Value of 1 is equal to the Yaw angle in radians.
  41190. */
  41191. bankedTurnMultiplier: number;
  41192. /**
  41193. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41194. */
  41195. inputs: FlyCameraInputsManager;
  41196. /**
  41197. * Gets the input sensibility for mouse input.
  41198. * Higher values reduce sensitivity.
  41199. */
  41200. get angularSensibility(): number;
  41201. /**
  41202. * Sets the input sensibility for a mouse input.
  41203. * Higher values reduce sensitivity.
  41204. */
  41205. set angularSensibility(value: number);
  41206. /**
  41207. * Get the keys for camera movement forward.
  41208. */
  41209. get keysForward(): number[];
  41210. /**
  41211. * Set the keys for camera movement forward.
  41212. */
  41213. set keysForward(value: number[]);
  41214. /**
  41215. * Get the keys for camera movement backward.
  41216. */
  41217. get keysBackward(): number[];
  41218. set keysBackward(value: number[]);
  41219. /**
  41220. * Get the keys for camera movement up.
  41221. */
  41222. get keysUp(): number[];
  41223. /**
  41224. * Set the keys for camera movement up.
  41225. */
  41226. set keysUp(value: number[]);
  41227. /**
  41228. * Get the keys for camera movement down.
  41229. */
  41230. get keysDown(): number[];
  41231. /**
  41232. * Set the keys for camera movement down.
  41233. */
  41234. set keysDown(value: number[]);
  41235. /**
  41236. * Get the keys for camera movement left.
  41237. */
  41238. get keysLeft(): number[];
  41239. /**
  41240. * Set the keys for camera movement left.
  41241. */
  41242. set keysLeft(value: number[]);
  41243. /**
  41244. * Set the keys for camera movement right.
  41245. */
  41246. get keysRight(): number[];
  41247. /**
  41248. * Set the keys for camera movement right.
  41249. */
  41250. set keysRight(value: number[]);
  41251. /**
  41252. * Event raised when the camera collides with a mesh in the scene.
  41253. */
  41254. onCollide: (collidedMesh: AbstractMesh) => void;
  41255. private _collider;
  41256. private _needMoveForGravity;
  41257. private _oldPosition;
  41258. private _diffPosition;
  41259. private _newPosition;
  41260. /** @hidden */
  41261. _localDirection: Vector3;
  41262. /** @hidden */
  41263. _transformedDirection: Vector3;
  41264. /**
  41265. * Instantiates a FlyCamera.
  41266. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41267. * such as in a 3D Space Shooter or a Flight Simulator.
  41268. * @param name Define the name of the camera in the scene.
  41269. * @param position Define the starting position of the camera in the scene.
  41270. * @param scene Define the scene the camera belongs to.
  41271. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41272. */
  41273. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41274. /**
  41275. * Attach a control to the HTML DOM element.
  41276. * @param element Defines the element that listens to the input events.
  41277. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41278. */
  41279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41280. /**
  41281. * Detach a control from the HTML DOM element.
  41282. * The camera will stop reacting to that input.
  41283. * @param element Defines the element that listens to the input events.
  41284. */
  41285. detachControl(element: HTMLElement): void;
  41286. private _collisionMask;
  41287. /**
  41288. * Get the mask that the camera ignores in collision events.
  41289. */
  41290. get collisionMask(): number;
  41291. /**
  41292. * Set the mask that the camera ignores in collision events.
  41293. */
  41294. set collisionMask(mask: number);
  41295. /** @hidden */
  41296. _collideWithWorld(displacement: Vector3): void;
  41297. /** @hidden */
  41298. private _onCollisionPositionChange;
  41299. /** @hidden */
  41300. _checkInputs(): void;
  41301. /** @hidden */
  41302. _decideIfNeedsToMove(): boolean;
  41303. /** @hidden */
  41304. _updatePosition(): void;
  41305. /**
  41306. * Restore the Roll to its target value at the rate specified.
  41307. * @param rate - Higher means slower restoring.
  41308. * @hidden
  41309. */
  41310. restoreRoll(rate: number): void;
  41311. /**
  41312. * Destroy the camera and release the current resources held by it.
  41313. */
  41314. dispose(): void;
  41315. /**
  41316. * Get the current object class name.
  41317. * @returns the class name.
  41318. */
  41319. getClassName(): string;
  41320. }
  41321. }
  41322. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41323. import { Nullable } from "babylonjs/types";
  41324. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41325. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41326. /**
  41327. * Listen to keyboard events to control the camera.
  41328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41329. */
  41330. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41331. /**
  41332. * Defines the camera the input is attached to.
  41333. */
  41334. camera: FlyCamera;
  41335. /**
  41336. * The list of keyboard keys used to control the forward move of the camera.
  41337. */
  41338. keysForward: number[];
  41339. /**
  41340. * The list of keyboard keys used to control the backward move of the camera.
  41341. */
  41342. keysBackward: number[];
  41343. /**
  41344. * The list of keyboard keys used to control the forward move of the camera.
  41345. */
  41346. keysUp: number[];
  41347. /**
  41348. * The list of keyboard keys used to control the backward move of the camera.
  41349. */
  41350. keysDown: number[];
  41351. /**
  41352. * The list of keyboard keys used to control the right strafe move of the camera.
  41353. */
  41354. keysRight: number[];
  41355. /**
  41356. * The list of keyboard keys used to control the left strafe move of the camera.
  41357. */
  41358. keysLeft: number[];
  41359. private _keys;
  41360. private _onCanvasBlurObserver;
  41361. private _onKeyboardObserver;
  41362. private _engine;
  41363. private _scene;
  41364. /**
  41365. * Attach the input controls to a specific dom element to get the input from.
  41366. * @param element Defines the element the controls should be listened from
  41367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41368. */
  41369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41370. /**
  41371. * Detach the current controls from the specified dom element.
  41372. * @param element Defines the element to stop listening the inputs from
  41373. */
  41374. detachControl(element: Nullable<HTMLElement>): void;
  41375. /**
  41376. * Gets the class name of the current intput.
  41377. * @returns the class name
  41378. */
  41379. getClassName(): string;
  41380. /** @hidden */
  41381. _onLostFocus(e: FocusEvent): void;
  41382. /**
  41383. * Get the friendly name associated with the input class.
  41384. * @returns the input friendly name
  41385. */
  41386. getSimpleName(): string;
  41387. /**
  41388. * Update the current camera state depending on the inputs that have been used this frame.
  41389. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41390. */
  41391. checkInputs(): void;
  41392. }
  41393. }
  41394. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41395. import { Nullable } from "babylonjs/types";
  41396. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41397. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41398. /**
  41399. * Manage the mouse wheel inputs to control a follow camera.
  41400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41401. */
  41402. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41403. /**
  41404. * Defines the camera the input is attached to.
  41405. */
  41406. camera: FollowCamera;
  41407. /**
  41408. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41409. */
  41410. axisControlRadius: boolean;
  41411. /**
  41412. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41413. */
  41414. axisControlHeight: boolean;
  41415. /**
  41416. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41417. */
  41418. axisControlRotation: boolean;
  41419. /**
  41420. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41421. * relation to mouseWheel events.
  41422. */
  41423. wheelPrecision: number;
  41424. /**
  41425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41427. */
  41428. wheelDeltaPercentage: number;
  41429. private _wheel;
  41430. private _observer;
  41431. /**
  41432. * Attach the input controls to a specific dom element to get the input from.
  41433. * @param element Defines the element the controls should be listened from
  41434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41435. */
  41436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41437. /**
  41438. * Detach the current controls from the specified dom element.
  41439. * @param element Defines the element to stop listening the inputs from
  41440. */
  41441. detachControl(element: Nullable<HTMLElement>): void;
  41442. /**
  41443. * Gets the class name of the current intput.
  41444. * @returns the class name
  41445. */
  41446. getClassName(): string;
  41447. /**
  41448. * Get the friendly name associated with the input class.
  41449. * @returns the input friendly name
  41450. */
  41451. getSimpleName(): string;
  41452. }
  41453. }
  41454. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41455. import { Nullable } from "babylonjs/types";
  41456. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41457. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41458. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41459. /**
  41460. * Manage the pointers inputs to control an follow camera.
  41461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41462. */
  41463. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41464. /**
  41465. * Defines the camera the input is attached to.
  41466. */
  41467. camera: FollowCamera;
  41468. /**
  41469. * Gets the class name of the current input.
  41470. * @returns the class name
  41471. */
  41472. getClassName(): string;
  41473. /**
  41474. * Defines the pointer angular sensibility along the X axis or how fast is
  41475. * the camera rotating.
  41476. * A negative number will reverse the axis direction.
  41477. */
  41478. angularSensibilityX: number;
  41479. /**
  41480. * Defines the pointer angular sensibility along the Y axis or how fast is
  41481. * the camera rotating.
  41482. * A negative number will reverse the axis direction.
  41483. */
  41484. angularSensibilityY: number;
  41485. /**
  41486. * Defines the pointer pinch precision or how fast is the camera zooming.
  41487. * A negative number will reverse the axis direction.
  41488. */
  41489. pinchPrecision: number;
  41490. /**
  41491. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41492. * from 0.
  41493. * It defines the percentage of current camera.radius to use as delta when
  41494. * pinch zoom is used.
  41495. */
  41496. pinchDeltaPercentage: number;
  41497. /**
  41498. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41499. */
  41500. axisXControlRadius: boolean;
  41501. /**
  41502. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41503. */
  41504. axisXControlHeight: boolean;
  41505. /**
  41506. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41507. */
  41508. axisXControlRotation: boolean;
  41509. /**
  41510. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41511. */
  41512. axisYControlRadius: boolean;
  41513. /**
  41514. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41515. */
  41516. axisYControlHeight: boolean;
  41517. /**
  41518. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41519. */
  41520. axisYControlRotation: boolean;
  41521. /**
  41522. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41523. */
  41524. axisPinchControlRadius: boolean;
  41525. /**
  41526. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41527. */
  41528. axisPinchControlHeight: boolean;
  41529. /**
  41530. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41531. */
  41532. axisPinchControlRotation: boolean;
  41533. /**
  41534. * Log error messages if basic misconfiguration has occurred.
  41535. */
  41536. warningEnable: boolean;
  41537. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41538. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41539. private _warningCounter;
  41540. private _warning;
  41541. }
  41542. }
  41543. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41544. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41545. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41546. /**
  41547. * Default Inputs manager for the FollowCamera.
  41548. * It groups all the default supported inputs for ease of use.
  41549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41550. */
  41551. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41552. /**
  41553. * Instantiates a new FollowCameraInputsManager.
  41554. * @param camera Defines the camera the inputs belong to
  41555. */
  41556. constructor(camera: FollowCamera);
  41557. /**
  41558. * Add keyboard input support to the input manager.
  41559. * @returns the current input manager
  41560. */
  41561. addKeyboard(): FollowCameraInputsManager;
  41562. /**
  41563. * Add mouse wheel input support to the input manager.
  41564. * @returns the current input manager
  41565. */
  41566. addMouseWheel(): FollowCameraInputsManager;
  41567. /**
  41568. * Add pointers input support to the input manager.
  41569. * @returns the current input manager
  41570. */
  41571. addPointers(): FollowCameraInputsManager;
  41572. /**
  41573. * Add orientation input support to the input manager.
  41574. * @returns the current input manager
  41575. */
  41576. addVRDeviceOrientation(): FollowCameraInputsManager;
  41577. }
  41578. }
  41579. declare module "babylonjs/Cameras/followCamera" {
  41580. import { Nullable } from "babylonjs/types";
  41581. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41582. import { Scene } from "babylonjs/scene";
  41583. import { Vector3 } from "babylonjs/Maths/math.vector";
  41584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41585. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41586. /**
  41587. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41588. * an arc rotate version arcFollowCamera are available.
  41589. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41590. */
  41591. export class FollowCamera extends TargetCamera {
  41592. /**
  41593. * Distance the follow camera should follow an object at
  41594. */
  41595. radius: number;
  41596. /**
  41597. * Minimum allowed distance of the camera to the axis of rotation
  41598. * (The camera can not get closer).
  41599. * This can help limiting how the Camera is able to move in the scene.
  41600. */
  41601. lowerRadiusLimit: Nullable<number>;
  41602. /**
  41603. * Maximum allowed distance of the camera to the axis of rotation
  41604. * (The camera can not get further).
  41605. * This can help limiting how the Camera is able to move in the scene.
  41606. */
  41607. upperRadiusLimit: Nullable<number>;
  41608. /**
  41609. * Define a rotation offset between the camera and the object it follows
  41610. */
  41611. rotationOffset: number;
  41612. /**
  41613. * Minimum allowed angle to camera position relative to target object.
  41614. * This can help limiting how the Camera is able to move in the scene.
  41615. */
  41616. lowerRotationOffsetLimit: Nullable<number>;
  41617. /**
  41618. * Maximum allowed angle to camera position relative to target object.
  41619. * This can help limiting how the Camera is able to move in the scene.
  41620. */
  41621. upperRotationOffsetLimit: Nullable<number>;
  41622. /**
  41623. * Define a height offset between the camera and the object it follows.
  41624. * It can help following an object from the top (like a car chaing a plane)
  41625. */
  41626. heightOffset: number;
  41627. /**
  41628. * Minimum allowed height of camera position relative to target object.
  41629. * This can help limiting how the Camera is able to move in the scene.
  41630. */
  41631. lowerHeightOffsetLimit: Nullable<number>;
  41632. /**
  41633. * Maximum allowed height of camera position relative to target object.
  41634. * This can help limiting how the Camera is able to move in the scene.
  41635. */
  41636. upperHeightOffsetLimit: Nullable<number>;
  41637. /**
  41638. * Define how fast the camera can accelerate to follow it s target.
  41639. */
  41640. cameraAcceleration: number;
  41641. /**
  41642. * Define the speed limit of the camera following an object.
  41643. */
  41644. maxCameraSpeed: number;
  41645. /**
  41646. * Define the target of the camera.
  41647. */
  41648. lockedTarget: Nullable<AbstractMesh>;
  41649. /**
  41650. * Defines the input associated with the camera.
  41651. */
  41652. inputs: FollowCameraInputsManager;
  41653. /**
  41654. * Instantiates the follow camera.
  41655. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41656. * @param name Define the name of the camera in the scene
  41657. * @param position Define the position of the camera
  41658. * @param scene Define the scene the camera belong to
  41659. * @param lockedTarget Define the target of the camera
  41660. */
  41661. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41662. private _follow;
  41663. /**
  41664. * Attached controls to the current camera.
  41665. * @param element Defines the element the controls should be listened from
  41666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41667. */
  41668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41669. /**
  41670. * Detach the current controls from the camera.
  41671. * The camera will stop reacting to inputs.
  41672. * @param element Defines the element to stop listening the inputs from
  41673. */
  41674. detachControl(element: HTMLElement): void;
  41675. /** @hidden */
  41676. _checkInputs(): void;
  41677. private _checkLimits;
  41678. /**
  41679. * Gets the camera class name.
  41680. * @returns the class name
  41681. */
  41682. getClassName(): string;
  41683. }
  41684. /**
  41685. * Arc Rotate version of the follow camera.
  41686. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41687. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41688. */
  41689. export class ArcFollowCamera extends TargetCamera {
  41690. /** The longitudinal angle of the camera */
  41691. alpha: number;
  41692. /** The latitudinal angle of the camera */
  41693. beta: number;
  41694. /** The radius of the camera from its target */
  41695. radius: number;
  41696. /** Define the camera target (the messh it should follow) */
  41697. target: Nullable<AbstractMesh>;
  41698. private _cartesianCoordinates;
  41699. /**
  41700. * Instantiates a new ArcFollowCamera
  41701. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41702. * @param name Define the name of the camera
  41703. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41704. * @param beta Define the rotation angle of the camera around the elevation axis
  41705. * @param radius Define the radius of the camera from its target point
  41706. * @param target Define the target of the camera
  41707. * @param scene Define the scene the camera belongs to
  41708. */
  41709. constructor(name: string,
  41710. /** The longitudinal angle of the camera */
  41711. alpha: number,
  41712. /** The latitudinal angle of the camera */
  41713. beta: number,
  41714. /** The radius of the camera from its target */
  41715. radius: number,
  41716. /** Define the camera target (the messh it should follow) */
  41717. target: Nullable<AbstractMesh>, scene: Scene);
  41718. private _follow;
  41719. /** @hidden */
  41720. _checkInputs(): void;
  41721. /**
  41722. * Returns the class name of the object.
  41723. * It is mostly used internally for serialization purposes.
  41724. */
  41725. getClassName(): string;
  41726. }
  41727. }
  41728. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41730. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41731. import { Nullable } from "babylonjs/types";
  41732. /**
  41733. * Manage the keyboard inputs to control the movement of a follow camera.
  41734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41735. */
  41736. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41737. /**
  41738. * Defines the camera the input is attached to.
  41739. */
  41740. camera: FollowCamera;
  41741. /**
  41742. * Defines the list of key codes associated with the up action (increase heightOffset)
  41743. */
  41744. keysHeightOffsetIncr: number[];
  41745. /**
  41746. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41747. */
  41748. keysHeightOffsetDecr: number[];
  41749. /**
  41750. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41751. */
  41752. keysHeightOffsetModifierAlt: boolean;
  41753. /**
  41754. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41755. */
  41756. keysHeightOffsetModifierCtrl: boolean;
  41757. /**
  41758. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41759. */
  41760. keysHeightOffsetModifierShift: boolean;
  41761. /**
  41762. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41763. */
  41764. keysRotationOffsetIncr: number[];
  41765. /**
  41766. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41767. */
  41768. keysRotationOffsetDecr: number[];
  41769. /**
  41770. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41771. */
  41772. keysRotationOffsetModifierAlt: boolean;
  41773. /**
  41774. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41775. */
  41776. keysRotationOffsetModifierCtrl: boolean;
  41777. /**
  41778. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41779. */
  41780. keysRotationOffsetModifierShift: boolean;
  41781. /**
  41782. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41783. */
  41784. keysRadiusIncr: number[];
  41785. /**
  41786. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41787. */
  41788. keysRadiusDecr: number[];
  41789. /**
  41790. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41791. */
  41792. keysRadiusModifierAlt: boolean;
  41793. /**
  41794. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41795. */
  41796. keysRadiusModifierCtrl: boolean;
  41797. /**
  41798. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41799. */
  41800. keysRadiusModifierShift: boolean;
  41801. /**
  41802. * Defines the rate of change of heightOffset.
  41803. */
  41804. heightSensibility: number;
  41805. /**
  41806. * Defines the rate of change of rotationOffset.
  41807. */
  41808. rotationSensibility: number;
  41809. /**
  41810. * Defines the rate of change of radius.
  41811. */
  41812. radiusSensibility: number;
  41813. private _keys;
  41814. private _ctrlPressed;
  41815. private _altPressed;
  41816. private _shiftPressed;
  41817. private _onCanvasBlurObserver;
  41818. private _onKeyboardObserver;
  41819. private _engine;
  41820. private _scene;
  41821. /**
  41822. * Attach the input controls to a specific dom element to get the input from.
  41823. * @param element Defines the element the controls should be listened from
  41824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41825. */
  41826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41827. /**
  41828. * Detach the current controls from the specified dom element.
  41829. * @param element Defines the element to stop listening the inputs from
  41830. */
  41831. detachControl(element: Nullable<HTMLElement>): void;
  41832. /**
  41833. * Update the current camera state depending on the inputs that have been used this frame.
  41834. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41835. */
  41836. checkInputs(): void;
  41837. /**
  41838. * Gets the class name of the current input.
  41839. * @returns the class name
  41840. */
  41841. getClassName(): string;
  41842. /**
  41843. * Get the friendly name associated with the input class.
  41844. * @returns the input friendly name
  41845. */
  41846. getSimpleName(): string;
  41847. /**
  41848. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41849. * allow modification of the heightOffset value.
  41850. */
  41851. private _modifierHeightOffset;
  41852. /**
  41853. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41854. * allow modification of the rotationOffset value.
  41855. */
  41856. private _modifierRotationOffset;
  41857. /**
  41858. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41859. * allow modification of the radius value.
  41860. */
  41861. private _modifierRadius;
  41862. }
  41863. }
  41864. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41865. import { Nullable } from "babylonjs/types";
  41866. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41867. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41868. import { Observable } from "babylonjs/Misc/observable";
  41869. module "babylonjs/Cameras/freeCameraInputsManager" {
  41870. interface FreeCameraInputsManager {
  41871. /**
  41872. * @hidden
  41873. */
  41874. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41875. /**
  41876. * Add orientation input support to the input manager.
  41877. * @returns the current input manager
  41878. */
  41879. addDeviceOrientation(): FreeCameraInputsManager;
  41880. }
  41881. }
  41882. /**
  41883. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41884. * Screen rotation is taken into account.
  41885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41886. */
  41887. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41888. private _camera;
  41889. private _screenOrientationAngle;
  41890. private _constantTranform;
  41891. private _screenQuaternion;
  41892. private _alpha;
  41893. private _beta;
  41894. private _gamma;
  41895. /**
  41896. * Can be used to detect if a device orientation sensor is available on a device
  41897. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41898. * @returns a promise that will resolve on orientation change
  41899. */
  41900. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41901. /**
  41902. * @hidden
  41903. */
  41904. _onDeviceOrientationChangedObservable: Observable<void>;
  41905. /**
  41906. * Instantiates a new input
  41907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41908. */
  41909. constructor();
  41910. /**
  41911. * Define the camera controlled by the input.
  41912. */
  41913. get camera(): FreeCamera;
  41914. set camera(camera: FreeCamera);
  41915. /**
  41916. * Attach the input controls to a specific dom element to get the input from.
  41917. * @param element Defines the element the controls should be listened from
  41918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41919. */
  41920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41921. private _orientationChanged;
  41922. private _deviceOrientation;
  41923. /**
  41924. * Detach the current controls from the specified dom element.
  41925. * @param element Defines the element to stop listening the inputs from
  41926. */
  41927. detachControl(element: Nullable<HTMLElement>): void;
  41928. /**
  41929. * Update the current camera state depending on the inputs that have been used this frame.
  41930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41931. */
  41932. checkInputs(): void;
  41933. /**
  41934. * Gets the class name of the current intput.
  41935. * @returns the class name
  41936. */
  41937. getClassName(): string;
  41938. /**
  41939. * Get the friendly name associated with the input class.
  41940. * @returns the input friendly name
  41941. */
  41942. getSimpleName(): string;
  41943. }
  41944. }
  41945. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41946. import { Nullable } from "babylonjs/types";
  41947. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41948. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41949. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41950. /**
  41951. * Manage the gamepad inputs to control a free camera.
  41952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41953. */
  41954. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41955. /**
  41956. * Define the camera the input is attached to.
  41957. */
  41958. camera: FreeCamera;
  41959. /**
  41960. * Define the Gamepad controlling the input
  41961. */
  41962. gamepad: Nullable<Gamepad>;
  41963. /**
  41964. * Defines the gamepad rotation sensiblity.
  41965. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41966. */
  41967. gamepadAngularSensibility: number;
  41968. /**
  41969. * Defines the gamepad move sensiblity.
  41970. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41971. */
  41972. gamepadMoveSensibility: number;
  41973. private _yAxisScale;
  41974. /**
  41975. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41976. */
  41977. get invertYAxis(): boolean;
  41978. set invertYAxis(value: boolean);
  41979. private _onGamepadConnectedObserver;
  41980. private _onGamepadDisconnectedObserver;
  41981. private _cameraTransform;
  41982. private _deltaTransform;
  41983. private _vector3;
  41984. private _vector2;
  41985. /**
  41986. * Attach the input controls to a specific dom element to get the input from.
  41987. * @param element Defines the element the controls should be listened from
  41988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41989. */
  41990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41991. /**
  41992. * Detach the current controls from the specified dom element.
  41993. * @param element Defines the element to stop listening the inputs from
  41994. */
  41995. detachControl(element: Nullable<HTMLElement>): void;
  41996. /**
  41997. * Update the current camera state depending on the inputs that have been used this frame.
  41998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41999. */
  42000. checkInputs(): void;
  42001. /**
  42002. * Gets the class name of the current intput.
  42003. * @returns the class name
  42004. */
  42005. getClassName(): string;
  42006. /**
  42007. * Get the friendly name associated with the input class.
  42008. * @returns the input friendly name
  42009. */
  42010. getSimpleName(): string;
  42011. }
  42012. }
  42013. declare module "babylonjs/Misc/virtualJoystick" {
  42014. import { Nullable } from "babylonjs/types";
  42015. import { Vector3 } from "babylonjs/Maths/math.vector";
  42016. /**
  42017. * Defines the potential axis of a Joystick
  42018. */
  42019. export enum JoystickAxis {
  42020. /** X axis */
  42021. X = 0,
  42022. /** Y axis */
  42023. Y = 1,
  42024. /** Z axis */
  42025. Z = 2
  42026. }
  42027. /**
  42028. * Class used to define virtual joystick (used in touch mode)
  42029. */
  42030. export class VirtualJoystick {
  42031. /**
  42032. * Gets or sets a boolean indicating that left and right values must be inverted
  42033. */
  42034. reverseLeftRight: boolean;
  42035. /**
  42036. * Gets or sets a boolean indicating that up and down values must be inverted
  42037. */
  42038. reverseUpDown: boolean;
  42039. /**
  42040. * Gets the offset value for the position (ie. the change of the position value)
  42041. */
  42042. deltaPosition: Vector3;
  42043. /**
  42044. * Gets a boolean indicating if the virtual joystick was pressed
  42045. */
  42046. pressed: boolean;
  42047. /**
  42048. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42049. */
  42050. static Canvas: Nullable<HTMLCanvasElement>;
  42051. private static _globalJoystickIndex;
  42052. private static vjCanvasContext;
  42053. private static vjCanvasWidth;
  42054. private static vjCanvasHeight;
  42055. private static halfWidth;
  42056. private _action;
  42057. private _axisTargetedByLeftAndRight;
  42058. private _axisTargetedByUpAndDown;
  42059. private _joystickSensibility;
  42060. private _inversedSensibility;
  42061. private _joystickPointerID;
  42062. private _joystickColor;
  42063. private _joystickPointerPos;
  42064. private _joystickPreviousPointerPos;
  42065. private _joystickPointerStartPos;
  42066. private _deltaJoystickVector;
  42067. private _leftJoystick;
  42068. private _touches;
  42069. private _onPointerDownHandlerRef;
  42070. private _onPointerMoveHandlerRef;
  42071. private _onPointerUpHandlerRef;
  42072. private _onResize;
  42073. /**
  42074. * Creates a new virtual joystick
  42075. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42076. */
  42077. constructor(leftJoystick?: boolean);
  42078. /**
  42079. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42080. * @param newJoystickSensibility defines the new sensibility
  42081. */
  42082. setJoystickSensibility(newJoystickSensibility: number): void;
  42083. private _onPointerDown;
  42084. private _onPointerMove;
  42085. private _onPointerUp;
  42086. /**
  42087. * Change the color of the virtual joystick
  42088. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42089. */
  42090. setJoystickColor(newColor: string): void;
  42091. /**
  42092. * Defines a callback to call when the joystick is touched
  42093. * @param action defines the callback
  42094. */
  42095. setActionOnTouch(action: () => any): void;
  42096. /**
  42097. * Defines which axis you'd like to control for left & right
  42098. * @param axis defines the axis to use
  42099. */
  42100. setAxisForLeftRight(axis: JoystickAxis): void;
  42101. /**
  42102. * Defines which axis you'd like to control for up & down
  42103. * @param axis defines the axis to use
  42104. */
  42105. setAxisForUpDown(axis: JoystickAxis): void;
  42106. private _drawVirtualJoystick;
  42107. /**
  42108. * Release internal HTML canvas
  42109. */
  42110. releaseCanvas(): void;
  42111. }
  42112. }
  42113. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42114. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42115. import { Nullable } from "babylonjs/types";
  42116. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42118. module "babylonjs/Cameras/freeCameraInputsManager" {
  42119. interface FreeCameraInputsManager {
  42120. /**
  42121. * Add virtual joystick input support to the input manager.
  42122. * @returns the current input manager
  42123. */
  42124. addVirtualJoystick(): FreeCameraInputsManager;
  42125. }
  42126. }
  42127. /**
  42128. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42130. */
  42131. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42132. /**
  42133. * Defines the camera the input is attached to.
  42134. */
  42135. camera: FreeCamera;
  42136. private _leftjoystick;
  42137. private _rightjoystick;
  42138. /**
  42139. * Gets the left stick of the virtual joystick.
  42140. * @returns The virtual Joystick
  42141. */
  42142. getLeftJoystick(): VirtualJoystick;
  42143. /**
  42144. * Gets the right stick of the virtual joystick.
  42145. * @returns The virtual Joystick
  42146. */
  42147. getRightJoystick(): VirtualJoystick;
  42148. /**
  42149. * Update the current camera state depending on the inputs that have been used this frame.
  42150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42151. */
  42152. checkInputs(): void;
  42153. /**
  42154. * Attach the input controls to a specific dom element to get the input from.
  42155. * @param element Defines the element the controls should be listened from
  42156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42157. */
  42158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42159. /**
  42160. * Detach the current controls from the specified dom element.
  42161. * @param element Defines the element to stop listening the inputs from
  42162. */
  42163. detachControl(element: Nullable<HTMLElement>): void;
  42164. /**
  42165. * Gets the class name of the current intput.
  42166. * @returns the class name
  42167. */
  42168. getClassName(): string;
  42169. /**
  42170. * Get the friendly name associated with the input class.
  42171. * @returns the input friendly name
  42172. */
  42173. getSimpleName(): string;
  42174. }
  42175. }
  42176. declare module "babylonjs/Cameras/Inputs/index" {
  42177. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42178. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42179. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42180. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42181. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42182. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42183. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42184. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42185. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42186. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42187. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42188. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42189. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42190. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42191. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42192. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42193. }
  42194. declare module "babylonjs/Cameras/touchCamera" {
  42195. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42196. import { Scene } from "babylonjs/scene";
  42197. import { Vector3 } from "babylonjs/Maths/math.vector";
  42198. /**
  42199. * This represents a FPS type of camera controlled by touch.
  42200. * This is like a universal camera minus the Gamepad controls.
  42201. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42202. */
  42203. export class TouchCamera extends FreeCamera {
  42204. /**
  42205. * Defines the touch sensibility for rotation.
  42206. * The higher the faster.
  42207. */
  42208. get touchAngularSensibility(): number;
  42209. set touchAngularSensibility(value: number);
  42210. /**
  42211. * Defines the touch sensibility for move.
  42212. * The higher the faster.
  42213. */
  42214. get touchMoveSensibility(): number;
  42215. set touchMoveSensibility(value: number);
  42216. /**
  42217. * Instantiates a new touch camera.
  42218. * This represents a FPS type of camera controlled by touch.
  42219. * This is like a universal camera minus the Gamepad controls.
  42220. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42221. * @param name Define the name of the camera in the scene
  42222. * @param position Define the start position of the camera in the scene
  42223. * @param scene Define the scene the camera belongs to
  42224. */
  42225. constructor(name: string, position: Vector3, scene: Scene);
  42226. /**
  42227. * Gets the current object class name.
  42228. * @return the class name
  42229. */
  42230. getClassName(): string;
  42231. /** @hidden */
  42232. _setupInputs(): void;
  42233. }
  42234. }
  42235. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42236. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42237. import { Scene } from "babylonjs/scene";
  42238. import { Vector3 } from "babylonjs/Maths/math.vector";
  42239. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42240. import { Axis } from "babylonjs/Maths/math.axis";
  42241. /**
  42242. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42243. * being tilted forward or back and left or right.
  42244. */
  42245. export class DeviceOrientationCamera extends FreeCamera {
  42246. private _initialQuaternion;
  42247. private _quaternionCache;
  42248. private _tmpDragQuaternion;
  42249. private _disablePointerInputWhenUsingDeviceOrientation;
  42250. /**
  42251. * Creates a new device orientation camera
  42252. * @param name The name of the camera
  42253. * @param position The start position camera
  42254. * @param scene The scene the camera belongs to
  42255. */
  42256. constructor(name: string, position: Vector3, scene: Scene);
  42257. /**
  42258. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42259. */
  42260. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42261. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42262. private _dragFactor;
  42263. /**
  42264. * Enabled turning on the y axis when the orientation sensor is active
  42265. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42266. */
  42267. enableHorizontalDragging(dragFactor?: number): void;
  42268. /**
  42269. * Gets the current instance class name ("DeviceOrientationCamera").
  42270. * This helps avoiding instanceof at run time.
  42271. * @returns the class name
  42272. */
  42273. getClassName(): string;
  42274. /**
  42275. * @hidden
  42276. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42277. */
  42278. _checkInputs(): void;
  42279. /**
  42280. * Reset the camera to its default orientation on the specified axis only.
  42281. * @param axis The axis to reset
  42282. */
  42283. resetToCurrentRotation(axis?: Axis): void;
  42284. }
  42285. }
  42286. declare module "babylonjs/Gamepads/xboxGamepad" {
  42287. import { Observable } from "babylonjs/Misc/observable";
  42288. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42289. /**
  42290. * Defines supported buttons for XBox360 compatible gamepads
  42291. */
  42292. export enum Xbox360Button {
  42293. /** A */
  42294. A = 0,
  42295. /** B */
  42296. B = 1,
  42297. /** X */
  42298. X = 2,
  42299. /** Y */
  42300. Y = 3,
  42301. /** Start */
  42302. Start = 4,
  42303. /** Back */
  42304. Back = 5,
  42305. /** Left button */
  42306. LB = 6,
  42307. /** Right button */
  42308. RB = 7,
  42309. /** Left stick */
  42310. LeftStick = 8,
  42311. /** Right stick */
  42312. RightStick = 9
  42313. }
  42314. /** Defines values for XBox360 DPad */
  42315. export enum Xbox360Dpad {
  42316. /** Up */
  42317. Up = 0,
  42318. /** Down */
  42319. Down = 1,
  42320. /** Left */
  42321. Left = 2,
  42322. /** Right */
  42323. Right = 3
  42324. }
  42325. /**
  42326. * Defines a XBox360 gamepad
  42327. */
  42328. export class Xbox360Pad extends Gamepad {
  42329. private _leftTrigger;
  42330. private _rightTrigger;
  42331. private _onlefttriggerchanged;
  42332. private _onrighttriggerchanged;
  42333. private _onbuttondown;
  42334. private _onbuttonup;
  42335. private _ondpaddown;
  42336. private _ondpadup;
  42337. /** Observable raised when a button is pressed */
  42338. onButtonDownObservable: Observable<Xbox360Button>;
  42339. /** Observable raised when a button is released */
  42340. onButtonUpObservable: Observable<Xbox360Button>;
  42341. /** Observable raised when a pad is pressed */
  42342. onPadDownObservable: Observable<Xbox360Dpad>;
  42343. /** Observable raised when a pad is released */
  42344. onPadUpObservable: Observable<Xbox360Dpad>;
  42345. private _buttonA;
  42346. private _buttonB;
  42347. private _buttonX;
  42348. private _buttonY;
  42349. private _buttonBack;
  42350. private _buttonStart;
  42351. private _buttonLB;
  42352. private _buttonRB;
  42353. private _buttonLeftStick;
  42354. private _buttonRightStick;
  42355. private _dPadUp;
  42356. private _dPadDown;
  42357. private _dPadLeft;
  42358. private _dPadRight;
  42359. private _isXboxOnePad;
  42360. /**
  42361. * Creates a new XBox360 gamepad object
  42362. * @param id defines the id of this gamepad
  42363. * @param index defines its index
  42364. * @param gamepad defines the internal HTML gamepad object
  42365. * @param xboxOne defines if it is a XBox One gamepad
  42366. */
  42367. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42368. /**
  42369. * Defines the callback to call when left trigger is pressed
  42370. * @param callback defines the callback to use
  42371. */
  42372. onlefttriggerchanged(callback: (value: number) => void): void;
  42373. /**
  42374. * Defines the callback to call when right trigger is pressed
  42375. * @param callback defines the callback to use
  42376. */
  42377. onrighttriggerchanged(callback: (value: number) => void): void;
  42378. /**
  42379. * Gets the left trigger value
  42380. */
  42381. get leftTrigger(): number;
  42382. /**
  42383. * Sets the left trigger value
  42384. */
  42385. set leftTrigger(newValue: number);
  42386. /**
  42387. * Gets the right trigger value
  42388. */
  42389. get rightTrigger(): number;
  42390. /**
  42391. * Sets the right trigger value
  42392. */
  42393. set rightTrigger(newValue: number);
  42394. /**
  42395. * Defines the callback to call when a button is pressed
  42396. * @param callback defines the callback to use
  42397. */
  42398. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42399. /**
  42400. * Defines the callback to call when a button is released
  42401. * @param callback defines the callback to use
  42402. */
  42403. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42404. /**
  42405. * Defines the callback to call when a pad is pressed
  42406. * @param callback defines the callback to use
  42407. */
  42408. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42409. /**
  42410. * Defines the callback to call when a pad is released
  42411. * @param callback defines the callback to use
  42412. */
  42413. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42414. private _setButtonValue;
  42415. private _setDPadValue;
  42416. /**
  42417. * Gets the value of the `A` button
  42418. */
  42419. get buttonA(): number;
  42420. /**
  42421. * Sets the value of the `A` button
  42422. */
  42423. set buttonA(value: number);
  42424. /**
  42425. * Gets the value of the `B` button
  42426. */
  42427. get buttonB(): number;
  42428. /**
  42429. * Sets the value of the `B` button
  42430. */
  42431. set buttonB(value: number);
  42432. /**
  42433. * Gets the value of the `X` button
  42434. */
  42435. get buttonX(): number;
  42436. /**
  42437. * Sets the value of the `X` button
  42438. */
  42439. set buttonX(value: number);
  42440. /**
  42441. * Gets the value of the `Y` button
  42442. */
  42443. get buttonY(): number;
  42444. /**
  42445. * Sets the value of the `Y` button
  42446. */
  42447. set buttonY(value: number);
  42448. /**
  42449. * Gets the value of the `Start` button
  42450. */
  42451. get buttonStart(): number;
  42452. /**
  42453. * Sets the value of the `Start` button
  42454. */
  42455. set buttonStart(value: number);
  42456. /**
  42457. * Gets the value of the `Back` button
  42458. */
  42459. get buttonBack(): number;
  42460. /**
  42461. * Sets the value of the `Back` button
  42462. */
  42463. set buttonBack(value: number);
  42464. /**
  42465. * Gets the value of the `Left` button
  42466. */
  42467. get buttonLB(): number;
  42468. /**
  42469. * Sets the value of the `Left` button
  42470. */
  42471. set buttonLB(value: number);
  42472. /**
  42473. * Gets the value of the `Right` button
  42474. */
  42475. get buttonRB(): number;
  42476. /**
  42477. * Sets the value of the `Right` button
  42478. */
  42479. set buttonRB(value: number);
  42480. /**
  42481. * Gets the value of the Left joystick
  42482. */
  42483. get buttonLeftStick(): number;
  42484. /**
  42485. * Sets the value of the Left joystick
  42486. */
  42487. set buttonLeftStick(value: number);
  42488. /**
  42489. * Gets the value of the Right joystick
  42490. */
  42491. get buttonRightStick(): number;
  42492. /**
  42493. * Sets the value of the Right joystick
  42494. */
  42495. set buttonRightStick(value: number);
  42496. /**
  42497. * Gets the value of D-pad up
  42498. */
  42499. get dPadUp(): number;
  42500. /**
  42501. * Sets the value of D-pad up
  42502. */
  42503. set dPadUp(value: number);
  42504. /**
  42505. * Gets the value of D-pad down
  42506. */
  42507. get dPadDown(): number;
  42508. /**
  42509. * Sets the value of D-pad down
  42510. */
  42511. set dPadDown(value: number);
  42512. /**
  42513. * Gets the value of D-pad left
  42514. */
  42515. get dPadLeft(): number;
  42516. /**
  42517. * Sets the value of D-pad left
  42518. */
  42519. set dPadLeft(value: number);
  42520. /**
  42521. * Gets the value of D-pad right
  42522. */
  42523. get dPadRight(): number;
  42524. /**
  42525. * Sets the value of D-pad right
  42526. */
  42527. set dPadRight(value: number);
  42528. /**
  42529. * Force the gamepad to synchronize with device values
  42530. */
  42531. update(): void;
  42532. /**
  42533. * Disposes the gamepad
  42534. */
  42535. dispose(): void;
  42536. }
  42537. }
  42538. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42539. import { Observable } from "babylonjs/Misc/observable";
  42540. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42541. /**
  42542. * Defines supported buttons for DualShock compatible gamepads
  42543. */
  42544. export enum DualShockButton {
  42545. /** Cross */
  42546. Cross = 0,
  42547. /** Circle */
  42548. Circle = 1,
  42549. /** Square */
  42550. Square = 2,
  42551. /** Triangle */
  42552. Triangle = 3,
  42553. /** Options */
  42554. Options = 4,
  42555. /** Share */
  42556. Share = 5,
  42557. /** L1 */
  42558. L1 = 6,
  42559. /** R1 */
  42560. R1 = 7,
  42561. /** Left stick */
  42562. LeftStick = 8,
  42563. /** Right stick */
  42564. RightStick = 9
  42565. }
  42566. /** Defines values for DualShock DPad */
  42567. export enum DualShockDpad {
  42568. /** Up */
  42569. Up = 0,
  42570. /** Down */
  42571. Down = 1,
  42572. /** Left */
  42573. Left = 2,
  42574. /** Right */
  42575. Right = 3
  42576. }
  42577. /**
  42578. * Defines a DualShock gamepad
  42579. */
  42580. export class DualShockPad extends Gamepad {
  42581. private _leftTrigger;
  42582. private _rightTrigger;
  42583. private _onlefttriggerchanged;
  42584. private _onrighttriggerchanged;
  42585. private _onbuttondown;
  42586. private _onbuttonup;
  42587. private _ondpaddown;
  42588. private _ondpadup;
  42589. /** Observable raised when a button is pressed */
  42590. onButtonDownObservable: Observable<DualShockButton>;
  42591. /** Observable raised when a button is released */
  42592. onButtonUpObservable: Observable<DualShockButton>;
  42593. /** Observable raised when a pad is pressed */
  42594. onPadDownObservable: Observable<DualShockDpad>;
  42595. /** Observable raised when a pad is released */
  42596. onPadUpObservable: Observable<DualShockDpad>;
  42597. private _buttonCross;
  42598. private _buttonCircle;
  42599. private _buttonSquare;
  42600. private _buttonTriangle;
  42601. private _buttonShare;
  42602. private _buttonOptions;
  42603. private _buttonL1;
  42604. private _buttonR1;
  42605. private _buttonLeftStick;
  42606. private _buttonRightStick;
  42607. private _dPadUp;
  42608. private _dPadDown;
  42609. private _dPadLeft;
  42610. private _dPadRight;
  42611. /**
  42612. * Creates a new DualShock gamepad object
  42613. * @param id defines the id of this gamepad
  42614. * @param index defines its index
  42615. * @param gamepad defines the internal HTML gamepad object
  42616. */
  42617. constructor(id: string, index: number, gamepad: any);
  42618. /**
  42619. * Defines the callback to call when left trigger is pressed
  42620. * @param callback defines the callback to use
  42621. */
  42622. onlefttriggerchanged(callback: (value: number) => void): void;
  42623. /**
  42624. * Defines the callback to call when right trigger is pressed
  42625. * @param callback defines the callback to use
  42626. */
  42627. onrighttriggerchanged(callback: (value: number) => void): void;
  42628. /**
  42629. * Gets the left trigger value
  42630. */
  42631. get leftTrigger(): number;
  42632. /**
  42633. * Sets the left trigger value
  42634. */
  42635. set leftTrigger(newValue: number);
  42636. /**
  42637. * Gets the right trigger value
  42638. */
  42639. get rightTrigger(): number;
  42640. /**
  42641. * Sets the right trigger value
  42642. */
  42643. set rightTrigger(newValue: number);
  42644. /**
  42645. * Defines the callback to call when a button is pressed
  42646. * @param callback defines the callback to use
  42647. */
  42648. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42649. /**
  42650. * Defines the callback to call when a button is released
  42651. * @param callback defines the callback to use
  42652. */
  42653. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42654. /**
  42655. * Defines the callback to call when a pad is pressed
  42656. * @param callback defines the callback to use
  42657. */
  42658. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42659. /**
  42660. * Defines the callback to call when a pad is released
  42661. * @param callback defines the callback to use
  42662. */
  42663. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42664. private _setButtonValue;
  42665. private _setDPadValue;
  42666. /**
  42667. * Gets the value of the `Cross` button
  42668. */
  42669. get buttonCross(): number;
  42670. /**
  42671. * Sets the value of the `Cross` button
  42672. */
  42673. set buttonCross(value: number);
  42674. /**
  42675. * Gets the value of the `Circle` button
  42676. */
  42677. get buttonCircle(): number;
  42678. /**
  42679. * Sets the value of the `Circle` button
  42680. */
  42681. set buttonCircle(value: number);
  42682. /**
  42683. * Gets the value of the `Square` button
  42684. */
  42685. get buttonSquare(): number;
  42686. /**
  42687. * Sets the value of the `Square` button
  42688. */
  42689. set buttonSquare(value: number);
  42690. /**
  42691. * Gets the value of the `Triangle` button
  42692. */
  42693. get buttonTriangle(): number;
  42694. /**
  42695. * Sets the value of the `Triangle` button
  42696. */
  42697. set buttonTriangle(value: number);
  42698. /**
  42699. * Gets the value of the `Options` button
  42700. */
  42701. get buttonOptions(): number;
  42702. /**
  42703. * Sets the value of the `Options` button
  42704. */
  42705. set buttonOptions(value: number);
  42706. /**
  42707. * Gets the value of the `Share` button
  42708. */
  42709. get buttonShare(): number;
  42710. /**
  42711. * Sets the value of the `Share` button
  42712. */
  42713. set buttonShare(value: number);
  42714. /**
  42715. * Gets the value of the `L1` button
  42716. */
  42717. get buttonL1(): number;
  42718. /**
  42719. * Sets the value of the `L1` button
  42720. */
  42721. set buttonL1(value: number);
  42722. /**
  42723. * Gets the value of the `R1` button
  42724. */
  42725. get buttonR1(): number;
  42726. /**
  42727. * Sets the value of the `R1` button
  42728. */
  42729. set buttonR1(value: number);
  42730. /**
  42731. * Gets the value of the Left joystick
  42732. */
  42733. get buttonLeftStick(): number;
  42734. /**
  42735. * Sets the value of the Left joystick
  42736. */
  42737. set buttonLeftStick(value: number);
  42738. /**
  42739. * Gets the value of the Right joystick
  42740. */
  42741. get buttonRightStick(): number;
  42742. /**
  42743. * Sets the value of the Right joystick
  42744. */
  42745. set buttonRightStick(value: number);
  42746. /**
  42747. * Gets the value of D-pad up
  42748. */
  42749. get dPadUp(): number;
  42750. /**
  42751. * Sets the value of D-pad up
  42752. */
  42753. set dPadUp(value: number);
  42754. /**
  42755. * Gets the value of D-pad down
  42756. */
  42757. get dPadDown(): number;
  42758. /**
  42759. * Sets the value of D-pad down
  42760. */
  42761. set dPadDown(value: number);
  42762. /**
  42763. * Gets the value of D-pad left
  42764. */
  42765. get dPadLeft(): number;
  42766. /**
  42767. * Sets the value of D-pad left
  42768. */
  42769. set dPadLeft(value: number);
  42770. /**
  42771. * Gets the value of D-pad right
  42772. */
  42773. get dPadRight(): number;
  42774. /**
  42775. * Sets the value of D-pad right
  42776. */
  42777. set dPadRight(value: number);
  42778. /**
  42779. * Force the gamepad to synchronize with device values
  42780. */
  42781. update(): void;
  42782. /**
  42783. * Disposes the gamepad
  42784. */
  42785. dispose(): void;
  42786. }
  42787. }
  42788. declare module "babylonjs/Gamepads/gamepadManager" {
  42789. import { Observable } from "babylonjs/Misc/observable";
  42790. import { Nullable } from "babylonjs/types";
  42791. import { Scene } from "babylonjs/scene";
  42792. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42793. /**
  42794. * Manager for handling gamepads
  42795. */
  42796. export class GamepadManager {
  42797. private _scene?;
  42798. private _babylonGamepads;
  42799. private _oneGamepadConnected;
  42800. /** @hidden */
  42801. _isMonitoring: boolean;
  42802. private _gamepadEventSupported;
  42803. private _gamepadSupport?;
  42804. /**
  42805. * observable to be triggered when the gamepad controller has been connected
  42806. */
  42807. onGamepadConnectedObservable: Observable<Gamepad>;
  42808. /**
  42809. * observable to be triggered when the gamepad controller has been disconnected
  42810. */
  42811. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42812. private _onGamepadConnectedEvent;
  42813. private _onGamepadDisconnectedEvent;
  42814. /**
  42815. * Initializes the gamepad manager
  42816. * @param _scene BabylonJS scene
  42817. */
  42818. constructor(_scene?: Scene | undefined);
  42819. /**
  42820. * The gamepads in the game pad manager
  42821. */
  42822. get gamepads(): Gamepad[];
  42823. /**
  42824. * Get the gamepad controllers based on type
  42825. * @param type The type of gamepad controller
  42826. * @returns Nullable gamepad
  42827. */
  42828. getGamepadByType(type?: number): Nullable<Gamepad>;
  42829. /**
  42830. * Disposes the gamepad manager
  42831. */
  42832. dispose(): void;
  42833. private _addNewGamepad;
  42834. private _startMonitoringGamepads;
  42835. private _stopMonitoringGamepads;
  42836. /** @hidden */
  42837. _checkGamepadsStatus(): void;
  42838. private _updateGamepadObjects;
  42839. }
  42840. }
  42841. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42842. import { Nullable } from "babylonjs/types";
  42843. import { Scene } from "babylonjs/scene";
  42844. import { ISceneComponent } from "babylonjs/sceneComponent";
  42845. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42846. module "babylonjs/scene" {
  42847. interface Scene {
  42848. /** @hidden */
  42849. _gamepadManager: Nullable<GamepadManager>;
  42850. /**
  42851. * Gets the gamepad manager associated with the scene
  42852. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42853. */
  42854. gamepadManager: GamepadManager;
  42855. }
  42856. }
  42857. module "babylonjs/Cameras/freeCameraInputsManager" {
  42858. /**
  42859. * Interface representing a free camera inputs manager
  42860. */
  42861. interface FreeCameraInputsManager {
  42862. /**
  42863. * Adds gamepad input support to the FreeCameraInputsManager.
  42864. * @returns the FreeCameraInputsManager
  42865. */
  42866. addGamepad(): FreeCameraInputsManager;
  42867. }
  42868. }
  42869. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42870. /**
  42871. * Interface representing an arc rotate camera inputs manager
  42872. */
  42873. interface ArcRotateCameraInputsManager {
  42874. /**
  42875. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42876. * @returns the camera inputs manager
  42877. */
  42878. addGamepad(): ArcRotateCameraInputsManager;
  42879. }
  42880. }
  42881. /**
  42882. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42883. */
  42884. export class GamepadSystemSceneComponent implements ISceneComponent {
  42885. /**
  42886. * The component name helpfull to identify the component in the list of scene components.
  42887. */
  42888. readonly name: string;
  42889. /**
  42890. * The scene the component belongs to.
  42891. */
  42892. scene: Scene;
  42893. /**
  42894. * Creates a new instance of the component for the given scene
  42895. * @param scene Defines the scene to register the component in
  42896. */
  42897. constructor(scene: Scene);
  42898. /**
  42899. * Registers the component in a given scene
  42900. */
  42901. register(): void;
  42902. /**
  42903. * Rebuilds the elements related to this component in case of
  42904. * context lost for instance.
  42905. */
  42906. rebuild(): void;
  42907. /**
  42908. * Disposes the component and the associated ressources
  42909. */
  42910. dispose(): void;
  42911. private _beforeCameraUpdate;
  42912. }
  42913. }
  42914. declare module "babylonjs/Cameras/universalCamera" {
  42915. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42916. import { Scene } from "babylonjs/scene";
  42917. import { Vector3 } from "babylonjs/Maths/math.vector";
  42918. import "babylonjs/Gamepads/gamepadSceneComponent";
  42919. /**
  42920. * 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,
  42921. * which still works and will still be found in many Playgrounds.
  42922. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42923. */
  42924. export class UniversalCamera extends TouchCamera {
  42925. /**
  42926. * Defines the gamepad rotation sensiblity.
  42927. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42928. */
  42929. get gamepadAngularSensibility(): number;
  42930. set gamepadAngularSensibility(value: number);
  42931. /**
  42932. * Defines the gamepad move sensiblity.
  42933. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42934. */
  42935. get gamepadMoveSensibility(): number;
  42936. set gamepadMoveSensibility(value: number);
  42937. /**
  42938. * 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,
  42939. * which still works and will still be found in many Playgrounds.
  42940. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42941. * @param name Define the name of the camera in the scene
  42942. * @param position Define the start position of the camera in the scene
  42943. * @param scene Define the scene the camera belongs to
  42944. */
  42945. constructor(name: string, position: Vector3, scene: Scene);
  42946. /**
  42947. * Gets the current object class name.
  42948. * @return the class name
  42949. */
  42950. getClassName(): string;
  42951. }
  42952. }
  42953. declare module "babylonjs/Cameras/gamepadCamera" {
  42954. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42955. import { Scene } from "babylonjs/scene";
  42956. import { Vector3 } from "babylonjs/Maths/math.vector";
  42957. /**
  42958. * This represents a FPS type of camera. This is only here for back compat purpose.
  42959. * Please use the UniversalCamera instead as both are identical.
  42960. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42961. */
  42962. export class GamepadCamera extends UniversalCamera {
  42963. /**
  42964. * Instantiates a new Gamepad Camera
  42965. * This represents a FPS type of camera. This is only here for back compat purpose.
  42966. * Please use the UniversalCamera instead as both are identical.
  42967. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42968. * @param name Define the name of the camera in the scene
  42969. * @param position Define the start position of the camera in the scene
  42970. * @param scene Define the scene the camera belongs to
  42971. */
  42972. constructor(name: string, position: Vector3, scene: Scene);
  42973. /**
  42974. * Gets the current object class name.
  42975. * @return the class name
  42976. */
  42977. getClassName(): string;
  42978. }
  42979. }
  42980. declare module "babylonjs/Shaders/pass.fragment" {
  42981. /** @hidden */
  42982. export var passPixelShader: {
  42983. name: string;
  42984. shader: string;
  42985. };
  42986. }
  42987. declare module "babylonjs/Shaders/passCube.fragment" {
  42988. /** @hidden */
  42989. export var passCubePixelShader: {
  42990. name: string;
  42991. shader: string;
  42992. };
  42993. }
  42994. declare module "babylonjs/PostProcesses/passPostProcess" {
  42995. import { Nullable } from "babylonjs/types";
  42996. import { Camera } from "babylonjs/Cameras/camera";
  42997. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42998. import { Engine } from "babylonjs/Engines/engine";
  42999. import "babylonjs/Shaders/pass.fragment";
  43000. import "babylonjs/Shaders/passCube.fragment";
  43001. /**
  43002. * PassPostProcess which produces an output the same as it's input
  43003. */
  43004. export class PassPostProcess extends PostProcess {
  43005. /**
  43006. * Creates the PassPostProcess
  43007. * @param name The name of the effect.
  43008. * @param options The required width/height ratio to downsize to before computing the render pass.
  43009. * @param camera The camera to apply the render pass to.
  43010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43011. * @param engine The engine which the post process will be applied. (default: current engine)
  43012. * @param reusable If the post process can be reused on the same frame. (default: false)
  43013. * @param textureType The type of texture to be used when performing the post processing.
  43014. * @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)
  43015. */
  43016. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43017. }
  43018. /**
  43019. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43020. */
  43021. export class PassCubePostProcess extends PostProcess {
  43022. private _face;
  43023. /**
  43024. * Gets or sets the cube face to display.
  43025. * * 0 is +X
  43026. * * 1 is -X
  43027. * * 2 is +Y
  43028. * * 3 is -Y
  43029. * * 4 is +Z
  43030. * * 5 is -Z
  43031. */
  43032. get face(): number;
  43033. set face(value: number);
  43034. /**
  43035. * Creates the PassCubePostProcess
  43036. * @param name The name of the effect.
  43037. * @param options The required width/height ratio to downsize to before computing the render pass.
  43038. * @param camera The camera to apply the render pass to.
  43039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43040. * @param engine The engine which the post process will be applied. (default: current engine)
  43041. * @param reusable If the post process can be reused on the same frame. (default: false)
  43042. * @param textureType The type of texture to be used when performing the post processing.
  43043. * @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)
  43044. */
  43045. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43046. }
  43047. }
  43048. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43049. /** @hidden */
  43050. export var anaglyphPixelShader: {
  43051. name: string;
  43052. shader: string;
  43053. };
  43054. }
  43055. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43056. import { Engine } from "babylonjs/Engines/engine";
  43057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43058. import { Camera } from "babylonjs/Cameras/camera";
  43059. import "babylonjs/Shaders/anaglyph.fragment";
  43060. /**
  43061. * Postprocess used to generate anaglyphic rendering
  43062. */
  43063. export class AnaglyphPostProcess extends PostProcess {
  43064. private _passedProcess;
  43065. /**
  43066. * Creates a new AnaglyphPostProcess
  43067. * @param name defines postprocess name
  43068. * @param options defines creation options or target ratio scale
  43069. * @param rigCameras defines cameras using this postprocess
  43070. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43071. * @param engine defines hosting engine
  43072. * @param reusable defines if the postprocess will be reused multiple times per frame
  43073. */
  43074. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43075. }
  43076. }
  43077. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43078. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43079. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43080. import { Scene } from "babylonjs/scene";
  43081. import { Vector3 } from "babylonjs/Maths/math.vector";
  43082. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43083. /**
  43084. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43085. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43086. */
  43087. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43088. /**
  43089. * Creates a new AnaglyphArcRotateCamera
  43090. * @param name defines camera name
  43091. * @param alpha defines alpha angle (in radians)
  43092. * @param beta defines beta angle (in radians)
  43093. * @param radius defines radius
  43094. * @param target defines camera target
  43095. * @param interaxialDistance defines distance between each color axis
  43096. * @param scene defines the hosting scene
  43097. */
  43098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43099. /**
  43100. * Gets camera class name
  43101. * @returns AnaglyphArcRotateCamera
  43102. */
  43103. getClassName(): string;
  43104. }
  43105. }
  43106. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43107. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43108. import { Scene } from "babylonjs/scene";
  43109. import { Vector3 } from "babylonjs/Maths/math.vector";
  43110. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43111. /**
  43112. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43113. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43114. */
  43115. export class AnaglyphFreeCamera extends FreeCamera {
  43116. /**
  43117. * Creates a new AnaglyphFreeCamera
  43118. * @param name defines camera name
  43119. * @param position defines initial position
  43120. * @param interaxialDistance defines distance between each color axis
  43121. * @param scene defines the hosting scene
  43122. */
  43123. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43124. /**
  43125. * Gets camera class name
  43126. * @returns AnaglyphFreeCamera
  43127. */
  43128. getClassName(): string;
  43129. }
  43130. }
  43131. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43132. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43133. import { Scene } from "babylonjs/scene";
  43134. import { Vector3 } from "babylonjs/Maths/math.vector";
  43135. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43136. /**
  43137. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43138. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43139. */
  43140. export class AnaglyphGamepadCamera extends GamepadCamera {
  43141. /**
  43142. * Creates a new AnaglyphGamepadCamera
  43143. * @param name defines camera name
  43144. * @param position defines initial position
  43145. * @param interaxialDistance defines distance between each color axis
  43146. * @param scene defines the hosting scene
  43147. */
  43148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43149. /**
  43150. * Gets camera class name
  43151. * @returns AnaglyphGamepadCamera
  43152. */
  43153. getClassName(): string;
  43154. }
  43155. }
  43156. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43157. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43158. import { Scene } from "babylonjs/scene";
  43159. import { Vector3 } from "babylonjs/Maths/math.vector";
  43160. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43161. /**
  43162. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43163. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43164. */
  43165. export class AnaglyphUniversalCamera extends UniversalCamera {
  43166. /**
  43167. * Creates a new AnaglyphUniversalCamera
  43168. * @param name defines camera name
  43169. * @param position defines initial position
  43170. * @param interaxialDistance defines distance between each color axis
  43171. * @param scene defines the hosting scene
  43172. */
  43173. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43174. /**
  43175. * Gets camera class name
  43176. * @returns AnaglyphUniversalCamera
  43177. */
  43178. getClassName(): string;
  43179. }
  43180. }
  43181. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43182. /** @hidden */
  43183. export var stereoscopicInterlacePixelShader: {
  43184. name: string;
  43185. shader: string;
  43186. };
  43187. }
  43188. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43189. import { Camera } from "babylonjs/Cameras/camera";
  43190. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43191. import { Engine } from "babylonjs/Engines/engine";
  43192. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43193. /**
  43194. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43195. */
  43196. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43197. private _stepSize;
  43198. private _passedProcess;
  43199. /**
  43200. * Initializes a StereoscopicInterlacePostProcessI
  43201. * @param name The name of the effect.
  43202. * @param rigCameras The rig cameras to be appled to the post process
  43203. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43204. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43206. * @param engine The engine which the post process will be applied. (default: current engine)
  43207. * @param reusable If the post process can be reused on the same frame. (default: false)
  43208. */
  43209. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43210. }
  43211. /**
  43212. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43213. */
  43214. export class StereoscopicInterlacePostProcess extends PostProcess {
  43215. private _stepSize;
  43216. private _passedProcess;
  43217. /**
  43218. * Initializes a StereoscopicInterlacePostProcess
  43219. * @param name The name of the effect.
  43220. * @param rigCameras The rig cameras to be appled to the post process
  43221. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43223. * @param engine The engine which the post process will be applied. (default: current engine)
  43224. * @param reusable If the post process can be reused on the same frame. (default: false)
  43225. */
  43226. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43227. }
  43228. }
  43229. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43230. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43231. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43232. import { Scene } from "babylonjs/scene";
  43233. import { Vector3 } from "babylonjs/Maths/math.vector";
  43234. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43235. /**
  43236. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43237. * @see http://doc.babylonjs.com/features/cameras
  43238. */
  43239. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43240. /**
  43241. * Creates a new StereoscopicArcRotateCamera
  43242. * @param name defines camera name
  43243. * @param alpha defines alpha angle (in radians)
  43244. * @param beta defines beta angle (in radians)
  43245. * @param radius defines radius
  43246. * @param target defines camera target
  43247. * @param interaxialDistance defines distance between each color axis
  43248. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43249. * @param scene defines the hosting scene
  43250. */
  43251. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43252. /**
  43253. * Gets camera class name
  43254. * @returns StereoscopicArcRotateCamera
  43255. */
  43256. getClassName(): string;
  43257. }
  43258. }
  43259. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43260. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43261. import { Scene } from "babylonjs/scene";
  43262. import { Vector3 } from "babylonjs/Maths/math.vector";
  43263. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43264. /**
  43265. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43266. * @see http://doc.babylonjs.com/features/cameras
  43267. */
  43268. export class StereoscopicFreeCamera extends FreeCamera {
  43269. /**
  43270. * Creates a new StereoscopicFreeCamera
  43271. * @param name defines camera name
  43272. * @param position defines initial position
  43273. * @param interaxialDistance defines distance between each color axis
  43274. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43275. * @param scene defines the hosting scene
  43276. */
  43277. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43278. /**
  43279. * Gets camera class name
  43280. * @returns StereoscopicFreeCamera
  43281. */
  43282. getClassName(): string;
  43283. }
  43284. }
  43285. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43286. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43287. import { Scene } from "babylonjs/scene";
  43288. import { Vector3 } from "babylonjs/Maths/math.vector";
  43289. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43290. /**
  43291. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43292. * @see http://doc.babylonjs.com/features/cameras
  43293. */
  43294. export class StereoscopicGamepadCamera extends GamepadCamera {
  43295. /**
  43296. * Creates a new StereoscopicGamepadCamera
  43297. * @param name defines camera name
  43298. * @param position defines initial position
  43299. * @param interaxialDistance defines distance between each color axis
  43300. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43301. * @param scene defines the hosting scene
  43302. */
  43303. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43304. /**
  43305. * Gets camera class name
  43306. * @returns StereoscopicGamepadCamera
  43307. */
  43308. getClassName(): string;
  43309. }
  43310. }
  43311. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43312. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43313. import { Scene } from "babylonjs/scene";
  43314. import { Vector3 } from "babylonjs/Maths/math.vector";
  43315. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43316. /**
  43317. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43318. * @see http://doc.babylonjs.com/features/cameras
  43319. */
  43320. export class StereoscopicUniversalCamera extends UniversalCamera {
  43321. /**
  43322. * Creates a new StereoscopicUniversalCamera
  43323. * @param name defines camera name
  43324. * @param position defines initial position
  43325. * @param interaxialDistance defines distance between each color axis
  43326. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43327. * @param scene defines the hosting scene
  43328. */
  43329. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43330. /**
  43331. * Gets camera class name
  43332. * @returns StereoscopicUniversalCamera
  43333. */
  43334. getClassName(): string;
  43335. }
  43336. }
  43337. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43338. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43339. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43340. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43341. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43342. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43343. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43344. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43345. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43346. }
  43347. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43348. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43349. import { Scene } from "babylonjs/scene";
  43350. import { Vector3 } from "babylonjs/Maths/math.vector";
  43351. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43352. /**
  43353. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43354. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43355. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43356. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43357. */
  43358. export class VirtualJoysticksCamera extends FreeCamera {
  43359. /**
  43360. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43361. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43362. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43363. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43364. * @param name Define the name of the camera in the scene
  43365. * @param position Define the start position of the camera in the scene
  43366. * @param scene Define the scene the camera belongs to
  43367. */
  43368. constructor(name: string, position: Vector3, scene: Scene);
  43369. /**
  43370. * Gets the current object class name.
  43371. * @return the class name
  43372. */
  43373. getClassName(): string;
  43374. }
  43375. }
  43376. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43377. import { Matrix } from "babylonjs/Maths/math.vector";
  43378. /**
  43379. * This represents all the required metrics to create a VR camera.
  43380. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43381. */
  43382. export class VRCameraMetrics {
  43383. /**
  43384. * Define the horizontal resolution off the screen.
  43385. */
  43386. hResolution: number;
  43387. /**
  43388. * Define the vertical resolution off the screen.
  43389. */
  43390. vResolution: number;
  43391. /**
  43392. * Define the horizontal screen size.
  43393. */
  43394. hScreenSize: number;
  43395. /**
  43396. * Define the vertical screen size.
  43397. */
  43398. vScreenSize: number;
  43399. /**
  43400. * Define the vertical screen center position.
  43401. */
  43402. vScreenCenter: number;
  43403. /**
  43404. * Define the distance of the eyes to the screen.
  43405. */
  43406. eyeToScreenDistance: number;
  43407. /**
  43408. * Define the distance between both lenses
  43409. */
  43410. lensSeparationDistance: number;
  43411. /**
  43412. * Define the distance between both viewer's eyes.
  43413. */
  43414. interpupillaryDistance: number;
  43415. /**
  43416. * Define the distortion factor of the VR postprocess.
  43417. * Please, touch with care.
  43418. */
  43419. distortionK: number[];
  43420. /**
  43421. * Define the chromatic aberration correction factors for the VR post process.
  43422. */
  43423. chromaAbCorrection: number[];
  43424. /**
  43425. * Define the scale factor of the post process.
  43426. * The smaller the better but the slower.
  43427. */
  43428. postProcessScaleFactor: number;
  43429. /**
  43430. * Define an offset for the lens center.
  43431. */
  43432. lensCenterOffset: number;
  43433. /**
  43434. * Define if the current vr camera should compensate the distortion of the lense or not.
  43435. */
  43436. compensateDistortion: boolean;
  43437. /**
  43438. * Defines if multiview should be enabled when rendering (Default: false)
  43439. */
  43440. multiviewEnabled: boolean;
  43441. /**
  43442. * Gets the rendering aspect ratio based on the provided resolutions.
  43443. */
  43444. get aspectRatio(): number;
  43445. /**
  43446. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43447. */
  43448. get aspectRatioFov(): number;
  43449. /**
  43450. * @hidden
  43451. */
  43452. get leftHMatrix(): Matrix;
  43453. /**
  43454. * @hidden
  43455. */
  43456. get rightHMatrix(): Matrix;
  43457. /**
  43458. * @hidden
  43459. */
  43460. get leftPreViewMatrix(): Matrix;
  43461. /**
  43462. * @hidden
  43463. */
  43464. get rightPreViewMatrix(): Matrix;
  43465. /**
  43466. * Get the default VRMetrics based on the most generic setup.
  43467. * @returns the default vr metrics
  43468. */
  43469. static GetDefault(): VRCameraMetrics;
  43470. }
  43471. }
  43472. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43473. /** @hidden */
  43474. export var vrDistortionCorrectionPixelShader: {
  43475. name: string;
  43476. shader: string;
  43477. };
  43478. }
  43479. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43480. import { Camera } from "babylonjs/Cameras/camera";
  43481. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43482. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43483. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43484. /**
  43485. * VRDistortionCorrectionPostProcess used for mobile VR
  43486. */
  43487. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43488. private _isRightEye;
  43489. private _distortionFactors;
  43490. private _postProcessScaleFactor;
  43491. private _lensCenterOffset;
  43492. private _scaleIn;
  43493. private _scaleFactor;
  43494. private _lensCenter;
  43495. /**
  43496. * Initializes the VRDistortionCorrectionPostProcess
  43497. * @param name The name of the effect.
  43498. * @param camera The camera to apply the render pass to.
  43499. * @param isRightEye If this is for the right eye distortion
  43500. * @param vrMetrics All the required metrics for the VR camera
  43501. */
  43502. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43503. }
  43504. }
  43505. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43506. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43507. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43508. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43509. import { Scene } from "babylonjs/scene";
  43510. import { Vector3 } from "babylonjs/Maths/math.vector";
  43511. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43512. import "babylonjs/Cameras/RigModes/vrRigMode";
  43513. /**
  43514. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43515. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43516. */
  43517. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43518. /**
  43519. * Creates a new VRDeviceOrientationArcRotateCamera
  43520. * @param name defines camera name
  43521. * @param alpha defines the camera rotation along the logitudinal axis
  43522. * @param beta defines the camera rotation along the latitudinal axis
  43523. * @param radius defines the camera distance from its target
  43524. * @param target defines the camera target
  43525. * @param scene defines the scene the camera belongs to
  43526. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43527. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43528. */
  43529. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43530. /**
  43531. * Gets camera class name
  43532. * @returns VRDeviceOrientationArcRotateCamera
  43533. */
  43534. getClassName(): string;
  43535. }
  43536. }
  43537. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43538. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43539. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43540. import { Scene } from "babylonjs/scene";
  43541. import { Vector3 } from "babylonjs/Maths/math.vector";
  43542. import "babylonjs/Cameras/RigModes/vrRigMode";
  43543. /**
  43544. * Camera used to simulate VR rendering (based on FreeCamera)
  43545. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43546. */
  43547. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43548. /**
  43549. * Creates a new VRDeviceOrientationFreeCamera
  43550. * @param name defines camera name
  43551. * @param position defines the start position of the camera
  43552. * @param scene defines the scene the camera belongs to
  43553. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43554. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43555. */
  43556. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43557. /**
  43558. * Gets camera class name
  43559. * @returns VRDeviceOrientationFreeCamera
  43560. */
  43561. getClassName(): string;
  43562. }
  43563. }
  43564. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43565. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43566. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43567. import { Scene } from "babylonjs/scene";
  43568. import { Vector3 } from "babylonjs/Maths/math.vector";
  43569. import "babylonjs/Gamepads/gamepadSceneComponent";
  43570. /**
  43571. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43572. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43573. */
  43574. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43575. /**
  43576. * Creates a new VRDeviceOrientationGamepadCamera
  43577. * @param name defines camera name
  43578. * @param position defines the start position of the camera
  43579. * @param scene defines the scene the camera belongs to
  43580. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43581. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43582. */
  43583. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43584. /**
  43585. * Gets camera class name
  43586. * @returns VRDeviceOrientationGamepadCamera
  43587. */
  43588. getClassName(): string;
  43589. }
  43590. }
  43591. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43592. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43594. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43595. /** @hidden */
  43596. export var imageProcessingPixelShader: {
  43597. name: string;
  43598. shader: string;
  43599. };
  43600. }
  43601. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43602. import { Nullable } from "babylonjs/types";
  43603. import { Color4 } from "babylonjs/Maths/math.color";
  43604. import { Camera } from "babylonjs/Cameras/camera";
  43605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43606. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43607. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43609. import { Engine } from "babylonjs/Engines/engine";
  43610. import "babylonjs/Shaders/imageProcessing.fragment";
  43611. import "babylonjs/Shaders/postprocess.vertex";
  43612. /**
  43613. * ImageProcessingPostProcess
  43614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43615. */
  43616. export class ImageProcessingPostProcess extends PostProcess {
  43617. /**
  43618. * Default configuration related to image processing available in the PBR Material.
  43619. */
  43620. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43621. /**
  43622. * Gets the image processing configuration used either in this material.
  43623. */
  43624. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43625. /**
  43626. * Sets the Default image processing configuration used either in the this material.
  43627. *
  43628. * If sets to null, the scene one is in use.
  43629. */
  43630. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43631. /**
  43632. * Keep track of the image processing observer to allow dispose and replace.
  43633. */
  43634. private _imageProcessingObserver;
  43635. /**
  43636. * Attaches a new image processing configuration to the PBR Material.
  43637. * @param configuration
  43638. */
  43639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43640. /**
  43641. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43642. */
  43643. get colorCurves(): Nullable<ColorCurves>;
  43644. /**
  43645. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43646. */
  43647. set colorCurves(value: Nullable<ColorCurves>);
  43648. /**
  43649. * Gets wether the color curves effect is enabled.
  43650. */
  43651. get colorCurvesEnabled(): boolean;
  43652. /**
  43653. * Sets wether the color curves effect is enabled.
  43654. */
  43655. set colorCurvesEnabled(value: boolean);
  43656. /**
  43657. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43658. */
  43659. get colorGradingTexture(): Nullable<BaseTexture>;
  43660. /**
  43661. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43662. */
  43663. set colorGradingTexture(value: Nullable<BaseTexture>);
  43664. /**
  43665. * Gets wether the color grading effect is enabled.
  43666. */
  43667. get colorGradingEnabled(): boolean;
  43668. /**
  43669. * Gets wether the color grading effect is enabled.
  43670. */
  43671. set colorGradingEnabled(value: boolean);
  43672. /**
  43673. * Gets exposure used in the effect.
  43674. */
  43675. get exposure(): number;
  43676. /**
  43677. * Sets exposure used in the effect.
  43678. */
  43679. set exposure(value: number);
  43680. /**
  43681. * Gets wether tonemapping is enabled or not.
  43682. */
  43683. get toneMappingEnabled(): boolean;
  43684. /**
  43685. * Sets wether tonemapping is enabled or not
  43686. */
  43687. set toneMappingEnabled(value: boolean);
  43688. /**
  43689. * Gets the type of tone mapping effect.
  43690. */
  43691. get toneMappingType(): number;
  43692. /**
  43693. * Sets the type of tone mapping effect.
  43694. */
  43695. set toneMappingType(value: number);
  43696. /**
  43697. * Gets contrast used in the effect.
  43698. */
  43699. get contrast(): number;
  43700. /**
  43701. * Sets contrast used in the effect.
  43702. */
  43703. set contrast(value: number);
  43704. /**
  43705. * Gets Vignette stretch size.
  43706. */
  43707. get vignetteStretch(): number;
  43708. /**
  43709. * Sets Vignette stretch size.
  43710. */
  43711. set vignetteStretch(value: number);
  43712. /**
  43713. * Gets Vignette centre X Offset.
  43714. */
  43715. get vignetteCentreX(): number;
  43716. /**
  43717. * Sets Vignette centre X Offset.
  43718. */
  43719. set vignetteCentreX(value: number);
  43720. /**
  43721. * Gets Vignette centre Y Offset.
  43722. */
  43723. get vignetteCentreY(): number;
  43724. /**
  43725. * Sets Vignette centre Y Offset.
  43726. */
  43727. set vignetteCentreY(value: number);
  43728. /**
  43729. * Gets Vignette weight or intensity of the vignette effect.
  43730. */
  43731. get vignetteWeight(): number;
  43732. /**
  43733. * Sets Vignette weight or intensity of the vignette effect.
  43734. */
  43735. set vignetteWeight(value: number);
  43736. /**
  43737. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43738. * if vignetteEnabled is set to true.
  43739. */
  43740. get vignetteColor(): Color4;
  43741. /**
  43742. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43743. * if vignetteEnabled is set to true.
  43744. */
  43745. set vignetteColor(value: Color4);
  43746. /**
  43747. * Gets Camera field of view used by the Vignette effect.
  43748. */
  43749. get vignetteCameraFov(): number;
  43750. /**
  43751. * Sets Camera field of view used by the Vignette effect.
  43752. */
  43753. set vignetteCameraFov(value: number);
  43754. /**
  43755. * Gets the vignette blend mode allowing different kind of effect.
  43756. */
  43757. get vignetteBlendMode(): number;
  43758. /**
  43759. * Sets the vignette blend mode allowing different kind of effect.
  43760. */
  43761. set vignetteBlendMode(value: number);
  43762. /**
  43763. * Gets wether the vignette effect is enabled.
  43764. */
  43765. get vignetteEnabled(): boolean;
  43766. /**
  43767. * Sets wether the vignette effect is enabled.
  43768. */
  43769. set vignetteEnabled(value: boolean);
  43770. private _fromLinearSpace;
  43771. /**
  43772. * Gets wether the input of the processing is in Gamma or Linear Space.
  43773. */
  43774. get fromLinearSpace(): boolean;
  43775. /**
  43776. * Sets wether the input of the processing is in Gamma or Linear Space.
  43777. */
  43778. set fromLinearSpace(value: boolean);
  43779. /**
  43780. * Defines cache preventing GC.
  43781. */
  43782. private _defines;
  43783. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43784. /**
  43785. * "ImageProcessingPostProcess"
  43786. * @returns "ImageProcessingPostProcess"
  43787. */
  43788. getClassName(): string;
  43789. protected _updateParameters(): void;
  43790. dispose(camera?: Camera): void;
  43791. }
  43792. }
  43793. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43794. import { Scene } from "babylonjs/scene";
  43795. import { Color3 } from "babylonjs/Maths/math.color";
  43796. import { Mesh } from "babylonjs/Meshes/mesh";
  43797. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43798. import { Nullable } from "babylonjs/types";
  43799. /**
  43800. * Class containing static functions to help procedurally build meshes
  43801. */
  43802. export class GroundBuilder {
  43803. /**
  43804. * Creates a ground mesh
  43805. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43806. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43808. * @param name defines the name of the mesh
  43809. * @param options defines the options used to create the mesh
  43810. * @param scene defines the hosting scene
  43811. * @returns the ground mesh
  43812. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43813. */
  43814. static CreateGround(name: string, options: {
  43815. width?: number;
  43816. height?: number;
  43817. subdivisions?: number;
  43818. subdivisionsX?: number;
  43819. subdivisionsY?: number;
  43820. updatable?: boolean;
  43821. }, scene: any): Mesh;
  43822. /**
  43823. * Creates a tiled ground mesh
  43824. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43825. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43826. * * 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
  43827. * * 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
  43828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43829. * @param name defines the name of the mesh
  43830. * @param options defines the options used to create the mesh
  43831. * @param scene defines the hosting scene
  43832. * @returns the tiled ground mesh
  43833. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43834. */
  43835. static CreateTiledGround(name: string, options: {
  43836. xmin: number;
  43837. zmin: number;
  43838. xmax: number;
  43839. zmax: number;
  43840. subdivisions?: {
  43841. w: number;
  43842. h: number;
  43843. };
  43844. precision?: {
  43845. w: number;
  43846. h: number;
  43847. };
  43848. updatable?: boolean;
  43849. }, scene?: Nullable<Scene>): Mesh;
  43850. /**
  43851. * Creates a ground mesh from a height map
  43852. * * The parameter `url` sets the URL of the height map image resource.
  43853. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43854. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43855. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43856. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43857. * * 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.
  43858. * * 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).
  43859. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43861. * @param name defines the name of the mesh
  43862. * @param url defines the url to the height map
  43863. * @param options defines the options used to create the mesh
  43864. * @param scene defines the hosting scene
  43865. * @returns the ground mesh
  43866. * @see https://doc.babylonjs.com/babylon101/height_map
  43867. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43868. */
  43869. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43870. width?: number;
  43871. height?: number;
  43872. subdivisions?: number;
  43873. minHeight?: number;
  43874. maxHeight?: number;
  43875. colorFilter?: Color3;
  43876. alphaFilter?: number;
  43877. updatable?: boolean;
  43878. onReady?: (mesh: GroundMesh) => void;
  43879. }, scene?: Nullable<Scene>): GroundMesh;
  43880. }
  43881. }
  43882. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43883. import { Vector4 } from "babylonjs/Maths/math.vector";
  43884. import { Mesh } from "babylonjs/Meshes/mesh";
  43885. /**
  43886. * Class containing static functions to help procedurally build meshes
  43887. */
  43888. export class TorusBuilder {
  43889. /**
  43890. * Creates a torus mesh
  43891. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43892. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43893. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43897. * @param name defines the name of the mesh
  43898. * @param options defines the options used to create the mesh
  43899. * @param scene defines the hosting scene
  43900. * @returns the torus mesh
  43901. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43902. */
  43903. static CreateTorus(name: string, options: {
  43904. diameter?: number;
  43905. thickness?: number;
  43906. tessellation?: number;
  43907. updatable?: boolean;
  43908. sideOrientation?: number;
  43909. frontUVs?: Vector4;
  43910. backUVs?: Vector4;
  43911. }, scene: any): Mesh;
  43912. }
  43913. }
  43914. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43915. import { Vector4 } from "babylonjs/Maths/math.vector";
  43916. import { Color4 } from "babylonjs/Maths/math.color";
  43917. import { Mesh } from "babylonjs/Meshes/mesh";
  43918. /**
  43919. * Class containing static functions to help procedurally build meshes
  43920. */
  43921. export class CylinderBuilder {
  43922. /**
  43923. * Creates a cylinder or a cone mesh
  43924. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43925. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43926. * * 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.
  43927. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43928. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43929. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43930. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43931. * * 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).
  43932. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43933. * * 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).
  43934. * * 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
  43935. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43936. * * 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
  43937. * * 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.
  43938. * * If `enclose` is false, a ring surface is one element.
  43939. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43940. * * 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
  43941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43944. * @param name defines the name of the mesh
  43945. * @param options defines the options used to create the mesh
  43946. * @param scene defines the hosting scene
  43947. * @returns the cylinder mesh
  43948. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43949. */
  43950. static CreateCylinder(name: string, options: {
  43951. height?: number;
  43952. diameterTop?: number;
  43953. diameterBottom?: number;
  43954. diameter?: number;
  43955. tessellation?: number;
  43956. subdivisions?: number;
  43957. arc?: number;
  43958. faceColors?: Color4[];
  43959. faceUV?: Vector4[];
  43960. updatable?: boolean;
  43961. hasRings?: boolean;
  43962. enclose?: boolean;
  43963. cap?: number;
  43964. sideOrientation?: number;
  43965. frontUVs?: Vector4;
  43966. backUVs?: Vector4;
  43967. }, scene: any): Mesh;
  43968. }
  43969. }
  43970. declare module "babylonjs/XR/webXRTypes" {
  43971. import { Nullable } from "babylonjs/types";
  43972. import { IDisposable } from "babylonjs/scene";
  43973. /**
  43974. * States of the webXR experience
  43975. */
  43976. export enum WebXRState {
  43977. /**
  43978. * Transitioning to being in XR mode
  43979. */
  43980. ENTERING_XR = 0,
  43981. /**
  43982. * Transitioning to non XR mode
  43983. */
  43984. EXITING_XR = 1,
  43985. /**
  43986. * In XR mode and presenting
  43987. */
  43988. IN_XR = 2,
  43989. /**
  43990. * Not entered XR mode
  43991. */
  43992. NOT_IN_XR = 3
  43993. }
  43994. /**
  43995. * Abstraction of the XR render target
  43996. */
  43997. export interface WebXRRenderTarget extends IDisposable {
  43998. /**
  43999. * xrpresent context of the canvas which can be used to display/mirror xr content
  44000. */
  44001. canvasContext: WebGLRenderingContext;
  44002. /**
  44003. * xr layer for the canvas
  44004. */
  44005. xrLayer: Nullable<XRWebGLLayer>;
  44006. /**
  44007. * Initializes the xr layer for the session
  44008. * @param xrSession xr session
  44009. * @returns a promise that will resolve once the XR Layer has been created
  44010. */
  44011. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44012. }
  44013. }
  44014. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44015. import { Nullable } from "babylonjs/types";
  44016. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44017. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44018. /**
  44019. * COnfiguration object for WebXR output canvas
  44020. */
  44021. export class WebXRManagedOutputCanvasOptions {
  44022. /**
  44023. * Options for this XR Layer output
  44024. */
  44025. canvasOptions?: XRWebGLLayerOptions;
  44026. /**
  44027. * CSS styling for a newly created canvas (if not provided)
  44028. */
  44029. newCanvasCssStyle?: string;
  44030. /**
  44031. * An optional canvas in case you wish to create it yourself and provide it here.
  44032. * If not provided, a new canvas will be created
  44033. */
  44034. canvasElement?: HTMLCanvasElement;
  44035. /**
  44036. * Get the default values of the configuration object
  44037. * @returns default values of this configuration object
  44038. */
  44039. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44040. }
  44041. /**
  44042. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44043. */
  44044. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44045. private _options;
  44046. private _engine;
  44047. private _canvas;
  44048. /**
  44049. * Rendering context of the canvas which can be used to display/mirror xr content
  44050. */
  44051. canvasContext: WebGLRenderingContext;
  44052. /**
  44053. * xr layer for the canvas
  44054. */
  44055. xrLayer: Nullable<XRWebGLLayer>;
  44056. /**
  44057. * Initializes the xr layer for the session
  44058. * @param xrSession xr session
  44059. * @returns a promise that will resolve once the XR Layer has been created
  44060. */
  44061. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44062. /**
  44063. * Initializes the canvas to be added/removed upon entering/exiting xr
  44064. * @param _xrSessionManager The XR Session manager
  44065. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44066. */
  44067. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44068. /**
  44069. * Disposes of the object
  44070. */
  44071. dispose(): void;
  44072. private _setManagedOutputCanvas;
  44073. private _addCanvas;
  44074. private _removeCanvas;
  44075. }
  44076. }
  44077. declare module "babylonjs/XR/webXRSessionManager" {
  44078. import { Observable } from "babylonjs/Misc/observable";
  44079. import { Nullable } from "babylonjs/types";
  44080. import { IDisposable, Scene } from "babylonjs/scene";
  44081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44082. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44083. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44084. /**
  44085. * Manages an XRSession to work with Babylon's engine
  44086. * @see https://doc.babylonjs.com/how_to/webxr
  44087. */
  44088. export class WebXRSessionManager implements IDisposable {
  44089. /** The scene which the session should be created for */
  44090. scene: Scene;
  44091. /**
  44092. * Fires every time a new xrFrame arrives which can be used to update the camera
  44093. */
  44094. onXRFrameObservable: Observable<XRFrame>;
  44095. /**
  44096. * Fires when the xr session is ended either by the device or manually done
  44097. */
  44098. onXRSessionEnded: Observable<any>;
  44099. /**
  44100. * Fires when the xr session is ended either by the device or manually done
  44101. */
  44102. onXRSessionInit: Observable<XRSession>;
  44103. /**
  44104. * Fires when the reference space changed
  44105. */
  44106. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44107. /**
  44108. * Underlying xr session
  44109. */
  44110. session: XRSession;
  44111. /**
  44112. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44113. * or get the offset the player is currently at.
  44114. */
  44115. viewerReferenceSpace: XRReferenceSpace;
  44116. private _referenceSpace;
  44117. /**
  44118. * The current reference space used in this session. This reference space can constantly change!
  44119. * It is mainly used to offset the camera's position.
  44120. */
  44121. get referenceSpace(): XRReferenceSpace;
  44122. /**
  44123. * Set a new reference space and triggers the observable
  44124. */
  44125. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44126. /**
  44127. * The base reference space from which the session started. good if you want to reset your
  44128. * reference space
  44129. */
  44130. baseReferenceSpace: XRReferenceSpace;
  44131. /**
  44132. * Used just in case of a failure to initialize an immersive session.
  44133. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44134. */
  44135. defaultHeightCompensation: number;
  44136. /**
  44137. * Current XR frame
  44138. */
  44139. currentFrame: Nullable<XRFrame>;
  44140. /** WebXR timestamp updated every frame */
  44141. currentTimestamp: number;
  44142. private _xrNavigator;
  44143. private baseLayer;
  44144. private _rttProvider;
  44145. private _sessionEnded;
  44146. /**
  44147. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44148. * @param scene The scene which the session should be created for
  44149. */
  44150. constructor(
  44151. /** The scene which the session should be created for */
  44152. scene: Scene);
  44153. /**
  44154. * Initializes the manager
  44155. * After initialization enterXR can be called to start an XR session
  44156. * @returns Promise which resolves after it is initialized
  44157. */
  44158. initializeAsync(): Promise<void>;
  44159. /**
  44160. * Initializes an xr session
  44161. * @param xrSessionMode mode to initialize
  44162. * @param xrSessionInit defines optional and required values to pass to the session builder
  44163. * @returns a promise which will resolve once the session has been initialized
  44164. */
  44165. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44166. /**
  44167. * Sets the reference space on the xr session
  44168. * @param referenceSpaceType space to set
  44169. * @returns a promise that will resolve once the reference space has been set
  44170. */
  44171. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44172. /**
  44173. * Resets the reference space to the one started the session
  44174. */
  44175. resetReferenceSpace(): void;
  44176. /**
  44177. * Updates the render state of the session
  44178. * @param state state to set
  44179. * @returns a promise that resolves once the render state has been updated
  44180. */
  44181. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44182. /**
  44183. * Starts rendering to the xr layer
  44184. */
  44185. runXRRenderLoop(): void;
  44186. /**
  44187. * Gets the correct render target texture to be rendered this frame for this eye
  44188. * @param eye the eye for which to get the render target
  44189. * @returns the render target for the specified eye
  44190. */
  44191. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44192. /**
  44193. * Stops the xrSession and restores the renderloop
  44194. * @returns Promise which resolves after it exits XR
  44195. */
  44196. exitXRAsync(): Promise<void>;
  44197. /**
  44198. * Checks if a session would be supported for the creation options specified
  44199. * @param sessionMode session mode to check if supported eg. immersive-vr
  44200. * @returns A Promise that resolves to true if supported and false if not
  44201. */
  44202. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44203. /**
  44204. * Creates a WebXRRenderTarget object for the XR session
  44205. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44206. * @param options optional options to provide when creating a new render target
  44207. * @returns a WebXR render target to which the session can render
  44208. */
  44209. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44210. /**
  44211. * @hidden
  44212. * Converts the render layer of xrSession to a render target
  44213. * @param session session to create render target for
  44214. * @param scene scene the new render target should be created for
  44215. * @param baseLayer the webgl layer to create the render target for
  44216. */
  44217. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44218. /**
  44219. * Disposes of the session manager
  44220. */
  44221. dispose(): void;
  44222. /**
  44223. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44224. * @param sessionMode defines the session to test
  44225. * @returns a promise with boolean as final value
  44226. */
  44227. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44228. }
  44229. }
  44230. declare module "babylonjs/XR/webXRCamera" {
  44231. import { Scene } from "babylonjs/scene";
  44232. import { Camera } from "babylonjs/Cameras/camera";
  44233. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44234. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44235. /**
  44236. * WebXR Camera which holds the views for the xrSession
  44237. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44238. */
  44239. export class WebXRCamera extends FreeCamera {
  44240. private _xrSessionManager;
  44241. private _firstFrame;
  44242. private _referenceQuaternion;
  44243. private _referencedPosition;
  44244. private _xrInvPositionCache;
  44245. private _xrInvQuaternionCache;
  44246. /**
  44247. * Should position compensation execute on first frame.
  44248. * This is used when copying the position from a native (non XR) camera
  44249. */
  44250. compensateOnFirstFrame: boolean;
  44251. /**
  44252. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44253. * @param name the name of the camera
  44254. * @param scene the scene to add the camera to
  44255. * @param _xrSessionManager a constructed xr session manager
  44256. */
  44257. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44258. /**
  44259. * Return the user's height, unrelated to the current ground.
  44260. * This will be the y position of this camera, when ground level is 0.
  44261. */
  44262. get realWorldHeight(): number;
  44263. /** @hidden */
  44264. _updateForDualEyeDebugging(): void;
  44265. /**
  44266. * Sets this camera's transformation based on a non-vr camera
  44267. * @param otherCamera the non-vr camera to copy the transformation from
  44268. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44269. */
  44270. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44271. private _updateFromXRSession;
  44272. private _updateNumberOfRigCameras;
  44273. private _updateReferenceSpace;
  44274. private _updateReferenceSpaceOffset;
  44275. }
  44276. }
  44277. declare module "babylonjs/XR/webXRFeaturesManager" {
  44278. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44279. import { IDisposable } from "babylonjs/scene";
  44280. /**
  44281. * Defining the interface required for a (webxr) feature
  44282. */
  44283. export interface IWebXRFeature extends IDisposable {
  44284. /**
  44285. * Is this feature attached
  44286. */
  44287. attached: boolean;
  44288. /**
  44289. * Should auto-attach be disabled?
  44290. */
  44291. disableAutoAttach: boolean;
  44292. /**
  44293. * Attach the feature to the session
  44294. * Will usually be called by the features manager
  44295. *
  44296. * @param force should attachment be forced (even when already attached)
  44297. * @returns true if successful.
  44298. */
  44299. attach(force?: boolean): boolean;
  44300. /**
  44301. * Detach the feature from the session
  44302. * Will usually be called by the features manager
  44303. *
  44304. * @returns true if successful.
  44305. */
  44306. detach(): boolean;
  44307. }
  44308. /**
  44309. * A list of the currently available features without referencing them
  44310. */
  44311. export class WebXRFeatureName {
  44312. /**
  44313. * The name of the hit test feature
  44314. */
  44315. static HIT_TEST: string;
  44316. /**
  44317. * The name of the anchor system feature
  44318. */
  44319. static ANCHOR_SYSTEM: string;
  44320. /**
  44321. * The name of the background remover feature
  44322. */
  44323. static BACKGROUND_REMOVER: string;
  44324. /**
  44325. * The name of the pointer selection feature
  44326. */
  44327. static POINTER_SELECTION: string;
  44328. /**
  44329. * The name of the teleportation feature
  44330. */
  44331. static TELEPORTATION: string;
  44332. /**
  44333. * The name of the plane detection feature
  44334. */
  44335. static PLANE_DETECTION: string;
  44336. /**
  44337. * physics impostors for xr controllers feature
  44338. */
  44339. static PHYSICS_CONTROLLERS: string;
  44340. }
  44341. /**
  44342. * Defining the constructor of a feature. Used to register the modules.
  44343. */
  44344. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44345. /**
  44346. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44347. * It is mainly used in AR sessions.
  44348. *
  44349. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44350. */
  44351. export class WebXRFeaturesManager implements IDisposable {
  44352. private _xrSessionManager;
  44353. private static readonly _AvailableFeatures;
  44354. /**
  44355. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44356. * Mainly used internally.
  44357. *
  44358. * @param featureName the name of the feature to register
  44359. * @param constructorFunction the function used to construct the module
  44360. * @param version the (babylon) version of the module
  44361. * @param stable is that a stable version of this module
  44362. */
  44363. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44364. /**
  44365. * Returns a constructor of a specific feature.
  44366. *
  44367. * @param featureName the name of the feature to construct
  44368. * @param version the version of the feature to load
  44369. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44370. * @param options optional options provided to the module.
  44371. * @returns a function that, when called, will return a new instance of this feature
  44372. */
  44373. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44374. /**
  44375. * Return the latest unstable version of this feature
  44376. * @param featureName the name of the feature to search
  44377. * @returns the version number. if not found will return -1
  44378. */
  44379. static GetLatestVersionOfFeature(featureName: string): number;
  44380. /**
  44381. * Return the latest stable version of this feature
  44382. * @param featureName the name of the feature to search
  44383. * @returns the version number. if not found will return -1
  44384. */
  44385. static GetStableVersionOfFeature(featureName: string): number;
  44386. /**
  44387. * Can be used to return the list of features currently registered
  44388. *
  44389. * @returns an Array of available features
  44390. */
  44391. static GetAvailableFeatures(): string[];
  44392. /**
  44393. * Gets the versions available for a specific feature
  44394. * @param featureName the name of the feature
  44395. * @returns an array with the available versions
  44396. */
  44397. static GetAvailableVersions(featureName: string): string[];
  44398. private _features;
  44399. /**
  44400. * constructs a new features manages.
  44401. *
  44402. * @param _xrSessionManager an instance of WebXRSessionManager
  44403. */
  44404. constructor(_xrSessionManager: WebXRSessionManager);
  44405. /**
  44406. * 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.
  44407. * 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.
  44408. *
  44409. * @param featureName the name of the feature to load or the class of the feature
  44410. * @param version optional version to load. if not provided the latest version will be enabled
  44411. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44412. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44413. * @returns a new constructed feature or throws an error if feature not found.
  44414. */
  44415. enableFeature(featureName: string | {
  44416. Name: string;
  44417. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44418. /**
  44419. * Used to disable an already-enabled feature
  44420. * The feature will be disposed and will be recreated once enabled.
  44421. * @param featureName the feature to disable
  44422. * @returns true if disable was successful
  44423. */
  44424. disableFeature(featureName: string | {
  44425. Name: string;
  44426. }): boolean;
  44427. /**
  44428. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44429. * Can be used during a session to start a feature
  44430. * @param featureName the name of feature to attach
  44431. */
  44432. attachFeature(featureName: string): void;
  44433. /**
  44434. * Can be used inside a session or when the session ends to detach a specific feature
  44435. * @param featureName the name of the feature to detach
  44436. */
  44437. detachFeature(featureName: string): void;
  44438. /**
  44439. * Get the list of enabled features
  44440. * @returns an array of enabled features
  44441. */
  44442. getEnabledFeatures(): string[];
  44443. /**
  44444. * get the implementation of an enabled feature.
  44445. * @param featureName the name of the feature to load
  44446. * @returns the feature class, if found
  44447. */
  44448. getEnabledFeature(featureName: string): IWebXRFeature;
  44449. /**
  44450. * dispose this features manager
  44451. */
  44452. dispose(): void;
  44453. }
  44454. }
  44455. declare module "babylonjs/XR/webXRExperienceHelper" {
  44456. import { Observable } from "babylonjs/Misc/observable";
  44457. import { IDisposable, Scene } from "babylonjs/scene";
  44458. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44459. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44460. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44461. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44462. /**
  44463. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44464. * @see https://doc.babylonjs.com/how_to/webxr
  44465. */
  44466. export class WebXRExperienceHelper implements IDisposable {
  44467. private scene;
  44468. /**
  44469. * Camera used to render xr content
  44470. */
  44471. camera: WebXRCamera;
  44472. /**
  44473. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44474. */
  44475. state: WebXRState;
  44476. private _setState;
  44477. /**
  44478. * Fires when the state of the experience helper has changed
  44479. */
  44480. onStateChangedObservable: Observable<WebXRState>;
  44481. /**
  44482. * Observers registered here will be triggered after the camera's initial transformation is set
  44483. * This can be used to set a different ground level or an extra rotation.
  44484. *
  44485. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44486. * to the position set after this observable is done executing.
  44487. */
  44488. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44489. /** Session manager used to keep track of xr session */
  44490. sessionManager: WebXRSessionManager;
  44491. /** A features manager for this xr session */
  44492. featuresManager: WebXRFeaturesManager;
  44493. private _nonVRCamera;
  44494. private _originalSceneAutoClear;
  44495. private _supported;
  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. * Creates a WebXRExperienceHelper
  44504. * @param scene The scene the helper should be created in
  44505. */
  44506. private constructor();
  44507. /**
  44508. * Exits XR mode and returns the scene to its original state
  44509. * @returns promise that resolves after xr mode has exited
  44510. */
  44511. exitXRAsync(): Promise<void>;
  44512. /**
  44513. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44514. * @param sessionMode options for the XR session
  44515. * @param referenceSpaceType frame of reference of the XR session
  44516. * @param renderTarget the output canvas that will be used to enter XR mode
  44517. * @returns promise that resolves after xr mode has entered
  44518. */
  44519. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44520. /**
  44521. * Disposes of the experience helper
  44522. */
  44523. dispose(): void;
  44524. private _nonXRToXRCamera;
  44525. }
  44526. }
  44527. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44528. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44529. import { Observable } from "babylonjs/Misc/observable";
  44530. import { IDisposable } from "babylonjs/scene";
  44531. /**
  44532. * X-Y values for axes in WebXR
  44533. */
  44534. export interface IWebXRMotionControllerAxesValue {
  44535. /**
  44536. * The value of the x axis
  44537. */
  44538. x: number;
  44539. /**
  44540. * The value of the y-axis
  44541. */
  44542. y: number;
  44543. }
  44544. /**
  44545. * changed / previous values for the values of this component
  44546. */
  44547. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44548. /**
  44549. * current (this frame) value
  44550. */
  44551. current: T;
  44552. /**
  44553. * previous (last change) value
  44554. */
  44555. previous: T;
  44556. }
  44557. /**
  44558. * Represents changes in the component between current frame and last values recorded
  44559. */
  44560. export interface IWebXRMotionControllerComponentChanges {
  44561. /**
  44562. * will be populated with previous and current values if touched changed
  44563. */
  44564. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44565. /**
  44566. * will be populated with previous and current values if pressed changed
  44567. */
  44568. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44569. /**
  44570. * will be populated with previous and current values if value changed
  44571. */
  44572. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44573. /**
  44574. * will be populated with previous and current values if axes changed
  44575. */
  44576. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44577. }
  44578. /**
  44579. * This class represents a single component (for example button or thumbstick) of a motion controller
  44580. */
  44581. export class WebXRControllerComponent implements IDisposable {
  44582. /**
  44583. * the id of this component
  44584. */
  44585. id: string;
  44586. /**
  44587. * the type of the component
  44588. */
  44589. type: MotionControllerComponentType;
  44590. private _buttonIndex;
  44591. private _axesIndices;
  44592. /**
  44593. * Thumbstick component type
  44594. */
  44595. static THUMBSTICK: MotionControllerComponentType;
  44596. /**
  44597. * Touchpad component type
  44598. */
  44599. static TOUCHPAD: MotionControllerComponentType;
  44600. /**
  44601. * trigger component type
  44602. */
  44603. static TRIGGER: MotionControllerComponentType;
  44604. /**
  44605. * squeeze component type
  44606. */
  44607. static SQUEEZE: MotionControllerComponentType;
  44608. /**
  44609. * button component type
  44610. */
  44611. static BUTTON: MotionControllerComponentType;
  44612. /**
  44613. * Observers registered here will be triggered when the state of a button changes
  44614. * State change is either pressed / touched / value
  44615. */
  44616. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44617. /**
  44618. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44619. * the axes data changes
  44620. */
  44621. onAxisValueChangedObservable: Observable<{
  44622. x: number;
  44623. y: number;
  44624. }>;
  44625. private _currentValue;
  44626. private _touched;
  44627. private _pressed;
  44628. private _axes;
  44629. private _changes;
  44630. private _hasChanges;
  44631. /**
  44632. * Return whether or not the component changed the last frame
  44633. */
  44634. get hasChanges(): boolean;
  44635. /**
  44636. * Creates a new component for a motion controller.
  44637. * It is created by the motion controller itself
  44638. *
  44639. * @param id the id of this component
  44640. * @param type the type of the component
  44641. * @param _buttonIndex index in the buttons array of the gamepad
  44642. * @param _axesIndices indices of the values in the axes array of the gamepad
  44643. */
  44644. constructor(
  44645. /**
  44646. * the id of this component
  44647. */
  44648. id: string,
  44649. /**
  44650. * the type of the component
  44651. */
  44652. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44653. /**
  44654. * Get the current value of this component
  44655. */
  44656. get value(): number;
  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. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44667. */
  44668. get axes(): IWebXRMotionControllerAxesValue;
  44669. /**
  44670. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44671. */
  44672. get changes(): IWebXRMotionControllerComponentChanges;
  44673. /**
  44674. * Is this component a button (hence - pressable)
  44675. * @returns true if can be pressed
  44676. */
  44677. isButton(): boolean;
  44678. /**
  44679. * Are there axes correlating to this component
  44680. * @return true is axes data is available
  44681. */
  44682. isAxes(): 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. * Dispose this component
  44690. */
  44691. dispose(): void;
  44692. }
  44693. }
  44694. declare module "babylonjs/Loading/sceneLoader" {
  44695. import { Observable } from "babylonjs/Misc/observable";
  44696. import { Nullable } from "babylonjs/types";
  44697. import { Scene } from "babylonjs/scene";
  44698. import { Engine } from "babylonjs/Engines/engine";
  44699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44700. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44701. import { AssetContainer } from "babylonjs/assetContainer";
  44702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44703. import { Skeleton } from "babylonjs/Bones/skeleton";
  44704. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44705. import { WebRequest } from "babylonjs/Misc/webRequest";
  44706. /**
  44707. * Class used to represent data loading progression
  44708. */
  44709. export class SceneLoaderProgressEvent {
  44710. /** defines if data length to load can be evaluated */
  44711. readonly lengthComputable: boolean;
  44712. /** defines the loaded data length */
  44713. readonly loaded: number;
  44714. /** defines the data length to load */
  44715. readonly total: number;
  44716. /**
  44717. * Create a new progress event
  44718. * @param lengthComputable defines if data length to load can be evaluated
  44719. * @param loaded defines the loaded data length
  44720. * @param total defines the data length to load
  44721. */
  44722. constructor(
  44723. /** defines if data length to load can be evaluated */
  44724. lengthComputable: boolean,
  44725. /** defines the loaded data length */
  44726. loaded: number,
  44727. /** defines the data length to load */
  44728. total: number);
  44729. /**
  44730. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44731. * @param event defines the source event
  44732. * @returns a new SceneLoaderProgressEvent
  44733. */
  44734. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44735. }
  44736. /**
  44737. * Interface used by SceneLoader plugins to define supported file extensions
  44738. */
  44739. export interface ISceneLoaderPluginExtensions {
  44740. /**
  44741. * Defines the list of supported extensions
  44742. */
  44743. [extension: string]: {
  44744. isBinary: boolean;
  44745. };
  44746. }
  44747. /**
  44748. * Interface used by SceneLoader plugin factory
  44749. */
  44750. export interface ISceneLoaderPluginFactory {
  44751. /**
  44752. * Defines the name of the factory
  44753. */
  44754. name: string;
  44755. /**
  44756. * Function called to create a new plugin
  44757. * @return the new plugin
  44758. */
  44759. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44760. /**
  44761. * The callback that returns true if the data can be directly loaded.
  44762. * @param data string containing the file data
  44763. * @returns if the data can be loaded directly
  44764. */
  44765. canDirectLoad?(data: string): boolean;
  44766. }
  44767. /**
  44768. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44769. */
  44770. export interface ISceneLoaderPluginBase {
  44771. /**
  44772. * The friendly name of this plugin.
  44773. */
  44774. name: string;
  44775. /**
  44776. * The file extensions supported by this plugin.
  44777. */
  44778. extensions: string | ISceneLoaderPluginExtensions;
  44779. /**
  44780. * The callback called when loading from a url.
  44781. * @param scene scene loading this url
  44782. * @param url url to load
  44783. * @param onSuccess callback called when the file successfully loads
  44784. * @param onProgress callback called while file is loading (if the server supports this mode)
  44785. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44786. * @param onError callback called when the file fails to load
  44787. * @returns a file request object
  44788. */
  44789. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44790. /**
  44791. * The callback called when loading from a file object.
  44792. * @param scene scene loading this file
  44793. * @param file defines the file to load
  44794. * @param onSuccess defines the callback to call when data is loaded
  44795. * @param onProgress defines the callback to call during loading process
  44796. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44797. * @param onError defines the callback to call when an error occurs
  44798. * @returns a file request object
  44799. */
  44800. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44801. /**
  44802. * The callback that returns true if the data can be directly loaded.
  44803. * @param data string containing the file data
  44804. * @returns if the data can be loaded directly
  44805. */
  44806. canDirectLoad?(data: string): boolean;
  44807. /**
  44808. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44809. * @param scene scene loading this data
  44810. * @param data string containing the data
  44811. * @returns data to pass to the plugin
  44812. */
  44813. directLoad?(scene: Scene, data: string): any;
  44814. /**
  44815. * The callback that allows custom handling of the root url based on the response url.
  44816. * @param rootUrl the original root url
  44817. * @param responseURL the response url if available
  44818. * @returns the new root url
  44819. */
  44820. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44821. }
  44822. /**
  44823. * Interface used to define a SceneLoader plugin
  44824. */
  44825. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44826. /**
  44827. * Import meshes into a scene.
  44828. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44829. * @param scene The scene to import into
  44830. * @param data The data to import
  44831. * @param rootUrl The root url for scene and resources
  44832. * @param meshes The meshes array to import into
  44833. * @param particleSystems The particle systems array to import into
  44834. * @param skeletons The skeletons array to import into
  44835. * @param onError The callback when import fails
  44836. * @returns True if successful or false otherwise
  44837. */
  44838. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44839. /**
  44840. * Load into a scene.
  44841. * @param scene The scene to load into
  44842. * @param data The data to import
  44843. * @param rootUrl The root url for scene and resources
  44844. * @param onError The callback when import fails
  44845. * @returns True if successful or false otherwise
  44846. */
  44847. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44848. /**
  44849. * Load into an asset container.
  44850. * @param scene The scene to load into
  44851. * @param data The data to import
  44852. * @param rootUrl The root url for scene and resources
  44853. * @param onError The callback when import fails
  44854. * @returns The loaded asset container
  44855. */
  44856. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44857. }
  44858. /**
  44859. * Interface used to define an async SceneLoader plugin
  44860. */
  44861. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44862. /**
  44863. * Import meshes into a scene.
  44864. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44865. * @param scene The scene to import into
  44866. * @param data The data to import
  44867. * @param rootUrl The root url for scene and resources
  44868. * @param onProgress The callback when the load progresses
  44869. * @param fileName Defines the name of the file to load
  44870. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44871. */
  44872. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44873. meshes: AbstractMesh[];
  44874. particleSystems: IParticleSystem[];
  44875. skeletons: Skeleton[];
  44876. animationGroups: AnimationGroup[];
  44877. }>;
  44878. /**
  44879. * Load into a scene.
  44880. * @param scene The scene to load into
  44881. * @param data The data to import
  44882. * @param rootUrl The root url for scene and resources
  44883. * @param onProgress The callback when the load progresses
  44884. * @param fileName Defines the name of the file to load
  44885. * @returns Nothing
  44886. */
  44887. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44888. /**
  44889. * Load into an asset container.
  44890. * @param scene The scene to load into
  44891. * @param data The data to import
  44892. * @param rootUrl The root url for scene and resources
  44893. * @param onProgress The callback when the load progresses
  44894. * @param fileName Defines the name of the file to load
  44895. * @returns The loaded asset container
  44896. */
  44897. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44898. }
  44899. /**
  44900. * Mode that determines how to handle old animation groups before loading new ones.
  44901. */
  44902. export enum SceneLoaderAnimationGroupLoadingMode {
  44903. /**
  44904. * Reset all old animations to initial state then dispose them.
  44905. */
  44906. Clean = 0,
  44907. /**
  44908. * Stop all old animations.
  44909. */
  44910. Stop = 1,
  44911. /**
  44912. * Restart old animations from first frame.
  44913. */
  44914. Sync = 2,
  44915. /**
  44916. * Old animations remains untouched.
  44917. */
  44918. NoSync = 3
  44919. }
  44920. /**
  44921. * Class used to load scene from various file formats using registered plugins
  44922. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44923. */
  44924. export class SceneLoader {
  44925. /**
  44926. * No logging while loading
  44927. */
  44928. static readonly NO_LOGGING: number;
  44929. /**
  44930. * Minimal logging while loading
  44931. */
  44932. static readonly MINIMAL_LOGGING: number;
  44933. /**
  44934. * Summary logging while loading
  44935. */
  44936. static readonly SUMMARY_LOGGING: number;
  44937. /**
  44938. * Detailled logging while loading
  44939. */
  44940. static readonly DETAILED_LOGGING: number;
  44941. /**
  44942. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44943. */
  44944. static get ForceFullSceneLoadingForIncremental(): boolean;
  44945. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44946. /**
  44947. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44948. */
  44949. static get ShowLoadingScreen(): boolean;
  44950. static set ShowLoadingScreen(value: boolean);
  44951. /**
  44952. * Defines the current logging level (while loading the scene)
  44953. * @ignorenaming
  44954. */
  44955. static get loggingLevel(): number;
  44956. static set loggingLevel(value: number);
  44957. /**
  44958. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44959. */
  44960. static get CleanBoneMatrixWeights(): boolean;
  44961. static set CleanBoneMatrixWeights(value: boolean);
  44962. /**
  44963. * Event raised when a plugin is used to load a scene
  44964. */
  44965. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44966. private static _registeredPlugins;
  44967. private static _getDefaultPlugin;
  44968. private static _getPluginForExtension;
  44969. private static _getPluginForDirectLoad;
  44970. private static _getPluginForFilename;
  44971. private static _getDirectLoad;
  44972. private static _loadData;
  44973. private static _getFileInfo;
  44974. /**
  44975. * Gets a plugin that can load the given extension
  44976. * @param extension defines the extension to load
  44977. * @returns a plugin or null if none works
  44978. */
  44979. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44980. /**
  44981. * Gets a boolean indicating that the given extension can be loaded
  44982. * @param extension defines the extension to load
  44983. * @returns true if the extension is supported
  44984. */
  44985. static IsPluginForExtensionAvailable(extension: string): boolean;
  44986. /**
  44987. * Adds a new plugin to the list of registered plugins
  44988. * @param plugin defines the plugin to add
  44989. */
  44990. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44991. /**
  44992. * Import meshes into a scene
  44993. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44994. * @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)
  44995. * @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)
  44996. * @param scene the instance of BABYLON.Scene to append to
  44997. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44998. * @param onProgress a callback with a progress event for each file being loaded
  44999. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45000. * @param pluginExtension the extension used to determine the plugin
  45001. * @returns The loaded plugin
  45002. */
  45003. 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>;
  45004. /**
  45005. * Import meshes into a scene
  45006. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45007. * @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)
  45008. * @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)
  45009. * @param scene the instance of BABYLON.Scene to append to
  45010. * @param onProgress a callback with a progress event for each file being loaded
  45011. * @param pluginExtension the extension used to determine the plugin
  45012. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45013. */
  45014. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45015. meshes: AbstractMesh[];
  45016. particleSystems: IParticleSystem[];
  45017. skeletons: Skeleton[];
  45018. animationGroups: AnimationGroup[];
  45019. }>;
  45020. /**
  45021. * Load a scene
  45022. * @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)
  45023. * @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)
  45024. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45025. * @param onSuccess a callback with the scene when import succeeds
  45026. * @param onProgress a callback with a progress event for each file being loaded
  45027. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45028. * @param pluginExtension the extension used to determine the plugin
  45029. * @returns The loaded plugin
  45030. */
  45031. 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>;
  45032. /**
  45033. * Load a scene
  45034. * @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)
  45035. * @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)
  45036. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45037. * @param onProgress a callback with a progress event for each file being loaded
  45038. * @param pluginExtension the extension used to determine the plugin
  45039. * @returns The loaded scene
  45040. */
  45041. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45042. /**
  45043. * Append a scene
  45044. * @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)
  45045. * @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)
  45046. * @param scene is the instance of BABYLON.Scene to append to
  45047. * @param onSuccess a callback with the scene when import succeeds
  45048. * @param onProgress a callback with a progress event for each file being loaded
  45049. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45050. * @param pluginExtension the extension used to determine the plugin
  45051. * @returns The loaded plugin
  45052. */
  45053. 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>;
  45054. /**
  45055. * Append a scene
  45056. * @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)
  45057. * @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)
  45058. * @param scene is the instance of BABYLON.Scene to append to
  45059. * @param onProgress a callback with a progress event for each file being loaded
  45060. * @param pluginExtension the extension used to determine the plugin
  45061. * @returns The given scene
  45062. */
  45063. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45064. /**
  45065. * Load a scene into an asset container
  45066. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45067. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45068. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45069. * @param onSuccess a callback with the scene when import succeeds
  45070. * @param onProgress a callback with a progress event for each file being loaded
  45071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45072. * @param pluginExtension the extension used to determine the plugin
  45073. * @returns The loaded plugin
  45074. */
  45075. 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>;
  45076. /**
  45077. * Load a scene into an asset container
  45078. * @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)
  45079. * @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)
  45080. * @param scene is the instance of Scene to append to
  45081. * @param onProgress a callback with a progress event for each file being loaded
  45082. * @param pluginExtension the extension used to determine the plugin
  45083. * @returns The loaded asset container
  45084. */
  45085. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45086. /**
  45087. * Import animations from a file into a scene
  45088. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45089. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45090. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45091. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45092. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45093. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45094. * @param onSuccess a callback with the scene when import succeeds
  45095. * @param onProgress a callback with a progress event for each file being loaded
  45096. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45097. */
  45098. 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;
  45099. /**
  45100. * Import animations from a file into a scene
  45101. * @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)
  45102. * @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)
  45103. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45104. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45105. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45106. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45107. * @param onSuccess a callback with the scene when import succeeds
  45108. * @param onProgress a callback with a progress event for each file being loaded
  45109. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45110. * @returns the updated scene with imported animations
  45111. */
  45112. 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>;
  45113. }
  45114. }
  45115. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45116. import { IDisposable, Scene } from "babylonjs/scene";
  45117. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45118. import { Observable } from "babylonjs/Misc/observable";
  45119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45120. import { Nullable } from "babylonjs/types";
  45121. /**
  45122. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45123. */
  45124. export type MotionControllerHandness = "none" | "left" | "right";
  45125. /**
  45126. * The type of components available in motion controllers.
  45127. * This is not the name of the component.
  45128. */
  45129. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45130. /**
  45131. * The state of a controller component
  45132. */
  45133. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45134. /**
  45135. * The schema of motion controller layout.
  45136. * No object will be initialized using this interface
  45137. * This is used just to define the profile.
  45138. */
  45139. export interface IMotionControllerLayout {
  45140. /**
  45141. * Defines the main button component id
  45142. */
  45143. selectComponentId: string;
  45144. /**
  45145. * Available components (unsorted)
  45146. */
  45147. components: {
  45148. /**
  45149. * A map of component Ids
  45150. */
  45151. [componentId: string]: {
  45152. /**
  45153. * The type of input the component outputs
  45154. */
  45155. type: MotionControllerComponentType;
  45156. /**
  45157. * The indices of this component in the gamepad object
  45158. */
  45159. gamepadIndices: {
  45160. /**
  45161. * Index of button
  45162. */
  45163. button?: number;
  45164. /**
  45165. * If available, index of x-axis
  45166. */
  45167. xAxis?: number;
  45168. /**
  45169. * If available, index of y-axis
  45170. */
  45171. yAxis?: number;
  45172. };
  45173. /**
  45174. * The mesh's root node name
  45175. */
  45176. rootNodeName: string;
  45177. /**
  45178. * Animation definitions for this model
  45179. */
  45180. visualResponses: {
  45181. [stateKey: string]: {
  45182. /**
  45183. * What property will be animated
  45184. */
  45185. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45186. /**
  45187. * What states influence this visual reponse
  45188. */
  45189. states: MotionControllerComponentStateType[];
  45190. /**
  45191. * Type of animation - movement or visibility
  45192. */
  45193. valueNodeProperty: "transform" | "visibility";
  45194. /**
  45195. * Base node name to move. Its position will be calculated according to the min and max nodes
  45196. */
  45197. valueNodeName?: string;
  45198. /**
  45199. * Minimum movement node
  45200. */
  45201. minNodeName?: string;
  45202. /**
  45203. * Max movement node
  45204. */
  45205. maxNodeName?: string;
  45206. };
  45207. };
  45208. /**
  45209. * If touch enabled, what is the name of node to display user feedback
  45210. */
  45211. touchPointNodeName?: string;
  45212. };
  45213. };
  45214. /**
  45215. * Is it xr standard mapping or not
  45216. */
  45217. gamepadMapping: "" | "xr-standard";
  45218. /**
  45219. * Base root node of this entire model
  45220. */
  45221. rootNodeName: string;
  45222. /**
  45223. * Path to load the assets. Usually relative to the base path
  45224. */
  45225. assetPath: string;
  45226. }
  45227. /**
  45228. * A definition for the layout map in the input profile
  45229. */
  45230. export interface IMotionControllerLayoutMap {
  45231. /**
  45232. * Layouts with handness type as a key
  45233. */
  45234. [handness: string]: IMotionControllerLayout;
  45235. }
  45236. /**
  45237. * The XR Input profile schema
  45238. * Profiles can be found here:
  45239. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45240. */
  45241. export interface IMotionControllerProfile {
  45242. /**
  45243. * The id of this profile
  45244. * correlates to the profile(s) in the xrInput.profiles array
  45245. */
  45246. profileId: string;
  45247. /**
  45248. * fallback profiles for this profileId
  45249. */
  45250. fallbackProfileIds: string[];
  45251. /**
  45252. * The layout map, with handness as key
  45253. */
  45254. layouts: IMotionControllerLayoutMap;
  45255. }
  45256. /**
  45257. * A helper-interface for the 3 meshes needed for controller button animation
  45258. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45259. */
  45260. export interface IMotionControllerButtonMeshMap {
  45261. /**
  45262. * The mesh that will be changed when value changes
  45263. */
  45264. valueMesh: AbstractMesh;
  45265. /**
  45266. * the mesh that defines the pressed value mesh position.
  45267. * This is used to find the max-position of this button
  45268. */
  45269. pressedMesh: AbstractMesh;
  45270. /**
  45271. * the mesh that defines the unpressed value mesh position.
  45272. * This is used to find the min (or initial) position of this button
  45273. */
  45274. unpressedMesh: AbstractMesh;
  45275. }
  45276. /**
  45277. * A helper-interface for the 3 meshes needed for controller axis animation.
  45278. * This will be expanded when touchpad animations are fully supported
  45279. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45280. */
  45281. export interface IMotionControllerMeshMap {
  45282. /**
  45283. * The mesh that will be changed when axis value changes
  45284. */
  45285. valueMesh: AbstractMesh;
  45286. /**
  45287. * the mesh that defines the minimum value mesh position.
  45288. */
  45289. minMesh?: AbstractMesh;
  45290. /**
  45291. * the mesh that defines the maximum value mesh position.
  45292. */
  45293. maxMesh?: AbstractMesh;
  45294. }
  45295. /**
  45296. * The elements needed for change-detection of the gamepad objects in motion controllers
  45297. */
  45298. export interface IMinimalMotionControllerObject {
  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. * Available axes of this controller
  45318. */
  45319. axes: number[];
  45320. }
  45321. /**
  45322. * An Abstract Motion controller
  45323. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45324. * Each component has an observable to check for changes in value and state
  45325. */
  45326. export abstract class WebXRAbstractMotionController implements IDisposable {
  45327. protected scene: Scene;
  45328. protected layout: IMotionControllerLayout;
  45329. /**
  45330. * The gamepad object correlating to this controller
  45331. */
  45332. gamepadObject: IMinimalMotionControllerObject;
  45333. /**
  45334. * handness (left/right/none) of this controller
  45335. */
  45336. handness: MotionControllerHandness;
  45337. /**
  45338. * The profile id of this motion controller
  45339. */
  45340. abstract profileId: string;
  45341. /**
  45342. * A map of components (WebXRControllerComponent) in this motion controller
  45343. * Components have a ComponentType and can also have both button and axis definitions
  45344. */
  45345. readonly components: {
  45346. [id: string]: WebXRControllerComponent;
  45347. };
  45348. /**
  45349. * Observers registered here will be triggered when the model of this controller is done loading
  45350. */
  45351. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45352. /**
  45353. * The root mesh of the model. It is null if the model was not yet initialized
  45354. */
  45355. rootMesh: Nullable<AbstractMesh>;
  45356. /**
  45357. * Disable the model's animation. Can be set at any time.
  45358. */
  45359. disableAnimation: boolean;
  45360. private _modelReady;
  45361. /**
  45362. * constructs a new abstract motion controller
  45363. * @param scene the scene to which the model of the controller will be added
  45364. * @param layout The profile layout to load
  45365. * @param gamepadObject The gamepad object correlating to this controller
  45366. * @param handness handness (left/right/none) of this controller
  45367. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45368. */
  45369. constructor(scene: Scene, layout: IMotionControllerLayout,
  45370. /**
  45371. * The gamepad object correlating to this controller
  45372. */
  45373. gamepadObject: IMinimalMotionControllerObject,
  45374. /**
  45375. * handness (left/right/none) of this controller
  45376. */
  45377. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45378. private _initComponent;
  45379. /**
  45380. * Update this model using the current XRFrame
  45381. * @param xrFrame the current xr frame to use and update the model
  45382. */
  45383. updateFromXRFrame(xrFrame: XRFrame): void;
  45384. /**
  45385. * Get the list of components available in this motion controller
  45386. * @returns an array of strings correlating to available components
  45387. */
  45388. getComponentIds(): string[];
  45389. /**
  45390. * Get the main (Select) component of this controller as defined in the layout
  45391. * @returns the main component of this controller
  45392. */
  45393. getMainComponent(): WebXRControllerComponent;
  45394. /**
  45395. * get a component based an its component id as defined in layout.components
  45396. * @param id the id of the component
  45397. * @returns the component correlates to the id or undefined if not found
  45398. */
  45399. getComponent(id: string): WebXRControllerComponent;
  45400. /**
  45401. * Get the first component of specific type
  45402. * @param type type of component to find
  45403. * @return a controller component or null if not found
  45404. */
  45405. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45406. /**
  45407. * Returns all components of specific type
  45408. * @param type the type to search for
  45409. * @return an array of components with this type
  45410. */
  45411. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45412. /**
  45413. * Loads the model correlating to this controller
  45414. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45415. * @returns A promise fulfilled with the result of the model loading
  45416. */
  45417. loadModel(): Promise<boolean>;
  45418. /**
  45419. * Update the model itself with the current frame data
  45420. * @param xrFrame the frame to use for updating the model mesh
  45421. */
  45422. protected updateModel(xrFrame: XRFrame): void;
  45423. /**
  45424. * Moves the axis on the controller mesh based on its current state
  45425. * @param axis the index of the axis
  45426. * @param axisValue the value of the axis which determines the meshes new position
  45427. * @hidden
  45428. */
  45429. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45430. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45431. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45432. private _getGenericFilenameAndPath;
  45433. private _getGenericParentMesh;
  45434. /**
  45435. * Get the filename and path for this controller's model
  45436. * @returns a map of filename and path
  45437. */
  45438. protected abstract _getFilenameAndPath(): {
  45439. filename: string;
  45440. path: string;
  45441. };
  45442. /**
  45443. * This function will be called after the model was successfully loaded and can be used
  45444. * for mesh transformations before it is available for the user
  45445. * @param meshes the loaded meshes
  45446. */
  45447. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45448. /**
  45449. * Set the root mesh for this controller. Important for the WebXR controller class
  45450. * @param meshes the loaded meshes
  45451. */
  45452. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45453. /**
  45454. * A function executed each frame that updates the mesh (if needed)
  45455. * @param xrFrame the current xrFrame
  45456. */
  45457. protected abstract _updateModel(xrFrame: XRFrame): void;
  45458. /**
  45459. * This function is called before the mesh is loaded. It checks for loading constraints.
  45460. * For example, this function can check if the GLB loader is available
  45461. * If this function returns false, the generic controller will be loaded instead
  45462. * @returns Is the client ready to load the mesh
  45463. */
  45464. protected abstract _getModelLoadingConstraints(): boolean;
  45465. /**
  45466. * Dispose this controller, the model mesh and all its components
  45467. */
  45468. dispose(): void;
  45469. }
  45470. }
  45471. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45472. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45474. import { Scene } from "babylonjs/scene";
  45475. /**
  45476. * A generic trigger-only motion controller for WebXR
  45477. */
  45478. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45479. /**
  45480. * Static version of the profile id of this controller
  45481. */
  45482. static ProfileId: string;
  45483. profileId: string;
  45484. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45485. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45486. protected _updateModel(): void;
  45487. protected _getFilenameAndPath(): {
  45488. filename: string;
  45489. path: string;
  45490. };
  45491. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45492. protected _getModelLoadingConstraints(): boolean;
  45493. }
  45494. }
  45495. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45496. import { Vector4 } from "babylonjs/Maths/math.vector";
  45497. import { Mesh } from "babylonjs/Meshes/mesh";
  45498. import { Scene } from "babylonjs/scene";
  45499. import { Nullable } from "babylonjs/types";
  45500. /**
  45501. * Class containing static functions to help procedurally build meshes
  45502. */
  45503. export class SphereBuilder {
  45504. /**
  45505. * Creates a sphere mesh
  45506. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45507. * * 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`)
  45508. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45509. * * 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
  45510. * * 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)
  45511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45514. * @param name defines the name of the mesh
  45515. * @param options defines the options used to create the mesh
  45516. * @param scene defines the hosting scene
  45517. * @returns the sphere mesh
  45518. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45519. */
  45520. static CreateSphere(name: string, options: {
  45521. segments?: number;
  45522. diameter?: number;
  45523. diameterX?: number;
  45524. diameterY?: number;
  45525. diameterZ?: number;
  45526. arc?: number;
  45527. slice?: number;
  45528. sideOrientation?: number;
  45529. frontUVs?: Vector4;
  45530. backUVs?: Vector4;
  45531. updatable?: boolean;
  45532. }, scene?: Nullable<Scene>): Mesh;
  45533. }
  45534. }
  45535. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45537. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45538. import { Scene } from "babylonjs/scene";
  45539. /**
  45540. * A profiled motion controller has its profile loaded from an online repository.
  45541. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45542. */
  45543. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45544. private _repositoryUrl;
  45545. /**
  45546. * The profile ID of this controller. Will be populated when the controller initializes.
  45547. */
  45548. profileId: string;
  45549. private _buttonMeshMapping;
  45550. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45551. protected _getFilenameAndPath(): {
  45552. filename: string;
  45553. path: string;
  45554. };
  45555. private _touchDots;
  45556. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45557. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45558. protected _updateModel(_xrFrame: XRFrame): void;
  45559. protected _getModelLoadingConstraints(): boolean;
  45560. dispose(): void;
  45561. }
  45562. }
  45563. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45564. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45565. import { Scene } from "babylonjs/scene";
  45566. /**
  45567. * A construction function type to create a new controller based on an xrInput object
  45568. */
  45569. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45570. /**
  45571. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45572. *
  45573. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45574. * it should be replaced with auto-loaded controllers.
  45575. *
  45576. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45577. */
  45578. export class WebXRMotionControllerManager {
  45579. /**
  45580. * The base URL of the online controller repository. Can be changed at any time.
  45581. */
  45582. static BaseRepositoryUrl: string;
  45583. /**
  45584. * Use the online repository, or use only locally-defined controllers
  45585. */
  45586. static UseOnlineRepository: boolean;
  45587. /**
  45588. * Which repository gets priority - local or online
  45589. */
  45590. static PrioritizeOnlineRepository: boolean;
  45591. private static _AvailableControllers;
  45592. private static _Fallbacks;
  45593. /**
  45594. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45595. *
  45596. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45597. *
  45598. * @param type the profile type to register
  45599. * @param constructFunction the function to be called when loading this profile
  45600. */
  45601. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45602. /**
  45603. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45604. * The order of search:
  45605. *
  45606. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45607. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45608. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45609. * 4) return the generic trigger controller if none were found
  45610. *
  45611. * @param xrInput the xrInput to which a new controller is initialized
  45612. * @param scene the scene to which the model will be added
  45613. * @param forceProfile force a certain profile for this controller
  45614. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45615. */
  45616. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45617. private static _LoadProfilesFromAvailableControllers;
  45618. private static _ProfilesList;
  45619. private static _ProfileLoadingPromises;
  45620. private static _LoadProfileFromRepository;
  45621. /**
  45622. * Clear the cache used for profile loading and reload when requested again
  45623. */
  45624. static ClearProfilesCache(): void;
  45625. /**
  45626. * Will update the list of profiles available in the repository
  45627. * @return a promise that resolves to a map of profiles available online
  45628. */
  45629. static UpdateProfilesList(): Promise<{
  45630. [profile: string]: string;
  45631. }>;
  45632. /**
  45633. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45634. * @param profileId the profile to which a fallback needs to be found
  45635. * @return an array with corresponding fallback profiles
  45636. */
  45637. static FindFallbackWithProfileId(profileId: string): string[];
  45638. /**
  45639. * Register a fallback to a specific profile.
  45640. * @param profileId the profileId that will receive the fallbacks
  45641. * @param fallbacks A list of fallback profiles
  45642. */
  45643. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45644. /**
  45645. * Register the default fallbacks.
  45646. * This function is called automatically when this file is imported.
  45647. */
  45648. static DefaultFallbacks(): void;
  45649. }
  45650. }
  45651. declare module "babylonjs/XR/webXRInputSource" {
  45652. import { Observable } from "babylonjs/Misc/observable";
  45653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45654. import { Ray } from "babylonjs/Culling/ray";
  45655. import { Scene } from "babylonjs/scene";
  45656. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45657. /**
  45658. * Configuration options for the WebXR controller creation
  45659. */
  45660. export interface IWebXRControllerOptions {
  45661. /**
  45662. * Force a specific controller type for this controller.
  45663. * This can be used when creating your own profile or when testing different controllers
  45664. */
  45665. forceControllerProfile?: string;
  45666. /**
  45667. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45668. */
  45669. doNotLoadControllerMesh?: boolean;
  45670. /**
  45671. * Should the controller mesh be animated when a user interacts with it
  45672. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45673. */
  45674. disableMotionControllerAnimation?: boolean;
  45675. }
  45676. /**
  45677. * Represents an XR controller
  45678. */
  45679. export class WebXRInputSource {
  45680. private _scene;
  45681. /** The underlying input source for the controller */
  45682. inputSource: XRInputSource;
  45683. private _options;
  45684. /**
  45685. * 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
  45686. */
  45687. grip?: AbstractMesh;
  45688. /**
  45689. * Pointer which can be used to select objects or attach a visible laser to
  45690. */
  45691. pointer: AbstractMesh;
  45692. /**
  45693. * If available, this is the gamepad object related to this controller.
  45694. * Using this object it is possible to get click events and trackpad changes of the
  45695. * webxr controller that is currently being used.
  45696. */
  45697. motionController?: WebXRAbstractMotionController;
  45698. /**
  45699. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45700. */
  45701. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45702. /**
  45703. * Will be triggered when the mesh associated with the motion controller is done loading.
  45704. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45705. * A shortened version of controller -> motion controller -> on mesh loaded.
  45706. */
  45707. onMeshLoadedObservable: Observable<AbstractMesh>;
  45708. /**
  45709. * Event that fires when the controller is removed/disposed.
  45710. * The object provided as event data is this controller, after associated assets were disposed.
  45711. * uniqueId is still available.
  45712. */
  45713. onDisposeObservable: Observable<WebXRInputSource>;
  45714. private _tmpQuaternion;
  45715. private _tmpVector;
  45716. private _uniqueId;
  45717. /**
  45718. * Creates the controller
  45719. * @see https://doc.babylonjs.com/how_to/webxr
  45720. * @param _scene the scene which the controller should be associated to
  45721. * @param inputSource the underlying input source for the controller
  45722. * @param _options options for this controller creation
  45723. */
  45724. constructor(_scene: Scene,
  45725. /** The underlying input source for the controller */
  45726. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45727. /**
  45728. * Get this controllers unique id
  45729. */
  45730. get uniqueId(): string;
  45731. /**
  45732. * Updates the controller pose based on the given XRFrame
  45733. * @param xrFrame xr frame to update the pose with
  45734. * @param referenceSpace reference space to use
  45735. */
  45736. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45737. /**
  45738. * Gets a world space ray coming from the pointer or grip
  45739. * @param result the resulting ray
  45740. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45741. */
  45742. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45743. /**
  45744. * Disposes of the object
  45745. */
  45746. dispose(): void;
  45747. }
  45748. }
  45749. declare module "babylonjs/XR/webXRInput" {
  45750. import { Observable } from "babylonjs/Misc/observable";
  45751. import { IDisposable } from "babylonjs/scene";
  45752. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45753. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45754. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45755. /**
  45756. * The schema for initialization options of the XR Input class
  45757. */
  45758. export interface IWebXRInputOptions {
  45759. /**
  45760. * If set to true no model will be automatically loaded
  45761. */
  45762. doNotLoadControllerMeshes?: boolean;
  45763. /**
  45764. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45765. * If not found, the xr input profile data will be used.
  45766. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45767. */
  45768. forceInputProfile?: string;
  45769. /**
  45770. * Do not send a request to the controlle repository to load the profile.
  45771. *
  45772. * Instead, use the controllers available in babylon itself.
  45773. */
  45774. disableOnlineControllerRepository?: boolean;
  45775. /**
  45776. * A custom URL for the controllers repository
  45777. */
  45778. customControllersRepositoryURL?: string;
  45779. /**
  45780. * Should the controller model's components not move according to the user input
  45781. */
  45782. disableControllerAnimation?: boolean;
  45783. }
  45784. /**
  45785. * XR input used to track XR inputs such as controllers/rays
  45786. */
  45787. export class WebXRInput implements IDisposable {
  45788. /**
  45789. * the xr session manager for this session
  45790. */
  45791. xrSessionManager: WebXRSessionManager;
  45792. /**
  45793. * the WebXR camera for this session. Mainly used for teleportation
  45794. */
  45795. xrCamera: WebXRCamera;
  45796. private readonly options;
  45797. /**
  45798. * XR controllers being tracked
  45799. */
  45800. controllers: Array<WebXRInputSource>;
  45801. private _frameObserver;
  45802. private _sessionEndedObserver;
  45803. private _sessionInitObserver;
  45804. /**
  45805. * Event when a controller has been connected/added
  45806. */
  45807. onControllerAddedObservable: Observable<WebXRInputSource>;
  45808. /**
  45809. * Event when a controller has been removed/disconnected
  45810. */
  45811. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45812. /**
  45813. * Initializes the WebXRInput
  45814. * @param xrSessionManager the xr session manager for this session
  45815. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45816. * @param options = initialization options for this xr input
  45817. */
  45818. constructor(
  45819. /**
  45820. * the xr session manager for this session
  45821. */
  45822. xrSessionManager: WebXRSessionManager,
  45823. /**
  45824. * the WebXR camera for this session. Mainly used for teleportation
  45825. */
  45826. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45827. private _onInputSourcesChange;
  45828. private _addAndRemoveControllers;
  45829. /**
  45830. * Disposes of the object
  45831. */
  45832. dispose(): void;
  45833. }
  45834. }
  45835. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45836. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45837. import { Observable, EventState } from "babylonjs/Misc/observable";
  45838. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45839. /**
  45840. * This is the base class for all WebXR features.
  45841. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45842. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45843. */
  45844. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45845. protected _xrSessionManager: WebXRSessionManager;
  45846. /**
  45847. * Construct a new (abstract) webxr feature
  45848. * @param _xrSessionManager the xr session manager for this feature
  45849. */
  45850. constructor(_xrSessionManager: WebXRSessionManager);
  45851. private _attached;
  45852. private _removeOnDetach;
  45853. /**
  45854. * Is this feature attached
  45855. */
  45856. get attached(): boolean;
  45857. /**
  45858. * Should auto-attach be disabled?
  45859. */
  45860. disableAutoAttach: boolean;
  45861. /**
  45862. * attach this feature
  45863. *
  45864. * @param force should attachment be forced (even when already attached)
  45865. * @returns true if successful, false is failed or already attached
  45866. */
  45867. attach(force?: boolean): boolean;
  45868. /**
  45869. * detach this feature.
  45870. *
  45871. * @returns true if successful, false if failed or already detached
  45872. */
  45873. detach(): boolean;
  45874. /**
  45875. * Dispose this feature and all of the resources attached
  45876. */
  45877. dispose(): void;
  45878. /**
  45879. * Code in this function will be executed on each xrFrame received from the browser.
  45880. * This function will not execute after the feature is detached.
  45881. * @param _xrFrame the current frame
  45882. */
  45883. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45884. /**
  45885. * This is used to register callbacks that will automatically be removed when detach is called.
  45886. * @param observable the observable to which the observer will be attached
  45887. * @param callback the callback to register
  45888. */
  45889. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45890. }
  45891. }
  45892. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45893. import { IDisposable, Scene } from "babylonjs/scene";
  45894. import { Nullable } from "babylonjs/types";
  45895. import { Observable } from "babylonjs/Misc/observable";
  45896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45897. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45898. import { Camera } from "babylonjs/Cameras/camera";
  45899. /**
  45900. * Renders a layer on top of an existing scene
  45901. */
  45902. export class UtilityLayerRenderer implements IDisposable {
  45903. /** the original scene that will be rendered on top of */
  45904. originalScene: Scene;
  45905. private _pointerCaptures;
  45906. private _lastPointerEvents;
  45907. private static _DefaultUtilityLayer;
  45908. private static _DefaultKeepDepthUtilityLayer;
  45909. private _sharedGizmoLight;
  45910. private _renderCamera;
  45911. /**
  45912. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45913. * @returns the camera that is used when rendering the utility layer
  45914. */
  45915. getRenderCamera(): Camera;
  45916. /**
  45917. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45918. * @param cam the camera that should be used when rendering the utility layer
  45919. */
  45920. setRenderCamera(cam: Nullable<Camera>): void;
  45921. /**
  45922. * @hidden
  45923. * Light which used by gizmos to get light shading
  45924. */
  45925. _getSharedGizmoLight(): HemisphericLight;
  45926. /**
  45927. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45928. */
  45929. pickUtilitySceneFirst: boolean;
  45930. /**
  45931. * 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)
  45932. */
  45933. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45934. /**
  45935. * 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)
  45936. */
  45937. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45938. /**
  45939. * The scene that is rendered on top of the original scene
  45940. */
  45941. utilityLayerScene: Scene;
  45942. /**
  45943. * If the utility layer should automatically be rendered on top of existing scene
  45944. */
  45945. shouldRender: boolean;
  45946. /**
  45947. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45948. */
  45949. onlyCheckPointerDownEvents: boolean;
  45950. /**
  45951. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45952. */
  45953. processAllEvents: boolean;
  45954. /**
  45955. * Observable raised when the pointer move from the utility layer scene to the main scene
  45956. */
  45957. onPointerOutObservable: Observable<number>;
  45958. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45959. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45960. private _afterRenderObserver;
  45961. private _sceneDisposeObserver;
  45962. private _originalPointerObserver;
  45963. /**
  45964. * Instantiates a UtilityLayerRenderer
  45965. * @param originalScene the original scene that will be rendered on top of
  45966. * @param handleEvents boolean indicating if the utility layer should handle events
  45967. */
  45968. constructor(
  45969. /** the original scene that will be rendered on top of */
  45970. originalScene: Scene, handleEvents?: boolean);
  45971. private _notifyObservers;
  45972. /**
  45973. * Renders the utility layers scene on top of the original scene
  45974. */
  45975. render(): void;
  45976. /**
  45977. * Disposes of the renderer
  45978. */
  45979. dispose(): void;
  45980. private _updateCamera;
  45981. }
  45982. }
  45983. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45984. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45985. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45986. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45987. import { Scene } from "babylonjs/scene";
  45988. import { Nullable } from "babylonjs/types";
  45989. import { Color3 } from "babylonjs/Maths/math.color";
  45990. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45991. /**
  45992. * Options interface for the pointer selection module
  45993. */
  45994. export interface IWebXRControllerPointerSelectionOptions {
  45995. /**
  45996. * the xr input to use with this pointer selection
  45997. */
  45998. xrInput: WebXRInput;
  45999. /**
  46000. * Different button type to use instead of the main component
  46001. */
  46002. overrideButtonId?: string;
  46003. /**
  46004. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  46005. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46006. * 3000 means 3 seconds between pointing at something and selecting it
  46007. */
  46008. timeToSelect?: number;
  46009. /**
  46010. * 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)
  46011. * If not disabled, the last picked point will be used to execute a pointer up event
  46012. * If disabled, pointer up event will be triggered right after the pointer down event.
  46013. * Used in screen and gaze target ray mode only
  46014. */
  46015. disablePointerUpOnTouchOut: boolean;
  46016. /**
  46017. * For gaze mode (time to select instead of press)
  46018. */
  46019. forceGazeMode: boolean;
  46020. /**
  46021. * 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
  46022. * to start a new countdown to the pointer down event.
  46023. * Defaults to 1.
  46024. */
  46025. gazeModePointerMovedFactor?: number;
  46026. /**
  46027. * Should meshes created here be added to a utility layer or the main scene
  46028. */
  46029. useUtilityLayer?: boolean;
  46030. /**
  46031. * if provided, this scene will be used to render meshes.
  46032. */
  46033. customUtilityLayerScene?: Scene;
  46034. }
  46035. /**
  46036. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46037. */
  46038. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46039. private readonly _options;
  46040. /**
  46041. * The module's name
  46042. */
  46043. static readonly Name: string;
  46044. /**
  46045. * The (Babylon) version of this module.
  46046. * This is an integer representing the implementation version.
  46047. * This number does not correspond to the webxr specs version
  46048. */
  46049. static readonly Version: number;
  46050. /**
  46051. * This color will be set to the laser pointer when selection is triggered
  46052. */
  46053. laserPointerPickedColor: Color3;
  46054. /**
  46055. * This color will be applied to the selection ring when selection is triggered
  46056. */
  46057. selectionMeshPickedColor: Color3;
  46058. /**
  46059. * default color of the selection ring
  46060. */
  46061. selectionMeshDefaultColor: Color3;
  46062. /**
  46063. * Default color of the laser pointer
  46064. */
  46065. lasterPointerDefaultColor: Color3;
  46066. /**
  46067. * Should the laser pointer be displayed
  46068. */
  46069. displayLaserPointer: boolean;
  46070. /**
  46071. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46072. */
  46073. displaySelectionMesh: boolean;
  46074. /**
  46075. * Disable lighting on the laser pointer (so it will always be visible)
  46076. */
  46077. disablePointerLighting: boolean;
  46078. /**
  46079. * Disable lighting on the selection mesh (so it will always be visible)
  46080. */
  46081. disableSelectionMeshLighting: boolean;
  46082. private static _idCounter;
  46083. private _tmpRay;
  46084. private _controllers;
  46085. private _scene;
  46086. /**
  46087. * constructs a new background remover module
  46088. * @param _xrSessionManager the session manager for this module
  46089. * @param _options read-only options to be used in this module
  46090. */
  46091. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46092. /**
  46093. * attach this feature
  46094. * Will usually be called by the features manager
  46095. *
  46096. * @returns true if successful.
  46097. */
  46098. attach(): boolean;
  46099. /**
  46100. * detach this feature.
  46101. * Will usually be called by the features manager
  46102. *
  46103. * @returns true if successful.
  46104. */
  46105. detach(): boolean;
  46106. /**
  46107. * Get the xr controller that correlates to the pointer id in the pointer event
  46108. *
  46109. * @param id the pointer id to search for
  46110. * @returns the controller that correlates to this id or null if not found
  46111. */
  46112. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46113. protected _onXRFrame(_xrFrame: XRFrame): void;
  46114. private _attachController;
  46115. private _attachScreenRayMode;
  46116. private _attachGazeMode;
  46117. private _tmpVectorForPickCompare;
  46118. private _pickingMoved;
  46119. private _attachTrackedPointerRayMode;
  46120. private _detachController;
  46121. private _generateNewMeshPair;
  46122. private _convertNormalToDirectionOfRay;
  46123. private _updatePointerDistance;
  46124. }
  46125. }
  46126. declare module "babylonjs/XR/webXREnterExitUI" {
  46127. import { Nullable } from "babylonjs/types";
  46128. import { Observable } from "babylonjs/Misc/observable";
  46129. import { IDisposable, Scene } from "babylonjs/scene";
  46130. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46131. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46132. /**
  46133. * Button which can be used to enter a different mode of XR
  46134. */
  46135. export class WebXREnterExitUIButton {
  46136. /** button element */
  46137. element: HTMLElement;
  46138. /** XR initialization options for the button */
  46139. sessionMode: XRSessionMode;
  46140. /** Reference space type */
  46141. referenceSpaceType: XRReferenceSpaceType;
  46142. /**
  46143. * Creates a WebXREnterExitUIButton
  46144. * @param element button element
  46145. * @param sessionMode XR initialization session mode
  46146. * @param referenceSpaceType the type of reference space to be used
  46147. */
  46148. constructor(
  46149. /** button element */
  46150. element: HTMLElement,
  46151. /** XR initialization options for the button */
  46152. sessionMode: XRSessionMode,
  46153. /** Reference space type */
  46154. referenceSpaceType: XRReferenceSpaceType);
  46155. /**
  46156. * Overwritable function which can be used to update the button's visuals when the state changes
  46157. * @param activeButton the current active button in the UI
  46158. */
  46159. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46160. }
  46161. /**
  46162. * Options to create the webXR UI
  46163. */
  46164. export class WebXREnterExitUIOptions {
  46165. /**
  46166. * Context to enter xr with
  46167. */
  46168. renderTarget?: Nullable<WebXRRenderTarget>;
  46169. /**
  46170. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46171. */
  46172. customButtons?: Array<WebXREnterExitUIButton>;
  46173. /**
  46174. * A session mode to use when creating the default button.
  46175. * Default is immersive-vr
  46176. */
  46177. sessionMode?: XRSessionMode;
  46178. /**
  46179. * A reference space type to use when creating the default button.
  46180. * Default is local-floor
  46181. */
  46182. referenceSpaceType?: XRReferenceSpaceType;
  46183. }
  46184. /**
  46185. * UI to allow the user to enter/exit XR mode
  46186. */
  46187. export class WebXREnterExitUI implements IDisposable {
  46188. private scene;
  46189. /** version of the options passed to this UI */
  46190. options: WebXREnterExitUIOptions;
  46191. private _overlay;
  46192. private _buttons;
  46193. private _activeButton;
  46194. /**
  46195. * Fired every time the active button is changed.
  46196. *
  46197. * When xr is entered via a button that launches xr that button will be the callback parameter
  46198. *
  46199. * When exiting xr the callback parameter will be null)
  46200. */
  46201. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46202. /**
  46203. * Creates UI to allow the user to enter/exit XR mode
  46204. * @param scene the scene to add the ui to
  46205. * @param helper the xr experience helper to enter/exit xr with
  46206. * @param options options to configure the UI
  46207. * @returns the created ui
  46208. */
  46209. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  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. private _updateButtons;
  46217. /**
  46218. * Disposes of the object
  46219. */
  46220. dispose(): void;
  46221. }
  46222. }
  46223. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46224. import { Vector3 } from "babylonjs/Maths/math.vector";
  46225. import { Color4 } from "babylonjs/Maths/math.color";
  46226. import { Nullable } from "babylonjs/types";
  46227. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46228. import { Scene } from "babylonjs/scene";
  46229. /**
  46230. * Class containing static functions to help procedurally build meshes
  46231. */
  46232. export class LinesBuilder {
  46233. /**
  46234. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46235. * * 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
  46236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46237. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46238. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46239. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46241. * * 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
  46242. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46245. * @param name defines the name of the new line system
  46246. * @param options defines the options used to create the line system
  46247. * @param scene defines the hosting scene
  46248. * @returns a new line system mesh
  46249. */
  46250. static CreateLineSystem(name: string, options: {
  46251. lines: Vector3[][];
  46252. updatable?: boolean;
  46253. instance?: Nullable<LinesMesh>;
  46254. colors?: Nullable<Color4[][]>;
  46255. useVertexAlpha?: boolean;
  46256. }, scene: Nullable<Scene>): LinesMesh;
  46257. /**
  46258. * Creates a line mesh
  46259. * 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
  46260. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46261. * * The parameter `points` is an array successive Vector3
  46262. * * 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
  46263. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46264. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46265. * * When updating an instance, remember that only point positions can change, not the number of points
  46266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46268. * @param name defines the name of the new line system
  46269. * @param options defines the options used to create the line system
  46270. * @param scene defines the hosting scene
  46271. * @returns a new line mesh
  46272. */
  46273. static CreateLines(name: string, options: {
  46274. points: Vector3[];
  46275. updatable?: boolean;
  46276. instance?: Nullable<LinesMesh>;
  46277. colors?: Color4[];
  46278. useVertexAlpha?: boolean;
  46279. }, scene?: Nullable<Scene>): LinesMesh;
  46280. /**
  46281. * Creates a dashed line mesh
  46282. * * 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
  46283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46284. * * The parameter `points` is an array successive Vector3
  46285. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46286. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46287. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46288. * * 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
  46289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46290. * * When updating an instance, remember that only point positions can change, not the number of points
  46291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46292. * @param name defines the name of the mesh
  46293. * @param options defines the options used to create the mesh
  46294. * @param scene defines the hosting scene
  46295. * @returns the dashed line mesh
  46296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46297. */
  46298. static CreateDashedLines(name: string, options: {
  46299. points: Vector3[];
  46300. dashSize?: number;
  46301. gapSize?: number;
  46302. dashNb?: number;
  46303. updatable?: boolean;
  46304. instance?: LinesMesh;
  46305. useVertexAlpha?: boolean;
  46306. }, scene?: Nullable<Scene>): LinesMesh;
  46307. }
  46308. }
  46309. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46310. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46311. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46312. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46314. import { Material } from "babylonjs/Materials/material";
  46315. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46316. import { Scene } from "babylonjs/scene";
  46317. /**
  46318. * The options container for the teleportation module
  46319. */
  46320. export interface IWebXRTeleportationOptions {
  46321. /**
  46322. * Babylon XR Input class for controller
  46323. */
  46324. xrInput: WebXRInput;
  46325. /**
  46326. * A list of meshes to use as floor meshes.
  46327. * Meshes can be added and removed after initializing the feature using the
  46328. * addFloorMesh and removeFloorMesh functions
  46329. * If empty, rotation will still work
  46330. */
  46331. floorMeshes?: AbstractMesh[];
  46332. /**
  46333. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46334. * If you want to support rotation, make sure your mesh has a direction indicator.
  46335. *
  46336. * When left untouched, the default mesh will be initialized.
  46337. */
  46338. teleportationTargetMesh?: AbstractMesh;
  46339. /**
  46340. * Values to configure the default target mesh
  46341. */
  46342. defaultTargetMeshOptions?: {
  46343. /**
  46344. * Fill color of the teleportation area
  46345. */
  46346. teleportationFillColor?: string;
  46347. /**
  46348. * Border color for the teleportation area
  46349. */
  46350. teleportationBorderColor?: string;
  46351. /**
  46352. * Disable the mesh's animation sequence
  46353. */
  46354. disableAnimation?: boolean;
  46355. /**
  46356. * Disable lighting on the material or the ring and arrow
  46357. */
  46358. disableLighting?: boolean;
  46359. /**
  46360. * Override the default material of the torus and arrow
  46361. */
  46362. torusArrowMaterial?: Material;
  46363. };
  46364. /**
  46365. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46366. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46367. */
  46368. useMainComponentOnly?: boolean;
  46369. /**
  46370. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46371. */
  46372. timeToTeleport?: number;
  46373. /**
  46374. * Should meshes created here be added to a utility layer or the main scene
  46375. */
  46376. useUtilityLayer?: boolean;
  46377. /**
  46378. * if provided, this scene will be used to render meshes.
  46379. */
  46380. customUtilityLayerScene?: Scene;
  46381. }
  46382. /**
  46383. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46384. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  46385. * the input of the attached controllers.
  46386. */
  46387. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46388. private _options;
  46389. /**
  46390. * The module's name
  46391. */
  46392. static readonly Name: string;
  46393. /**
  46394. * The (Babylon) version of this module.
  46395. * This is an integer representing the implementation version.
  46396. * This number does not correspond to the webxr specs version
  46397. */
  46398. static readonly Version: number;
  46399. /**
  46400. * Is rotation enabled when moving forward?
  46401. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46402. */
  46403. rotationEnabled: boolean;
  46404. /**
  46405. * Should the module support parabolic ray on top of direct ray
  46406. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46407. * Very helpful when moving between floors / different heights
  46408. */
  46409. parabolicRayEnabled: boolean;
  46410. /**
  46411. * The distance from the user to the inspection point in the direction of the controller
  46412. * A higher number will allow the user to move further
  46413. * defaults to 5 (meters, in xr units)
  46414. */
  46415. parabolicCheckRadius: number;
  46416. /**
  46417. * How much rotation should be applied when rotating right and left
  46418. */
  46419. rotationAngle: number;
  46420. /**
  46421. * Is movement backwards enabled
  46422. */
  46423. backwardsMovementEnabled: boolean;
  46424. /**
  46425. * Distance to travel when moving backwards
  46426. */
  46427. backwardsTeleportationDistance: number;
  46428. /**
  46429. * Add a new mesh to the floor meshes array
  46430. * @param mesh the mesh to use as floor mesh
  46431. */
  46432. addFloorMesh(mesh: AbstractMesh): void;
  46433. /**
  46434. * Remove a mesh from the floor meshes array
  46435. * @param mesh the mesh to remove
  46436. */
  46437. removeFloorMesh(mesh: AbstractMesh): void;
  46438. /**
  46439. * Remove a mesh from the floor meshes array using its name
  46440. * @param name the mesh name to remove
  46441. */
  46442. removeFloorMeshByName(name: string): void;
  46443. private _tmpRay;
  46444. private _tmpVector;
  46445. private _floorMeshes;
  46446. private _controllers;
  46447. /**
  46448. * constructs a new anchor system
  46449. * @param _xrSessionManager an instance of WebXRSessionManager
  46450. * @param _options configuration object for this feature
  46451. */
  46452. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46453. private _selectionFeature;
  46454. /**
  46455. * This function sets a selection feature that will be disabled when
  46456. * the forward ray is shown and will be reattached when hidden.
  46457. * This is used to remove the selection rays when moving.
  46458. * @param selectionFeature the feature to disable when forward movement is enabled
  46459. */
  46460. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46461. attach(): boolean;
  46462. detach(): boolean;
  46463. dispose(): void;
  46464. protected _onXRFrame(_xrFrame: XRFrame): void;
  46465. private _currentTeleportationControllerId;
  46466. private _attachController;
  46467. private _teleportForward;
  46468. private _detachController;
  46469. private createDefaultTargetMesh;
  46470. private setTargetMeshVisibility;
  46471. private setTargetMeshPosition;
  46472. private _quadraticBezierCurve;
  46473. private _showParabolicPath;
  46474. }
  46475. }
  46476. declare module "babylonjs/XR/webXRDefaultExperience" {
  46477. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46478. import { Scene } from "babylonjs/scene";
  46479. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46480. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46481. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46482. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46484. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46485. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46486. /**
  46487. * Options for the default xr helper
  46488. */
  46489. export class WebXRDefaultExperienceOptions {
  46490. /**
  46491. * Floor meshes that will be used for teleporting
  46492. */
  46493. floorMeshes?: Array<AbstractMesh>;
  46494. /**
  46495. * Enable or disable default UI to enter XR
  46496. */
  46497. disableDefaultUI?: boolean;
  46498. /**
  46499. * optional configuration for the output canvas
  46500. */
  46501. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46502. /**
  46503. * optional UI options. This can be used among other to change session mode and reference space type
  46504. */
  46505. uiOptions?: WebXREnterExitUIOptions;
  46506. /**
  46507. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46508. */
  46509. inputOptions?: IWebXRInputOptions;
  46510. /**
  46511. * Should teleportation not initialize. defaults to false.
  46512. */
  46513. disableTeleportation?: boolean;
  46514. /**
  46515. * If set to true, the first frame will not be used to reset position
  46516. * The first frame is mainly used when copying transformation from the old camera
  46517. * Mainly used in AR
  46518. */
  46519. ignoreNativeCameraTransformation?: boolean;
  46520. /**
  46521. * When loading teleportation and pointer select, use stable versions instead of latest.
  46522. */
  46523. useStablePlugins?: boolean;
  46524. }
  46525. /**
  46526. * Default experience which provides a similar setup to the previous webVRExperience
  46527. */
  46528. export class WebXRDefaultExperience {
  46529. /**
  46530. * Base experience
  46531. */
  46532. baseExperience: WebXRExperienceHelper;
  46533. /**
  46534. * Input experience extension
  46535. */
  46536. input: WebXRInput;
  46537. /**
  46538. * Enables laser pointer and selection
  46539. */
  46540. pointerSelection: WebXRControllerPointerSelection;
  46541. /**
  46542. * Enables teleportation
  46543. */
  46544. teleportation: WebXRMotionControllerTeleportation;
  46545. /**
  46546. * Enables ui for entering/exiting xr
  46547. */
  46548. enterExitUI: WebXREnterExitUI;
  46549. /**
  46550. * Default target xr should render to
  46551. */
  46552. renderTarget: WebXRRenderTarget;
  46553. /**
  46554. * Creates the default xr experience
  46555. * @param scene scene
  46556. * @param options options for basic configuration
  46557. * @returns resulting WebXRDefaultExperience
  46558. */
  46559. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46560. private constructor();
  46561. /**
  46562. * DIsposes of the experience helper
  46563. */
  46564. dispose(): void;
  46565. }
  46566. }
  46567. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46568. import { Observable } from "babylonjs/Misc/observable";
  46569. import { Nullable } from "babylonjs/types";
  46570. import { Camera } from "babylonjs/Cameras/camera";
  46571. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46572. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46573. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46574. import { Scene } from "babylonjs/scene";
  46575. import { Vector3 } from "babylonjs/Maths/math.vector";
  46576. import { Color3 } from "babylonjs/Maths/math.color";
  46577. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46579. import { Mesh } from "babylonjs/Meshes/mesh";
  46580. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46581. import { EasingFunction } from "babylonjs/Animations/easing";
  46582. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46583. import "babylonjs/Meshes/Builders/groundBuilder";
  46584. import "babylonjs/Meshes/Builders/torusBuilder";
  46585. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46586. import "babylonjs/Gamepads/gamepadSceneComponent";
  46587. import "babylonjs/Animations/animatable";
  46588. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46589. /**
  46590. * Options to modify the vr teleportation behavior.
  46591. */
  46592. export interface VRTeleportationOptions {
  46593. /**
  46594. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46595. */
  46596. floorMeshName?: string;
  46597. /**
  46598. * A list of meshes to be used as the teleportation floor. (default: empty)
  46599. */
  46600. floorMeshes?: Mesh[];
  46601. /**
  46602. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46603. */
  46604. teleportationMode?: number;
  46605. /**
  46606. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46607. */
  46608. teleportationTime?: number;
  46609. /**
  46610. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46611. */
  46612. teleportationSpeed?: number;
  46613. /**
  46614. * The easing function used in the animation or null for Linear. (default CircleEase)
  46615. */
  46616. easingFunction?: EasingFunction;
  46617. }
  46618. /**
  46619. * Options to modify the vr experience helper's behavior.
  46620. */
  46621. export interface VRExperienceHelperOptions extends WebVROptions {
  46622. /**
  46623. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46624. */
  46625. createDeviceOrientationCamera?: boolean;
  46626. /**
  46627. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46628. */
  46629. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46630. /**
  46631. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46632. */
  46633. laserToggle?: boolean;
  46634. /**
  46635. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46636. */
  46637. floorMeshes?: Mesh[];
  46638. /**
  46639. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46640. */
  46641. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46642. /**
  46643. * Defines if WebXR should be used instead of WebVR (if available)
  46644. */
  46645. useXR?: boolean;
  46646. }
  46647. /**
  46648. * Event containing information after VR has been entered
  46649. */
  46650. export class OnAfterEnteringVRObservableEvent {
  46651. /**
  46652. * If entering vr was successful
  46653. */
  46654. success: boolean;
  46655. }
  46656. /**
  46657. * Helps to quickly add VR support to an existing scene.
  46658. * See http://doc.babylonjs.com/how_to/webvr_helper
  46659. */
  46660. export class VRExperienceHelper {
  46661. /** Options to modify the vr experience helper's behavior. */
  46662. webVROptions: VRExperienceHelperOptions;
  46663. private _scene;
  46664. private _position;
  46665. private _btnVR;
  46666. private _btnVRDisplayed;
  46667. private _webVRsupported;
  46668. private _webVRready;
  46669. private _webVRrequesting;
  46670. private _webVRpresenting;
  46671. private _hasEnteredVR;
  46672. private _fullscreenVRpresenting;
  46673. private _inputElement;
  46674. private _webVRCamera;
  46675. private _vrDeviceOrientationCamera;
  46676. private _deviceOrientationCamera;
  46677. private _existingCamera;
  46678. private _onKeyDown;
  46679. private _onVrDisplayPresentChange;
  46680. private _onVRDisplayChanged;
  46681. private _onVRRequestPresentStart;
  46682. private _onVRRequestPresentComplete;
  46683. /**
  46684. * 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)
  46685. */
  46686. enableGazeEvenWhenNoPointerLock: boolean;
  46687. /**
  46688. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46689. */
  46690. exitVROnDoubleTap: boolean;
  46691. /**
  46692. * Observable raised right before entering VR.
  46693. */
  46694. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46695. /**
  46696. * Observable raised when entering VR has completed.
  46697. */
  46698. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46699. /**
  46700. * Observable raised when exiting VR.
  46701. */
  46702. onExitingVRObservable: Observable<VRExperienceHelper>;
  46703. /**
  46704. * Observable raised when controller mesh is loaded.
  46705. */
  46706. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46707. /** Return this.onEnteringVRObservable
  46708. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46709. */
  46710. get onEnteringVR(): Observable<VRExperienceHelper>;
  46711. /** Return this.onExitingVRObservable
  46712. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46713. */
  46714. get onExitingVR(): Observable<VRExperienceHelper>;
  46715. /** Return this.onControllerMeshLoadedObservable
  46716. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46717. */
  46718. get onControllerMeshLoaded(): Observable<WebVRController>;
  46719. private _rayLength;
  46720. private _useCustomVRButton;
  46721. private _teleportationRequested;
  46722. private _teleportActive;
  46723. private _floorMeshName;
  46724. private _floorMeshesCollection;
  46725. private _teleportationMode;
  46726. private _teleportationTime;
  46727. private _teleportationSpeed;
  46728. private _teleportationEasing;
  46729. private _rotationAllowed;
  46730. private _teleportBackwardsVector;
  46731. private _teleportationTarget;
  46732. private _isDefaultTeleportationTarget;
  46733. private _postProcessMove;
  46734. private _teleportationFillColor;
  46735. private _teleportationBorderColor;
  46736. private _rotationAngle;
  46737. private _haloCenter;
  46738. private _cameraGazer;
  46739. private _padSensibilityUp;
  46740. private _padSensibilityDown;
  46741. private _leftController;
  46742. private _rightController;
  46743. private _gazeColor;
  46744. private _laserColor;
  46745. private _pickedLaserColor;
  46746. private _pickedGazeColor;
  46747. /**
  46748. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46749. */
  46750. onNewMeshSelected: Observable<AbstractMesh>;
  46751. /**
  46752. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46753. * This observable will provide the mesh and the controller used to select the mesh
  46754. */
  46755. onMeshSelectedWithController: Observable<{
  46756. mesh: AbstractMesh;
  46757. controller: WebVRController;
  46758. }>;
  46759. /**
  46760. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46761. */
  46762. onNewMeshPicked: Observable<PickingInfo>;
  46763. private _circleEase;
  46764. /**
  46765. * Observable raised before camera teleportation
  46766. */
  46767. onBeforeCameraTeleport: Observable<Vector3>;
  46768. /**
  46769. * Observable raised after camera teleportation
  46770. */
  46771. onAfterCameraTeleport: Observable<Vector3>;
  46772. /**
  46773. * Observable raised when current selected mesh gets unselected
  46774. */
  46775. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46776. private _raySelectionPredicate;
  46777. /**
  46778. * To be optionaly changed by user to define custom ray selection
  46779. */
  46780. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46781. /**
  46782. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46783. */
  46784. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46785. /**
  46786. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46787. */
  46788. teleportationEnabled: boolean;
  46789. private _defaultHeight;
  46790. private _teleportationInitialized;
  46791. private _interactionsEnabled;
  46792. private _interactionsRequested;
  46793. private _displayGaze;
  46794. private _displayLaserPointer;
  46795. /**
  46796. * The mesh used to display where the user is going to teleport.
  46797. */
  46798. get teleportationTarget(): Mesh;
  46799. /**
  46800. * Sets the mesh to be used to display where the user is going to teleport.
  46801. */
  46802. set teleportationTarget(value: Mesh);
  46803. /**
  46804. * 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
  46805. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46806. * See http://doc.babylonjs.com/resources/baking_transformations
  46807. */
  46808. get gazeTrackerMesh(): Mesh;
  46809. set gazeTrackerMesh(value: Mesh);
  46810. /**
  46811. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46812. */
  46813. updateGazeTrackerScale: boolean;
  46814. /**
  46815. * If the gaze trackers color should be updated when selecting meshes
  46816. */
  46817. updateGazeTrackerColor: boolean;
  46818. /**
  46819. * If the controller laser color should be updated when selecting meshes
  46820. */
  46821. updateControllerLaserColor: boolean;
  46822. /**
  46823. * The gaze tracking mesh corresponding to the left controller
  46824. */
  46825. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46826. /**
  46827. * The gaze tracking mesh corresponding to the right controller
  46828. */
  46829. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46830. /**
  46831. * If the ray of the gaze should be displayed.
  46832. */
  46833. get displayGaze(): boolean;
  46834. /**
  46835. * Sets if the ray of the gaze should be displayed.
  46836. */
  46837. set displayGaze(value: boolean);
  46838. /**
  46839. * If the ray of the LaserPointer should be displayed.
  46840. */
  46841. get displayLaserPointer(): boolean;
  46842. /**
  46843. * Sets if the ray of the LaserPointer should be displayed.
  46844. */
  46845. set displayLaserPointer(value: boolean);
  46846. /**
  46847. * The deviceOrientationCamera used as the camera when not in VR.
  46848. */
  46849. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46850. /**
  46851. * Based on the current WebVR support, returns the current VR camera used.
  46852. */
  46853. get currentVRCamera(): Nullable<Camera>;
  46854. /**
  46855. * The webVRCamera which is used when in VR.
  46856. */
  46857. get webVRCamera(): WebVRFreeCamera;
  46858. /**
  46859. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46860. */
  46861. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46862. /**
  46863. * The html button that is used to trigger entering into VR.
  46864. */
  46865. get vrButton(): Nullable<HTMLButtonElement>;
  46866. private get _teleportationRequestInitiated();
  46867. /**
  46868. * Defines whether or not Pointer lock should be requested when switching to
  46869. * full screen.
  46870. */
  46871. requestPointerLockOnFullScreen: boolean;
  46872. /**
  46873. * If asking to force XR, this will be populated with the default xr experience
  46874. */
  46875. xr: WebXRDefaultExperience;
  46876. /**
  46877. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46878. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46879. */
  46880. xrTestDone: boolean;
  46881. /**
  46882. * Instantiates a VRExperienceHelper.
  46883. * Helps to quickly add VR support to an existing scene.
  46884. * @param scene The scene the VRExperienceHelper belongs to.
  46885. * @param webVROptions Options to modify the vr experience helper's behavior.
  46886. */
  46887. constructor(scene: Scene,
  46888. /** Options to modify the vr experience helper's behavior. */
  46889. webVROptions?: VRExperienceHelperOptions);
  46890. private completeVRInit;
  46891. private _onDefaultMeshLoaded;
  46892. private _onResize;
  46893. private _onFullscreenChange;
  46894. /**
  46895. * Gets a value indicating if we are currently in VR mode.
  46896. */
  46897. get isInVRMode(): boolean;
  46898. private onVrDisplayPresentChange;
  46899. private onVRDisplayChanged;
  46900. private moveButtonToBottomRight;
  46901. private displayVRButton;
  46902. private updateButtonVisibility;
  46903. private _cachedAngularSensibility;
  46904. /**
  46905. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46906. * Otherwise, will use the fullscreen API.
  46907. */
  46908. enterVR(): void;
  46909. /**
  46910. * Attempt to exit VR, or fullscreen.
  46911. */
  46912. exitVR(): void;
  46913. /**
  46914. * The position of the vr experience helper.
  46915. */
  46916. get position(): Vector3;
  46917. /**
  46918. * Sets the position of the vr experience helper.
  46919. */
  46920. set position(value: Vector3);
  46921. /**
  46922. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46923. */
  46924. enableInteractions(): void;
  46925. private get _noControllerIsActive();
  46926. private beforeRender;
  46927. private _isTeleportationFloor;
  46928. /**
  46929. * Adds a floor mesh to be used for teleportation.
  46930. * @param floorMesh the mesh to be used for teleportation.
  46931. */
  46932. addFloorMesh(floorMesh: Mesh): void;
  46933. /**
  46934. * Removes a floor mesh from being used for teleportation.
  46935. * @param floorMesh the mesh to be removed.
  46936. */
  46937. removeFloorMesh(floorMesh: Mesh): void;
  46938. /**
  46939. * Enables interactions and teleportation using the VR controllers and gaze.
  46940. * @param vrTeleportationOptions options to modify teleportation behavior.
  46941. */
  46942. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46943. private _onNewGamepadConnected;
  46944. private _tryEnableInteractionOnController;
  46945. private _onNewGamepadDisconnected;
  46946. private _enableInteractionOnController;
  46947. private _checkTeleportWithRay;
  46948. private _checkRotate;
  46949. private _checkTeleportBackwards;
  46950. private _enableTeleportationOnController;
  46951. private _createTeleportationCircles;
  46952. private _displayTeleportationTarget;
  46953. private _hideTeleportationTarget;
  46954. private _rotateCamera;
  46955. private _moveTeleportationSelectorTo;
  46956. private _workingVector;
  46957. private _workingQuaternion;
  46958. private _workingMatrix;
  46959. /**
  46960. * Time Constant Teleportation Mode
  46961. */
  46962. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46963. /**
  46964. * Speed Constant Teleportation Mode
  46965. */
  46966. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46967. /**
  46968. * Teleports the users feet to the desired location
  46969. * @param location The location where the user's feet should be placed
  46970. */
  46971. teleportCamera(location: Vector3): void;
  46972. private _convertNormalToDirectionOfRay;
  46973. private _castRayAndSelectObject;
  46974. private _notifySelectedMeshUnselected;
  46975. /**
  46976. * Permanently set new colors for the laser pointer
  46977. * @param color the new laser color
  46978. * @param pickedColor the new laser color when picked mesh detected
  46979. */
  46980. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46981. /**
  46982. * Set lighting enabled / disabled on the laser pointer of both controllers
  46983. * @param enabled should the lighting be enabled on the laser pointer
  46984. */
  46985. setLaserLightingState(enabled?: boolean): void;
  46986. /**
  46987. * Permanently set new colors for the gaze pointer
  46988. * @param color the new gaze color
  46989. * @param pickedColor the new gaze color when picked mesh detected
  46990. */
  46991. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46992. /**
  46993. * Sets the color of the laser ray from the vr controllers.
  46994. * @param color new color for the ray.
  46995. */
  46996. changeLaserColor(color: Color3): void;
  46997. /**
  46998. * Sets the color of the ray from the vr headsets gaze.
  46999. * @param color new color for the ray.
  47000. */
  47001. changeGazeColor(color: Color3): void;
  47002. /**
  47003. * Exits VR and disposes of the vr experience helper
  47004. */
  47005. dispose(): void;
  47006. /**
  47007. * Gets the name of the VRExperienceHelper class
  47008. * @returns "VRExperienceHelper"
  47009. */
  47010. getClassName(): string;
  47011. }
  47012. }
  47013. declare module "babylonjs/Cameras/VR/index" {
  47014. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47015. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47016. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47017. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47018. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47019. export * from "babylonjs/Cameras/VR/webVRCamera";
  47020. }
  47021. declare module "babylonjs/Cameras/RigModes/index" {
  47022. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47023. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47024. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47025. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47026. }
  47027. declare module "babylonjs/Cameras/index" {
  47028. export * from "babylonjs/Cameras/Inputs/index";
  47029. export * from "babylonjs/Cameras/cameraInputsManager";
  47030. export * from "babylonjs/Cameras/camera";
  47031. export * from "babylonjs/Cameras/targetCamera";
  47032. export * from "babylonjs/Cameras/freeCamera";
  47033. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47034. export * from "babylonjs/Cameras/touchCamera";
  47035. export * from "babylonjs/Cameras/arcRotateCamera";
  47036. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47037. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47038. export * from "babylonjs/Cameras/flyCamera";
  47039. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47040. export * from "babylonjs/Cameras/followCamera";
  47041. export * from "babylonjs/Cameras/followCameraInputsManager";
  47042. export * from "babylonjs/Cameras/gamepadCamera";
  47043. export * from "babylonjs/Cameras/Stereoscopic/index";
  47044. export * from "babylonjs/Cameras/universalCamera";
  47045. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47046. export * from "babylonjs/Cameras/VR/index";
  47047. export * from "babylonjs/Cameras/RigModes/index";
  47048. }
  47049. declare module "babylonjs/Collisions/index" {
  47050. export * from "babylonjs/Collisions/collider";
  47051. export * from "babylonjs/Collisions/collisionCoordinator";
  47052. export * from "babylonjs/Collisions/pickingInfo";
  47053. export * from "babylonjs/Collisions/intersectionInfo";
  47054. export * from "babylonjs/Collisions/meshCollisionData";
  47055. }
  47056. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47057. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47058. import { Vector3 } from "babylonjs/Maths/math.vector";
  47059. import { Ray } from "babylonjs/Culling/ray";
  47060. import { Plane } from "babylonjs/Maths/math.plane";
  47061. /**
  47062. * Contains an array of blocks representing the octree
  47063. */
  47064. export interface IOctreeContainer<T> {
  47065. /**
  47066. * Blocks within the octree
  47067. */
  47068. blocks: Array<OctreeBlock<T>>;
  47069. }
  47070. /**
  47071. * Class used to store a cell in an octree
  47072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47073. */
  47074. export class OctreeBlock<T> {
  47075. /**
  47076. * Gets the content of the current block
  47077. */
  47078. entries: T[];
  47079. /**
  47080. * Gets the list of block children
  47081. */
  47082. blocks: Array<OctreeBlock<T>>;
  47083. private _depth;
  47084. private _maxDepth;
  47085. private _capacity;
  47086. private _minPoint;
  47087. private _maxPoint;
  47088. private _boundingVectors;
  47089. private _creationFunc;
  47090. /**
  47091. * Creates a new block
  47092. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47093. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47094. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47095. * @param depth defines the current depth of this block in the octree
  47096. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47097. * @param creationFunc defines a callback to call when an element is added to the block
  47098. */
  47099. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47100. /**
  47101. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47102. */
  47103. get capacity(): number;
  47104. /**
  47105. * Gets the minimum vector (in world space) of the block's bounding box
  47106. */
  47107. get minPoint(): Vector3;
  47108. /**
  47109. * Gets the maximum vector (in world space) of the block's bounding box
  47110. */
  47111. get maxPoint(): Vector3;
  47112. /**
  47113. * Add a new element to this block
  47114. * @param entry defines the element to add
  47115. */
  47116. addEntry(entry: T): void;
  47117. /**
  47118. * Remove an element from this block
  47119. * @param entry defines the element to remove
  47120. */
  47121. removeEntry(entry: T): void;
  47122. /**
  47123. * Add an array of elements to this block
  47124. * @param entries defines the array of elements to add
  47125. */
  47126. addEntries(entries: T[]): void;
  47127. /**
  47128. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47129. * @param frustumPlanes defines the frustum planes to test
  47130. * @param selection defines the array to store current content if selection is positive
  47131. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47132. */
  47133. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47134. /**
  47135. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47136. * @param sphereCenter defines the bounding sphere center
  47137. * @param sphereRadius defines the bounding sphere radius
  47138. * @param selection defines the array to store current content if selection is positive
  47139. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47140. */
  47141. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47142. /**
  47143. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47144. * @param ray defines the ray to test with
  47145. * @param selection defines the array to store current content if selection is positive
  47146. */
  47147. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47148. /**
  47149. * Subdivide the content into child blocks (this block will then be empty)
  47150. */
  47151. createInnerBlocks(): void;
  47152. /**
  47153. * @hidden
  47154. */
  47155. 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;
  47156. }
  47157. }
  47158. declare module "babylonjs/Culling/Octrees/octree" {
  47159. import { SmartArray } from "babylonjs/Misc/smartArray";
  47160. import { Vector3 } from "babylonjs/Maths/math.vector";
  47161. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47163. import { Ray } from "babylonjs/Culling/ray";
  47164. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47165. import { Plane } from "babylonjs/Maths/math.plane";
  47166. /**
  47167. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47168. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47169. */
  47170. export class Octree<T> {
  47171. /** 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.) */
  47172. maxDepth: number;
  47173. /**
  47174. * Blocks within the octree containing objects
  47175. */
  47176. blocks: Array<OctreeBlock<T>>;
  47177. /**
  47178. * Content stored in the octree
  47179. */
  47180. dynamicContent: T[];
  47181. private _maxBlockCapacity;
  47182. private _selectionContent;
  47183. private _creationFunc;
  47184. /**
  47185. * Creates a octree
  47186. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47187. * @param creationFunc function to be used to instatiate the octree
  47188. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47189. * @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.)
  47190. */
  47191. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47192. /** 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.) */
  47193. maxDepth?: number);
  47194. /**
  47195. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47196. * @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);
  47197. * @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);
  47198. * @param entries meshes to be added to the octree blocks
  47199. */
  47200. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47201. /**
  47202. * Adds a mesh to the octree
  47203. * @param entry Mesh to add to the octree
  47204. */
  47205. addMesh(entry: T): void;
  47206. /**
  47207. * Remove an element from the octree
  47208. * @param entry defines the element to remove
  47209. */
  47210. removeMesh(entry: T): void;
  47211. /**
  47212. * Selects an array of meshes within the frustum
  47213. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47214. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47215. * @returns array of meshes within the frustum
  47216. */
  47217. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47218. /**
  47219. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47220. * @param sphereCenter defines the bounding sphere center
  47221. * @param sphereRadius defines the bounding sphere radius
  47222. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47223. * @returns an array of objects that intersect the sphere
  47224. */
  47225. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47226. /**
  47227. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47228. * @param ray defines the ray to test with
  47229. * @returns array of intersected objects
  47230. */
  47231. intersectsRay(ray: Ray): SmartArray<T>;
  47232. /**
  47233. * Adds a mesh into the octree block if it intersects the block
  47234. */
  47235. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47236. /**
  47237. * Adds a submesh into the octree block if it intersects the block
  47238. */
  47239. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47240. }
  47241. }
  47242. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47243. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47244. import { Scene } from "babylonjs/scene";
  47245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47247. import { Ray } from "babylonjs/Culling/ray";
  47248. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47249. import { Collider } from "babylonjs/Collisions/collider";
  47250. module "babylonjs/scene" {
  47251. interface Scene {
  47252. /**
  47253. * @hidden
  47254. * Backing Filed
  47255. */
  47256. _selectionOctree: Octree<AbstractMesh>;
  47257. /**
  47258. * Gets the octree used to boost mesh selection (picking)
  47259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47260. */
  47261. selectionOctree: Octree<AbstractMesh>;
  47262. /**
  47263. * Creates or updates the octree used to boost selection (picking)
  47264. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47265. * @param maxCapacity defines the maximum capacity per leaf
  47266. * @param maxDepth defines the maximum depth of the octree
  47267. * @returns an octree of AbstractMesh
  47268. */
  47269. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47270. }
  47271. }
  47272. module "babylonjs/Meshes/abstractMesh" {
  47273. interface AbstractMesh {
  47274. /**
  47275. * @hidden
  47276. * Backing Field
  47277. */
  47278. _submeshesOctree: Octree<SubMesh>;
  47279. /**
  47280. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47281. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47282. * @param maxCapacity defines the maximum size of each block (64 by default)
  47283. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47284. * @returns the new octree
  47285. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47287. */
  47288. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47289. }
  47290. }
  47291. /**
  47292. * Defines the octree scene component responsible to manage any octrees
  47293. * in a given scene.
  47294. */
  47295. export class OctreeSceneComponent {
  47296. /**
  47297. * The component name help to identify the component in the list of scene components.
  47298. */
  47299. readonly name: string;
  47300. /**
  47301. * The scene the component belongs to.
  47302. */
  47303. scene: Scene;
  47304. /**
  47305. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47306. */
  47307. readonly checksIsEnabled: boolean;
  47308. /**
  47309. * Creates a new instance of the component for the given scene
  47310. * @param scene Defines the scene to register the component in
  47311. */
  47312. constructor(scene: Scene);
  47313. /**
  47314. * Registers the component in a given scene
  47315. */
  47316. register(): void;
  47317. /**
  47318. * Return the list of active meshes
  47319. * @returns the list of active meshes
  47320. */
  47321. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47322. /**
  47323. * Return the list of active sub meshes
  47324. * @param mesh The mesh to get the candidates sub meshes from
  47325. * @returns the list of active sub meshes
  47326. */
  47327. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47328. private _tempRay;
  47329. /**
  47330. * Return the list of sub meshes intersecting with a given local ray
  47331. * @param mesh defines the mesh to find the submesh for
  47332. * @param localRay defines the ray in local space
  47333. * @returns the list of intersecting sub meshes
  47334. */
  47335. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47336. /**
  47337. * Return the list of sub meshes colliding with a collider
  47338. * @param mesh defines the mesh to find the submesh for
  47339. * @param collider defines the collider to evaluate the collision against
  47340. * @returns the list of colliding sub meshes
  47341. */
  47342. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47343. /**
  47344. * Rebuilds the elements related to this component in case of
  47345. * context lost for instance.
  47346. */
  47347. rebuild(): void;
  47348. /**
  47349. * Disposes the component and the associated ressources.
  47350. */
  47351. dispose(): void;
  47352. }
  47353. }
  47354. declare module "babylonjs/Culling/Octrees/index" {
  47355. export * from "babylonjs/Culling/Octrees/octree";
  47356. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47357. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47358. }
  47359. declare module "babylonjs/Culling/index" {
  47360. export * from "babylonjs/Culling/boundingBox";
  47361. export * from "babylonjs/Culling/boundingInfo";
  47362. export * from "babylonjs/Culling/boundingSphere";
  47363. export * from "babylonjs/Culling/Octrees/index";
  47364. export * from "babylonjs/Culling/ray";
  47365. }
  47366. declare module "babylonjs/Gizmos/gizmo" {
  47367. import { Nullable } from "babylonjs/types";
  47368. import { IDisposable } from "babylonjs/scene";
  47369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47370. import { Mesh } from "babylonjs/Meshes/mesh";
  47371. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47372. /**
  47373. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47374. */
  47375. export class Gizmo implements IDisposable {
  47376. /** The utility layer the gizmo will be added to */
  47377. gizmoLayer: UtilityLayerRenderer;
  47378. /**
  47379. * The root mesh of the gizmo
  47380. */
  47381. _rootMesh: Mesh;
  47382. private _attachedMesh;
  47383. /**
  47384. * Ratio for the scale of the gizmo (Default: 1)
  47385. */
  47386. scaleRatio: number;
  47387. /**
  47388. * If a custom mesh has been set (Default: false)
  47389. */
  47390. protected _customMeshSet: boolean;
  47391. /**
  47392. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47393. * * When set, interactions will be enabled
  47394. */
  47395. get attachedMesh(): Nullable<AbstractMesh>;
  47396. set attachedMesh(value: Nullable<AbstractMesh>);
  47397. /**
  47398. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47399. * @param mesh The mesh to replace the default mesh of the gizmo
  47400. */
  47401. setCustomMesh(mesh: Mesh): void;
  47402. /**
  47403. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47404. */
  47405. updateGizmoRotationToMatchAttachedMesh: boolean;
  47406. /**
  47407. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47408. */
  47409. updateGizmoPositionToMatchAttachedMesh: boolean;
  47410. /**
  47411. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47412. */
  47413. updateScale: boolean;
  47414. protected _interactionsEnabled: boolean;
  47415. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47416. private _beforeRenderObserver;
  47417. private _tempVector;
  47418. /**
  47419. * Creates a gizmo
  47420. * @param gizmoLayer The utility layer the gizmo will be added to
  47421. */
  47422. constructor(
  47423. /** The utility layer the gizmo will be added to */
  47424. gizmoLayer?: UtilityLayerRenderer);
  47425. /**
  47426. * Updates the gizmo to match the attached mesh's position/rotation
  47427. */
  47428. protected _update(): void;
  47429. /**
  47430. * Disposes of the gizmo
  47431. */
  47432. dispose(): void;
  47433. }
  47434. }
  47435. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47436. import { Observable } from "babylonjs/Misc/observable";
  47437. import { Nullable } from "babylonjs/types";
  47438. import { Vector3 } from "babylonjs/Maths/math.vector";
  47439. import { Color3 } from "babylonjs/Maths/math.color";
  47440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47442. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47443. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47444. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47445. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47446. import { Scene } from "babylonjs/scene";
  47447. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47448. /**
  47449. * Single plane drag gizmo
  47450. */
  47451. export class PlaneDragGizmo extends Gizmo {
  47452. /**
  47453. * Drag behavior responsible for the gizmos dragging interactions
  47454. */
  47455. dragBehavior: PointerDragBehavior;
  47456. private _pointerObserver;
  47457. /**
  47458. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47459. */
  47460. snapDistance: number;
  47461. /**
  47462. * Event that fires each time the gizmo snaps to a new location.
  47463. * * snapDistance is the the change in distance
  47464. */
  47465. onSnapObservable: Observable<{
  47466. snapDistance: number;
  47467. }>;
  47468. private _plane;
  47469. private _coloredMaterial;
  47470. private _hoverMaterial;
  47471. private _isEnabled;
  47472. private _parent;
  47473. /** @hidden */
  47474. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47475. /** @hidden */
  47476. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47477. /**
  47478. * Creates a PlaneDragGizmo
  47479. * @param gizmoLayer The utility layer the gizmo will be added to
  47480. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47481. * @param color The color of the gizmo
  47482. */
  47483. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47484. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47485. /**
  47486. * If the gizmo is enabled
  47487. */
  47488. set isEnabled(value: boolean);
  47489. get isEnabled(): boolean;
  47490. /**
  47491. * Disposes of the gizmo
  47492. */
  47493. dispose(): void;
  47494. }
  47495. }
  47496. declare module "babylonjs/Gizmos/positionGizmo" {
  47497. import { Observable } from "babylonjs/Misc/observable";
  47498. import { Nullable } from "babylonjs/types";
  47499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47500. import { Mesh } from "babylonjs/Meshes/mesh";
  47501. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47502. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47503. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47504. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47505. /**
  47506. * Gizmo that enables dragging a mesh along 3 axis
  47507. */
  47508. export class PositionGizmo extends Gizmo {
  47509. /**
  47510. * Internal gizmo used for interactions on the x axis
  47511. */
  47512. xGizmo: AxisDragGizmo;
  47513. /**
  47514. * Internal gizmo used for interactions on the y axis
  47515. */
  47516. yGizmo: AxisDragGizmo;
  47517. /**
  47518. * Internal gizmo used for interactions on the z axis
  47519. */
  47520. zGizmo: AxisDragGizmo;
  47521. /**
  47522. * Internal gizmo used for interactions on the yz plane
  47523. */
  47524. xPlaneGizmo: PlaneDragGizmo;
  47525. /**
  47526. * Internal gizmo used for interactions on the xz plane
  47527. */
  47528. yPlaneGizmo: PlaneDragGizmo;
  47529. /**
  47530. * Internal gizmo used for interactions on the xy plane
  47531. */
  47532. zPlaneGizmo: PlaneDragGizmo;
  47533. /**
  47534. * private variables
  47535. */
  47536. private _meshAttached;
  47537. private _updateGizmoRotationToMatchAttachedMesh;
  47538. private _snapDistance;
  47539. private _scaleRatio;
  47540. /** Fires an event when any of it's sub gizmos are dragged */
  47541. onDragStartObservable: Observable<unknown>;
  47542. /** Fires an event when any of it's sub gizmos are released from dragging */
  47543. onDragEndObservable: Observable<unknown>;
  47544. /**
  47545. * If set to true, planar drag is enabled
  47546. */
  47547. private _planarGizmoEnabled;
  47548. get attachedMesh(): Nullable<AbstractMesh>;
  47549. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47550. /**
  47551. * Creates a PositionGizmo
  47552. * @param gizmoLayer The utility layer the gizmo will be added to
  47553. */
  47554. constructor(gizmoLayer?: UtilityLayerRenderer);
  47555. /**
  47556. * If the planar drag gizmo is enabled
  47557. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47558. */
  47559. set planarGizmoEnabled(value: boolean);
  47560. get planarGizmoEnabled(): boolean;
  47561. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47562. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47563. /**
  47564. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47565. */
  47566. set snapDistance(value: number);
  47567. get snapDistance(): number;
  47568. /**
  47569. * Ratio for the scale of the gizmo (Default: 1)
  47570. */
  47571. set scaleRatio(value: number);
  47572. get scaleRatio(): number;
  47573. /**
  47574. * Disposes of the gizmo
  47575. */
  47576. dispose(): void;
  47577. /**
  47578. * CustomMeshes are not supported by this gizmo
  47579. * @param mesh The mesh to replace the default mesh of the gizmo
  47580. */
  47581. setCustomMesh(mesh: Mesh): void;
  47582. }
  47583. }
  47584. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47585. import { Observable } from "babylonjs/Misc/observable";
  47586. import { Nullable } from "babylonjs/types";
  47587. import { Vector3 } from "babylonjs/Maths/math.vector";
  47588. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47590. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47591. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47592. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47593. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47594. import { Scene } from "babylonjs/scene";
  47595. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47596. import { Color3 } from "babylonjs/Maths/math.color";
  47597. /**
  47598. * Single axis drag gizmo
  47599. */
  47600. export class AxisDragGizmo extends Gizmo {
  47601. /**
  47602. * Drag behavior responsible for the gizmos dragging interactions
  47603. */
  47604. dragBehavior: PointerDragBehavior;
  47605. private _pointerObserver;
  47606. /**
  47607. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47608. */
  47609. snapDistance: number;
  47610. /**
  47611. * Event that fires each time the gizmo snaps to a new location.
  47612. * * snapDistance is the the change in distance
  47613. */
  47614. onSnapObservable: Observable<{
  47615. snapDistance: number;
  47616. }>;
  47617. private _isEnabled;
  47618. private _parent;
  47619. private _arrow;
  47620. private _coloredMaterial;
  47621. private _hoverMaterial;
  47622. /** @hidden */
  47623. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47624. /** @hidden */
  47625. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47626. /**
  47627. * Creates an AxisDragGizmo
  47628. * @param gizmoLayer The utility layer the gizmo will be added to
  47629. * @param dragAxis The axis which the gizmo will be able to drag on
  47630. * @param color The color of the gizmo
  47631. */
  47632. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47633. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47634. /**
  47635. * If the gizmo is enabled
  47636. */
  47637. set isEnabled(value: boolean);
  47638. get isEnabled(): boolean;
  47639. /**
  47640. * Disposes of the gizmo
  47641. */
  47642. dispose(): void;
  47643. }
  47644. }
  47645. declare module "babylonjs/Debug/axesViewer" {
  47646. import { Vector3 } from "babylonjs/Maths/math.vector";
  47647. import { Nullable } from "babylonjs/types";
  47648. import { Scene } from "babylonjs/scene";
  47649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47650. /**
  47651. * The Axes viewer will show 3 axes in a specific point in space
  47652. */
  47653. export class AxesViewer {
  47654. private _xAxis;
  47655. private _yAxis;
  47656. private _zAxis;
  47657. private _scaleLinesFactor;
  47658. private _instanced;
  47659. /**
  47660. * Gets the hosting scene
  47661. */
  47662. scene: Scene;
  47663. /**
  47664. * Gets or sets a number used to scale line length
  47665. */
  47666. scaleLines: number;
  47667. /** Gets the node hierarchy used to render x-axis */
  47668. get xAxis(): TransformNode;
  47669. /** Gets the node hierarchy used to render y-axis */
  47670. get yAxis(): TransformNode;
  47671. /** Gets the node hierarchy used to render z-axis */
  47672. get zAxis(): TransformNode;
  47673. /**
  47674. * Creates a new AxesViewer
  47675. * @param scene defines the hosting scene
  47676. * @param scaleLines defines a number used to scale line length (1 by default)
  47677. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47678. * @param xAxis defines the node hierarchy used to render the x-axis
  47679. * @param yAxis defines the node hierarchy used to render the y-axis
  47680. * @param zAxis defines the node hierarchy used to render the z-axis
  47681. */
  47682. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47683. /**
  47684. * Force the viewer to update
  47685. * @param position defines the position of the viewer
  47686. * @param xaxis defines the x axis of the viewer
  47687. * @param yaxis defines the y axis of the viewer
  47688. * @param zaxis defines the z axis of the viewer
  47689. */
  47690. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47691. /**
  47692. * Creates an instance of this axes viewer.
  47693. * @returns a new axes viewer with instanced meshes
  47694. */
  47695. createInstance(): AxesViewer;
  47696. /** Releases resources */
  47697. dispose(): void;
  47698. private static _SetRenderingGroupId;
  47699. }
  47700. }
  47701. declare module "babylonjs/Debug/boneAxesViewer" {
  47702. import { Nullable } from "babylonjs/types";
  47703. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47704. import { Vector3 } from "babylonjs/Maths/math.vector";
  47705. import { Mesh } from "babylonjs/Meshes/mesh";
  47706. import { Bone } from "babylonjs/Bones/bone";
  47707. import { Scene } from "babylonjs/scene";
  47708. /**
  47709. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47710. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47711. */
  47712. export class BoneAxesViewer extends AxesViewer {
  47713. /**
  47714. * Gets or sets the target mesh where to display the axes viewer
  47715. */
  47716. mesh: Nullable<Mesh>;
  47717. /**
  47718. * Gets or sets the target bone where to display the axes viewer
  47719. */
  47720. bone: Nullable<Bone>;
  47721. /** Gets current position */
  47722. pos: Vector3;
  47723. /** Gets direction of X axis */
  47724. xaxis: Vector3;
  47725. /** Gets direction of Y axis */
  47726. yaxis: Vector3;
  47727. /** Gets direction of Z axis */
  47728. zaxis: Vector3;
  47729. /**
  47730. * Creates a new BoneAxesViewer
  47731. * @param scene defines the hosting scene
  47732. * @param bone defines the target bone
  47733. * @param mesh defines the target mesh
  47734. * @param scaleLines defines a scaling factor for line length (1 by default)
  47735. */
  47736. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47737. /**
  47738. * Force the viewer to update
  47739. */
  47740. update(): void;
  47741. /** Releases resources */
  47742. dispose(): void;
  47743. }
  47744. }
  47745. declare module "babylonjs/Debug/debugLayer" {
  47746. import { Scene } from "babylonjs/scene";
  47747. /**
  47748. * Interface used to define scene explorer extensibility option
  47749. */
  47750. export interface IExplorerExtensibilityOption {
  47751. /**
  47752. * Define the option label
  47753. */
  47754. label: string;
  47755. /**
  47756. * Defines the action to execute on click
  47757. */
  47758. action: (entity: any) => void;
  47759. }
  47760. /**
  47761. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47762. */
  47763. export interface IExplorerExtensibilityGroup {
  47764. /**
  47765. * Defines a predicate to test if a given type mut be extended
  47766. */
  47767. predicate: (entity: any) => boolean;
  47768. /**
  47769. * Gets the list of options added to a type
  47770. */
  47771. entries: IExplorerExtensibilityOption[];
  47772. }
  47773. /**
  47774. * Interface used to define the options to use to create the Inspector
  47775. */
  47776. export interface IInspectorOptions {
  47777. /**
  47778. * Display in overlay mode (default: false)
  47779. */
  47780. overlay?: boolean;
  47781. /**
  47782. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47783. */
  47784. globalRoot?: HTMLElement;
  47785. /**
  47786. * Display the Scene explorer
  47787. */
  47788. showExplorer?: boolean;
  47789. /**
  47790. * Display the property inspector
  47791. */
  47792. showInspector?: boolean;
  47793. /**
  47794. * Display in embed mode (both panes on the right)
  47795. */
  47796. embedMode?: boolean;
  47797. /**
  47798. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47799. */
  47800. handleResize?: boolean;
  47801. /**
  47802. * Allow the panes to popup (default: true)
  47803. */
  47804. enablePopup?: boolean;
  47805. /**
  47806. * Allow the panes to be closed by users (default: true)
  47807. */
  47808. enableClose?: boolean;
  47809. /**
  47810. * Optional list of extensibility entries
  47811. */
  47812. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47813. /**
  47814. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47815. */
  47816. inspectorURL?: string;
  47817. /**
  47818. * Optional initial tab (default to DebugLayerTab.Properties)
  47819. */
  47820. initialTab?: DebugLayerTab;
  47821. }
  47822. module "babylonjs/scene" {
  47823. interface Scene {
  47824. /**
  47825. * @hidden
  47826. * Backing field
  47827. */
  47828. _debugLayer: DebugLayer;
  47829. /**
  47830. * Gets the debug layer (aka Inspector) associated with the scene
  47831. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47832. */
  47833. debugLayer: DebugLayer;
  47834. }
  47835. }
  47836. /**
  47837. * Enum of inspector action tab
  47838. */
  47839. export enum DebugLayerTab {
  47840. /**
  47841. * Properties tag (default)
  47842. */
  47843. Properties = 0,
  47844. /**
  47845. * Debug tab
  47846. */
  47847. Debug = 1,
  47848. /**
  47849. * Statistics tab
  47850. */
  47851. Statistics = 2,
  47852. /**
  47853. * Tools tab
  47854. */
  47855. Tools = 3,
  47856. /**
  47857. * Settings tab
  47858. */
  47859. Settings = 4
  47860. }
  47861. /**
  47862. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47863. * what is happening in your scene
  47864. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47865. */
  47866. export class DebugLayer {
  47867. /**
  47868. * Define the url to get the inspector script from.
  47869. * By default it uses the babylonjs CDN.
  47870. * @ignoreNaming
  47871. */
  47872. static InspectorURL: string;
  47873. private _scene;
  47874. private BJSINSPECTOR;
  47875. private _onPropertyChangedObservable?;
  47876. /**
  47877. * Observable triggered when a property is changed through the inspector.
  47878. */
  47879. get onPropertyChangedObservable(): any;
  47880. /**
  47881. * Instantiates a new debug layer.
  47882. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47883. * what is happening in your scene
  47884. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47885. * @param scene Defines the scene to inspect
  47886. */
  47887. constructor(scene: Scene);
  47888. /** Creates the inspector window. */
  47889. private _createInspector;
  47890. /**
  47891. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47892. * @param entity defines the entity to select
  47893. * @param lineContainerTitle defines the specific block to highlight
  47894. */
  47895. select(entity: any, lineContainerTitle?: string): void;
  47896. /** Get the inspector from bundle or global */
  47897. private _getGlobalInspector;
  47898. /**
  47899. * Get if the inspector is visible or not.
  47900. * @returns true if visible otherwise, false
  47901. */
  47902. isVisible(): boolean;
  47903. /**
  47904. * Hide the inspector and close its window.
  47905. */
  47906. hide(): void;
  47907. /**
  47908. * Launch the debugLayer.
  47909. * @param config Define the configuration of the inspector
  47910. * @return a promise fulfilled when the debug layer is visible
  47911. */
  47912. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47913. }
  47914. }
  47915. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47916. import { Nullable } from "babylonjs/types";
  47917. import { Scene } from "babylonjs/scene";
  47918. import { Vector4 } from "babylonjs/Maths/math.vector";
  47919. import { Color4 } from "babylonjs/Maths/math.color";
  47920. import { Mesh } from "babylonjs/Meshes/mesh";
  47921. /**
  47922. * Class containing static functions to help procedurally build meshes
  47923. */
  47924. export class BoxBuilder {
  47925. /**
  47926. * Creates a box mesh
  47927. * * The parameter `size` sets the size (float) of each box side (default 1)
  47928. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47929. * * 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)
  47930. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47934. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47935. * @param name defines the name of the mesh
  47936. * @param options defines the options used to create the mesh
  47937. * @param scene defines the hosting scene
  47938. * @returns the box mesh
  47939. */
  47940. static CreateBox(name: string, options: {
  47941. size?: number;
  47942. width?: number;
  47943. height?: number;
  47944. depth?: number;
  47945. faceUV?: Vector4[];
  47946. faceColors?: Color4[];
  47947. sideOrientation?: number;
  47948. frontUVs?: Vector4;
  47949. backUVs?: Vector4;
  47950. wrap?: boolean;
  47951. topBaseAt?: number;
  47952. bottomBaseAt?: number;
  47953. updatable?: boolean;
  47954. }, scene?: Nullable<Scene>): Mesh;
  47955. }
  47956. }
  47957. declare module "babylonjs/Debug/physicsViewer" {
  47958. import { Nullable } from "babylonjs/types";
  47959. import { Scene } from "babylonjs/scene";
  47960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47961. import { Mesh } from "babylonjs/Meshes/mesh";
  47962. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47963. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47964. /**
  47965. * Used to show the physics impostor around the specific mesh
  47966. */
  47967. export class PhysicsViewer {
  47968. /** @hidden */
  47969. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47970. /** @hidden */
  47971. protected _meshes: Array<Nullable<AbstractMesh>>;
  47972. /** @hidden */
  47973. protected _scene: Nullable<Scene>;
  47974. /** @hidden */
  47975. protected _numMeshes: number;
  47976. /** @hidden */
  47977. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47978. private _renderFunction;
  47979. private _utilityLayer;
  47980. private _debugBoxMesh;
  47981. private _debugSphereMesh;
  47982. private _debugCylinderMesh;
  47983. private _debugMaterial;
  47984. private _debugMeshMeshes;
  47985. /**
  47986. * Creates a new PhysicsViewer
  47987. * @param scene defines the hosting scene
  47988. */
  47989. constructor(scene: Scene);
  47990. /** @hidden */
  47991. protected _updateDebugMeshes(): void;
  47992. /**
  47993. * Renders a specified physic impostor
  47994. * @param impostor defines the impostor to render
  47995. * @param targetMesh defines the mesh represented by the impostor
  47996. * @returns the new debug mesh used to render the impostor
  47997. */
  47998. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47999. /**
  48000. * Hides a specified physic impostor
  48001. * @param impostor defines the impostor to hide
  48002. */
  48003. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48004. private _getDebugMaterial;
  48005. private _getDebugBoxMesh;
  48006. private _getDebugSphereMesh;
  48007. private _getDebugCylinderMesh;
  48008. private _getDebugMeshMesh;
  48009. private _getDebugMesh;
  48010. /** Releases all resources */
  48011. dispose(): void;
  48012. }
  48013. }
  48014. declare module "babylonjs/Debug/rayHelper" {
  48015. import { Nullable } from "babylonjs/types";
  48016. import { Ray } from "babylonjs/Culling/ray";
  48017. import { Vector3 } from "babylonjs/Maths/math.vector";
  48018. import { Color3 } from "babylonjs/Maths/math.color";
  48019. import { Scene } from "babylonjs/scene";
  48020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48021. import "babylonjs/Meshes/Builders/linesBuilder";
  48022. /**
  48023. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48024. * in order to better appreciate the issue one might have.
  48025. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48026. */
  48027. export class RayHelper {
  48028. /**
  48029. * Defines the ray we are currently tryin to visualize.
  48030. */
  48031. ray: Nullable<Ray>;
  48032. private _renderPoints;
  48033. private _renderLine;
  48034. private _renderFunction;
  48035. private _scene;
  48036. private _updateToMeshFunction;
  48037. private _attachedToMesh;
  48038. private _meshSpaceDirection;
  48039. private _meshSpaceOrigin;
  48040. /**
  48041. * Helper function to create a colored helper in a scene in one line.
  48042. * @param ray Defines the ray we are currently tryin to visualize
  48043. * @param scene Defines the scene the ray is used in
  48044. * @param color Defines the color we want to see the ray in
  48045. * @returns The newly created ray helper.
  48046. */
  48047. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48048. /**
  48049. * Instantiate a new ray helper.
  48050. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48051. * in order to better appreciate the issue one might have.
  48052. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48053. * @param ray Defines the ray we are currently tryin to visualize
  48054. */
  48055. constructor(ray: Ray);
  48056. /**
  48057. * Shows the ray we are willing to debug.
  48058. * @param scene Defines the scene the ray needs to be rendered in
  48059. * @param color Defines the color the ray needs to be rendered in
  48060. */
  48061. show(scene: Scene, color?: Color3): void;
  48062. /**
  48063. * Hides the ray we are debugging.
  48064. */
  48065. hide(): void;
  48066. private _render;
  48067. /**
  48068. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48069. * @param mesh Defines the mesh we want the helper attached to
  48070. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48071. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48072. * @param length Defines the length of the ray
  48073. */
  48074. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48075. /**
  48076. * Detach the ray helper from the mesh it has previously been attached to.
  48077. */
  48078. detachFromMesh(): void;
  48079. private _updateToMesh;
  48080. /**
  48081. * Dispose the helper and release its associated resources.
  48082. */
  48083. dispose(): void;
  48084. }
  48085. }
  48086. declare module "babylonjs/Debug/skeletonViewer" {
  48087. import { Color3 } from "babylonjs/Maths/math.color";
  48088. import { Scene } from "babylonjs/scene";
  48089. import { Nullable } from "babylonjs/types";
  48090. import { Skeleton } from "babylonjs/Bones/skeleton";
  48091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48092. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48093. /**
  48094. * Class used to render a debug view of a given skeleton
  48095. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48096. */
  48097. export class SkeletonViewer {
  48098. /** defines the skeleton to render */
  48099. skeleton: Skeleton;
  48100. /** defines the mesh attached to the skeleton */
  48101. mesh: AbstractMesh;
  48102. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48103. autoUpdateBonesMatrices: boolean;
  48104. /** defines the rendering group id to use with the viewer */
  48105. renderingGroupId: number;
  48106. /** Gets or sets the color used to render the skeleton */
  48107. color: Color3;
  48108. private _scene;
  48109. private _debugLines;
  48110. private _debugMesh;
  48111. private _isEnabled;
  48112. private _renderFunction;
  48113. private _utilityLayer;
  48114. /**
  48115. * Returns the mesh used to render the bones
  48116. */
  48117. get debugMesh(): Nullable<LinesMesh>;
  48118. /**
  48119. * Creates a new SkeletonViewer
  48120. * @param skeleton defines the skeleton to render
  48121. * @param mesh defines the mesh attached to the skeleton
  48122. * @param scene defines the hosting scene
  48123. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48124. * @param renderingGroupId defines the rendering group id to use with the viewer
  48125. */
  48126. constructor(
  48127. /** defines the skeleton to render */
  48128. skeleton: Skeleton,
  48129. /** defines the mesh attached to the skeleton */
  48130. mesh: AbstractMesh, scene: Scene,
  48131. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48132. autoUpdateBonesMatrices?: boolean,
  48133. /** defines the rendering group id to use with the viewer */
  48134. renderingGroupId?: number);
  48135. /** Gets or sets a boolean indicating if the viewer is enabled */
  48136. set isEnabled(value: boolean);
  48137. get isEnabled(): boolean;
  48138. private _getBonePosition;
  48139. private _getLinesForBonesWithLength;
  48140. private _getLinesForBonesNoLength;
  48141. /** Update the viewer to sync with current skeleton state */
  48142. update(): void;
  48143. /** Release associated resources */
  48144. dispose(): void;
  48145. }
  48146. }
  48147. declare module "babylonjs/Debug/index" {
  48148. export * from "babylonjs/Debug/axesViewer";
  48149. export * from "babylonjs/Debug/boneAxesViewer";
  48150. export * from "babylonjs/Debug/debugLayer";
  48151. export * from "babylonjs/Debug/physicsViewer";
  48152. export * from "babylonjs/Debug/rayHelper";
  48153. export * from "babylonjs/Debug/skeletonViewer";
  48154. }
  48155. declare module "babylonjs/Engines/nullEngine" {
  48156. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48157. import { Scene } from "babylonjs/scene";
  48158. import { Engine } from "babylonjs/Engines/engine";
  48159. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48160. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48162. import { Effect } from "babylonjs/Materials/effect";
  48163. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48164. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48165. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48166. /**
  48167. * Options to create the null engine
  48168. */
  48169. export class NullEngineOptions {
  48170. /**
  48171. * Render width (Default: 512)
  48172. */
  48173. renderWidth: number;
  48174. /**
  48175. * Render height (Default: 256)
  48176. */
  48177. renderHeight: number;
  48178. /**
  48179. * Texture size (Default: 512)
  48180. */
  48181. textureSize: number;
  48182. /**
  48183. * If delta time between frames should be constant
  48184. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48185. */
  48186. deterministicLockstep: boolean;
  48187. /**
  48188. * Maximum about of steps between frames (Default: 4)
  48189. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48190. */
  48191. lockstepMaxSteps: number;
  48192. }
  48193. /**
  48194. * The null engine class provides support for headless version of babylon.js.
  48195. * This can be used in server side scenario or for testing purposes
  48196. */
  48197. export class NullEngine extends Engine {
  48198. private _options;
  48199. /**
  48200. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48202. * @returns true if engine is in deterministic lock step mode
  48203. */
  48204. isDeterministicLockStep(): boolean;
  48205. /**
  48206. * Gets the max steps when engine is running in deterministic lock step
  48207. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48208. * @returns the max steps
  48209. */
  48210. getLockstepMaxSteps(): number;
  48211. /**
  48212. * Gets the current hardware scaling level.
  48213. * By default the hardware scaling level is computed from the window device ratio.
  48214. * 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.
  48215. * @returns a number indicating the current hardware scaling level
  48216. */
  48217. getHardwareScalingLevel(): number;
  48218. constructor(options?: NullEngineOptions);
  48219. /**
  48220. * Creates a vertex buffer
  48221. * @param vertices the data for the vertex buffer
  48222. * @returns the new WebGL static buffer
  48223. */
  48224. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48225. /**
  48226. * Creates a new index buffer
  48227. * @param indices defines the content of the index buffer
  48228. * @param updatable defines if the index buffer must be updatable
  48229. * @returns a new webGL buffer
  48230. */
  48231. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48232. /**
  48233. * Clear the current render buffer or the current render target (if any is set up)
  48234. * @param color defines the color to use
  48235. * @param backBuffer defines if the back buffer must be cleared
  48236. * @param depth defines if the depth buffer must be cleared
  48237. * @param stencil defines if the stencil buffer must be cleared
  48238. */
  48239. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48240. /**
  48241. * Gets the current render width
  48242. * @param useScreen defines if screen size must be used (or the current render target if any)
  48243. * @returns a number defining the current render width
  48244. */
  48245. getRenderWidth(useScreen?: boolean): number;
  48246. /**
  48247. * Gets the current render height
  48248. * @param useScreen defines if screen size must be used (or the current render target if any)
  48249. * @returns a number defining the current render height
  48250. */
  48251. getRenderHeight(useScreen?: boolean): number;
  48252. /**
  48253. * Set the WebGL's viewport
  48254. * @param viewport defines the viewport element to be used
  48255. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48256. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48257. */
  48258. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48259. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48260. /**
  48261. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48262. * @param pipelineContext defines the pipeline context to use
  48263. * @param uniformsNames defines the list of uniform names
  48264. * @returns an array of webGL uniform locations
  48265. */
  48266. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48267. /**
  48268. * Gets the lsit of active attributes for a given webGL program
  48269. * @param pipelineContext defines the pipeline context to use
  48270. * @param attributesNames defines the list of attribute names to get
  48271. * @returns an array of indices indicating the offset of each attribute
  48272. */
  48273. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48274. /**
  48275. * Binds an effect to the webGL context
  48276. * @param effect defines the effect to bind
  48277. */
  48278. bindSamplers(effect: Effect): void;
  48279. /**
  48280. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48281. * @param effect defines the effect to activate
  48282. */
  48283. enableEffect(effect: Effect): void;
  48284. /**
  48285. * Set various states to the webGL context
  48286. * @param culling defines backface culling state
  48287. * @param zOffset defines the value to apply to zOffset (0 by default)
  48288. * @param force defines if states must be applied even if cache is up to date
  48289. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48290. */
  48291. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48292. /**
  48293. * Set the value of an uniform to an array of int32
  48294. * @param uniform defines the webGL uniform location where to store the value
  48295. * @param array defines the array of int32 to store
  48296. */
  48297. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48298. /**
  48299. * Set the value of an uniform to an array of int32 (stored as vec2)
  48300. * @param uniform defines the webGL uniform location where to store the value
  48301. * @param array defines the array of int32 to store
  48302. */
  48303. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48304. /**
  48305. * Set the value of an uniform to an array of int32 (stored as vec3)
  48306. * @param uniform defines the webGL uniform location where to store the value
  48307. * @param array defines the array of int32 to store
  48308. */
  48309. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48310. /**
  48311. * Set the value of an uniform to an array of int32 (stored as vec4)
  48312. * @param uniform defines the webGL uniform location where to store the value
  48313. * @param array defines the array of int32 to store
  48314. */
  48315. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48316. /**
  48317. * Set the value of an uniform to an array of float32
  48318. * @param uniform defines the webGL uniform location where to store the value
  48319. * @param array defines the array of float32 to store
  48320. */
  48321. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48322. /**
  48323. * Set the value of an uniform to an array of float32 (stored as vec2)
  48324. * @param uniform defines the webGL uniform location where to store the value
  48325. * @param array defines the array of float32 to store
  48326. */
  48327. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48328. /**
  48329. * Set the value of an uniform to an array of float32 (stored as vec3)
  48330. * @param uniform defines the webGL uniform location where to store the value
  48331. * @param array defines the array of float32 to store
  48332. */
  48333. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48334. /**
  48335. * Set the value of an uniform to an array of float32 (stored as vec4)
  48336. * @param uniform defines the webGL uniform location where to store the value
  48337. * @param array defines the array of float32 to store
  48338. */
  48339. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48340. /**
  48341. * Set the value of an uniform to an array of number
  48342. * @param uniform defines the webGL uniform location where to store the value
  48343. * @param array defines the array of number to store
  48344. */
  48345. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48346. /**
  48347. * Set the value of an uniform to an array of number (stored as vec2)
  48348. * @param uniform defines the webGL uniform location where to store the value
  48349. * @param array defines the array of number to store
  48350. */
  48351. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48352. /**
  48353. * Set the value of an uniform to an array of number (stored as vec3)
  48354. * @param uniform defines the webGL uniform location where to store the value
  48355. * @param array defines the array of number to store
  48356. */
  48357. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48358. /**
  48359. * Set the value of an uniform to an array of number (stored as vec4)
  48360. * @param uniform defines the webGL uniform location where to store the value
  48361. * @param array defines the array of number to store
  48362. */
  48363. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48364. /**
  48365. * Set the value of an uniform to an array of float32 (stored as matrices)
  48366. * @param uniform defines the webGL uniform location where to store the value
  48367. * @param matrices defines the array of float32 to store
  48368. */
  48369. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48370. /**
  48371. * Set the value of an uniform to a matrix (3x3)
  48372. * @param uniform defines the webGL uniform location where to store the value
  48373. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48374. */
  48375. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48376. /**
  48377. * Set the value of an uniform to a matrix (2x2)
  48378. * @param uniform defines the webGL uniform location where to store the value
  48379. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48380. */
  48381. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48382. /**
  48383. * Set the value of an uniform to a number (float)
  48384. * @param uniform defines the webGL uniform location where to store the value
  48385. * @param value defines the float number to store
  48386. */
  48387. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48388. /**
  48389. * Set the value of an uniform to a vec2
  48390. * @param uniform defines the webGL uniform location where to store the value
  48391. * @param x defines the 1st component of the value
  48392. * @param y defines the 2nd component of the value
  48393. */
  48394. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48395. /**
  48396. * Set the value of an uniform to a vec3
  48397. * @param uniform defines the webGL uniform location where to store the value
  48398. * @param x defines the 1st component of the value
  48399. * @param y defines the 2nd component of the value
  48400. * @param z defines the 3rd component of the value
  48401. */
  48402. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48403. /**
  48404. * Set the value of an uniform to a boolean
  48405. * @param uniform defines the webGL uniform location where to store the value
  48406. * @param bool defines the boolean to store
  48407. */
  48408. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48409. /**
  48410. * Set the value of an uniform to a vec4
  48411. * @param uniform defines the webGL uniform location where to store the value
  48412. * @param x defines the 1st component of the value
  48413. * @param y defines the 2nd component of the value
  48414. * @param z defines the 3rd component of the value
  48415. * @param w defines the 4th component of the value
  48416. */
  48417. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48418. /**
  48419. * Sets the current alpha mode
  48420. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48421. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48422. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48423. */
  48424. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48425. /**
  48426. * Bind webGl buffers directly to the webGL context
  48427. * @param vertexBuffers defines the vertex buffer to bind
  48428. * @param indexBuffer defines the index buffer to bind
  48429. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48430. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48431. * @param effect defines the effect associated with the vertex buffer
  48432. */
  48433. bindBuffers(vertexBuffers: {
  48434. [key: string]: VertexBuffer;
  48435. }, indexBuffer: DataBuffer, effect: Effect): void;
  48436. /**
  48437. * Force the entire cache to be cleared
  48438. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48439. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48440. */
  48441. wipeCaches(bruteForce?: boolean): void;
  48442. /**
  48443. * Send a draw order
  48444. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48445. * @param indexStart defines the starting index
  48446. * @param indexCount defines the number of index to draw
  48447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48448. */
  48449. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48450. /**
  48451. * Draw a list of indexed primitives
  48452. * @param fillMode defines the primitive to use
  48453. * @param indexStart defines the starting index
  48454. * @param indexCount defines the number of index to draw
  48455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48456. */
  48457. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48458. /**
  48459. * Draw a list of unindexed primitives
  48460. * @param fillMode defines the primitive to use
  48461. * @param verticesStart defines the index of first vertex to draw
  48462. * @param verticesCount defines the count of vertices to draw
  48463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48464. */
  48465. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48466. /** @hidden */
  48467. _createTexture(): WebGLTexture;
  48468. /** @hidden */
  48469. _releaseTexture(texture: InternalTexture): void;
  48470. /**
  48471. * Usually called from Texture.ts.
  48472. * Passed information to create a WebGLTexture
  48473. * @param urlArg defines a value which contains one of the following:
  48474. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48475. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48476. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48477. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48478. * @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)
  48479. * @param scene needed for loading to the correct scene
  48480. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48481. * @param onLoad optional callback to be called upon successful completion
  48482. * @param onError optional callback to be called upon failure
  48483. * @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
  48484. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48485. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48486. * @param forcedExtension defines the extension to use to pick the right loader
  48487. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48488. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48489. */
  48490. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  48491. /**
  48492. * Creates a new render target texture
  48493. * @param size defines the size of the texture
  48494. * @param options defines the options used to create the texture
  48495. * @returns a new render target texture stored in an InternalTexture
  48496. */
  48497. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48498. /**
  48499. * Update the sampling mode of a given texture
  48500. * @param samplingMode defines the required sampling mode
  48501. * @param texture defines the texture to update
  48502. */
  48503. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48504. /**
  48505. * Binds the frame buffer to the specified texture.
  48506. * @param texture The texture to render to or null for the default canvas
  48507. * @param faceIndex The face of the texture to render to in case of cube texture
  48508. * @param requiredWidth The width of the target to render to
  48509. * @param requiredHeight The height of the target to render to
  48510. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48511. * @param lodLevel defines le lod level to bind to the frame buffer
  48512. */
  48513. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48514. /**
  48515. * Unbind the current render target texture from the webGL context
  48516. * @param texture defines the render target texture to unbind
  48517. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48518. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48519. */
  48520. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48521. /**
  48522. * Creates a dynamic vertex buffer
  48523. * @param vertices the data for the dynamic vertex buffer
  48524. * @returns the new WebGL dynamic buffer
  48525. */
  48526. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48527. /**
  48528. * Update the content of a dynamic texture
  48529. * @param texture defines the texture to update
  48530. * @param canvas defines the canvas containing the source
  48531. * @param invertY defines if data must be stored with Y axis inverted
  48532. * @param premulAlpha defines if alpha is stored as premultiplied
  48533. * @param format defines the format of the data
  48534. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48535. */
  48536. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48537. /**
  48538. * Gets a boolean indicating if all created effects are ready
  48539. * @returns true if all effects are ready
  48540. */
  48541. areAllEffectsReady(): boolean;
  48542. /**
  48543. * @hidden
  48544. * Get the current error code of the webGL context
  48545. * @returns the error code
  48546. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48547. */
  48548. getError(): number;
  48549. /** @hidden */
  48550. _getUnpackAlignement(): number;
  48551. /** @hidden */
  48552. _unpackFlipY(value: boolean): void;
  48553. /**
  48554. * Update a dynamic index buffer
  48555. * @param indexBuffer defines the target index buffer
  48556. * @param indices defines the data to update
  48557. * @param offset defines the offset in the target index buffer where update should start
  48558. */
  48559. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48560. /**
  48561. * Updates a dynamic vertex buffer.
  48562. * @param vertexBuffer the vertex buffer to update
  48563. * @param vertices the data used to update the vertex buffer
  48564. * @param byteOffset the byte offset of the data (optional)
  48565. * @param byteLength the byte length of the data (optional)
  48566. */
  48567. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48568. /** @hidden */
  48569. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48570. /** @hidden */
  48571. _bindTexture(channel: number, texture: InternalTexture): void;
  48572. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48573. /**
  48574. * 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
  48575. */
  48576. releaseEffects(): void;
  48577. displayLoadingUI(): void;
  48578. hideLoadingUI(): void;
  48579. /** @hidden */
  48580. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48581. /** @hidden */
  48582. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48583. /** @hidden */
  48584. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48585. /** @hidden */
  48586. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48587. }
  48588. }
  48589. declare module "babylonjs/Instrumentation/timeToken" {
  48590. import { Nullable } from "babylonjs/types";
  48591. /**
  48592. * @hidden
  48593. **/
  48594. export class _TimeToken {
  48595. _startTimeQuery: Nullable<WebGLQuery>;
  48596. _endTimeQuery: Nullable<WebGLQuery>;
  48597. _timeElapsedQuery: Nullable<WebGLQuery>;
  48598. _timeElapsedQueryEnded: boolean;
  48599. }
  48600. }
  48601. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48602. import { Nullable, int } from "babylonjs/types";
  48603. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48604. /** @hidden */
  48605. export class _OcclusionDataStorage {
  48606. /** @hidden */
  48607. occlusionInternalRetryCounter: number;
  48608. /** @hidden */
  48609. isOcclusionQueryInProgress: boolean;
  48610. /** @hidden */
  48611. isOccluded: boolean;
  48612. /** @hidden */
  48613. occlusionRetryCount: number;
  48614. /** @hidden */
  48615. occlusionType: number;
  48616. /** @hidden */
  48617. occlusionQueryAlgorithmType: number;
  48618. }
  48619. module "babylonjs/Engines/engine" {
  48620. interface Engine {
  48621. /**
  48622. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48623. * @return the new query
  48624. */
  48625. createQuery(): WebGLQuery;
  48626. /**
  48627. * Delete and release a webGL query
  48628. * @param query defines the query to delete
  48629. * @return the current engine
  48630. */
  48631. deleteQuery(query: WebGLQuery): Engine;
  48632. /**
  48633. * Check if a given query has resolved and got its value
  48634. * @param query defines the query to check
  48635. * @returns true if the query got its value
  48636. */
  48637. isQueryResultAvailable(query: WebGLQuery): boolean;
  48638. /**
  48639. * Gets the value of a given query
  48640. * @param query defines the query to check
  48641. * @returns the value of the query
  48642. */
  48643. getQueryResult(query: WebGLQuery): number;
  48644. /**
  48645. * Initiates an occlusion query
  48646. * @param algorithmType defines the algorithm to use
  48647. * @param query defines the query to use
  48648. * @returns the current engine
  48649. * @see http://doc.babylonjs.com/features/occlusionquery
  48650. */
  48651. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48652. /**
  48653. * Ends an occlusion query
  48654. * @see http://doc.babylonjs.com/features/occlusionquery
  48655. * @param algorithmType defines the algorithm to use
  48656. * @returns the current engine
  48657. */
  48658. endOcclusionQuery(algorithmType: number): Engine;
  48659. /**
  48660. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48661. * Please note that only one query can be issued at a time
  48662. * @returns a time token used to track the time span
  48663. */
  48664. startTimeQuery(): Nullable<_TimeToken>;
  48665. /**
  48666. * Ends a time query
  48667. * @param token defines the token used to measure the time span
  48668. * @returns the time spent (in ns)
  48669. */
  48670. endTimeQuery(token: _TimeToken): int;
  48671. /** @hidden */
  48672. _currentNonTimestampToken: Nullable<_TimeToken>;
  48673. /** @hidden */
  48674. _createTimeQuery(): WebGLQuery;
  48675. /** @hidden */
  48676. _deleteTimeQuery(query: WebGLQuery): void;
  48677. /** @hidden */
  48678. _getGlAlgorithmType(algorithmType: number): number;
  48679. /** @hidden */
  48680. _getTimeQueryResult(query: WebGLQuery): any;
  48681. /** @hidden */
  48682. _getTimeQueryAvailability(query: WebGLQuery): any;
  48683. }
  48684. }
  48685. module "babylonjs/Meshes/abstractMesh" {
  48686. interface AbstractMesh {
  48687. /**
  48688. * Backing filed
  48689. * @hidden
  48690. */
  48691. __occlusionDataStorage: _OcclusionDataStorage;
  48692. /**
  48693. * Access property
  48694. * @hidden
  48695. */
  48696. _occlusionDataStorage: _OcclusionDataStorage;
  48697. /**
  48698. * 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.
  48699. * The default value is -1 which means don't break the query and wait till the result
  48700. * @see http://doc.babylonjs.com/features/occlusionquery
  48701. */
  48702. occlusionRetryCount: number;
  48703. /**
  48704. * 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:
  48705. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48706. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48707. * * 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.
  48708. * @see http://doc.babylonjs.com/features/occlusionquery
  48709. */
  48710. occlusionType: number;
  48711. /**
  48712. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48713. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48714. * * 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.
  48715. * @see http://doc.babylonjs.com/features/occlusionquery
  48716. */
  48717. occlusionQueryAlgorithmType: number;
  48718. /**
  48719. * 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
  48720. * @see http://doc.babylonjs.com/features/occlusionquery
  48721. */
  48722. isOccluded: boolean;
  48723. /**
  48724. * Flag to check the progress status of the query
  48725. * @see http://doc.babylonjs.com/features/occlusionquery
  48726. */
  48727. isOcclusionQueryInProgress: boolean;
  48728. }
  48729. }
  48730. }
  48731. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48732. import { Nullable } from "babylonjs/types";
  48733. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48734. /** @hidden */
  48735. export var _forceTransformFeedbackToBundle: boolean;
  48736. module "babylonjs/Engines/engine" {
  48737. interface Engine {
  48738. /**
  48739. * Creates a webGL transform feedback object
  48740. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48741. * @returns the webGL transform feedback object
  48742. */
  48743. createTransformFeedback(): WebGLTransformFeedback;
  48744. /**
  48745. * Delete a webGL transform feedback object
  48746. * @param value defines the webGL transform feedback object to delete
  48747. */
  48748. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48749. /**
  48750. * Bind a webGL transform feedback object to the webgl context
  48751. * @param value defines the webGL transform feedback object to bind
  48752. */
  48753. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48754. /**
  48755. * Begins a transform feedback operation
  48756. * @param usePoints defines if points or triangles must be used
  48757. */
  48758. beginTransformFeedback(usePoints: boolean): void;
  48759. /**
  48760. * Ends a transform feedback operation
  48761. */
  48762. endTransformFeedback(): void;
  48763. /**
  48764. * Specify the varyings to use with transform feedback
  48765. * @param program defines the associated webGL program
  48766. * @param value defines the list of strings representing the varying names
  48767. */
  48768. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48769. /**
  48770. * Bind a webGL buffer for a transform feedback operation
  48771. * @param value defines the webGL buffer to bind
  48772. */
  48773. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48774. }
  48775. }
  48776. }
  48777. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48778. import { Scene } from "babylonjs/scene";
  48779. import { Engine } from "babylonjs/Engines/engine";
  48780. import { Texture } from "babylonjs/Materials/Textures/texture";
  48781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48782. import "babylonjs/Engines/Extensions/engine.multiRender";
  48783. /**
  48784. * Creation options of the multi render target texture.
  48785. */
  48786. export interface IMultiRenderTargetOptions {
  48787. /**
  48788. * Define if the texture needs to create mip maps after render.
  48789. */
  48790. generateMipMaps?: boolean;
  48791. /**
  48792. * Define the types of all the draw buffers we want to create
  48793. */
  48794. types?: number[];
  48795. /**
  48796. * Define the sampling modes of all the draw buffers we want to create
  48797. */
  48798. samplingModes?: number[];
  48799. /**
  48800. * Define if a depth buffer is required
  48801. */
  48802. generateDepthBuffer?: boolean;
  48803. /**
  48804. * Define if a stencil buffer is required
  48805. */
  48806. generateStencilBuffer?: boolean;
  48807. /**
  48808. * Define if a depth texture is required instead of a depth buffer
  48809. */
  48810. generateDepthTexture?: boolean;
  48811. /**
  48812. * Define the number of desired draw buffers
  48813. */
  48814. textureCount?: number;
  48815. /**
  48816. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48817. */
  48818. doNotChangeAspectRatio?: boolean;
  48819. /**
  48820. * Define the default type of the buffers we are creating
  48821. */
  48822. defaultType?: number;
  48823. }
  48824. /**
  48825. * A multi render target, like a render target provides the ability to render to a texture.
  48826. * Unlike the render target, it can render to several draw buffers in one draw.
  48827. * This is specially interesting in deferred rendering or for any effects requiring more than
  48828. * just one color from a single pass.
  48829. */
  48830. export class MultiRenderTarget extends RenderTargetTexture {
  48831. private _internalTextures;
  48832. private _textures;
  48833. private _multiRenderTargetOptions;
  48834. /**
  48835. * Get if draw buffers are currently supported by the used hardware and browser.
  48836. */
  48837. get isSupported(): boolean;
  48838. /**
  48839. * Get the list of textures generated by the multi render target.
  48840. */
  48841. get textures(): Texture[];
  48842. /**
  48843. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48844. */
  48845. get depthTexture(): Texture;
  48846. /**
  48847. * Set the wrapping mode on U of all the textures we are rendering to.
  48848. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48849. */
  48850. set wrapU(wrap: number);
  48851. /**
  48852. * Set the wrapping mode on V of all the textures we are rendering to.
  48853. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48854. */
  48855. set wrapV(wrap: number);
  48856. /**
  48857. * Instantiate a new multi render target texture.
  48858. * A multi render target, like a render target provides the ability to render to a texture.
  48859. * Unlike the render target, it can render to several draw buffers in one draw.
  48860. * This is specially interesting in deferred rendering or for any effects requiring more than
  48861. * just one color from a single pass.
  48862. * @param name Define the name of the texture
  48863. * @param size Define the size of the buffers to render to
  48864. * @param count Define the number of target we are rendering into
  48865. * @param scene Define the scene the texture belongs to
  48866. * @param options Define the options used to create the multi render target
  48867. */
  48868. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48869. /** @hidden */
  48870. _rebuild(): void;
  48871. private _createInternalTextures;
  48872. private _createTextures;
  48873. /**
  48874. * Define the number of samples used if MSAA is enabled.
  48875. */
  48876. get samples(): number;
  48877. set samples(value: number);
  48878. /**
  48879. * Resize all the textures in the multi render target.
  48880. * Be carrefull as it will recreate all the data in the new texture.
  48881. * @param size Define the new size
  48882. */
  48883. resize(size: any): void;
  48884. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48885. /**
  48886. * Dispose the render targets and their associated resources
  48887. */
  48888. dispose(): void;
  48889. /**
  48890. * Release all the underlying texture used as draw buffers.
  48891. */
  48892. releaseInternalTextures(): void;
  48893. }
  48894. }
  48895. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48897. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48898. import { Nullable } from "babylonjs/types";
  48899. module "babylonjs/Engines/thinEngine" {
  48900. interface ThinEngine {
  48901. /**
  48902. * Unbind a list of render target textures from the webGL context
  48903. * This is used only when drawBuffer extension or webGL2 are active
  48904. * @param textures defines the render target textures to unbind
  48905. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48906. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48907. */
  48908. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48909. /**
  48910. * Create a multi render target texture
  48911. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48912. * @param size defines the size of the texture
  48913. * @param options defines the creation options
  48914. * @returns the cube texture as an InternalTexture
  48915. */
  48916. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48917. /**
  48918. * Update the sample count for a given multiple render target texture
  48919. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48920. * @param textures defines the textures to update
  48921. * @param samples defines the sample count to set
  48922. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48923. */
  48924. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48925. }
  48926. }
  48927. }
  48928. declare module "babylonjs/Engines/Extensions/engine.views" {
  48929. import { Camera } from "babylonjs/Cameras/camera";
  48930. import { Nullable } from "babylonjs/types";
  48931. /**
  48932. * Class used to define an additional view for the engine
  48933. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48934. */
  48935. export class EngineView {
  48936. /** Defines the canvas where to render the view */
  48937. target: HTMLCanvasElement;
  48938. /** Defines an optional camera used to render the view (will use active camera else) */
  48939. camera?: Camera;
  48940. }
  48941. module "babylonjs/Engines/engine" {
  48942. interface Engine {
  48943. /**
  48944. * Gets or sets the HTML element to use for attaching events
  48945. */
  48946. inputElement: Nullable<HTMLElement>;
  48947. /**
  48948. * Gets the current engine view
  48949. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48950. */
  48951. activeView: Nullable<EngineView>;
  48952. /** Gets or sets the list of views */
  48953. views: EngineView[];
  48954. /**
  48955. * Register a new child canvas
  48956. * @param canvas defines the canvas to register
  48957. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48958. * @returns the associated view
  48959. */
  48960. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48961. /**
  48962. * Remove a registered child canvas
  48963. * @param canvas defines the canvas to remove
  48964. * @returns the current engine
  48965. */
  48966. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48967. }
  48968. }
  48969. }
  48970. declare module "babylonjs/Engines/Extensions/index" {
  48971. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48972. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48973. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48974. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48975. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48976. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48977. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48978. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48979. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48980. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48981. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48982. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48983. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48984. export * from "babylonjs/Engines/Extensions/engine.views";
  48985. }
  48986. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48987. import { Nullable } from "babylonjs/types";
  48988. /**
  48989. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48990. */
  48991. export interface CubeMapInfo {
  48992. /**
  48993. * The pixel array for the front face.
  48994. * This is stored in format, left to right, up to down format.
  48995. */
  48996. front: Nullable<ArrayBufferView>;
  48997. /**
  48998. * The pixel array for the back face.
  48999. * This is stored in format, left to right, up to down format.
  49000. */
  49001. back: Nullable<ArrayBufferView>;
  49002. /**
  49003. * The pixel array for the left face.
  49004. * This is stored in format, left to right, up to down format.
  49005. */
  49006. left: Nullable<ArrayBufferView>;
  49007. /**
  49008. * The pixel array for the right face.
  49009. * This is stored in format, left to right, up to down format.
  49010. */
  49011. right: Nullable<ArrayBufferView>;
  49012. /**
  49013. * The pixel array for the up face.
  49014. * This is stored in format, left to right, up to down format.
  49015. */
  49016. up: Nullable<ArrayBufferView>;
  49017. /**
  49018. * The pixel array for the down face.
  49019. * This is stored in format, left to right, up to down format.
  49020. */
  49021. down: Nullable<ArrayBufferView>;
  49022. /**
  49023. * The size of the cubemap stored.
  49024. *
  49025. * Each faces will be size * size pixels.
  49026. */
  49027. size: number;
  49028. /**
  49029. * The format of the texture.
  49030. *
  49031. * RGBA, RGB.
  49032. */
  49033. format: number;
  49034. /**
  49035. * The type of the texture data.
  49036. *
  49037. * UNSIGNED_INT, FLOAT.
  49038. */
  49039. type: number;
  49040. /**
  49041. * Specifies whether the texture is in gamma space.
  49042. */
  49043. gammaSpace: boolean;
  49044. }
  49045. /**
  49046. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49047. */
  49048. export class PanoramaToCubeMapTools {
  49049. private static FACE_FRONT;
  49050. private static FACE_BACK;
  49051. private static FACE_RIGHT;
  49052. private static FACE_LEFT;
  49053. private static FACE_DOWN;
  49054. private static FACE_UP;
  49055. /**
  49056. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49057. *
  49058. * @param float32Array The source data.
  49059. * @param inputWidth The width of the input panorama.
  49060. * @param inputHeight The height of the input panorama.
  49061. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49062. * @return The cubemap data
  49063. */
  49064. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49065. private static CreateCubemapTexture;
  49066. private static CalcProjectionSpherical;
  49067. }
  49068. }
  49069. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49070. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49072. import { Nullable } from "babylonjs/types";
  49073. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49074. /**
  49075. * Helper class dealing with the extraction of spherical polynomial dataArray
  49076. * from a cube map.
  49077. */
  49078. export class CubeMapToSphericalPolynomialTools {
  49079. private static FileFaces;
  49080. /**
  49081. * Converts a texture to the according Spherical Polynomial data.
  49082. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49083. *
  49084. * @param texture The texture to extract the information from.
  49085. * @return The Spherical Polynomial data.
  49086. */
  49087. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49088. /**
  49089. * Converts a cubemap to the according Spherical Polynomial data.
  49090. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49091. *
  49092. * @param cubeInfo The Cube map to extract the information from.
  49093. * @return The Spherical Polynomial data.
  49094. */
  49095. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49096. }
  49097. }
  49098. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49099. import { Nullable } from "babylonjs/types";
  49100. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49101. module "babylonjs/Materials/Textures/baseTexture" {
  49102. interface BaseTexture {
  49103. /**
  49104. * Get the polynomial representation of the texture data.
  49105. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49106. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49107. */
  49108. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49109. }
  49110. }
  49111. }
  49112. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49113. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49114. /** @hidden */
  49115. export var rgbdEncodePixelShader: {
  49116. name: string;
  49117. shader: string;
  49118. };
  49119. }
  49120. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49121. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49122. /** @hidden */
  49123. export var rgbdDecodePixelShader: {
  49124. name: string;
  49125. shader: string;
  49126. };
  49127. }
  49128. declare module "babylonjs/Misc/environmentTextureTools" {
  49129. import { Nullable } from "babylonjs/types";
  49130. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49132. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49133. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49134. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49135. import "babylonjs/Shaders/rgbdEncode.fragment";
  49136. import "babylonjs/Shaders/rgbdDecode.fragment";
  49137. /**
  49138. * Raw texture data and descriptor sufficient for WebGL texture upload
  49139. */
  49140. export interface EnvironmentTextureInfo {
  49141. /**
  49142. * Version of the environment map
  49143. */
  49144. version: number;
  49145. /**
  49146. * Width of image
  49147. */
  49148. width: number;
  49149. /**
  49150. * Irradiance information stored in the file.
  49151. */
  49152. irradiance: any;
  49153. /**
  49154. * Specular information stored in the file.
  49155. */
  49156. specular: any;
  49157. }
  49158. /**
  49159. * Defines One Image in the file. It requires only the position in the file
  49160. * as well as the length.
  49161. */
  49162. interface BufferImageData {
  49163. /**
  49164. * Length of the image data.
  49165. */
  49166. length: number;
  49167. /**
  49168. * Position of the data from the null terminator delimiting the end of the JSON.
  49169. */
  49170. position: number;
  49171. }
  49172. /**
  49173. * Defines the specular data enclosed in the file.
  49174. * This corresponds to the version 1 of the data.
  49175. */
  49176. export interface EnvironmentTextureSpecularInfoV1 {
  49177. /**
  49178. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49179. */
  49180. specularDataPosition?: number;
  49181. /**
  49182. * This contains all the images data needed to reconstruct the cubemap.
  49183. */
  49184. mipmaps: Array<BufferImageData>;
  49185. /**
  49186. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49187. */
  49188. lodGenerationScale: number;
  49189. }
  49190. /**
  49191. * Sets of helpers addressing the serialization and deserialization of environment texture
  49192. * stored in a BabylonJS env file.
  49193. * Those files are usually stored as .env files.
  49194. */
  49195. export class EnvironmentTextureTools {
  49196. /**
  49197. * Magic number identifying the env file.
  49198. */
  49199. private static _MagicBytes;
  49200. /**
  49201. * Gets the environment info from an env file.
  49202. * @param data The array buffer containing the .env bytes.
  49203. * @returns the environment file info (the json header) if successfully parsed.
  49204. */
  49205. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49206. /**
  49207. * Creates an environment texture from a loaded cube texture.
  49208. * @param texture defines the cube texture to convert in env file
  49209. * @return a promise containing the environment data if succesfull.
  49210. */
  49211. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49212. /**
  49213. * Creates a JSON representation of the spherical data.
  49214. * @param texture defines the texture containing the polynomials
  49215. * @return the JSON representation of the spherical info
  49216. */
  49217. private static _CreateEnvTextureIrradiance;
  49218. /**
  49219. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49220. * @param data the image data
  49221. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49222. * @return the views described by info providing access to the underlying buffer
  49223. */
  49224. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49225. /**
  49226. * Uploads the texture info contained in the env file to the GPU.
  49227. * @param texture defines the internal texture to upload to
  49228. * @param data defines the data to load
  49229. * @param info defines the texture info retrieved through the GetEnvInfo method
  49230. * @returns a promise
  49231. */
  49232. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49233. private static _OnImageReadyAsync;
  49234. /**
  49235. * Uploads the levels of image data to the GPU.
  49236. * @param texture defines the internal texture to upload to
  49237. * @param imageData defines the array buffer views of image data [mipmap][face]
  49238. * @returns a promise
  49239. */
  49240. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49241. /**
  49242. * Uploads spherical polynomials information to the texture.
  49243. * @param texture defines the texture we are trying to upload the information to
  49244. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49245. */
  49246. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49247. /** @hidden */
  49248. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49249. }
  49250. }
  49251. declare module "babylonjs/Maths/math.vertexFormat" {
  49252. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49253. /**
  49254. * Contains position and normal vectors for a vertex
  49255. */
  49256. export class PositionNormalVertex {
  49257. /** the position of the vertex (defaut: 0,0,0) */
  49258. position: Vector3;
  49259. /** the normal of the vertex (defaut: 0,1,0) */
  49260. normal: Vector3;
  49261. /**
  49262. * Creates a PositionNormalVertex
  49263. * @param position the position of the vertex (defaut: 0,0,0)
  49264. * @param normal the normal of the vertex (defaut: 0,1,0)
  49265. */
  49266. constructor(
  49267. /** the position of the vertex (defaut: 0,0,0) */
  49268. position?: Vector3,
  49269. /** the normal of the vertex (defaut: 0,1,0) */
  49270. normal?: Vector3);
  49271. /**
  49272. * Clones the PositionNormalVertex
  49273. * @returns the cloned PositionNormalVertex
  49274. */
  49275. clone(): PositionNormalVertex;
  49276. }
  49277. /**
  49278. * Contains position, normal and uv vectors for a vertex
  49279. */
  49280. export class PositionNormalTextureVertex {
  49281. /** the position of the vertex (defaut: 0,0,0) */
  49282. position: Vector3;
  49283. /** the normal of the vertex (defaut: 0,1,0) */
  49284. normal: Vector3;
  49285. /** the uv of the vertex (default: 0,0) */
  49286. uv: Vector2;
  49287. /**
  49288. * Creates a PositionNormalTextureVertex
  49289. * @param position the position of the vertex (defaut: 0,0,0)
  49290. * @param normal the normal of the vertex (defaut: 0,1,0)
  49291. * @param uv the uv of the vertex (default: 0,0)
  49292. */
  49293. constructor(
  49294. /** the position of the vertex (defaut: 0,0,0) */
  49295. position?: Vector3,
  49296. /** the normal of the vertex (defaut: 0,1,0) */
  49297. normal?: Vector3,
  49298. /** the uv of the vertex (default: 0,0) */
  49299. uv?: Vector2);
  49300. /**
  49301. * Clones the PositionNormalTextureVertex
  49302. * @returns the cloned PositionNormalTextureVertex
  49303. */
  49304. clone(): PositionNormalTextureVertex;
  49305. }
  49306. }
  49307. declare module "babylonjs/Maths/math" {
  49308. export * from "babylonjs/Maths/math.axis";
  49309. export * from "babylonjs/Maths/math.color";
  49310. export * from "babylonjs/Maths/math.constants";
  49311. export * from "babylonjs/Maths/math.frustum";
  49312. export * from "babylonjs/Maths/math.path";
  49313. export * from "babylonjs/Maths/math.plane";
  49314. export * from "babylonjs/Maths/math.size";
  49315. export * from "babylonjs/Maths/math.vector";
  49316. export * from "babylonjs/Maths/math.vertexFormat";
  49317. export * from "babylonjs/Maths/math.viewport";
  49318. }
  49319. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49320. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49321. /** @hidden */
  49322. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49323. private _genericAttributeLocation;
  49324. private _varyingLocationCount;
  49325. private _varyingLocationMap;
  49326. private _replacements;
  49327. private _textureCount;
  49328. private _uniforms;
  49329. lineProcessor(line: string): string;
  49330. attributeProcessor(attribute: string): string;
  49331. varyingProcessor(varying: string, isFragment: boolean): string;
  49332. uniformProcessor(uniform: string): string;
  49333. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49334. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49335. }
  49336. }
  49337. declare module "babylonjs/Engines/nativeEngine" {
  49338. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49339. import { Engine } from "babylonjs/Engines/engine";
  49340. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49341. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49342. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49343. import { Effect } from "babylonjs/Materials/effect";
  49344. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49345. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49346. import { IColor4Like } from "babylonjs/Maths/math.like";
  49347. import { Scene } from "babylonjs/scene";
  49348. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49349. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49350. /**
  49351. * Container for accessors for natively-stored mesh data buffers.
  49352. */
  49353. class NativeDataBuffer extends DataBuffer {
  49354. /**
  49355. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49356. */
  49357. nativeIndexBuffer?: any;
  49358. /**
  49359. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49360. */
  49361. nativeVertexBuffer?: any;
  49362. }
  49363. /** @hidden */
  49364. class NativeTexture extends InternalTexture {
  49365. getInternalTexture(): InternalTexture;
  49366. getViewCount(): number;
  49367. }
  49368. /** @hidden */
  49369. export class NativeEngine extends Engine {
  49370. private readonly _native;
  49371. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49372. private readonly INVALID_HANDLE;
  49373. getHardwareScalingLevel(): number;
  49374. constructor();
  49375. /**
  49376. * Can be used to override the current requestAnimationFrame requester.
  49377. * @hidden
  49378. */
  49379. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49380. /**
  49381. * Override default engine behavior.
  49382. * @param color
  49383. * @param backBuffer
  49384. * @param depth
  49385. * @param stencil
  49386. */
  49387. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49388. /**
  49389. * Gets host document
  49390. * @returns the host document object
  49391. */
  49392. getHostDocument(): Nullable<Document>;
  49393. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49394. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49395. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49396. recordVertexArrayObject(vertexBuffers: {
  49397. [key: string]: VertexBuffer;
  49398. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49399. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49400. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49401. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49402. /**
  49403. * Draw a list of indexed primitives
  49404. * @param fillMode defines the primitive to use
  49405. * @param indexStart defines the starting index
  49406. * @param indexCount defines the number of index to draw
  49407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49408. */
  49409. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49410. /**
  49411. * Draw a list of unindexed primitives
  49412. * @param fillMode defines the primitive to use
  49413. * @param verticesStart defines the index of first vertex to draw
  49414. * @param verticesCount defines the count of vertices to draw
  49415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49416. */
  49417. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49418. createPipelineContext(): IPipelineContext;
  49419. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49420. /** @hidden */
  49421. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49422. /** @hidden */
  49423. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49424. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49425. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49426. protected _setProgram(program: WebGLProgram): void;
  49427. _releaseEffect(effect: Effect): void;
  49428. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49429. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49430. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49431. bindSamplers(effect: Effect): void;
  49432. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49433. getRenderWidth(useScreen?: boolean): number;
  49434. getRenderHeight(useScreen?: boolean): number;
  49435. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49436. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49437. /**
  49438. * Set the z offset to apply to current rendering
  49439. * @param value defines the offset to apply
  49440. */
  49441. setZOffset(value: number): void;
  49442. /**
  49443. * Gets the current value of the zOffset
  49444. * @returns the current zOffset state
  49445. */
  49446. getZOffset(): number;
  49447. /**
  49448. * Enable or disable depth buffering
  49449. * @param enable defines the state to set
  49450. */
  49451. setDepthBuffer(enable: boolean): void;
  49452. /**
  49453. * Gets a boolean indicating if depth writing is enabled
  49454. * @returns the current depth writing state
  49455. */
  49456. getDepthWrite(): boolean;
  49457. /**
  49458. * Enable or disable depth writing
  49459. * @param enable defines the state to set
  49460. */
  49461. setDepthWrite(enable: boolean): void;
  49462. /**
  49463. * Enable or disable color writing
  49464. * @param enable defines the state to set
  49465. */
  49466. setColorWrite(enable: boolean): void;
  49467. /**
  49468. * Gets a boolean indicating if color writing is enabled
  49469. * @returns the current color writing state
  49470. */
  49471. getColorWrite(): boolean;
  49472. /**
  49473. * Sets alpha constants used by some alpha blending modes
  49474. * @param r defines the red component
  49475. * @param g defines the green component
  49476. * @param b defines the blue component
  49477. * @param a defines the alpha component
  49478. */
  49479. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49480. /**
  49481. * Sets the current alpha mode
  49482. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49483. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49484. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49485. */
  49486. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49487. /**
  49488. * Gets the current alpha mode
  49489. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49490. * @returns the current alpha mode
  49491. */
  49492. getAlphaMode(): number;
  49493. setInt(uniform: WebGLUniformLocation, int: number): void;
  49494. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49495. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49496. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49497. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49498. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49499. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49500. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49501. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49502. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49503. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49504. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49505. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49506. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49507. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49508. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49509. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49510. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49511. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49512. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49513. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49514. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49515. wipeCaches(bruteForce?: boolean): void;
  49516. _createTexture(): WebGLTexture;
  49517. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49518. /**
  49519. * Usually called from BABYLON.Texture.ts.
  49520. * Passed information to create a WebGLTexture
  49521. * @param urlArg defines a value which contains one of the following:
  49522. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49523. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49524. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49525. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49526. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49527. * @param scene needed for loading to the correct scene
  49528. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49529. * @param onLoad optional callback to be called upon successful completion
  49530. * @param onError optional callback to be called upon failure
  49531. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49532. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49533. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49534. * @param forcedExtension defines the extension to use to pick the right loader
  49535. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49536. */
  49537. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49538. /**
  49539. * Creates a cube texture
  49540. * @param rootUrl defines the url where the files to load is located
  49541. * @param scene defines the current scene
  49542. * @param files defines the list of files to load (1 per face)
  49543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49544. * @param onLoad defines an optional callback raised when the texture is loaded
  49545. * @param onError defines an optional callback raised if there is an issue to load the texture
  49546. * @param format defines the format of the data
  49547. * @param forcedExtension defines the extension to use to pick the right loader
  49548. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49551. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49552. * @returns the cube texture as an InternalTexture
  49553. */
  49554. 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;
  49555. private _getSamplingFilter;
  49556. private static _GetNativeTextureFormat;
  49557. createRenderTargetTexture(size: number | {
  49558. width: number;
  49559. height: number;
  49560. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49561. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49562. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49563. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49564. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49565. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49566. /**
  49567. * Updates a dynamic vertex buffer.
  49568. * @param vertexBuffer the vertex buffer to update
  49569. * @param data the data used to update the vertex buffer
  49570. * @param byteOffset the byte offset of the data (optional)
  49571. * @param byteLength the byte length of the data (optional)
  49572. */
  49573. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49574. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49575. private _updateAnisotropicLevel;
  49576. private _getAddressMode;
  49577. /** @hidden */
  49578. _bindTexture(channel: number, texture: InternalTexture): void;
  49579. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49580. releaseEffects(): void;
  49581. /** @hidden */
  49582. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49583. /** @hidden */
  49584. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49585. /** @hidden */
  49586. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49587. /** @hidden */
  49588. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49589. }
  49590. }
  49591. declare module "babylonjs/Engines/index" {
  49592. export * from "babylonjs/Engines/constants";
  49593. export * from "babylonjs/Engines/engineCapabilities";
  49594. export * from "babylonjs/Engines/instancingAttributeInfo";
  49595. export * from "babylonjs/Engines/thinEngine";
  49596. export * from "babylonjs/Engines/engine";
  49597. export * from "babylonjs/Engines/engineStore";
  49598. export * from "babylonjs/Engines/nullEngine";
  49599. export * from "babylonjs/Engines/Extensions/index";
  49600. export * from "babylonjs/Engines/IPipelineContext";
  49601. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49602. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49603. export * from "babylonjs/Engines/nativeEngine";
  49604. }
  49605. declare module "babylonjs/Events/clipboardEvents" {
  49606. /**
  49607. * Gather the list of clipboard event types as constants.
  49608. */
  49609. export class ClipboardEventTypes {
  49610. /**
  49611. * The clipboard event is fired when a copy command is active (pressed).
  49612. */
  49613. static readonly COPY: number;
  49614. /**
  49615. * The clipboard event is fired when a cut command is active (pressed).
  49616. */
  49617. static readonly CUT: number;
  49618. /**
  49619. * The clipboard event is fired when a paste command is active (pressed).
  49620. */
  49621. static readonly PASTE: number;
  49622. }
  49623. /**
  49624. * This class is used to store clipboard related info for the onClipboardObservable event.
  49625. */
  49626. export class ClipboardInfo {
  49627. /**
  49628. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49629. */
  49630. type: number;
  49631. /**
  49632. * Defines the related dom event
  49633. */
  49634. event: ClipboardEvent;
  49635. /**
  49636. *Creates an instance of ClipboardInfo.
  49637. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49638. * @param event Defines the related dom event
  49639. */
  49640. constructor(
  49641. /**
  49642. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49643. */
  49644. type: number,
  49645. /**
  49646. * Defines the related dom event
  49647. */
  49648. event: ClipboardEvent);
  49649. /**
  49650. * Get the clipboard event's type from the keycode.
  49651. * @param keyCode Defines the keyCode for the current keyboard event.
  49652. * @return {number}
  49653. */
  49654. static GetTypeFromCharacter(keyCode: number): number;
  49655. }
  49656. }
  49657. declare module "babylonjs/Events/index" {
  49658. export * from "babylonjs/Events/keyboardEvents";
  49659. export * from "babylonjs/Events/pointerEvents";
  49660. export * from "babylonjs/Events/clipboardEvents";
  49661. }
  49662. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49663. import { Scene } from "babylonjs/scene";
  49664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49665. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49666. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49667. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49668. /**
  49669. * Google Daydream controller
  49670. */
  49671. export class DaydreamController extends WebVRController {
  49672. /**
  49673. * Base Url for the controller model.
  49674. */
  49675. static MODEL_BASE_URL: string;
  49676. /**
  49677. * File name for the controller model.
  49678. */
  49679. static MODEL_FILENAME: string;
  49680. /**
  49681. * Gamepad Id prefix used to identify Daydream Controller.
  49682. */
  49683. static readonly GAMEPAD_ID_PREFIX: string;
  49684. /**
  49685. * Creates a new DaydreamController from a gamepad
  49686. * @param vrGamepad the gamepad that the controller should be created from
  49687. */
  49688. constructor(vrGamepad: any);
  49689. /**
  49690. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49691. * @param scene scene in which to add meshes
  49692. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49693. */
  49694. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49695. /**
  49696. * Called once for each button that changed state since the last frame
  49697. * @param buttonIdx Which button index changed
  49698. * @param state New state of the button
  49699. * @param changes Which properties on the state changed since last frame
  49700. */
  49701. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49702. }
  49703. }
  49704. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49705. import { Scene } from "babylonjs/scene";
  49706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49707. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49708. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49709. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49710. /**
  49711. * Gear VR Controller
  49712. */
  49713. export class GearVRController extends WebVRController {
  49714. /**
  49715. * Base Url for the controller model.
  49716. */
  49717. static MODEL_BASE_URL: string;
  49718. /**
  49719. * File name for the controller model.
  49720. */
  49721. static MODEL_FILENAME: string;
  49722. /**
  49723. * Gamepad Id prefix used to identify this controller.
  49724. */
  49725. static readonly GAMEPAD_ID_PREFIX: string;
  49726. private readonly _buttonIndexToObservableNameMap;
  49727. /**
  49728. * Creates a new GearVRController from a gamepad
  49729. * @param vrGamepad the gamepad that the controller should be created from
  49730. */
  49731. constructor(vrGamepad: any);
  49732. /**
  49733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49734. * @param scene scene in which to add meshes
  49735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49736. */
  49737. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49738. /**
  49739. * Called once for each button that changed state since the last frame
  49740. * @param buttonIdx Which button index changed
  49741. * @param state New state of the button
  49742. * @param changes Which properties on the state changed since last frame
  49743. */
  49744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49745. }
  49746. }
  49747. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49748. import { Scene } from "babylonjs/scene";
  49749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49750. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49751. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49752. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49753. /**
  49754. * Generic Controller
  49755. */
  49756. export class GenericController extends WebVRController {
  49757. /**
  49758. * Base Url for the controller model.
  49759. */
  49760. static readonly MODEL_BASE_URL: string;
  49761. /**
  49762. * File name for the controller model.
  49763. */
  49764. static readonly MODEL_FILENAME: string;
  49765. /**
  49766. * Creates a new GenericController from a gamepad
  49767. * @param vrGamepad the gamepad that the controller should be created from
  49768. */
  49769. constructor(vrGamepad: any);
  49770. /**
  49771. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49772. * @param scene scene in which to add meshes
  49773. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49774. */
  49775. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49776. /**
  49777. * Called once for each button that changed state since the last frame
  49778. * @param buttonIdx Which button index changed
  49779. * @param state New state of the button
  49780. * @param changes Which properties on the state changed since last frame
  49781. */
  49782. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49783. }
  49784. }
  49785. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49786. import { Observable } from "babylonjs/Misc/observable";
  49787. import { Scene } from "babylonjs/scene";
  49788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49789. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49790. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49791. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49792. /**
  49793. * Oculus Touch Controller
  49794. */
  49795. export class OculusTouchController extends WebVRController {
  49796. /**
  49797. * Base Url for the controller model.
  49798. */
  49799. static MODEL_BASE_URL: string;
  49800. /**
  49801. * File name for the left controller model.
  49802. */
  49803. static MODEL_LEFT_FILENAME: string;
  49804. /**
  49805. * File name for the right controller model.
  49806. */
  49807. static MODEL_RIGHT_FILENAME: string;
  49808. /**
  49809. * Base Url for the Quest controller model.
  49810. */
  49811. static QUEST_MODEL_BASE_URL: string;
  49812. /**
  49813. * @hidden
  49814. * If the controllers are running on a device that needs the updated Quest controller models
  49815. */
  49816. static _IsQuest: boolean;
  49817. /**
  49818. * Fired when the secondary trigger on this controller is modified
  49819. */
  49820. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49821. /**
  49822. * Fired when the thumb rest on this controller is modified
  49823. */
  49824. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49825. /**
  49826. * Creates a new OculusTouchController from a gamepad
  49827. * @param vrGamepad the gamepad that the controller should be created from
  49828. */
  49829. constructor(vrGamepad: any);
  49830. /**
  49831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49832. * @param scene scene in which to add meshes
  49833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49834. */
  49835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49836. /**
  49837. * Fired when the A button on this controller is modified
  49838. */
  49839. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49840. /**
  49841. * Fired when the B button on this controller is modified
  49842. */
  49843. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49844. /**
  49845. * Fired when the X button on this controller is modified
  49846. */
  49847. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49848. /**
  49849. * Fired when the Y button on this controller is modified
  49850. */
  49851. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49852. /**
  49853. * Called once for each button that changed state since the last frame
  49854. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49855. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49856. * 2) secondary trigger (same)
  49857. * 3) A (right) X (left), touch, pressed = value
  49858. * 4) B / Y
  49859. * 5) thumb rest
  49860. * @param buttonIdx Which button index changed
  49861. * @param state New state of the button
  49862. * @param changes Which properties on the state changed since last frame
  49863. */
  49864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49865. }
  49866. }
  49867. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49868. import { Scene } from "babylonjs/scene";
  49869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49870. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49871. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49872. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49873. import { Observable } from "babylonjs/Misc/observable";
  49874. /**
  49875. * Vive Controller
  49876. */
  49877. export class ViveController extends WebVRController {
  49878. /**
  49879. * Base Url for the controller model.
  49880. */
  49881. static MODEL_BASE_URL: string;
  49882. /**
  49883. * File name for the controller model.
  49884. */
  49885. static MODEL_FILENAME: string;
  49886. /**
  49887. * Creates a new ViveController from a gamepad
  49888. * @param vrGamepad the gamepad that the controller should be created from
  49889. */
  49890. constructor(vrGamepad: any);
  49891. /**
  49892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49893. * @param scene scene in which to add meshes
  49894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49895. */
  49896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49897. /**
  49898. * Fired when the left button on this controller is modified
  49899. */
  49900. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49901. /**
  49902. * Fired when the right button on this controller is modified
  49903. */
  49904. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49905. /**
  49906. * Fired when the menu button on this controller is modified
  49907. */
  49908. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49909. /**
  49910. * Called once for each button that changed state since the last frame
  49911. * Vive mapping:
  49912. * 0: touchpad
  49913. * 1: trigger
  49914. * 2: left AND right buttons
  49915. * 3: menu button
  49916. * @param buttonIdx Which button index changed
  49917. * @param state New state of the button
  49918. * @param changes Which properties on the state changed since last frame
  49919. */
  49920. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49921. }
  49922. }
  49923. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49924. import { Observable } from "babylonjs/Misc/observable";
  49925. import { Scene } from "babylonjs/scene";
  49926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49927. import { Ray } from "babylonjs/Culling/ray";
  49928. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49929. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49930. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49931. /**
  49932. * Defines the WindowsMotionController object that the state of the windows motion controller
  49933. */
  49934. export class WindowsMotionController extends WebVRController {
  49935. /**
  49936. * The base url used to load the left and right controller models
  49937. */
  49938. static MODEL_BASE_URL: string;
  49939. /**
  49940. * The name of the left controller model file
  49941. */
  49942. static MODEL_LEFT_FILENAME: string;
  49943. /**
  49944. * The name of the right controller model file
  49945. */
  49946. static MODEL_RIGHT_FILENAME: string;
  49947. /**
  49948. * The controller name prefix for this controller type
  49949. */
  49950. static readonly GAMEPAD_ID_PREFIX: string;
  49951. /**
  49952. * The controller id pattern for this controller type
  49953. */
  49954. private static readonly GAMEPAD_ID_PATTERN;
  49955. private _loadedMeshInfo;
  49956. protected readonly _mapping: {
  49957. buttons: string[];
  49958. buttonMeshNames: {
  49959. 'trigger': string;
  49960. 'menu': string;
  49961. 'grip': string;
  49962. 'thumbstick': string;
  49963. 'trackpad': string;
  49964. };
  49965. buttonObservableNames: {
  49966. 'trigger': string;
  49967. 'menu': string;
  49968. 'grip': string;
  49969. 'thumbstick': string;
  49970. 'trackpad': string;
  49971. };
  49972. axisMeshNames: string[];
  49973. pointingPoseMeshName: string;
  49974. };
  49975. /**
  49976. * Fired when the trackpad on this controller is clicked
  49977. */
  49978. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49979. /**
  49980. * Fired when the trackpad on this controller is modified
  49981. */
  49982. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49983. /**
  49984. * The current x and y values of this controller's trackpad
  49985. */
  49986. trackpad: StickValues;
  49987. /**
  49988. * Creates a new WindowsMotionController from a gamepad
  49989. * @param vrGamepad the gamepad that the controller should be created from
  49990. */
  49991. constructor(vrGamepad: any);
  49992. /**
  49993. * Fired when the trigger on this controller is modified
  49994. */
  49995. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49996. /**
  49997. * Fired when the menu button on this controller is modified
  49998. */
  49999. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50000. /**
  50001. * Fired when the grip button on this controller is modified
  50002. */
  50003. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50004. /**
  50005. * Fired when the thumbstick button on this controller is modified
  50006. */
  50007. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50008. /**
  50009. * Fired when the touchpad button on this controller is modified
  50010. */
  50011. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50012. /**
  50013. * Fired when the touchpad values on this controller are modified
  50014. */
  50015. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50016. protected _updateTrackpad(): void;
  50017. /**
  50018. * Called once per frame by the engine.
  50019. */
  50020. update(): void;
  50021. /**
  50022. * Called once for each button that changed state since the last frame
  50023. * @param buttonIdx Which button index changed
  50024. * @param state New state of the button
  50025. * @param changes Which properties on the state changed since last frame
  50026. */
  50027. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50028. /**
  50029. * Moves the buttons on the controller mesh based on their current state
  50030. * @param buttonName the name of the button to move
  50031. * @param buttonValue the value of the button which determines the buttons new position
  50032. */
  50033. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50034. /**
  50035. * Moves the axis on the controller mesh based on its current state
  50036. * @param axis the index of the axis
  50037. * @param axisValue the value of the axis which determines the meshes new position
  50038. * @hidden
  50039. */
  50040. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50041. /**
  50042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50043. * @param scene scene in which to add meshes
  50044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50045. */
  50046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50047. /**
  50048. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50049. * can be transformed by button presses and axes values, based on this._mapping.
  50050. *
  50051. * @param scene scene in which the meshes exist
  50052. * @param meshes list of meshes that make up the controller model to process
  50053. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50054. */
  50055. private processModel;
  50056. private createMeshInfo;
  50057. /**
  50058. * Gets the ray of the controller in the direction the controller is pointing
  50059. * @param length the length the resulting ray should be
  50060. * @returns a ray in the direction the controller is pointing
  50061. */
  50062. getForwardRay(length?: number): Ray;
  50063. /**
  50064. * Disposes of the controller
  50065. */
  50066. dispose(): void;
  50067. }
  50068. /**
  50069. * This class represents a new windows motion controller in XR.
  50070. */
  50071. export class XRWindowsMotionController extends WindowsMotionController {
  50072. /**
  50073. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50074. */
  50075. protected readonly _mapping: {
  50076. buttons: string[];
  50077. buttonMeshNames: {
  50078. 'trigger': string;
  50079. 'menu': string;
  50080. 'grip': string;
  50081. 'thumbstick': string;
  50082. 'trackpad': string;
  50083. };
  50084. buttonObservableNames: {
  50085. 'trigger': string;
  50086. 'menu': string;
  50087. 'grip': string;
  50088. 'thumbstick': string;
  50089. 'trackpad': string;
  50090. };
  50091. axisMeshNames: string[];
  50092. pointingPoseMeshName: string;
  50093. };
  50094. /**
  50095. * Construct a new XR-Based windows motion controller
  50096. *
  50097. * @param gamepadInfo the gamepad object from the browser
  50098. */
  50099. constructor(gamepadInfo: any);
  50100. /**
  50101. * holds the thumbstick values (X,Y)
  50102. */
  50103. thumbstickValues: StickValues;
  50104. /**
  50105. * Fired when the thumbstick on this controller is clicked
  50106. */
  50107. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50108. /**
  50109. * Fired when the thumbstick on this controller is modified
  50110. */
  50111. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50112. /**
  50113. * Fired when the touchpad button on this controller is modified
  50114. */
  50115. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50116. /**
  50117. * Fired when the touchpad values on this controller are modified
  50118. */
  50119. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50120. /**
  50121. * Fired when the thumbstick button on this controller is modified
  50122. * here to prevent breaking changes
  50123. */
  50124. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50125. /**
  50126. * updating the thumbstick(!) and not the trackpad.
  50127. * This is named this way due to the difference between WebVR and XR and to avoid
  50128. * changing the parent class.
  50129. */
  50130. protected _updateTrackpad(): void;
  50131. /**
  50132. * Disposes the class with joy
  50133. */
  50134. dispose(): void;
  50135. }
  50136. }
  50137. declare module "babylonjs/Gamepads/Controllers/index" {
  50138. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50139. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50140. export * from "babylonjs/Gamepads/Controllers/genericController";
  50141. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50142. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50143. export * from "babylonjs/Gamepads/Controllers/viveController";
  50144. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50145. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50146. }
  50147. declare module "babylonjs/Gamepads/index" {
  50148. export * from "babylonjs/Gamepads/Controllers/index";
  50149. export * from "babylonjs/Gamepads/gamepad";
  50150. export * from "babylonjs/Gamepads/gamepadManager";
  50151. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50152. export * from "babylonjs/Gamepads/xboxGamepad";
  50153. export * from "babylonjs/Gamepads/dualShockGamepad";
  50154. }
  50155. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50156. import { Scene } from "babylonjs/scene";
  50157. import { Vector4 } from "babylonjs/Maths/math.vector";
  50158. import { Color4 } from "babylonjs/Maths/math.color";
  50159. import { Mesh } from "babylonjs/Meshes/mesh";
  50160. import { Nullable } from "babylonjs/types";
  50161. /**
  50162. * Class containing static functions to help procedurally build meshes
  50163. */
  50164. export class PolyhedronBuilder {
  50165. /**
  50166. * Creates a polyhedron mesh
  50167. * * 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
  50168. * * The parameter `size` (positive float, default 1) sets the polygon size
  50169. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50170. * * 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`
  50171. * * 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
  50172. * * 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)`)
  50173. * * 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
  50174. * * 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
  50175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50178. * @param name defines the name of the mesh
  50179. * @param options defines the options used to create the mesh
  50180. * @param scene defines the hosting scene
  50181. * @returns the polyhedron mesh
  50182. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50183. */
  50184. static CreatePolyhedron(name: string, options: {
  50185. type?: number;
  50186. size?: number;
  50187. sizeX?: number;
  50188. sizeY?: number;
  50189. sizeZ?: number;
  50190. custom?: any;
  50191. faceUV?: Vector4[];
  50192. faceColors?: Color4[];
  50193. flat?: boolean;
  50194. updatable?: boolean;
  50195. sideOrientation?: number;
  50196. frontUVs?: Vector4;
  50197. backUVs?: Vector4;
  50198. }, scene?: Nullable<Scene>): Mesh;
  50199. }
  50200. }
  50201. declare module "babylonjs/Gizmos/scaleGizmo" {
  50202. import { Observable } from "babylonjs/Misc/observable";
  50203. import { Nullable } from "babylonjs/types";
  50204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50205. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50206. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50207. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50208. /**
  50209. * Gizmo that enables scaling a mesh along 3 axis
  50210. */
  50211. export class ScaleGizmo extends Gizmo {
  50212. /**
  50213. * Internal gizmo used for interactions on the x axis
  50214. */
  50215. xGizmo: AxisScaleGizmo;
  50216. /**
  50217. * Internal gizmo used for interactions on the y axis
  50218. */
  50219. yGizmo: AxisScaleGizmo;
  50220. /**
  50221. * Internal gizmo used for interactions on the z axis
  50222. */
  50223. zGizmo: AxisScaleGizmo;
  50224. /**
  50225. * Internal gizmo used to scale all axis equally
  50226. */
  50227. uniformScaleGizmo: AxisScaleGizmo;
  50228. private _meshAttached;
  50229. private _updateGizmoRotationToMatchAttachedMesh;
  50230. private _snapDistance;
  50231. private _scaleRatio;
  50232. private _uniformScalingMesh;
  50233. private _octahedron;
  50234. private _sensitivity;
  50235. /** Fires an event when any of it's sub gizmos are dragged */
  50236. onDragStartObservable: Observable<unknown>;
  50237. /** Fires an event when any of it's sub gizmos are released from dragging */
  50238. onDragEndObservable: Observable<unknown>;
  50239. get attachedMesh(): Nullable<AbstractMesh>;
  50240. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50241. /**
  50242. * Creates a ScaleGizmo
  50243. * @param gizmoLayer The utility layer the gizmo will be added to
  50244. */
  50245. constructor(gizmoLayer?: UtilityLayerRenderer);
  50246. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50247. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50248. /**
  50249. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50250. */
  50251. set snapDistance(value: number);
  50252. get snapDistance(): number;
  50253. /**
  50254. * Ratio for the scale of the gizmo (Default: 1)
  50255. */
  50256. set scaleRatio(value: number);
  50257. get scaleRatio(): number;
  50258. /**
  50259. * Sensitivity factor for dragging (Default: 1)
  50260. */
  50261. set sensitivity(value: number);
  50262. get sensitivity(): number;
  50263. /**
  50264. * Disposes of the gizmo
  50265. */
  50266. dispose(): void;
  50267. }
  50268. }
  50269. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50270. import { Observable } from "babylonjs/Misc/observable";
  50271. import { Nullable } from "babylonjs/types";
  50272. import { Vector3 } from "babylonjs/Maths/math.vector";
  50273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50274. import { Mesh } from "babylonjs/Meshes/mesh";
  50275. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50276. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50277. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50278. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50279. import { Color3 } from "babylonjs/Maths/math.color";
  50280. /**
  50281. * Single axis scale gizmo
  50282. */
  50283. export class AxisScaleGizmo extends Gizmo {
  50284. /**
  50285. * Drag behavior responsible for the gizmos dragging interactions
  50286. */
  50287. dragBehavior: PointerDragBehavior;
  50288. private _pointerObserver;
  50289. /**
  50290. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50291. */
  50292. snapDistance: number;
  50293. /**
  50294. * Event that fires each time the gizmo snaps to a new location.
  50295. * * snapDistance is the the change in distance
  50296. */
  50297. onSnapObservable: Observable<{
  50298. snapDistance: number;
  50299. }>;
  50300. /**
  50301. * If the scaling operation should be done on all axis (default: false)
  50302. */
  50303. uniformScaling: boolean;
  50304. /**
  50305. * Custom sensitivity value for the drag strength
  50306. */
  50307. sensitivity: number;
  50308. private _isEnabled;
  50309. private _parent;
  50310. private _arrow;
  50311. private _coloredMaterial;
  50312. private _hoverMaterial;
  50313. /**
  50314. * Creates an AxisScaleGizmo
  50315. * @param gizmoLayer The utility layer the gizmo will be added to
  50316. * @param dragAxis The axis which the gizmo will be able to scale on
  50317. * @param color The color of the gizmo
  50318. */
  50319. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50320. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50321. /**
  50322. * If the gizmo is enabled
  50323. */
  50324. set isEnabled(value: boolean);
  50325. get isEnabled(): boolean;
  50326. /**
  50327. * Disposes of the gizmo
  50328. */
  50329. dispose(): void;
  50330. /**
  50331. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50332. * @param mesh The mesh to replace the default mesh of the gizmo
  50333. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50334. */
  50335. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50336. }
  50337. }
  50338. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50339. import { Observable } from "babylonjs/Misc/observable";
  50340. import { Nullable } from "babylonjs/types";
  50341. import { Vector3 } from "babylonjs/Maths/math.vector";
  50342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50343. import { Mesh } from "babylonjs/Meshes/mesh";
  50344. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50345. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50346. import { Color3 } from "babylonjs/Maths/math.color";
  50347. import "babylonjs/Meshes/Builders/boxBuilder";
  50348. /**
  50349. * Bounding box gizmo
  50350. */
  50351. export class BoundingBoxGizmo extends Gizmo {
  50352. private _lineBoundingBox;
  50353. private _rotateSpheresParent;
  50354. private _scaleBoxesParent;
  50355. private _boundingDimensions;
  50356. private _renderObserver;
  50357. private _pointerObserver;
  50358. private _scaleDragSpeed;
  50359. private _tmpQuaternion;
  50360. private _tmpVector;
  50361. private _tmpRotationMatrix;
  50362. /**
  50363. * 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)
  50364. */
  50365. ignoreChildren: boolean;
  50366. /**
  50367. * 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)
  50368. */
  50369. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50370. /**
  50371. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50372. */
  50373. rotationSphereSize: number;
  50374. /**
  50375. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50376. */
  50377. scaleBoxSize: number;
  50378. /**
  50379. * 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)
  50380. */
  50381. fixedDragMeshScreenSize: boolean;
  50382. /**
  50383. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50384. */
  50385. fixedDragMeshScreenSizeDistanceFactor: number;
  50386. /**
  50387. * Fired when a rotation sphere or scale box is dragged
  50388. */
  50389. onDragStartObservable: Observable<{}>;
  50390. /**
  50391. * Fired when a scale box is dragged
  50392. */
  50393. onScaleBoxDragObservable: Observable<{}>;
  50394. /**
  50395. * Fired when a scale box drag is ended
  50396. */
  50397. onScaleBoxDragEndObservable: Observable<{}>;
  50398. /**
  50399. * Fired when a rotation sphere is dragged
  50400. */
  50401. onRotationSphereDragObservable: Observable<{}>;
  50402. /**
  50403. * Fired when a rotation sphere drag is ended
  50404. */
  50405. onRotationSphereDragEndObservable: Observable<{}>;
  50406. /**
  50407. * 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)
  50408. */
  50409. scalePivot: Nullable<Vector3>;
  50410. /**
  50411. * Mesh used as a pivot to rotate the attached mesh
  50412. */
  50413. private _anchorMesh;
  50414. private _existingMeshScale;
  50415. private _dragMesh;
  50416. private pointerDragBehavior;
  50417. private coloredMaterial;
  50418. private hoverColoredMaterial;
  50419. /**
  50420. * Sets the color of the bounding box gizmo
  50421. * @param color the color to set
  50422. */
  50423. setColor(color: Color3): void;
  50424. /**
  50425. * Creates an BoundingBoxGizmo
  50426. * @param gizmoLayer The utility layer the gizmo will be added to
  50427. * @param color The color of the gizmo
  50428. */
  50429. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50430. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50431. private _selectNode;
  50432. /**
  50433. * Updates the bounding box information for the Gizmo
  50434. */
  50435. updateBoundingBox(): void;
  50436. private _updateRotationSpheres;
  50437. private _updateScaleBoxes;
  50438. /**
  50439. * Enables rotation on the specified axis and disables rotation on the others
  50440. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50441. */
  50442. setEnabledRotationAxis(axis: string): void;
  50443. /**
  50444. * Enables/disables scaling
  50445. * @param enable if scaling should be enabled
  50446. */
  50447. setEnabledScaling(enable: boolean): void;
  50448. private _updateDummy;
  50449. /**
  50450. * Enables a pointer drag behavior on the bounding box of the gizmo
  50451. */
  50452. enableDragBehavior(): void;
  50453. /**
  50454. * Disposes of the gizmo
  50455. */
  50456. dispose(): void;
  50457. /**
  50458. * 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)
  50459. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50460. * @returns the bounding box mesh with the passed in mesh as a child
  50461. */
  50462. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50463. /**
  50464. * CustomMeshes are not supported by this gizmo
  50465. * @param mesh The mesh to replace the default mesh of the gizmo
  50466. */
  50467. setCustomMesh(mesh: Mesh): void;
  50468. }
  50469. }
  50470. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50471. import { Observable } from "babylonjs/Misc/observable";
  50472. import { Nullable } from "babylonjs/types";
  50473. import { Vector3 } from "babylonjs/Maths/math.vector";
  50474. import { Color3 } from "babylonjs/Maths/math.color";
  50475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50476. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50477. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50478. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50479. import "babylonjs/Meshes/Builders/linesBuilder";
  50480. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50481. /**
  50482. * Single plane rotation gizmo
  50483. */
  50484. export class PlaneRotationGizmo extends Gizmo {
  50485. /**
  50486. * Drag behavior responsible for the gizmos dragging interactions
  50487. */
  50488. dragBehavior: PointerDragBehavior;
  50489. private _pointerObserver;
  50490. /**
  50491. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50492. */
  50493. snapDistance: number;
  50494. /**
  50495. * Event that fires each time the gizmo snaps to a new location.
  50496. * * snapDistance is the the change in distance
  50497. */
  50498. onSnapObservable: Observable<{
  50499. snapDistance: number;
  50500. }>;
  50501. private _isEnabled;
  50502. private _parent;
  50503. /**
  50504. * Creates a PlaneRotationGizmo
  50505. * @param gizmoLayer The utility layer the gizmo will be added to
  50506. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50507. * @param color The color of the gizmo
  50508. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50509. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50510. */
  50511. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50512. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50513. /**
  50514. * If the gizmo is enabled
  50515. */
  50516. set isEnabled(value: boolean);
  50517. get isEnabled(): boolean;
  50518. /**
  50519. * Disposes of the gizmo
  50520. */
  50521. dispose(): void;
  50522. }
  50523. }
  50524. declare module "babylonjs/Gizmos/rotationGizmo" {
  50525. import { Observable } from "babylonjs/Misc/observable";
  50526. import { Nullable } from "babylonjs/types";
  50527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50528. import { Mesh } from "babylonjs/Meshes/mesh";
  50529. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50530. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50531. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50532. /**
  50533. * Gizmo that enables rotating a mesh along 3 axis
  50534. */
  50535. export class RotationGizmo extends Gizmo {
  50536. /**
  50537. * Internal gizmo used for interactions on the x axis
  50538. */
  50539. xGizmo: PlaneRotationGizmo;
  50540. /**
  50541. * Internal gizmo used for interactions on the y axis
  50542. */
  50543. yGizmo: PlaneRotationGizmo;
  50544. /**
  50545. * Internal gizmo used for interactions on the z axis
  50546. */
  50547. zGizmo: PlaneRotationGizmo;
  50548. /** Fires an event when any of it's sub gizmos are dragged */
  50549. onDragStartObservable: Observable<unknown>;
  50550. /** Fires an event when any of it's sub gizmos are released from dragging */
  50551. onDragEndObservable: Observable<unknown>;
  50552. private _meshAttached;
  50553. get attachedMesh(): Nullable<AbstractMesh>;
  50554. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50555. /**
  50556. * Creates a RotationGizmo
  50557. * @param gizmoLayer The utility layer the gizmo will be added to
  50558. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50559. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50560. */
  50561. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50562. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50563. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50564. /**
  50565. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50566. */
  50567. set snapDistance(value: number);
  50568. get snapDistance(): number;
  50569. /**
  50570. * Ratio for the scale of the gizmo (Default: 1)
  50571. */
  50572. set scaleRatio(value: number);
  50573. get scaleRatio(): number;
  50574. /**
  50575. * Disposes of the gizmo
  50576. */
  50577. dispose(): void;
  50578. /**
  50579. * CustomMeshes are not supported by this gizmo
  50580. * @param mesh The mesh to replace the default mesh of the gizmo
  50581. */
  50582. setCustomMesh(mesh: Mesh): void;
  50583. }
  50584. }
  50585. declare module "babylonjs/Gizmos/gizmoManager" {
  50586. import { Observable } from "babylonjs/Misc/observable";
  50587. import { Nullable } from "babylonjs/types";
  50588. import { Scene, IDisposable } from "babylonjs/scene";
  50589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50591. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50592. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50593. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50594. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50595. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50596. /**
  50597. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50598. */
  50599. export class GizmoManager implements IDisposable {
  50600. private scene;
  50601. /**
  50602. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50603. */
  50604. gizmos: {
  50605. positionGizmo: Nullable<PositionGizmo>;
  50606. rotationGizmo: Nullable<RotationGizmo>;
  50607. scaleGizmo: Nullable<ScaleGizmo>;
  50608. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50609. };
  50610. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50611. clearGizmoOnEmptyPointerEvent: boolean;
  50612. /** Fires an event when the manager is attached to a mesh */
  50613. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50614. private _gizmosEnabled;
  50615. private _pointerObserver;
  50616. private _attachedMesh;
  50617. private _boundingBoxColor;
  50618. private _defaultUtilityLayer;
  50619. private _defaultKeepDepthUtilityLayer;
  50620. /**
  50621. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50622. */
  50623. boundingBoxDragBehavior: SixDofDragBehavior;
  50624. /**
  50625. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50626. */
  50627. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50628. /**
  50629. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50630. */
  50631. usePointerToAttachGizmos: boolean;
  50632. /**
  50633. * Utility layer that the bounding box gizmo belongs to
  50634. */
  50635. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50636. /**
  50637. * Utility layer that all gizmos besides bounding box belong to
  50638. */
  50639. get utilityLayer(): UtilityLayerRenderer;
  50640. /**
  50641. * Instatiates a gizmo manager
  50642. * @param scene the scene to overlay the gizmos on top of
  50643. */
  50644. constructor(scene: Scene);
  50645. /**
  50646. * Attaches a set of gizmos to the specified mesh
  50647. * @param mesh The mesh the gizmo's should be attached to
  50648. */
  50649. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50650. /**
  50651. * If the position gizmo is enabled
  50652. */
  50653. set positionGizmoEnabled(value: boolean);
  50654. get positionGizmoEnabled(): boolean;
  50655. /**
  50656. * If the rotation gizmo is enabled
  50657. */
  50658. set rotationGizmoEnabled(value: boolean);
  50659. get rotationGizmoEnabled(): boolean;
  50660. /**
  50661. * If the scale gizmo is enabled
  50662. */
  50663. set scaleGizmoEnabled(value: boolean);
  50664. get scaleGizmoEnabled(): boolean;
  50665. /**
  50666. * If the boundingBox gizmo is enabled
  50667. */
  50668. set boundingBoxGizmoEnabled(value: boolean);
  50669. get boundingBoxGizmoEnabled(): boolean;
  50670. /**
  50671. * Disposes of the gizmo manager
  50672. */
  50673. dispose(): void;
  50674. }
  50675. }
  50676. declare module "babylonjs/Lights/directionalLight" {
  50677. import { Camera } from "babylonjs/Cameras/camera";
  50678. import { Scene } from "babylonjs/scene";
  50679. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50681. import { Light } from "babylonjs/Lights/light";
  50682. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50683. import { Effect } from "babylonjs/Materials/effect";
  50684. /**
  50685. * A directional light is defined by a direction (what a surprise!).
  50686. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50687. * 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.
  50688. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50689. */
  50690. export class DirectionalLight extends ShadowLight {
  50691. private _shadowFrustumSize;
  50692. /**
  50693. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50694. */
  50695. get shadowFrustumSize(): number;
  50696. /**
  50697. * Specifies a fix frustum size for the shadow generation.
  50698. */
  50699. set shadowFrustumSize(value: number);
  50700. private _shadowOrthoScale;
  50701. /**
  50702. * Gets the shadow projection scale against the optimal computed one.
  50703. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50704. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50705. */
  50706. get shadowOrthoScale(): number;
  50707. /**
  50708. * Sets the shadow projection scale against the optimal computed one.
  50709. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50710. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50711. */
  50712. set shadowOrthoScale(value: number);
  50713. /**
  50714. * Automatically compute the projection matrix to best fit (including all the casters)
  50715. * on each frame.
  50716. */
  50717. autoUpdateExtends: boolean;
  50718. /**
  50719. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50720. * on each frame. autoUpdateExtends must be set to true for this to work
  50721. */
  50722. autoCalcShadowZBounds: boolean;
  50723. private _orthoLeft;
  50724. private _orthoRight;
  50725. private _orthoTop;
  50726. private _orthoBottom;
  50727. /**
  50728. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50729. * The directional light is emitted from everywhere in the given direction.
  50730. * It can cast shadows.
  50731. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50732. * @param name The friendly name of the light
  50733. * @param direction The direction of the light
  50734. * @param scene The scene the light belongs to
  50735. */
  50736. constructor(name: string, direction: Vector3, scene: Scene);
  50737. /**
  50738. * Returns the string "DirectionalLight".
  50739. * @return The class name
  50740. */
  50741. getClassName(): string;
  50742. /**
  50743. * Returns the integer 1.
  50744. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50745. */
  50746. getTypeID(): number;
  50747. /**
  50748. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50749. * Returns the DirectionalLight Shadow projection matrix.
  50750. */
  50751. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50752. /**
  50753. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50754. * Returns the DirectionalLight Shadow projection matrix.
  50755. */
  50756. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50757. /**
  50758. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50759. * Returns the DirectionalLight Shadow projection matrix.
  50760. */
  50761. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50762. protected _buildUniformLayout(): void;
  50763. /**
  50764. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50765. * @param effect The effect to update
  50766. * @param lightIndex The index of the light in the effect to update
  50767. * @returns The directional light
  50768. */
  50769. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50770. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50771. /**
  50772. * Gets the minZ used for shadow according to both the scene and the light.
  50773. *
  50774. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50775. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50776. * @param activeCamera The camera we are returning the min for
  50777. * @returns the depth min z
  50778. */
  50779. getDepthMinZ(activeCamera: Camera): number;
  50780. /**
  50781. * Gets the maxZ used for shadow according to both the scene and the light.
  50782. *
  50783. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50784. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50785. * @param activeCamera The camera we are returning the max for
  50786. * @returns the depth max z
  50787. */
  50788. getDepthMaxZ(activeCamera: Camera): number;
  50789. /**
  50790. * Prepares the list of defines specific to the light type.
  50791. * @param defines the list of defines
  50792. * @param lightIndex defines the index of the light for the effect
  50793. */
  50794. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50795. }
  50796. }
  50797. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50798. import { Mesh } from "babylonjs/Meshes/mesh";
  50799. /**
  50800. * Class containing static functions to help procedurally build meshes
  50801. */
  50802. export class HemisphereBuilder {
  50803. /**
  50804. * Creates a hemisphere mesh
  50805. * @param name defines the name of the mesh
  50806. * @param options defines the options used to create the mesh
  50807. * @param scene defines the hosting scene
  50808. * @returns the hemisphere mesh
  50809. */
  50810. static CreateHemisphere(name: string, options: {
  50811. segments?: number;
  50812. diameter?: number;
  50813. sideOrientation?: number;
  50814. }, scene: any): Mesh;
  50815. }
  50816. }
  50817. declare module "babylonjs/Lights/spotLight" {
  50818. import { Nullable } from "babylonjs/types";
  50819. import { Scene } from "babylonjs/scene";
  50820. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50822. import { Effect } from "babylonjs/Materials/effect";
  50823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50824. import { Light } from "babylonjs/Lights/light";
  50825. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50826. /**
  50827. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50828. * These values define a cone of light starting from the position, emitting toward the direction.
  50829. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50830. * and the exponent defines the speed of the decay of the light with distance (reach).
  50831. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50832. */
  50833. export class SpotLight extends ShadowLight {
  50834. private _angle;
  50835. private _innerAngle;
  50836. private _cosHalfAngle;
  50837. private _lightAngleScale;
  50838. private _lightAngleOffset;
  50839. /**
  50840. * Gets the cone angle of the spot light in Radians.
  50841. */
  50842. get angle(): number;
  50843. /**
  50844. * Sets the cone angle of the spot light in Radians.
  50845. */
  50846. set angle(value: number);
  50847. /**
  50848. * Only used in gltf falloff mode, this defines the angle where
  50849. * the directional falloff will start before cutting at angle which could be seen
  50850. * as outer angle.
  50851. */
  50852. get innerAngle(): number;
  50853. /**
  50854. * Only used in gltf falloff mode, this defines the angle where
  50855. * the directional falloff will start before cutting at angle which could be seen
  50856. * as outer angle.
  50857. */
  50858. set innerAngle(value: number);
  50859. private _shadowAngleScale;
  50860. /**
  50861. * Allows scaling the angle of the light for shadow generation only.
  50862. */
  50863. get shadowAngleScale(): number;
  50864. /**
  50865. * Allows scaling the angle of the light for shadow generation only.
  50866. */
  50867. set shadowAngleScale(value: number);
  50868. /**
  50869. * The light decay speed with the distance from the emission spot.
  50870. */
  50871. exponent: number;
  50872. private _projectionTextureMatrix;
  50873. /**
  50874. * Allows reading the projecton texture
  50875. */
  50876. get projectionTextureMatrix(): Matrix;
  50877. protected _projectionTextureLightNear: number;
  50878. /**
  50879. * Gets the near clip of the Spotlight for texture projection.
  50880. */
  50881. get projectionTextureLightNear(): number;
  50882. /**
  50883. * Sets the near clip of the Spotlight for texture projection.
  50884. */
  50885. set projectionTextureLightNear(value: number);
  50886. protected _projectionTextureLightFar: number;
  50887. /**
  50888. * Gets the far clip of the Spotlight for texture projection.
  50889. */
  50890. get projectionTextureLightFar(): number;
  50891. /**
  50892. * Sets the far clip of the Spotlight for texture projection.
  50893. */
  50894. set projectionTextureLightFar(value: number);
  50895. protected _projectionTextureUpDirection: Vector3;
  50896. /**
  50897. * Gets the Up vector of the Spotlight for texture projection.
  50898. */
  50899. get projectionTextureUpDirection(): Vector3;
  50900. /**
  50901. * Sets the Up vector of the Spotlight for texture projection.
  50902. */
  50903. set projectionTextureUpDirection(value: Vector3);
  50904. private _projectionTexture;
  50905. /**
  50906. * Gets the projection texture of the light.
  50907. */
  50908. get projectionTexture(): Nullable<BaseTexture>;
  50909. /**
  50910. * Sets the projection texture of the light.
  50911. */
  50912. set projectionTexture(value: Nullable<BaseTexture>);
  50913. private _projectionTextureViewLightDirty;
  50914. private _projectionTextureProjectionLightDirty;
  50915. private _projectionTextureDirty;
  50916. private _projectionTextureViewTargetVector;
  50917. private _projectionTextureViewLightMatrix;
  50918. private _projectionTextureProjectionLightMatrix;
  50919. private _projectionTextureScalingMatrix;
  50920. /**
  50921. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50922. * It can cast shadows.
  50923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50924. * @param name The light friendly name
  50925. * @param position The position of the spot light in the scene
  50926. * @param direction The direction of the light in the scene
  50927. * @param angle The cone angle of the light in Radians
  50928. * @param exponent The light decay speed with the distance from the emission spot
  50929. * @param scene The scene the lights belongs to
  50930. */
  50931. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50932. /**
  50933. * Returns the string "SpotLight".
  50934. * @returns the class name
  50935. */
  50936. getClassName(): string;
  50937. /**
  50938. * Returns the integer 2.
  50939. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50940. */
  50941. getTypeID(): number;
  50942. /**
  50943. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50944. */
  50945. protected _setDirection(value: Vector3): void;
  50946. /**
  50947. * Overrides the position setter to recompute the projection texture view light Matrix.
  50948. */
  50949. protected _setPosition(value: Vector3): void;
  50950. /**
  50951. * 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.
  50952. * Returns the SpotLight.
  50953. */
  50954. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50955. protected _computeProjectionTextureViewLightMatrix(): void;
  50956. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50957. /**
  50958. * Main function for light texture projection matrix computing.
  50959. */
  50960. protected _computeProjectionTextureMatrix(): void;
  50961. protected _buildUniformLayout(): void;
  50962. private _computeAngleValues;
  50963. /**
  50964. * Sets the passed Effect "effect" with the Light textures.
  50965. * @param effect The effect to update
  50966. * @param lightIndex The index of the light in the effect to update
  50967. * @returns The light
  50968. */
  50969. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50970. /**
  50971. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50972. * @param effect The effect to update
  50973. * @param lightIndex The index of the light in the effect to update
  50974. * @returns The spot light
  50975. */
  50976. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50977. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50978. /**
  50979. * Disposes the light and the associated resources.
  50980. */
  50981. dispose(): void;
  50982. /**
  50983. * Prepares the list of defines specific to the light type.
  50984. * @param defines the list of defines
  50985. * @param lightIndex defines the index of the light for the effect
  50986. */
  50987. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50988. }
  50989. }
  50990. declare module "babylonjs/Gizmos/lightGizmo" {
  50991. import { Nullable } from "babylonjs/types";
  50992. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50993. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50994. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50995. import { Light } from "babylonjs/Lights/light";
  50996. /**
  50997. * Gizmo that enables viewing a light
  50998. */
  50999. export class LightGizmo extends Gizmo {
  51000. private _lightMesh;
  51001. private _material;
  51002. private _cachedPosition;
  51003. private _cachedForward;
  51004. private _attachedMeshParent;
  51005. /**
  51006. * Creates a LightGizmo
  51007. * @param gizmoLayer The utility layer the gizmo will be added to
  51008. */
  51009. constructor(gizmoLayer?: UtilityLayerRenderer);
  51010. private _light;
  51011. /**
  51012. * The light that the gizmo is attached to
  51013. */
  51014. set light(light: Nullable<Light>);
  51015. get light(): Nullable<Light>;
  51016. /**
  51017. * Gets the material used to render the light gizmo
  51018. */
  51019. get material(): StandardMaterial;
  51020. /**
  51021. * @hidden
  51022. * Updates the gizmo to match the attached mesh's position/rotation
  51023. */
  51024. protected _update(): void;
  51025. private static _Scale;
  51026. /**
  51027. * Creates the lines for a light mesh
  51028. */
  51029. private static _CreateLightLines;
  51030. /**
  51031. * Disposes of the light gizmo
  51032. */
  51033. dispose(): void;
  51034. private static _CreateHemisphericLightMesh;
  51035. private static _CreatePointLightMesh;
  51036. private static _CreateSpotLightMesh;
  51037. private static _CreateDirectionalLightMesh;
  51038. }
  51039. }
  51040. declare module "babylonjs/Gizmos/index" {
  51041. export * from "babylonjs/Gizmos/axisDragGizmo";
  51042. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51043. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51044. export * from "babylonjs/Gizmos/gizmo";
  51045. export * from "babylonjs/Gizmos/gizmoManager";
  51046. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51047. export * from "babylonjs/Gizmos/positionGizmo";
  51048. export * from "babylonjs/Gizmos/rotationGizmo";
  51049. export * from "babylonjs/Gizmos/scaleGizmo";
  51050. export * from "babylonjs/Gizmos/lightGizmo";
  51051. export * from "babylonjs/Gizmos/planeDragGizmo";
  51052. }
  51053. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51054. /** @hidden */
  51055. export var backgroundFragmentDeclaration: {
  51056. name: string;
  51057. shader: string;
  51058. };
  51059. }
  51060. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51061. /** @hidden */
  51062. export var backgroundUboDeclaration: {
  51063. name: string;
  51064. shader: string;
  51065. };
  51066. }
  51067. declare module "babylonjs/Shaders/background.fragment" {
  51068. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51069. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51070. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51071. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51072. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51073. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51074. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51075. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51076. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51077. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51078. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51079. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51080. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51081. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51082. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51083. /** @hidden */
  51084. export var backgroundPixelShader: {
  51085. name: string;
  51086. shader: string;
  51087. };
  51088. }
  51089. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51090. /** @hidden */
  51091. export var backgroundVertexDeclaration: {
  51092. name: string;
  51093. shader: string;
  51094. };
  51095. }
  51096. declare module "babylonjs/Shaders/background.vertex" {
  51097. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51098. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51100. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51101. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51103. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51104. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51105. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51106. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51107. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51108. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51109. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51110. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51111. /** @hidden */
  51112. export var backgroundVertexShader: {
  51113. name: string;
  51114. shader: string;
  51115. };
  51116. }
  51117. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51118. import { Nullable, int, float } from "babylonjs/types";
  51119. import { Scene } from "babylonjs/scene";
  51120. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51123. import { Mesh } from "babylonjs/Meshes/mesh";
  51124. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51125. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51126. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51128. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51129. import { Color3 } from "babylonjs/Maths/math.color";
  51130. import "babylonjs/Shaders/background.fragment";
  51131. import "babylonjs/Shaders/background.vertex";
  51132. /**
  51133. * Background material used to create an efficient environement around your scene.
  51134. */
  51135. export class BackgroundMaterial extends PushMaterial {
  51136. /**
  51137. * Standard reflectance value at parallel view angle.
  51138. */
  51139. static StandardReflectance0: number;
  51140. /**
  51141. * Standard reflectance value at grazing angle.
  51142. */
  51143. static StandardReflectance90: number;
  51144. protected _primaryColor: Color3;
  51145. /**
  51146. * Key light Color (multiply against the environement texture)
  51147. */
  51148. primaryColor: Color3;
  51149. protected __perceptualColor: Nullable<Color3>;
  51150. /**
  51151. * Experimental Internal Use Only.
  51152. *
  51153. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51154. * This acts as a helper to set the primary color to a more "human friendly" value.
  51155. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51156. * output color as close as possible from the chosen value.
  51157. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51158. * part of lighting setup.)
  51159. */
  51160. get _perceptualColor(): Nullable<Color3>;
  51161. set _perceptualColor(value: Nullable<Color3>);
  51162. protected _primaryColorShadowLevel: float;
  51163. /**
  51164. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51165. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51166. */
  51167. get primaryColorShadowLevel(): float;
  51168. set primaryColorShadowLevel(value: float);
  51169. protected _primaryColorHighlightLevel: float;
  51170. /**
  51171. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51172. * The primary color is used at the level chosen to define what the white area would look.
  51173. */
  51174. get primaryColorHighlightLevel(): float;
  51175. set primaryColorHighlightLevel(value: float);
  51176. protected _reflectionTexture: Nullable<BaseTexture>;
  51177. /**
  51178. * Reflection Texture used in the material.
  51179. * Should be author in a specific way for the best result (refer to the documentation).
  51180. */
  51181. reflectionTexture: Nullable<BaseTexture>;
  51182. protected _reflectionBlur: float;
  51183. /**
  51184. * Reflection Texture level of blur.
  51185. *
  51186. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51187. * texture twice.
  51188. */
  51189. reflectionBlur: float;
  51190. protected _diffuseTexture: Nullable<BaseTexture>;
  51191. /**
  51192. * Diffuse Texture used in the material.
  51193. * Should be author in a specific way for the best result (refer to the documentation).
  51194. */
  51195. diffuseTexture: Nullable<BaseTexture>;
  51196. protected _shadowLights: Nullable<IShadowLight[]>;
  51197. /**
  51198. * Specify the list of lights casting shadow on the material.
  51199. * All scene shadow lights will be included if null.
  51200. */
  51201. shadowLights: Nullable<IShadowLight[]>;
  51202. protected _shadowLevel: float;
  51203. /**
  51204. * Helps adjusting the shadow to a softer level if required.
  51205. * 0 means black shadows and 1 means no shadows.
  51206. */
  51207. shadowLevel: float;
  51208. protected _sceneCenter: Vector3;
  51209. /**
  51210. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51211. * It is usually zero but might be interesting to modify according to your setup.
  51212. */
  51213. sceneCenter: Vector3;
  51214. protected _opacityFresnel: boolean;
  51215. /**
  51216. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51217. * This helps ensuring a nice transition when the camera goes under the ground.
  51218. */
  51219. opacityFresnel: boolean;
  51220. protected _reflectionFresnel: boolean;
  51221. /**
  51222. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51223. * This helps adding a mirror texture on the ground.
  51224. */
  51225. reflectionFresnel: boolean;
  51226. protected _reflectionFalloffDistance: number;
  51227. /**
  51228. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51229. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51230. */
  51231. reflectionFalloffDistance: number;
  51232. protected _reflectionAmount: number;
  51233. /**
  51234. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51235. */
  51236. reflectionAmount: number;
  51237. protected _reflectionReflectance0: number;
  51238. /**
  51239. * This specifies the weight of the reflection at grazing angle.
  51240. */
  51241. reflectionReflectance0: number;
  51242. protected _reflectionReflectance90: number;
  51243. /**
  51244. * This specifies the weight of the reflection at a perpendicular point of view.
  51245. */
  51246. reflectionReflectance90: number;
  51247. /**
  51248. * Sets the reflection reflectance fresnel values according to the default standard
  51249. * empirically know to work well :-)
  51250. */
  51251. set reflectionStandardFresnelWeight(value: number);
  51252. protected _useRGBColor: boolean;
  51253. /**
  51254. * Helps to directly use the maps channels instead of their level.
  51255. */
  51256. useRGBColor: boolean;
  51257. protected _enableNoise: boolean;
  51258. /**
  51259. * This helps reducing the banding effect that could occur on the background.
  51260. */
  51261. enableNoise: boolean;
  51262. /**
  51263. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51264. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51265. * Recommended to be keep at 1.0 except for special cases.
  51266. */
  51267. get fovMultiplier(): number;
  51268. set fovMultiplier(value: number);
  51269. private _fovMultiplier;
  51270. /**
  51271. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51272. */
  51273. useEquirectangularFOV: boolean;
  51274. private _maxSimultaneousLights;
  51275. /**
  51276. * Number of Simultaneous lights allowed on the material.
  51277. */
  51278. maxSimultaneousLights: int;
  51279. /**
  51280. * Default configuration related to image processing available in the Background Material.
  51281. */
  51282. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51283. /**
  51284. * Keep track of the image processing observer to allow dispose and replace.
  51285. */
  51286. private _imageProcessingObserver;
  51287. /**
  51288. * Attaches a new image processing configuration to the PBR Material.
  51289. * @param configuration (if null the scene configuration will be use)
  51290. */
  51291. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51292. /**
  51293. * Gets the image processing configuration used either in this material.
  51294. */
  51295. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51296. /**
  51297. * Sets the Default image processing configuration used either in the this material.
  51298. *
  51299. * If sets to null, the scene one is in use.
  51300. */
  51301. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51302. /**
  51303. * Gets wether the color curves effect is enabled.
  51304. */
  51305. get cameraColorCurvesEnabled(): boolean;
  51306. /**
  51307. * Sets wether the color curves effect is enabled.
  51308. */
  51309. set cameraColorCurvesEnabled(value: boolean);
  51310. /**
  51311. * Gets wether the color grading effect is enabled.
  51312. */
  51313. get cameraColorGradingEnabled(): boolean;
  51314. /**
  51315. * Gets wether the color grading effect is enabled.
  51316. */
  51317. set cameraColorGradingEnabled(value: boolean);
  51318. /**
  51319. * Gets wether tonemapping is enabled or not.
  51320. */
  51321. get cameraToneMappingEnabled(): boolean;
  51322. /**
  51323. * Sets wether tonemapping is enabled or not
  51324. */
  51325. set cameraToneMappingEnabled(value: boolean);
  51326. /**
  51327. * The camera exposure used on this material.
  51328. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51329. * This corresponds to a photographic exposure.
  51330. */
  51331. get cameraExposure(): float;
  51332. /**
  51333. * The camera exposure used on this material.
  51334. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51335. * This corresponds to a photographic exposure.
  51336. */
  51337. set cameraExposure(value: float);
  51338. /**
  51339. * Gets The camera contrast used on this material.
  51340. */
  51341. get cameraContrast(): float;
  51342. /**
  51343. * Sets The camera contrast used on this material.
  51344. */
  51345. set cameraContrast(value: float);
  51346. /**
  51347. * Gets the Color Grading 2D Lookup Texture.
  51348. */
  51349. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51350. /**
  51351. * Sets the Color Grading 2D Lookup Texture.
  51352. */
  51353. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51354. /**
  51355. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51356. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51357. * 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;
  51358. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51359. */
  51360. get cameraColorCurves(): Nullable<ColorCurves>;
  51361. /**
  51362. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51363. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51364. * 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;
  51365. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51366. */
  51367. set cameraColorCurves(value: Nullable<ColorCurves>);
  51368. /**
  51369. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51370. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51371. */
  51372. switchToBGR: boolean;
  51373. private _renderTargets;
  51374. private _reflectionControls;
  51375. private _white;
  51376. private _primaryShadowColor;
  51377. private _primaryHighlightColor;
  51378. /**
  51379. * Instantiates a Background Material in the given scene
  51380. * @param name The friendly name of the material
  51381. * @param scene The scene to add the material to
  51382. */
  51383. constructor(name: string, scene: Scene);
  51384. /**
  51385. * Gets a boolean indicating that current material needs to register RTT
  51386. */
  51387. get hasRenderTargetTextures(): boolean;
  51388. /**
  51389. * The entire material has been created in order to prevent overdraw.
  51390. * @returns false
  51391. */
  51392. needAlphaTesting(): boolean;
  51393. /**
  51394. * The entire material has been created in order to prevent overdraw.
  51395. * @returns true if blending is enable
  51396. */
  51397. needAlphaBlending(): boolean;
  51398. /**
  51399. * Checks wether the material is ready to be rendered for a given mesh.
  51400. * @param mesh The mesh to render
  51401. * @param subMesh The submesh to check against
  51402. * @param useInstances Specify wether or not the material is used with instances
  51403. * @returns true if all the dependencies are ready (Textures, Effects...)
  51404. */
  51405. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51406. /**
  51407. * Compute the primary color according to the chosen perceptual color.
  51408. */
  51409. private _computePrimaryColorFromPerceptualColor;
  51410. /**
  51411. * Compute the highlights and shadow colors according to their chosen levels.
  51412. */
  51413. private _computePrimaryColors;
  51414. /**
  51415. * Build the uniform buffer used in the material.
  51416. */
  51417. buildUniformLayout(): void;
  51418. /**
  51419. * Unbind the material.
  51420. */
  51421. unbind(): void;
  51422. /**
  51423. * Bind only the world matrix to the material.
  51424. * @param world The world matrix to bind.
  51425. */
  51426. bindOnlyWorldMatrix(world: Matrix): void;
  51427. /**
  51428. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51429. * @param world The world matrix to bind.
  51430. * @param subMesh The submesh to bind for.
  51431. */
  51432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51433. /**
  51434. * Checks to see if a texture is used in the material.
  51435. * @param texture - Base texture to use.
  51436. * @returns - Boolean specifying if a texture is used in the material.
  51437. */
  51438. hasTexture(texture: BaseTexture): boolean;
  51439. /**
  51440. * Dispose the material.
  51441. * @param forceDisposeEffect Force disposal of the associated effect.
  51442. * @param forceDisposeTextures Force disposal of the associated textures.
  51443. */
  51444. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51445. /**
  51446. * Clones the material.
  51447. * @param name The cloned name.
  51448. * @returns The cloned material.
  51449. */
  51450. clone(name: string): BackgroundMaterial;
  51451. /**
  51452. * Serializes the current material to its JSON representation.
  51453. * @returns The JSON representation.
  51454. */
  51455. serialize(): any;
  51456. /**
  51457. * Gets the class name of the material
  51458. * @returns "BackgroundMaterial"
  51459. */
  51460. getClassName(): string;
  51461. /**
  51462. * Parse a JSON input to create back a background material.
  51463. * @param source The JSON data to parse
  51464. * @param scene The scene to create the parsed material in
  51465. * @param rootUrl The root url of the assets the material depends upon
  51466. * @returns the instantiated BackgroundMaterial.
  51467. */
  51468. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51469. }
  51470. }
  51471. declare module "babylonjs/Helpers/environmentHelper" {
  51472. import { Observable } from "babylonjs/Misc/observable";
  51473. import { Nullable } from "babylonjs/types";
  51474. import { Scene } from "babylonjs/scene";
  51475. import { Vector3 } from "babylonjs/Maths/math.vector";
  51476. import { Color3 } from "babylonjs/Maths/math.color";
  51477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51478. import { Mesh } from "babylonjs/Meshes/mesh";
  51479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51480. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51481. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51482. import "babylonjs/Meshes/Builders/planeBuilder";
  51483. import "babylonjs/Meshes/Builders/boxBuilder";
  51484. /**
  51485. * Represents the different options available during the creation of
  51486. * a Environment helper.
  51487. *
  51488. * This can control the default ground, skybox and image processing setup of your scene.
  51489. */
  51490. export interface IEnvironmentHelperOptions {
  51491. /**
  51492. * Specifies whether or not to create a ground.
  51493. * True by default.
  51494. */
  51495. createGround: boolean;
  51496. /**
  51497. * Specifies the ground size.
  51498. * 15 by default.
  51499. */
  51500. groundSize: number;
  51501. /**
  51502. * The texture used on the ground for the main color.
  51503. * Comes from the BabylonJS CDN by default.
  51504. *
  51505. * Remarks: Can be either a texture or a url.
  51506. */
  51507. groundTexture: string | BaseTexture;
  51508. /**
  51509. * The color mixed in the ground texture by default.
  51510. * BabylonJS clearColor by default.
  51511. */
  51512. groundColor: Color3;
  51513. /**
  51514. * Specifies the ground opacity.
  51515. * 1 by default.
  51516. */
  51517. groundOpacity: number;
  51518. /**
  51519. * Enables the ground to receive shadows.
  51520. * True by default.
  51521. */
  51522. enableGroundShadow: boolean;
  51523. /**
  51524. * Helps preventing the shadow to be fully black on the ground.
  51525. * 0.5 by default.
  51526. */
  51527. groundShadowLevel: number;
  51528. /**
  51529. * Creates a mirror texture attach to the ground.
  51530. * false by default.
  51531. */
  51532. enableGroundMirror: boolean;
  51533. /**
  51534. * Specifies the ground mirror size ratio.
  51535. * 0.3 by default as the default kernel is 64.
  51536. */
  51537. groundMirrorSizeRatio: number;
  51538. /**
  51539. * Specifies the ground mirror blur kernel size.
  51540. * 64 by default.
  51541. */
  51542. groundMirrorBlurKernel: number;
  51543. /**
  51544. * Specifies the ground mirror visibility amount.
  51545. * 1 by default
  51546. */
  51547. groundMirrorAmount: number;
  51548. /**
  51549. * Specifies the ground mirror reflectance weight.
  51550. * This uses the standard weight of the background material to setup the fresnel effect
  51551. * of the mirror.
  51552. * 1 by default.
  51553. */
  51554. groundMirrorFresnelWeight: number;
  51555. /**
  51556. * Specifies the ground mirror Falloff distance.
  51557. * This can helps reducing the size of the reflection.
  51558. * 0 by Default.
  51559. */
  51560. groundMirrorFallOffDistance: number;
  51561. /**
  51562. * Specifies the ground mirror texture type.
  51563. * Unsigned Int by Default.
  51564. */
  51565. groundMirrorTextureType: number;
  51566. /**
  51567. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51568. * the shown objects.
  51569. */
  51570. groundYBias: number;
  51571. /**
  51572. * Specifies whether or not to create a skybox.
  51573. * True by default.
  51574. */
  51575. createSkybox: boolean;
  51576. /**
  51577. * Specifies the skybox size.
  51578. * 20 by default.
  51579. */
  51580. skyboxSize: number;
  51581. /**
  51582. * The texture used on the skybox for the main color.
  51583. * Comes from the BabylonJS CDN by default.
  51584. *
  51585. * Remarks: Can be either a texture or a url.
  51586. */
  51587. skyboxTexture: string | BaseTexture;
  51588. /**
  51589. * The color mixed in the skybox texture by default.
  51590. * BabylonJS clearColor by default.
  51591. */
  51592. skyboxColor: Color3;
  51593. /**
  51594. * The background rotation around the Y axis of the scene.
  51595. * This helps aligning the key lights of your scene with the background.
  51596. * 0 by default.
  51597. */
  51598. backgroundYRotation: number;
  51599. /**
  51600. * Compute automatically the size of the elements to best fit with the scene.
  51601. */
  51602. sizeAuto: boolean;
  51603. /**
  51604. * Default position of the rootMesh if autoSize is not true.
  51605. */
  51606. rootPosition: Vector3;
  51607. /**
  51608. * Sets up the image processing in the scene.
  51609. * true by default.
  51610. */
  51611. setupImageProcessing: boolean;
  51612. /**
  51613. * The texture used as your environment texture in the scene.
  51614. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51615. *
  51616. * Remarks: Can be either a texture or a url.
  51617. */
  51618. environmentTexture: string | BaseTexture;
  51619. /**
  51620. * The value of the exposure to apply to the scene.
  51621. * 0.6 by default if setupImageProcessing is true.
  51622. */
  51623. cameraExposure: number;
  51624. /**
  51625. * The value of the contrast to apply to the scene.
  51626. * 1.6 by default if setupImageProcessing is true.
  51627. */
  51628. cameraContrast: number;
  51629. /**
  51630. * Specifies whether or not tonemapping should be enabled in the scene.
  51631. * true by default if setupImageProcessing is true.
  51632. */
  51633. toneMappingEnabled: boolean;
  51634. }
  51635. /**
  51636. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51637. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51638. * It also helps with the default setup of your imageProcessing configuration.
  51639. */
  51640. export class EnvironmentHelper {
  51641. /**
  51642. * Default ground texture URL.
  51643. */
  51644. private static _groundTextureCDNUrl;
  51645. /**
  51646. * Default skybox texture URL.
  51647. */
  51648. private static _skyboxTextureCDNUrl;
  51649. /**
  51650. * Default environment texture URL.
  51651. */
  51652. private static _environmentTextureCDNUrl;
  51653. /**
  51654. * Creates the default options for the helper.
  51655. */
  51656. private static _getDefaultOptions;
  51657. private _rootMesh;
  51658. /**
  51659. * Gets the root mesh created by the helper.
  51660. */
  51661. get rootMesh(): Mesh;
  51662. private _skybox;
  51663. /**
  51664. * Gets the skybox created by the helper.
  51665. */
  51666. get skybox(): Nullable<Mesh>;
  51667. private _skyboxTexture;
  51668. /**
  51669. * Gets the skybox texture created by the helper.
  51670. */
  51671. get skyboxTexture(): Nullable<BaseTexture>;
  51672. private _skyboxMaterial;
  51673. /**
  51674. * Gets the skybox material created by the helper.
  51675. */
  51676. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51677. private _ground;
  51678. /**
  51679. * Gets the ground mesh created by the helper.
  51680. */
  51681. get ground(): Nullable<Mesh>;
  51682. private _groundTexture;
  51683. /**
  51684. * Gets the ground texture created by the helper.
  51685. */
  51686. get groundTexture(): Nullable<BaseTexture>;
  51687. private _groundMirror;
  51688. /**
  51689. * Gets the ground mirror created by the helper.
  51690. */
  51691. get groundMirror(): Nullable<MirrorTexture>;
  51692. /**
  51693. * Gets the ground mirror render list to helps pushing the meshes
  51694. * you wish in the ground reflection.
  51695. */
  51696. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51697. private _groundMaterial;
  51698. /**
  51699. * Gets the ground material created by the helper.
  51700. */
  51701. get groundMaterial(): Nullable<BackgroundMaterial>;
  51702. /**
  51703. * Stores the creation options.
  51704. */
  51705. private readonly _scene;
  51706. private _options;
  51707. /**
  51708. * This observable will be notified with any error during the creation of the environment,
  51709. * mainly texture creation errors.
  51710. */
  51711. onErrorObservable: Observable<{
  51712. message?: string;
  51713. exception?: any;
  51714. }>;
  51715. /**
  51716. * constructor
  51717. * @param options Defines the options we want to customize the helper
  51718. * @param scene The scene to add the material to
  51719. */
  51720. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51721. /**
  51722. * Updates the background according to the new options
  51723. * @param options
  51724. */
  51725. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51726. /**
  51727. * Sets the primary color of all the available elements.
  51728. * @param color the main color to affect to the ground and the background
  51729. */
  51730. setMainColor(color: Color3): void;
  51731. /**
  51732. * Setup the image processing according to the specified options.
  51733. */
  51734. private _setupImageProcessing;
  51735. /**
  51736. * Setup the environment texture according to the specified options.
  51737. */
  51738. private _setupEnvironmentTexture;
  51739. /**
  51740. * Setup the background according to the specified options.
  51741. */
  51742. private _setupBackground;
  51743. /**
  51744. * Get the scene sizes according to the setup.
  51745. */
  51746. private _getSceneSize;
  51747. /**
  51748. * Setup the ground according to the specified options.
  51749. */
  51750. private _setupGround;
  51751. /**
  51752. * Setup the ground material according to the specified options.
  51753. */
  51754. private _setupGroundMaterial;
  51755. /**
  51756. * Setup the ground diffuse texture according to the specified options.
  51757. */
  51758. private _setupGroundDiffuseTexture;
  51759. /**
  51760. * Setup the ground mirror texture according to the specified options.
  51761. */
  51762. private _setupGroundMirrorTexture;
  51763. /**
  51764. * Setup the ground to receive the mirror texture.
  51765. */
  51766. private _setupMirrorInGroundMaterial;
  51767. /**
  51768. * Setup the skybox according to the specified options.
  51769. */
  51770. private _setupSkybox;
  51771. /**
  51772. * Setup the skybox material according to the specified options.
  51773. */
  51774. private _setupSkyboxMaterial;
  51775. /**
  51776. * Setup the skybox reflection texture according to the specified options.
  51777. */
  51778. private _setupSkyboxReflectionTexture;
  51779. private _errorHandler;
  51780. /**
  51781. * Dispose all the elements created by the Helper.
  51782. */
  51783. dispose(): void;
  51784. }
  51785. }
  51786. declare module "babylonjs/Helpers/photoDome" {
  51787. import { Observable } from "babylonjs/Misc/observable";
  51788. import { Nullable } from "babylonjs/types";
  51789. import { Scene } from "babylonjs/scene";
  51790. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51791. import { Mesh } from "babylonjs/Meshes/mesh";
  51792. import { Texture } from "babylonjs/Materials/Textures/texture";
  51793. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51794. import "babylonjs/Meshes/Builders/sphereBuilder";
  51795. /**
  51796. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51797. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51798. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51799. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51800. */
  51801. export class PhotoDome extends TransformNode {
  51802. /**
  51803. * Define the image as a Monoscopic panoramic 360 image.
  51804. */
  51805. static readonly MODE_MONOSCOPIC: number;
  51806. /**
  51807. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51808. */
  51809. static readonly MODE_TOPBOTTOM: number;
  51810. /**
  51811. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51812. */
  51813. static readonly MODE_SIDEBYSIDE: number;
  51814. private _useDirectMapping;
  51815. /**
  51816. * The texture being displayed on the sphere
  51817. */
  51818. protected _photoTexture: Texture;
  51819. /**
  51820. * Gets or sets the texture being displayed on the sphere
  51821. */
  51822. get photoTexture(): Texture;
  51823. set photoTexture(value: Texture);
  51824. /**
  51825. * Observable raised when an error occured while loading the 360 image
  51826. */
  51827. onLoadErrorObservable: Observable<string>;
  51828. /**
  51829. * The skybox material
  51830. */
  51831. protected _material: BackgroundMaterial;
  51832. /**
  51833. * The surface used for the skybox
  51834. */
  51835. protected _mesh: Mesh;
  51836. /**
  51837. * Gets the mesh used for the skybox.
  51838. */
  51839. get mesh(): Mesh;
  51840. /**
  51841. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51842. * Also see the options.resolution property.
  51843. */
  51844. get fovMultiplier(): number;
  51845. set fovMultiplier(value: number);
  51846. private _imageMode;
  51847. /**
  51848. * Gets or set the current video mode for the video. It can be:
  51849. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51850. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51851. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51852. */
  51853. get imageMode(): number;
  51854. set imageMode(value: number);
  51855. /**
  51856. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51857. * @param name Element's name, child elements will append suffixes for their own names.
  51858. * @param urlsOfPhoto defines the url of the photo to display
  51859. * @param options defines an object containing optional or exposed sub element properties
  51860. * @param onError defines a callback called when an error occured while loading the texture
  51861. */
  51862. constructor(name: string, urlOfPhoto: string, options: {
  51863. resolution?: number;
  51864. size?: number;
  51865. useDirectMapping?: boolean;
  51866. faceForward?: boolean;
  51867. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51868. private _onBeforeCameraRenderObserver;
  51869. private _changeImageMode;
  51870. /**
  51871. * Releases resources associated with this node.
  51872. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51873. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51874. */
  51875. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51876. }
  51877. }
  51878. declare module "babylonjs/Misc/rgbdTextureTools" {
  51879. import "babylonjs/Shaders/rgbdDecode.fragment";
  51880. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51881. import { Texture } from "babylonjs/Materials/Textures/texture";
  51882. /**
  51883. * Class used to host RGBD texture specific utilities
  51884. */
  51885. export class RGBDTextureTools {
  51886. /**
  51887. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51888. * @param texture the texture to expand.
  51889. */
  51890. static ExpandRGBDTexture(texture: Texture): void;
  51891. }
  51892. }
  51893. declare module "babylonjs/Misc/brdfTextureTools" {
  51894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51895. import { Scene } from "babylonjs/scene";
  51896. /**
  51897. * Class used to host texture specific utilities
  51898. */
  51899. export class BRDFTextureTools {
  51900. /**
  51901. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51902. * @param scene defines the hosting scene
  51903. * @returns the environment BRDF texture
  51904. */
  51905. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51906. private static _environmentBRDFBase64Texture;
  51907. }
  51908. }
  51909. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51910. import { Nullable } from "babylonjs/types";
  51911. import { Color3 } from "babylonjs/Maths/math.color";
  51912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51913. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51914. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51915. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51916. import { Engine } from "babylonjs/Engines/engine";
  51917. import { Scene } from "babylonjs/scene";
  51918. /**
  51919. * @hidden
  51920. */
  51921. export interface IMaterialClearCoatDefines {
  51922. CLEARCOAT: boolean;
  51923. CLEARCOAT_DEFAULTIOR: boolean;
  51924. CLEARCOAT_TEXTURE: boolean;
  51925. CLEARCOAT_TEXTUREDIRECTUV: number;
  51926. CLEARCOAT_BUMP: boolean;
  51927. CLEARCOAT_BUMPDIRECTUV: number;
  51928. CLEARCOAT_TINT: boolean;
  51929. CLEARCOAT_TINT_TEXTURE: boolean;
  51930. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51931. /** @hidden */
  51932. _areTexturesDirty: boolean;
  51933. }
  51934. /**
  51935. * Define the code related to the clear coat parameters of the pbr material.
  51936. */
  51937. export class PBRClearCoatConfiguration {
  51938. /**
  51939. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51940. * The default fits with a polyurethane material.
  51941. */
  51942. private static readonly _DefaultIndexOfRefraction;
  51943. private _isEnabled;
  51944. /**
  51945. * Defines if the clear coat is enabled in the material.
  51946. */
  51947. isEnabled: boolean;
  51948. /**
  51949. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51950. */
  51951. intensity: number;
  51952. /**
  51953. * Defines the clear coat layer roughness.
  51954. */
  51955. roughness: number;
  51956. private _indexOfRefraction;
  51957. /**
  51958. * Defines the index of refraction of the clear coat.
  51959. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51960. * The default fits with a polyurethane material.
  51961. * Changing the default value is more performance intensive.
  51962. */
  51963. indexOfRefraction: number;
  51964. private _texture;
  51965. /**
  51966. * Stores the clear coat values in a texture.
  51967. */
  51968. texture: Nullable<BaseTexture>;
  51969. private _bumpTexture;
  51970. /**
  51971. * Define the clear coat specific bump texture.
  51972. */
  51973. bumpTexture: Nullable<BaseTexture>;
  51974. private _isTintEnabled;
  51975. /**
  51976. * Defines if the clear coat tint is enabled in the material.
  51977. */
  51978. isTintEnabled: boolean;
  51979. /**
  51980. * Defines the clear coat tint of the material.
  51981. * This is only use if tint is enabled
  51982. */
  51983. tintColor: Color3;
  51984. /**
  51985. * Defines the distance at which the tint color should be found in the
  51986. * clear coat media.
  51987. * This is only use if tint is enabled
  51988. */
  51989. tintColorAtDistance: number;
  51990. /**
  51991. * Defines the clear coat layer thickness.
  51992. * This is only use if tint is enabled
  51993. */
  51994. tintThickness: number;
  51995. private _tintTexture;
  51996. /**
  51997. * Stores the clear tint values in a texture.
  51998. * rgb is tint
  51999. * a is a thickness factor
  52000. */
  52001. tintTexture: Nullable<BaseTexture>;
  52002. /** @hidden */
  52003. private _internalMarkAllSubMeshesAsTexturesDirty;
  52004. /** @hidden */
  52005. _markAllSubMeshesAsTexturesDirty(): void;
  52006. /**
  52007. * Instantiate a new istance of clear coat configuration.
  52008. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52009. */
  52010. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52011. /**
  52012. * Gets wehter the submesh is ready to be used or not.
  52013. * @param defines the list of "defines" to update.
  52014. * @param scene defines the scene the material belongs to.
  52015. * @param engine defines the engine the material belongs to.
  52016. * @param disableBumpMap defines wether the material disables bump or not.
  52017. * @returns - boolean indicating that the submesh is ready or not.
  52018. */
  52019. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52020. /**
  52021. * Checks to see if a texture is used in the material.
  52022. * @param defines the list of "defines" to update.
  52023. * @param scene defines the scene to the material belongs to.
  52024. */
  52025. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52026. /**
  52027. * Binds the material data.
  52028. * @param uniformBuffer defines the Uniform buffer to fill in.
  52029. * @param scene defines the scene the material belongs to.
  52030. * @param engine defines the engine the material belongs to.
  52031. * @param disableBumpMap defines wether the material disables bump or not.
  52032. * @param isFrozen defines wether the material is frozen or not.
  52033. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52034. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52035. */
  52036. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52037. /**
  52038. * Checks to see if a texture is used in the material.
  52039. * @param texture - Base texture to use.
  52040. * @returns - Boolean specifying if a texture is used in the material.
  52041. */
  52042. hasTexture(texture: BaseTexture): boolean;
  52043. /**
  52044. * Returns an array of the actively used textures.
  52045. * @param activeTextures Array of BaseTextures
  52046. */
  52047. getActiveTextures(activeTextures: BaseTexture[]): void;
  52048. /**
  52049. * Returns the animatable textures.
  52050. * @param animatables Array of animatable textures.
  52051. */
  52052. getAnimatables(animatables: IAnimatable[]): void;
  52053. /**
  52054. * Disposes the resources of the material.
  52055. * @param forceDisposeTextures - Forces the disposal of all textures.
  52056. */
  52057. dispose(forceDisposeTextures?: boolean): void;
  52058. /**
  52059. * Get the current class name of the texture useful for serialization or dynamic coding.
  52060. * @returns "PBRClearCoatConfiguration"
  52061. */
  52062. getClassName(): string;
  52063. /**
  52064. * Add fallbacks to the effect fallbacks list.
  52065. * @param defines defines the Base texture to use.
  52066. * @param fallbacks defines the current fallback list.
  52067. * @param currentRank defines the current fallback rank.
  52068. * @returns the new fallback rank.
  52069. */
  52070. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52071. /**
  52072. * Add the required uniforms to the current list.
  52073. * @param uniforms defines the current uniform list.
  52074. */
  52075. static AddUniforms(uniforms: string[]): void;
  52076. /**
  52077. * Add the required samplers to the current list.
  52078. * @param samplers defines the current sampler list.
  52079. */
  52080. static AddSamplers(samplers: string[]): void;
  52081. /**
  52082. * Add the required uniforms to the current buffer.
  52083. * @param uniformBuffer defines the current uniform buffer.
  52084. */
  52085. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52086. /**
  52087. * Makes a duplicate of the current configuration into another one.
  52088. * @param clearCoatConfiguration define the config where to copy the info
  52089. */
  52090. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52091. /**
  52092. * Serializes this clear coat configuration.
  52093. * @returns - An object with the serialized config.
  52094. */
  52095. serialize(): any;
  52096. /**
  52097. * Parses a anisotropy Configuration from a serialized object.
  52098. * @param source - Serialized object.
  52099. * @param scene Defines the scene we are parsing for
  52100. * @param rootUrl Defines the rootUrl to load from
  52101. */
  52102. parse(source: any, scene: Scene, rootUrl: string): void;
  52103. }
  52104. }
  52105. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52106. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52108. import { Vector2 } from "babylonjs/Maths/math.vector";
  52109. import { Scene } from "babylonjs/scene";
  52110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52111. import { Nullable } from "babylonjs/types";
  52112. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52113. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52114. /**
  52115. * @hidden
  52116. */
  52117. export interface IMaterialAnisotropicDefines {
  52118. ANISOTROPIC: boolean;
  52119. ANISOTROPIC_TEXTURE: boolean;
  52120. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52121. MAINUV1: boolean;
  52122. _areTexturesDirty: boolean;
  52123. _needUVs: boolean;
  52124. }
  52125. /**
  52126. * Define the code related to the anisotropic parameters of the pbr material.
  52127. */
  52128. export class PBRAnisotropicConfiguration {
  52129. private _isEnabled;
  52130. /**
  52131. * Defines if the anisotropy is enabled in the material.
  52132. */
  52133. isEnabled: boolean;
  52134. /**
  52135. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52136. */
  52137. intensity: number;
  52138. /**
  52139. * Defines if the effect is along the tangents, bitangents or in between.
  52140. * By default, the effect is "strectching" the highlights along the tangents.
  52141. */
  52142. direction: Vector2;
  52143. private _texture;
  52144. /**
  52145. * Stores the anisotropy values in a texture.
  52146. * rg is direction (like normal from -1 to 1)
  52147. * b is a intensity
  52148. */
  52149. texture: Nullable<BaseTexture>;
  52150. /** @hidden */
  52151. private _internalMarkAllSubMeshesAsTexturesDirty;
  52152. /** @hidden */
  52153. _markAllSubMeshesAsTexturesDirty(): void;
  52154. /**
  52155. * Instantiate a new istance of anisotropy configuration.
  52156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52157. */
  52158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52159. /**
  52160. * Specifies that the submesh is ready to be used.
  52161. * @param defines the list of "defines" to update.
  52162. * @param scene defines the scene the material belongs to.
  52163. * @returns - boolean indicating that the submesh is ready or not.
  52164. */
  52165. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52166. /**
  52167. * Checks to see if a texture is used in the material.
  52168. * @param defines the list of "defines" to update.
  52169. * @param mesh the mesh we are preparing the defines for.
  52170. * @param scene defines the scene the material belongs to.
  52171. */
  52172. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52173. /**
  52174. * Binds the material data.
  52175. * @param uniformBuffer defines the Uniform buffer to fill in.
  52176. * @param scene defines the scene the material belongs to.
  52177. * @param isFrozen defines wether the material is frozen or not.
  52178. */
  52179. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52180. /**
  52181. * Checks to see if a texture is used in the material.
  52182. * @param texture - Base texture to use.
  52183. * @returns - Boolean specifying if a texture is used in the material.
  52184. */
  52185. hasTexture(texture: BaseTexture): boolean;
  52186. /**
  52187. * Returns an array of the actively used textures.
  52188. * @param activeTextures Array of BaseTextures
  52189. */
  52190. getActiveTextures(activeTextures: BaseTexture[]): void;
  52191. /**
  52192. * Returns the animatable textures.
  52193. * @param animatables Array of animatable textures.
  52194. */
  52195. getAnimatables(animatables: IAnimatable[]): void;
  52196. /**
  52197. * Disposes the resources of the material.
  52198. * @param forceDisposeTextures - Forces the disposal of all textures.
  52199. */
  52200. dispose(forceDisposeTextures?: boolean): void;
  52201. /**
  52202. * Get the current class name of the texture useful for serialization or dynamic coding.
  52203. * @returns "PBRAnisotropicConfiguration"
  52204. */
  52205. getClassName(): string;
  52206. /**
  52207. * Add fallbacks to the effect fallbacks list.
  52208. * @param defines defines the Base texture to use.
  52209. * @param fallbacks defines the current fallback list.
  52210. * @param currentRank defines the current fallback rank.
  52211. * @returns the new fallback rank.
  52212. */
  52213. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52214. /**
  52215. * Add the required uniforms to the current list.
  52216. * @param uniforms defines the current uniform list.
  52217. */
  52218. static AddUniforms(uniforms: string[]): void;
  52219. /**
  52220. * Add the required uniforms to the current buffer.
  52221. * @param uniformBuffer defines the current uniform buffer.
  52222. */
  52223. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52224. /**
  52225. * Add the required samplers to the current list.
  52226. * @param samplers defines the current sampler list.
  52227. */
  52228. static AddSamplers(samplers: string[]): void;
  52229. /**
  52230. * Makes a duplicate of the current configuration into another one.
  52231. * @param anisotropicConfiguration define the config where to copy the info
  52232. */
  52233. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52234. /**
  52235. * Serializes this anisotropy configuration.
  52236. * @returns - An object with the serialized config.
  52237. */
  52238. serialize(): any;
  52239. /**
  52240. * Parses a anisotropy Configuration from a serialized object.
  52241. * @param source - Serialized object.
  52242. * @param scene Defines the scene we are parsing for
  52243. * @param rootUrl Defines the rootUrl to load from
  52244. */
  52245. parse(source: any, scene: Scene, rootUrl: string): void;
  52246. }
  52247. }
  52248. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52249. import { Scene } from "babylonjs/scene";
  52250. /**
  52251. * @hidden
  52252. */
  52253. export interface IMaterialBRDFDefines {
  52254. BRDF_V_HEIGHT_CORRELATED: boolean;
  52255. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52256. SPHERICAL_HARMONICS: boolean;
  52257. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52258. /** @hidden */
  52259. _areMiscDirty: boolean;
  52260. }
  52261. /**
  52262. * Define the code related to the BRDF parameters of the pbr material.
  52263. */
  52264. export class PBRBRDFConfiguration {
  52265. /**
  52266. * Default value used for the energy conservation.
  52267. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52268. */
  52269. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52270. /**
  52271. * Default value used for the Smith Visibility Height Correlated mode.
  52272. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52273. */
  52274. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52275. /**
  52276. * Default value used for the IBL diffuse part.
  52277. * This can help switching back to the polynomials mode globally which is a tiny bit
  52278. * less GPU intensive at the drawback of a lower quality.
  52279. */
  52280. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52281. /**
  52282. * Default value used for activating energy conservation for the specular workflow.
  52283. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52284. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52285. */
  52286. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52287. private _useEnergyConservation;
  52288. /**
  52289. * Defines if the material uses energy conservation.
  52290. */
  52291. useEnergyConservation: boolean;
  52292. private _useSmithVisibilityHeightCorrelated;
  52293. /**
  52294. * LEGACY Mode set to false
  52295. * Defines if the material uses height smith correlated visibility term.
  52296. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52297. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52298. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52299. * Not relying on height correlated will also disable energy conservation.
  52300. */
  52301. useSmithVisibilityHeightCorrelated: boolean;
  52302. private _useSphericalHarmonics;
  52303. /**
  52304. * LEGACY Mode set to false
  52305. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52306. * diffuse part of the IBL.
  52307. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52308. * to the ground truth.
  52309. */
  52310. useSphericalHarmonics: boolean;
  52311. private _useSpecularGlossinessInputEnergyConservation;
  52312. /**
  52313. * Defines if the material uses energy conservation, when the specular workflow is active.
  52314. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52315. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52316. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52317. */
  52318. useSpecularGlossinessInputEnergyConservation: boolean;
  52319. /** @hidden */
  52320. private _internalMarkAllSubMeshesAsMiscDirty;
  52321. /** @hidden */
  52322. _markAllSubMeshesAsMiscDirty(): void;
  52323. /**
  52324. * Instantiate a new istance of clear coat configuration.
  52325. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52326. */
  52327. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52328. /**
  52329. * Checks to see if a texture is used in the material.
  52330. * @param defines the list of "defines" to update.
  52331. */
  52332. prepareDefines(defines: IMaterialBRDFDefines): void;
  52333. /**
  52334. * Get the current class name of the texture useful for serialization or dynamic coding.
  52335. * @returns "PBRClearCoatConfiguration"
  52336. */
  52337. getClassName(): string;
  52338. /**
  52339. * Makes a duplicate of the current configuration into another one.
  52340. * @param brdfConfiguration define the config where to copy the info
  52341. */
  52342. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52343. /**
  52344. * Serializes this BRDF configuration.
  52345. * @returns - An object with the serialized config.
  52346. */
  52347. serialize(): any;
  52348. /**
  52349. * Parses a anisotropy Configuration from a serialized object.
  52350. * @param source - Serialized object.
  52351. * @param scene Defines the scene we are parsing for
  52352. * @param rootUrl Defines the rootUrl to load from
  52353. */
  52354. parse(source: any, scene: Scene, rootUrl: string): void;
  52355. }
  52356. }
  52357. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52358. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52359. import { Color3 } from "babylonjs/Maths/math.color";
  52360. import { Scene } from "babylonjs/scene";
  52361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52362. import { Nullable } from "babylonjs/types";
  52363. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52364. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52365. /**
  52366. * @hidden
  52367. */
  52368. export interface IMaterialSheenDefines {
  52369. SHEEN: boolean;
  52370. SHEEN_TEXTURE: boolean;
  52371. SHEEN_TEXTUREDIRECTUV: number;
  52372. SHEEN_LINKWITHALBEDO: boolean;
  52373. /** @hidden */
  52374. _areTexturesDirty: boolean;
  52375. }
  52376. /**
  52377. * Define the code related to the Sheen parameters of the pbr material.
  52378. */
  52379. export class PBRSheenConfiguration {
  52380. private _isEnabled;
  52381. /**
  52382. * Defines if the material uses sheen.
  52383. */
  52384. isEnabled: boolean;
  52385. private _linkSheenWithAlbedo;
  52386. /**
  52387. * Defines if the sheen is linked to the sheen color.
  52388. */
  52389. linkSheenWithAlbedo: boolean;
  52390. /**
  52391. * Defines the sheen intensity.
  52392. */
  52393. intensity: number;
  52394. /**
  52395. * Defines the sheen color.
  52396. */
  52397. color: Color3;
  52398. private _texture;
  52399. /**
  52400. * Stores the sheen tint values in a texture.
  52401. * rgb is tint
  52402. * a is a intensity
  52403. */
  52404. texture: Nullable<BaseTexture>;
  52405. /** @hidden */
  52406. private _internalMarkAllSubMeshesAsTexturesDirty;
  52407. /** @hidden */
  52408. _markAllSubMeshesAsTexturesDirty(): void;
  52409. /**
  52410. * Instantiate a new istance of clear coat configuration.
  52411. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52412. */
  52413. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52414. /**
  52415. * Specifies that the submesh is ready to be used.
  52416. * @param defines the list of "defines" to update.
  52417. * @param scene defines the scene the material belongs to.
  52418. * @returns - boolean indicating that the submesh is ready or not.
  52419. */
  52420. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52421. /**
  52422. * Checks to see if a texture is used in the material.
  52423. * @param defines the list of "defines" to update.
  52424. * @param scene defines the scene the material belongs to.
  52425. */
  52426. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52427. /**
  52428. * Binds the material data.
  52429. * @param uniformBuffer defines the Uniform buffer to fill in.
  52430. * @param scene defines the scene the material belongs to.
  52431. * @param isFrozen defines wether the material is frozen or not.
  52432. */
  52433. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52434. /**
  52435. * Checks to see if a texture is used in the material.
  52436. * @param texture - Base texture to use.
  52437. * @returns - Boolean specifying if a texture is used in the material.
  52438. */
  52439. hasTexture(texture: BaseTexture): boolean;
  52440. /**
  52441. * Returns an array of the actively used textures.
  52442. * @param activeTextures Array of BaseTextures
  52443. */
  52444. getActiveTextures(activeTextures: BaseTexture[]): void;
  52445. /**
  52446. * Returns the animatable textures.
  52447. * @param animatables Array of animatable textures.
  52448. */
  52449. getAnimatables(animatables: IAnimatable[]): void;
  52450. /**
  52451. * Disposes the resources of the material.
  52452. * @param forceDisposeTextures - Forces the disposal of all textures.
  52453. */
  52454. dispose(forceDisposeTextures?: boolean): void;
  52455. /**
  52456. * Get the current class name of the texture useful for serialization or dynamic coding.
  52457. * @returns "PBRSheenConfiguration"
  52458. */
  52459. getClassName(): string;
  52460. /**
  52461. * Add fallbacks to the effect fallbacks list.
  52462. * @param defines defines the Base texture to use.
  52463. * @param fallbacks defines the current fallback list.
  52464. * @param currentRank defines the current fallback rank.
  52465. * @returns the new fallback rank.
  52466. */
  52467. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52468. /**
  52469. * Add the required uniforms to the current list.
  52470. * @param uniforms defines the current uniform list.
  52471. */
  52472. static AddUniforms(uniforms: string[]): void;
  52473. /**
  52474. * Add the required uniforms to the current buffer.
  52475. * @param uniformBuffer defines the current uniform buffer.
  52476. */
  52477. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52478. /**
  52479. * Add the required samplers to the current list.
  52480. * @param samplers defines the current sampler list.
  52481. */
  52482. static AddSamplers(samplers: string[]): void;
  52483. /**
  52484. * Makes a duplicate of the current configuration into another one.
  52485. * @param sheenConfiguration define the config where to copy the info
  52486. */
  52487. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52488. /**
  52489. * Serializes this BRDF configuration.
  52490. * @returns - An object with the serialized config.
  52491. */
  52492. serialize(): any;
  52493. /**
  52494. * Parses a anisotropy Configuration from a serialized object.
  52495. * @param source - Serialized object.
  52496. * @param scene Defines the scene we are parsing for
  52497. * @param rootUrl Defines the rootUrl to load from
  52498. */
  52499. parse(source: any, scene: Scene, rootUrl: string): void;
  52500. }
  52501. }
  52502. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52503. import { Nullable } from "babylonjs/types";
  52504. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52505. import { Color3 } from "babylonjs/Maths/math.color";
  52506. import { SmartArray } from "babylonjs/Misc/smartArray";
  52507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52508. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52509. import { Effect } from "babylonjs/Materials/effect";
  52510. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52511. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52512. import { Engine } from "babylonjs/Engines/engine";
  52513. import { Scene } from "babylonjs/scene";
  52514. /**
  52515. * @hidden
  52516. */
  52517. export interface IMaterialSubSurfaceDefines {
  52518. SUBSURFACE: boolean;
  52519. SS_REFRACTION: boolean;
  52520. SS_TRANSLUCENCY: boolean;
  52521. SS_SCATERRING: boolean;
  52522. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52523. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52524. SS_REFRACTIONMAP_3D: boolean;
  52525. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52526. SS_LODINREFRACTIONALPHA: boolean;
  52527. SS_GAMMAREFRACTION: boolean;
  52528. SS_RGBDREFRACTION: boolean;
  52529. SS_LINEARSPECULARREFRACTION: boolean;
  52530. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52531. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52532. /** @hidden */
  52533. _areTexturesDirty: boolean;
  52534. }
  52535. /**
  52536. * Define the code related to the sub surface parameters of the pbr material.
  52537. */
  52538. export class PBRSubSurfaceConfiguration {
  52539. private _isRefractionEnabled;
  52540. /**
  52541. * Defines if the refraction is enabled in the material.
  52542. */
  52543. isRefractionEnabled: boolean;
  52544. private _isTranslucencyEnabled;
  52545. /**
  52546. * Defines if the translucency is enabled in the material.
  52547. */
  52548. isTranslucencyEnabled: boolean;
  52549. private _isScatteringEnabled;
  52550. /**
  52551. * Defines the refraction intensity of the material.
  52552. * The refraction when enabled replaces the Diffuse part of the material.
  52553. * The intensity helps transitionning between diffuse and refraction.
  52554. */
  52555. refractionIntensity: number;
  52556. /**
  52557. * Defines the translucency intensity of the material.
  52558. * When translucency has been enabled, this defines how much of the "translucency"
  52559. * is addded to the diffuse part of the material.
  52560. */
  52561. translucencyIntensity: number;
  52562. /**
  52563. * Defines the scattering intensity of the material.
  52564. * When scattering has been enabled, this defines how much of the "scattered light"
  52565. * is addded to the diffuse part of the material.
  52566. */
  52567. scatteringIntensity: number;
  52568. private _thicknessTexture;
  52569. /**
  52570. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52571. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52572. * 0 would mean minimumThickness
  52573. * 1 would mean maximumThickness
  52574. * The other channels might be use as a mask to vary the different effects intensity.
  52575. */
  52576. thicknessTexture: Nullable<BaseTexture>;
  52577. private _refractionTexture;
  52578. /**
  52579. * Defines the texture to use for refraction.
  52580. */
  52581. refractionTexture: Nullable<BaseTexture>;
  52582. private _indexOfRefraction;
  52583. /**
  52584. * Defines the index of refraction used in the material.
  52585. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52586. */
  52587. indexOfRefraction: number;
  52588. private _invertRefractionY;
  52589. /**
  52590. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52591. */
  52592. invertRefractionY: boolean;
  52593. private _linkRefractionWithTransparency;
  52594. /**
  52595. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52596. * Materials half opaque for instance using refraction could benefit from this control.
  52597. */
  52598. linkRefractionWithTransparency: boolean;
  52599. /**
  52600. * Defines the minimum thickness stored in the thickness map.
  52601. * If no thickness map is defined, this value will be used to simulate thickness.
  52602. */
  52603. minimumThickness: number;
  52604. /**
  52605. * Defines the maximum thickness stored in the thickness map.
  52606. */
  52607. maximumThickness: number;
  52608. /**
  52609. * Defines the volume tint of the material.
  52610. * This is used for both translucency and scattering.
  52611. */
  52612. tintColor: Color3;
  52613. /**
  52614. * Defines the distance at which the tint color should be found in the media.
  52615. * This is used for refraction only.
  52616. */
  52617. tintColorAtDistance: number;
  52618. /**
  52619. * Defines how far each channel transmit through the media.
  52620. * It is defined as a color to simplify it selection.
  52621. */
  52622. diffusionDistance: Color3;
  52623. private _useMaskFromThicknessTexture;
  52624. /**
  52625. * Stores the intensity of the different subsurface effects in the thickness texture.
  52626. * * the green channel is the translucency intensity.
  52627. * * the blue channel is the scattering intensity.
  52628. * * the alpha channel is the refraction intensity.
  52629. */
  52630. useMaskFromThicknessTexture: boolean;
  52631. /** @hidden */
  52632. private _internalMarkAllSubMeshesAsTexturesDirty;
  52633. /** @hidden */
  52634. _markAllSubMeshesAsTexturesDirty(): void;
  52635. /**
  52636. * Instantiate a new istance of sub surface configuration.
  52637. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52638. */
  52639. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52640. /**
  52641. * Gets wehter the submesh is ready to be used or not.
  52642. * @param defines the list of "defines" to update.
  52643. * @param scene defines the scene the material belongs to.
  52644. * @returns - boolean indicating that the submesh is ready or not.
  52645. */
  52646. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52647. /**
  52648. * Checks to see if a texture is used in the material.
  52649. * @param defines the list of "defines" to update.
  52650. * @param scene defines the scene to the material belongs to.
  52651. */
  52652. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52653. /**
  52654. * Binds the material data.
  52655. * @param uniformBuffer defines the Uniform buffer to fill in.
  52656. * @param scene defines the scene the material belongs to.
  52657. * @param engine defines the engine the material belongs to.
  52658. * @param isFrozen defines wether the material is frozen or not.
  52659. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52660. */
  52661. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52662. /**
  52663. * Unbinds the material from the mesh.
  52664. * @param activeEffect defines the effect that should be unbound from.
  52665. * @returns true if unbound, otherwise false
  52666. */
  52667. unbind(activeEffect: Effect): boolean;
  52668. /**
  52669. * Returns the texture used for refraction or null if none is used.
  52670. * @param scene defines the scene the material belongs to.
  52671. * @returns - Refraction texture if present. If no refraction texture and refraction
  52672. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52673. */
  52674. private _getRefractionTexture;
  52675. /**
  52676. * Returns true if alpha blending should be disabled.
  52677. */
  52678. get disableAlphaBlending(): boolean;
  52679. /**
  52680. * Fills the list of render target textures.
  52681. * @param renderTargets the list of render targets to update
  52682. */
  52683. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52684. /**
  52685. * Checks to see if a texture is used in the material.
  52686. * @param texture - Base texture to use.
  52687. * @returns - Boolean specifying if a texture is used in the material.
  52688. */
  52689. hasTexture(texture: BaseTexture): boolean;
  52690. /**
  52691. * Gets a boolean indicating that current material needs to register RTT
  52692. * @returns true if this uses a render target otherwise false.
  52693. */
  52694. hasRenderTargetTextures(): boolean;
  52695. /**
  52696. * Returns an array of the actively used textures.
  52697. * @param activeTextures Array of BaseTextures
  52698. */
  52699. getActiveTextures(activeTextures: BaseTexture[]): void;
  52700. /**
  52701. * Returns the animatable textures.
  52702. * @param animatables Array of animatable textures.
  52703. */
  52704. getAnimatables(animatables: IAnimatable[]): void;
  52705. /**
  52706. * Disposes the resources of the material.
  52707. * @param forceDisposeTextures - Forces the disposal of all textures.
  52708. */
  52709. dispose(forceDisposeTextures?: boolean): void;
  52710. /**
  52711. * Get the current class name of the texture useful for serialization or dynamic coding.
  52712. * @returns "PBRSubSurfaceConfiguration"
  52713. */
  52714. getClassName(): string;
  52715. /**
  52716. * Add fallbacks to the effect fallbacks list.
  52717. * @param defines defines the Base texture to use.
  52718. * @param fallbacks defines the current fallback list.
  52719. * @param currentRank defines the current fallback rank.
  52720. * @returns the new fallback rank.
  52721. */
  52722. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52723. /**
  52724. * Add the required uniforms to the current list.
  52725. * @param uniforms defines the current uniform list.
  52726. */
  52727. static AddUniforms(uniforms: string[]): void;
  52728. /**
  52729. * Add the required samplers to the current list.
  52730. * @param samplers defines the current sampler list.
  52731. */
  52732. static AddSamplers(samplers: string[]): void;
  52733. /**
  52734. * Add the required uniforms to the current buffer.
  52735. * @param uniformBuffer defines the current uniform buffer.
  52736. */
  52737. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52738. /**
  52739. * Makes a duplicate of the current configuration into another one.
  52740. * @param configuration define the config where to copy the info
  52741. */
  52742. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52743. /**
  52744. * Serializes this Sub Surface configuration.
  52745. * @returns - An object with the serialized config.
  52746. */
  52747. serialize(): any;
  52748. /**
  52749. * Parses a anisotropy Configuration from a serialized object.
  52750. * @param source - Serialized object.
  52751. * @param scene Defines the scene we are parsing for
  52752. * @param rootUrl Defines the rootUrl to load from
  52753. */
  52754. parse(source: any, scene: Scene, rootUrl: string): void;
  52755. }
  52756. }
  52757. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52758. /** @hidden */
  52759. export var pbrFragmentDeclaration: {
  52760. name: string;
  52761. shader: string;
  52762. };
  52763. }
  52764. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52765. /** @hidden */
  52766. export var pbrUboDeclaration: {
  52767. name: string;
  52768. shader: string;
  52769. };
  52770. }
  52771. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52772. /** @hidden */
  52773. export var pbrFragmentExtraDeclaration: {
  52774. name: string;
  52775. shader: string;
  52776. };
  52777. }
  52778. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52779. /** @hidden */
  52780. export var pbrFragmentSamplersDeclaration: {
  52781. name: string;
  52782. shader: string;
  52783. };
  52784. }
  52785. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52786. /** @hidden */
  52787. export var pbrHelperFunctions: {
  52788. name: string;
  52789. shader: string;
  52790. };
  52791. }
  52792. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52793. /** @hidden */
  52794. export var harmonicsFunctions: {
  52795. name: string;
  52796. shader: string;
  52797. };
  52798. }
  52799. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52800. /** @hidden */
  52801. export var pbrDirectLightingSetupFunctions: {
  52802. name: string;
  52803. shader: string;
  52804. };
  52805. }
  52806. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52807. /** @hidden */
  52808. export var pbrDirectLightingFalloffFunctions: {
  52809. name: string;
  52810. shader: string;
  52811. };
  52812. }
  52813. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52814. /** @hidden */
  52815. export var pbrBRDFFunctions: {
  52816. name: string;
  52817. shader: string;
  52818. };
  52819. }
  52820. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52821. /** @hidden */
  52822. export var pbrDirectLightingFunctions: {
  52823. name: string;
  52824. shader: string;
  52825. };
  52826. }
  52827. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52828. /** @hidden */
  52829. export var pbrIBLFunctions: {
  52830. name: string;
  52831. shader: string;
  52832. };
  52833. }
  52834. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52835. /** @hidden */
  52836. export var pbrDebug: {
  52837. name: string;
  52838. shader: string;
  52839. };
  52840. }
  52841. declare module "babylonjs/Shaders/pbr.fragment" {
  52842. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52843. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52844. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52845. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52846. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52847. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52848. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52849. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52850. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52851. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52852. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52853. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52854. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52855. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52856. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52857. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52858. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52859. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52860. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52861. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52862. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52863. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52864. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52865. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52866. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52867. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52868. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52869. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52870. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52871. /** @hidden */
  52872. export var pbrPixelShader: {
  52873. name: string;
  52874. shader: string;
  52875. };
  52876. }
  52877. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52878. /** @hidden */
  52879. export var pbrVertexDeclaration: {
  52880. name: string;
  52881. shader: string;
  52882. };
  52883. }
  52884. declare module "babylonjs/Shaders/pbr.vertex" {
  52885. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52886. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52887. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52888. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52889. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52890. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52891. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52892. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52893. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52894. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52895. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52896. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52897. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52900. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52901. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52902. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52903. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52904. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52905. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52906. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52907. /** @hidden */
  52908. export var pbrVertexShader: {
  52909. name: string;
  52910. shader: string;
  52911. };
  52912. }
  52913. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52914. import { Nullable } from "babylonjs/types";
  52915. import { Scene } from "babylonjs/scene";
  52916. import { Matrix } from "babylonjs/Maths/math.vector";
  52917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52919. import { Mesh } from "babylonjs/Meshes/mesh";
  52920. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52921. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52922. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52923. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52924. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52925. import { Color3 } from "babylonjs/Maths/math.color";
  52926. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52927. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52928. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52929. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52930. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52932. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52933. import "babylonjs/Shaders/pbr.fragment";
  52934. import "babylonjs/Shaders/pbr.vertex";
  52935. /**
  52936. * Manages the defines for the PBR Material.
  52937. * @hidden
  52938. */
  52939. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52940. PBR: boolean;
  52941. MAINUV1: boolean;
  52942. MAINUV2: boolean;
  52943. UV1: boolean;
  52944. UV2: boolean;
  52945. ALBEDO: boolean;
  52946. ALBEDODIRECTUV: number;
  52947. VERTEXCOLOR: boolean;
  52948. AMBIENT: boolean;
  52949. AMBIENTDIRECTUV: number;
  52950. AMBIENTINGRAYSCALE: boolean;
  52951. OPACITY: boolean;
  52952. VERTEXALPHA: boolean;
  52953. OPACITYDIRECTUV: number;
  52954. OPACITYRGB: boolean;
  52955. ALPHATEST: boolean;
  52956. DEPTHPREPASS: boolean;
  52957. ALPHABLEND: boolean;
  52958. ALPHAFROMALBEDO: boolean;
  52959. ALPHATESTVALUE: string;
  52960. SPECULAROVERALPHA: boolean;
  52961. RADIANCEOVERALPHA: boolean;
  52962. ALPHAFRESNEL: boolean;
  52963. LINEARALPHAFRESNEL: boolean;
  52964. PREMULTIPLYALPHA: boolean;
  52965. EMISSIVE: boolean;
  52966. EMISSIVEDIRECTUV: number;
  52967. REFLECTIVITY: boolean;
  52968. REFLECTIVITYDIRECTUV: number;
  52969. SPECULARTERM: boolean;
  52970. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52971. MICROSURFACEAUTOMATIC: boolean;
  52972. LODBASEDMICROSFURACE: boolean;
  52973. MICROSURFACEMAP: boolean;
  52974. MICROSURFACEMAPDIRECTUV: number;
  52975. METALLICWORKFLOW: boolean;
  52976. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52977. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52978. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52979. AOSTOREINMETALMAPRED: boolean;
  52980. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52981. ENVIRONMENTBRDF: boolean;
  52982. ENVIRONMENTBRDF_RGBD: boolean;
  52983. NORMAL: boolean;
  52984. TANGENT: boolean;
  52985. BUMP: boolean;
  52986. BUMPDIRECTUV: number;
  52987. OBJECTSPACE_NORMALMAP: boolean;
  52988. PARALLAX: boolean;
  52989. PARALLAXOCCLUSION: boolean;
  52990. NORMALXYSCALE: boolean;
  52991. LIGHTMAP: boolean;
  52992. LIGHTMAPDIRECTUV: number;
  52993. USELIGHTMAPASSHADOWMAP: boolean;
  52994. GAMMALIGHTMAP: boolean;
  52995. RGBDLIGHTMAP: boolean;
  52996. REFLECTION: boolean;
  52997. REFLECTIONMAP_3D: boolean;
  52998. REFLECTIONMAP_SPHERICAL: boolean;
  52999. REFLECTIONMAP_PLANAR: boolean;
  53000. REFLECTIONMAP_CUBIC: boolean;
  53001. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53002. REFLECTIONMAP_PROJECTION: boolean;
  53003. REFLECTIONMAP_SKYBOX: boolean;
  53004. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  53005. REFLECTIONMAP_EXPLICIT: boolean;
  53006. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53007. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53008. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53009. INVERTCUBICMAP: boolean;
  53010. USESPHERICALFROMREFLECTIONMAP: boolean;
  53011. USEIRRADIANCEMAP: boolean;
  53012. SPHERICAL_HARMONICS: boolean;
  53013. USESPHERICALINVERTEX: boolean;
  53014. REFLECTIONMAP_OPPOSITEZ: boolean;
  53015. LODINREFLECTIONALPHA: boolean;
  53016. GAMMAREFLECTION: boolean;
  53017. RGBDREFLECTION: boolean;
  53018. LINEARSPECULARREFLECTION: boolean;
  53019. RADIANCEOCCLUSION: boolean;
  53020. HORIZONOCCLUSION: boolean;
  53021. INSTANCES: boolean;
  53022. NUM_BONE_INFLUENCERS: number;
  53023. BonesPerMesh: number;
  53024. BONETEXTURE: boolean;
  53025. NONUNIFORMSCALING: boolean;
  53026. MORPHTARGETS: boolean;
  53027. MORPHTARGETS_NORMAL: boolean;
  53028. MORPHTARGETS_TANGENT: boolean;
  53029. MORPHTARGETS_UV: boolean;
  53030. NUM_MORPH_INFLUENCERS: number;
  53031. IMAGEPROCESSING: boolean;
  53032. VIGNETTE: boolean;
  53033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53034. VIGNETTEBLENDMODEOPAQUE: boolean;
  53035. TONEMAPPING: boolean;
  53036. TONEMAPPING_ACES: boolean;
  53037. CONTRAST: boolean;
  53038. COLORCURVES: boolean;
  53039. COLORGRADING: boolean;
  53040. COLORGRADING3D: boolean;
  53041. SAMPLER3DGREENDEPTH: boolean;
  53042. SAMPLER3DBGRMAP: boolean;
  53043. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53044. EXPOSURE: boolean;
  53045. MULTIVIEW: boolean;
  53046. USEPHYSICALLIGHTFALLOFF: boolean;
  53047. USEGLTFLIGHTFALLOFF: boolean;
  53048. TWOSIDEDLIGHTING: boolean;
  53049. SHADOWFLOAT: boolean;
  53050. CLIPPLANE: boolean;
  53051. CLIPPLANE2: boolean;
  53052. CLIPPLANE3: boolean;
  53053. CLIPPLANE4: boolean;
  53054. CLIPPLANE5: boolean;
  53055. CLIPPLANE6: boolean;
  53056. POINTSIZE: boolean;
  53057. FOG: boolean;
  53058. LOGARITHMICDEPTH: boolean;
  53059. FORCENORMALFORWARD: boolean;
  53060. SPECULARAA: boolean;
  53061. CLEARCOAT: boolean;
  53062. CLEARCOAT_DEFAULTIOR: boolean;
  53063. CLEARCOAT_TEXTURE: boolean;
  53064. CLEARCOAT_TEXTUREDIRECTUV: number;
  53065. CLEARCOAT_BUMP: boolean;
  53066. CLEARCOAT_BUMPDIRECTUV: number;
  53067. CLEARCOAT_TINT: boolean;
  53068. CLEARCOAT_TINT_TEXTURE: boolean;
  53069. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53070. ANISOTROPIC: boolean;
  53071. ANISOTROPIC_TEXTURE: boolean;
  53072. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53073. BRDF_V_HEIGHT_CORRELATED: boolean;
  53074. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53075. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53076. SHEEN: boolean;
  53077. SHEEN_TEXTURE: boolean;
  53078. SHEEN_TEXTUREDIRECTUV: number;
  53079. SHEEN_LINKWITHALBEDO: boolean;
  53080. SUBSURFACE: boolean;
  53081. SS_REFRACTION: boolean;
  53082. SS_TRANSLUCENCY: boolean;
  53083. SS_SCATERRING: boolean;
  53084. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53085. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53086. SS_REFRACTIONMAP_3D: boolean;
  53087. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53088. SS_LODINREFRACTIONALPHA: boolean;
  53089. SS_GAMMAREFRACTION: boolean;
  53090. SS_RGBDREFRACTION: boolean;
  53091. SS_LINEARSPECULARREFRACTION: boolean;
  53092. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53093. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53094. UNLIT: boolean;
  53095. DEBUGMODE: number;
  53096. /**
  53097. * Initializes the PBR Material defines.
  53098. */
  53099. constructor();
  53100. /**
  53101. * Resets the PBR Material defines.
  53102. */
  53103. reset(): void;
  53104. }
  53105. /**
  53106. * The Physically based material base class of BJS.
  53107. *
  53108. * This offers the main features of a standard PBR material.
  53109. * For more information, please refer to the documentation :
  53110. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53111. */
  53112. export abstract class PBRBaseMaterial extends PushMaterial {
  53113. /**
  53114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53115. */
  53116. static readonly PBRMATERIAL_OPAQUE: number;
  53117. /**
  53118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53119. */
  53120. static readonly PBRMATERIAL_ALPHATEST: number;
  53121. /**
  53122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53123. */
  53124. static readonly PBRMATERIAL_ALPHABLEND: number;
  53125. /**
  53126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53127. * They are also discarded below the alpha cutoff threshold to improve performances.
  53128. */
  53129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53130. /**
  53131. * Defines the default value of how much AO map is occluding the analytical lights
  53132. * (point spot...).
  53133. */
  53134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53135. /**
  53136. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53137. */
  53138. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53139. /**
  53140. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53141. * to enhance interoperability with other engines.
  53142. */
  53143. static readonly LIGHTFALLOFF_GLTF: number;
  53144. /**
  53145. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53146. * to enhance interoperability with other materials.
  53147. */
  53148. static readonly LIGHTFALLOFF_STANDARD: number;
  53149. /**
  53150. * Intensity of the direct lights e.g. the four lights available in your scene.
  53151. * This impacts both the direct diffuse and specular highlights.
  53152. */
  53153. protected _directIntensity: number;
  53154. /**
  53155. * Intensity of the emissive part of the material.
  53156. * This helps controlling the emissive effect without modifying the emissive color.
  53157. */
  53158. protected _emissiveIntensity: number;
  53159. /**
  53160. * Intensity of the environment e.g. how much the environment will light the object
  53161. * either through harmonics for rough material or through the refelction for shiny ones.
  53162. */
  53163. protected _environmentIntensity: number;
  53164. /**
  53165. * This is a special control allowing the reduction of the specular highlights coming from the
  53166. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53167. */
  53168. protected _specularIntensity: number;
  53169. /**
  53170. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53171. */
  53172. private _lightingInfos;
  53173. /**
  53174. * Debug Control allowing disabling the bump map on this material.
  53175. */
  53176. protected _disableBumpMap: boolean;
  53177. /**
  53178. * AKA Diffuse Texture in standard nomenclature.
  53179. */
  53180. protected _albedoTexture: Nullable<BaseTexture>;
  53181. /**
  53182. * AKA Occlusion Texture in other nomenclature.
  53183. */
  53184. protected _ambientTexture: Nullable<BaseTexture>;
  53185. /**
  53186. * AKA Occlusion Texture Intensity in other nomenclature.
  53187. */
  53188. protected _ambientTextureStrength: number;
  53189. /**
  53190. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53191. * 1 means it completely occludes it
  53192. * 0 mean it has no impact
  53193. */
  53194. protected _ambientTextureImpactOnAnalyticalLights: number;
  53195. /**
  53196. * Stores the alpha values in a texture.
  53197. */
  53198. protected _opacityTexture: Nullable<BaseTexture>;
  53199. /**
  53200. * Stores the reflection values in a texture.
  53201. */
  53202. protected _reflectionTexture: Nullable<BaseTexture>;
  53203. /**
  53204. * Stores the emissive values in a texture.
  53205. */
  53206. protected _emissiveTexture: Nullable<BaseTexture>;
  53207. /**
  53208. * AKA Specular texture in other nomenclature.
  53209. */
  53210. protected _reflectivityTexture: Nullable<BaseTexture>;
  53211. /**
  53212. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53213. */
  53214. protected _metallicTexture: Nullable<BaseTexture>;
  53215. /**
  53216. * Specifies the metallic scalar of the metallic/roughness workflow.
  53217. * Can also be used to scale the metalness values of the metallic texture.
  53218. */
  53219. protected _metallic: Nullable<number>;
  53220. /**
  53221. * Specifies the roughness scalar of the metallic/roughness workflow.
  53222. * Can also be used to scale the roughness values of the metallic texture.
  53223. */
  53224. protected _roughness: Nullable<number>;
  53225. /**
  53226. * Specifies the an F0 factor to help configuring the material F0.
  53227. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53228. * to 0.5 the previously hard coded value stays the same.
  53229. * Can also be used to scale the F0 values of the metallic texture.
  53230. */
  53231. protected _metallicF0Factor: number;
  53232. /**
  53233. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53234. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53235. * your expectation as it multiplies with the texture data.
  53236. */
  53237. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53238. /**
  53239. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53240. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53241. */
  53242. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53243. /**
  53244. * Stores surface normal data used to displace a mesh in a texture.
  53245. */
  53246. protected _bumpTexture: Nullable<BaseTexture>;
  53247. /**
  53248. * Stores the pre-calculated light information of a mesh in a texture.
  53249. */
  53250. protected _lightmapTexture: Nullable<BaseTexture>;
  53251. /**
  53252. * The color of a material in ambient lighting.
  53253. */
  53254. protected _ambientColor: Color3;
  53255. /**
  53256. * AKA Diffuse Color in other nomenclature.
  53257. */
  53258. protected _albedoColor: Color3;
  53259. /**
  53260. * AKA Specular Color in other nomenclature.
  53261. */
  53262. protected _reflectivityColor: Color3;
  53263. /**
  53264. * The color applied when light is reflected from a material.
  53265. */
  53266. protected _reflectionColor: Color3;
  53267. /**
  53268. * The color applied when light is emitted from a material.
  53269. */
  53270. protected _emissiveColor: Color3;
  53271. /**
  53272. * AKA Glossiness in other nomenclature.
  53273. */
  53274. protected _microSurface: number;
  53275. /**
  53276. * Specifies that the material will use the light map as a show map.
  53277. */
  53278. protected _useLightmapAsShadowmap: boolean;
  53279. /**
  53280. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53281. * makes the reflect vector face the model (under horizon).
  53282. */
  53283. protected _useHorizonOcclusion: boolean;
  53284. /**
  53285. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53286. * too much the area relying on ambient texture to define their ambient occlusion.
  53287. */
  53288. protected _useRadianceOcclusion: boolean;
  53289. /**
  53290. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53291. */
  53292. protected _useAlphaFromAlbedoTexture: boolean;
  53293. /**
  53294. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53295. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53296. */
  53297. protected _useSpecularOverAlpha: boolean;
  53298. /**
  53299. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53300. */
  53301. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53302. /**
  53303. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53304. */
  53305. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53306. /**
  53307. * Specifies if the metallic texture contains the roughness information in its green channel.
  53308. */
  53309. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53310. /**
  53311. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53312. */
  53313. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53314. /**
  53315. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53316. */
  53317. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53318. /**
  53319. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53320. */
  53321. protected _useAmbientInGrayScale: boolean;
  53322. /**
  53323. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53324. * The material will try to infer what glossiness each pixel should be.
  53325. */
  53326. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53327. /**
  53328. * Defines the falloff type used in this material.
  53329. * It by default is Physical.
  53330. */
  53331. protected _lightFalloff: number;
  53332. /**
  53333. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53334. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53335. */
  53336. protected _useRadianceOverAlpha: boolean;
  53337. /**
  53338. * Allows using an object space normal map (instead of tangent space).
  53339. */
  53340. protected _useObjectSpaceNormalMap: boolean;
  53341. /**
  53342. * Allows using the bump map in parallax mode.
  53343. */
  53344. protected _useParallax: boolean;
  53345. /**
  53346. * Allows using the bump map in parallax occlusion mode.
  53347. */
  53348. protected _useParallaxOcclusion: boolean;
  53349. /**
  53350. * Controls the scale bias of the parallax mode.
  53351. */
  53352. protected _parallaxScaleBias: number;
  53353. /**
  53354. * If sets to true, disables all the lights affecting the material.
  53355. */
  53356. protected _disableLighting: boolean;
  53357. /**
  53358. * Number of Simultaneous lights allowed on the material.
  53359. */
  53360. protected _maxSimultaneousLights: number;
  53361. /**
  53362. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53363. */
  53364. protected _invertNormalMapX: boolean;
  53365. /**
  53366. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53367. */
  53368. protected _invertNormalMapY: boolean;
  53369. /**
  53370. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53371. */
  53372. protected _twoSidedLighting: boolean;
  53373. /**
  53374. * Defines the alpha limits in alpha test mode.
  53375. */
  53376. protected _alphaCutOff: number;
  53377. /**
  53378. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53379. */
  53380. protected _forceAlphaTest: boolean;
  53381. /**
  53382. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53383. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53384. */
  53385. protected _useAlphaFresnel: boolean;
  53386. /**
  53387. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53388. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53389. */
  53390. protected _useLinearAlphaFresnel: boolean;
  53391. /**
  53392. * The transparency mode of the material.
  53393. */
  53394. protected _transparencyMode: Nullable<number>;
  53395. /**
  53396. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53397. * from cos thetav and roughness:
  53398. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53399. */
  53400. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53401. /**
  53402. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53403. */
  53404. protected _forceIrradianceInFragment: boolean;
  53405. /**
  53406. * Force normal to face away from face.
  53407. */
  53408. protected _forceNormalForward: boolean;
  53409. /**
  53410. * Enables specular anti aliasing in the PBR shader.
  53411. * It will both interacts on the Geometry for analytical and IBL lighting.
  53412. * It also prefilter the roughness map based on the bump values.
  53413. */
  53414. protected _enableSpecularAntiAliasing: boolean;
  53415. /**
  53416. * Default configuration related to image processing available in the PBR Material.
  53417. */
  53418. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53419. /**
  53420. * Keep track of the image processing observer to allow dispose and replace.
  53421. */
  53422. private _imageProcessingObserver;
  53423. /**
  53424. * Attaches a new image processing configuration to the PBR Material.
  53425. * @param configuration
  53426. */
  53427. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53428. /**
  53429. * Stores the available render targets.
  53430. */
  53431. private _renderTargets;
  53432. /**
  53433. * Sets the global ambient color for the material used in lighting calculations.
  53434. */
  53435. private _globalAmbientColor;
  53436. /**
  53437. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53438. */
  53439. private _useLogarithmicDepth;
  53440. /**
  53441. * If set to true, no lighting calculations will be applied.
  53442. */
  53443. private _unlit;
  53444. private _debugMode;
  53445. /**
  53446. * @hidden
  53447. * This is reserved for the inspector.
  53448. * Defines the material debug mode.
  53449. * It helps seeing only some components of the material while troubleshooting.
  53450. */
  53451. debugMode: number;
  53452. /**
  53453. * @hidden
  53454. * This is reserved for the inspector.
  53455. * Specify from where on screen the debug mode should start.
  53456. * The value goes from -1 (full screen) to 1 (not visible)
  53457. * It helps with side by side comparison against the final render
  53458. * This defaults to -1
  53459. */
  53460. private debugLimit;
  53461. /**
  53462. * @hidden
  53463. * This is reserved for the inspector.
  53464. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53465. * You can use the factor to better multiply the final value.
  53466. */
  53467. private debugFactor;
  53468. /**
  53469. * Defines the clear coat layer parameters for the material.
  53470. */
  53471. readonly clearCoat: PBRClearCoatConfiguration;
  53472. /**
  53473. * Defines the anisotropic parameters for the material.
  53474. */
  53475. readonly anisotropy: PBRAnisotropicConfiguration;
  53476. /**
  53477. * Defines the BRDF parameters for the material.
  53478. */
  53479. readonly brdf: PBRBRDFConfiguration;
  53480. /**
  53481. * Defines the Sheen parameters for the material.
  53482. */
  53483. readonly sheen: PBRSheenConfiguration;
  53484. /**
  53485. * Defines the SubSurface parameters for the material.
  53486. */
  53487. readonly subSurface: PBRSubSurfaceConfiguration;
  53488. /**
  53489. * Custom callback helping to override the default shader used in the material.
  53490. */
  53491. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53492. protected _rebuildInParallel: boolean;
  53493. /**
  53494. * Instantiates a new PBRMaterial instance.
  53495. *
  53496. * @param name The material name
  53497. * @param scene The scene the material will be use in.
  53498. */
  53499. constructor(name: string, scene: Scene);
  53500. /**
  53501. * Gets a boolean indicating that current material needs to register RTT
  53502. */
  53503. get hasRenderTargetTextures(): boolean;
  53504. /**
  53505. * Gets the name of the material class.
  53506. */
  53507. getClassName(): string;
  53508. /**
  53509. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53510. */
  53511. get useLogarithmicDepth(): boolean;
  53512. /**
  53513. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53514. */
  53515. set useLogarithmicDepth(value: boolean);
  53516. /**
  53517. * Gets the current transparency mode.
  53518. */
  53519. get transparencyMode(): Nullable<number>;
  53520. /**
  53521. * Sets the transparency mode of the material.
  53522. *
  53523. * | Value | Type | Description |
  53524. * | ----- | ----------------------------------- | ----------- |
  53525. * | 0 | OPAQUE | |
  53526. * | 1 | ALPHATEST | |
  53527. * | 2 | ALPHABLEND | |
  53528. * | 3 | ALPHATESTANDBLEND | |
  53529. *
  53530. */
  53531. set transparencyMode(value: Nullable<number>);
  53532. /**
  53533. * Returns true if alpha blending should be disabled.
  53534. */
  53535. private get _disableAlphaBlending();
  53536. /**
  53537. * Specifies whether or not this material should be rendered in alpha blend mode.
  53538. */
  53539. needAlphaBlending(): boolean;
  53540. /**
  53541. * Specifies if the mesh will require alpha blending.
  53542. * @param mesh - BJS mesh.
  53543. */
  53544. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53545. /**
  53546. * Specifies whether or not this material should be rendered in alpha test mode.
  53547. */
  53548. needAlphaTesting(): boolean;
  53549. /**
  53550. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53551. */
  53552. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53553. /**
  53554. * Gets the texture used for the alpha test.
  53555. */
  53556. getAlphaTestTexture(): Nullable<BaseTexture>;
  53557. /**
  53558. * Specifies that the submesh is ready to be used.
  53559. * @param mesh - BJS mesh.
  53560. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53561. * @param useInstances - Specifies that instances should be used.
  53562. * @returns - boolean indicating that the submesh is ready or not.
  53563. */
  53564. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53565. /**
  53566. * Specifies if the material uses metallic roughness workflow.
  53567. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53568. */
  53569. isMetallicWorkflow(): boolean;
  53570. private _prepareEffect;
  53571. private _prepareDefines;
  53572. /**
  53573. * Force shader compilation
  53574. */
  53575. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53576. /**
  53577. * Initializes the uniform buffer layout for the shader.
  53578. */
  53579. buildUniformLayout(): void;
  53580. /**
  53581. * Unbinds the material from the mesh
  53582. */
  53583. unbind(): void;
  53584. /**
  53585. * Binds the submesh data.
  53586. * @param world - The world matrix.
  53587. * @param mesh - The BJS mesh.
  53588. * @param subMesh - A submesh of the BJS mesh.
  53589. */
  53590. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53591. /**
  53592. * Returns the animatable textures.
  53593. * @returns - Array of animatable textures.
  53594. */
  53595. getAnimatables(): IAnimatable[];
  53596. /**
  53597. * Returns the texture used for reflections.
  53598. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53599. */
  53600. private _getReflectionTexture;
  53601. /**
  53602. * Returns an array of the actively used textures.
  53603. * @returns - Array of BaseTextures
  53604. */
  53605. getActiveTextures(): BaseTexture[];
  53606. /**
  53607. * Checks to see if a texture is used in the material.
  53608. * @param texture - Base texture to use.
  53609. * @returns - Boolean specifying if a texture is used in the material.
  53610. */
  53611. hasTexture(texture: BaseTexture): boolean;
  53612. /**
  53613. * Disposes the resources of the material.
  53614. * @param forceDisposeEffect - Forces the disposal of effects.
  53615. * @param forceDisposeTextures - Forces the disposal of all textures.
  53616. */
  53617. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53618. }
  53619. }
  53620. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53621. import { Nullable } from "babylonjs/types";
  53622. import { Scene } from "babylonjs/scene";
  53623. import { Color3 } from "babylonjs/Maths/math.color";
  53624. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53625. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53627. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53628. /**
  53629. * The Physically based material of BJS.
  53630. *
  53631. * This offers the main features of a standard PBR material.
  53632. * For more information, please refer to the documentation :
  53633. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53634. */
  53635. export class PBRMaterial extends PBRBaseMaterial {
  53636. /**
  53637. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53638. */
  53639. static readonly PBRMATERIAL_OPAQUE: number;
  53640. /**
  53641. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53642. */
  53643. static readonly PBRMATERIAL_ALPHATEST: number;
  53644. /**
  53645. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53646. */
  53647. static readonly PBRMATERIAL_ALPHABLEND: number;
  53648. /**
  53649. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53650. * They are also discarded below the alpha cutoff threshold to improve performances.
  53651. */
  53652. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53653. /**
  53654. * Defines the default value of how much AO map is occluding the analytical lights
  53655. * (point spot...).
  53656. */
  53657. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53658. /**
  53659. * Intensity of the direct lights e.g. the four lights available in your scene.
  53660. * This impacts both the direct diffuse and specular highlights.
  53661. */
  53662. directIntensity: number;
  53663. /**
  53664. * Intensity of the emissive part of the material.
  53665. * This helps controlling the emissive effect without modifying the emissive color.
  53666. */
  53667. emissiveIntensity: number;
  53668. /**
  53669. * Intensity of the environment e.g. how much the environment will light the object
  53670. * either through harmonics for rough material or through the refelction for shiny ones.
  53671. */
  53672. environmentIntensity: number;
  53673. /**
  53674. * This is a special control allowing the reduction of the specular highlights coming from the
  53675. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53676. */
  53677. specularIntensity: number;
  53678. /**
  53679. * Debug Control allowing disabling the bump map on this material.
  53680. */
  53681. disableBumpMap: boolean;
  53682. /**
  53683. * AKA Diffuse Texture in standard nomenclature.
  53684. */
  53685. albedoTexture: BaseTexture;
  53686. /**
  53687. * AKA Occlusion Texture in other nomenclature.
  53688. */
  53689. ambientTexture: BaseTexture;
  53690. /**
  53691. * AKA Occlusion Texture Intensity in other nomenclature.
  53692. */
  53693. ambientTextureStrength: number;
  53694. /**
  53695. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53696. * 1 means it completely occludes it
  53697. * 0 mean it has no impact
  53698. */
  53699. ambientTextureImpactOnAnalyticalLights: number;
  53700. /**
  53701. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53702. */
  53703. opacityTexture: BaseTexture;
  53704. /**
  53705. * Stores the reflection values in a texture.
  53706. */
  53707. reflectionTexture: Nullable<BaseTexture>;
  53708. /**
  53709. * Stores the emissive values in a texture.
  53710. */
  53711. emissiveTexture: BaseTexture;
  53712. /**
  53713. * AKA Specular texture in other nomenclature.
  53714. */
  53715. reflectivityTexture: BaseTexture;
  53716. /**
  53717. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53718. */
  53719. metallicTexture: BaseTexture;
  53720. /**
  53721. * Specifies the metallic scalar of the metallic/roughness workflow.
  53722. * Can also be used to scale the metalness values of the metallic texture.
  53723. */
  53724. metallic: Nullable<number>;
  53725. /**
  53726. * Specifies the roughness scalar of the metallic/roughness workflow.
  53727. * Can also be used to scale the roughness values of the metallic texture.
  53728. */
  53729. roughness: Nullable<number>;
  53730. /**
  53731. * Specifies the an F0 factor to help configuring the material F0.
  53732. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53733. * to 0.5 the previously hard coded value stays the same.
  53734. * Can also be used to scale the F0 values of the metallic texture.
  53735. */
  53736. metallicF0Factor: number;
  53737. /**
  53738. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53739. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53740. * your expectation as it multiplies with the texture data.
  53741. */
  53742. useMetallicF0FactorFromMetallicTexture: boolean;
  53743. /**
  53744. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53745. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53746. */
  53747. microSurfaceTexture: BaseTexture;
  53748. /**
  53749. * Stores surface normal data used to displace a mesh in a texture.
  53750. */
  53751. bumpTexture: BaseTexture;
  53752. /**
  53753. * Stores the pre-calculated light information of a mesh in a texture.
  53754. */
  53755. lightmapTexture: BaseTexture;
  53756. /**
  53757. * Stores the refracted light information in a texture.
  53758. */
  53759. get refractionTexture(): Nullable<BaseTexture>;
  53760. set refractionTexture(value: Nullable<BaseTexture>);
  53761. /**
  53762. * The color of a material in ambient lighting.
  53763. */
  53764. ambientColor: Color3;
  53765. /**
  53766. * AKA Diffuse Color in other nomenclature.
  53767. */
  53768. albedoColor: Color3;
  53769. /**
  53770. * AKA Specular Color in other nomenclature.
  53771. */
  53772. reflectivityColor: Color3;
  53773. /**
  53774. * The color reflected from the material.
  53775. */
  53776. reflectionColor: Color3;
  53777. /**
  53778. * The color emitted from the material.
  53779. */
  53780. emissiveColor: Color3;
  53781. /**
  53782. * AKA Glossiness in other nomenclature.
  53783. */
  53784. microSurface: number;
  53785. /**
  53786. * source material index of refraction (IOR)' / 'destination material IOR.
  53787. */
  53788. get indexOfRefraction(): number;
  53789. set indexOfRefraction(value: number);
  53790. /**
  53791. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53792. */
  53793. get invertRefractionY(): boolean;
  53794. set invertRefractionY(value: boolean);
  53795. /**
  53796. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53797. * Materials half opaque for instance using refraction could benefit from this control.
  53798. */
  53799. get linkRefractionWithTransparency(): boolean;
  53800. set linkRefractionWithTransparency(value: boolean);
  53801. /**
  53802. * If true, the light map contains occlusion information instead of lighting info.
  53803. */
  53804. useLightmapAsShadowmap: boolean;
  53805. /**
  53806. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53807. */
  53808. useAlphaFromAlbedoTexture: boolean;
  53809. /**
  53810. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53811. */
  53812. forceAlphaTest: boolean;
  53813. /**
  53814. * Defines the alpha limits in alpha test mode.
  53815. */
  53816. alphaCutOff: number;
  53817. /**
  53818. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53819. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53820. */
  53821. useSpecularOverAlpha: boolean;
  53822. /**
  53823. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53824. */
  53825. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53826. /**
  53827. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53828. */
  53829. useRoughnessFromMetallicTextureAlpha: boolean;
  53830. /**
  53831. * Specifies if the metallic texture contains the roughness information in its green channel.
  53832. */
  53833. useRoughnessFromMetallicTextureGreen: boolean;
  53834. /**
  53835. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53836. */
  53837. useMetallnessFromMetallicTextureBlue: boolean;
  53838. /**
  53839. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53840. */
  53841. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53842. /**
  53843. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53844. */
  53845. useAmbientInGrayScale: boolean;
  53846. /**
  53847. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53848. * The material will try to infer what glossiness each pixel should be.
  53849. */
  53850. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53851. /**
  53852. * BJS is using an harcoded light falloff based on a manually sets up range.
  53853. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53854. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53855. */
  53856. get usePhysicalLightFalloff(): boolean;
  53857. /**
  53858. * BJS is using an harcoded light falloff based on a manually sets up range.
  53859. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53860. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53861. */
  53862. set usePhysicalLightFalloff(value: boolean);
  53863. /**
  53864. * In order to support the falloff compatibility with gltf, a special mode has been added
  53865. * to reproduce the gltf light falloff.
  53866. */
  53867. get useGLTFLightFalloff(): boolean;
  53868. /**
  53869. * In order to support the falloff compatibility with gltf, a special mode has been added
  53870. * to reproduce the gltf light falloff.
  53871. */
  53872. set useGLTFLightFalloff(value: boolean);
  53873. /**
  53874. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53875. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53876. */
  53877. useRadianceOverAlpha: boolean;
  53878. /**
  53879. * Allows using an object space normal map (instead of tangent space).
  53880. */
  53881. useObjectSpaceNormalMap: boolean;
  53882. /**
  53883. * Allows using the bump map in parallax mode.
  53884. */
  53885. useParallax: boolean;
  53886. /**
  53887. * Allows using the bump map in parallax occlusion mode.
  53888. */
  53889. useParallaxOcclusion: boolean;
  53890. /**
  53891. * Controls the scale bias of the parallax mode.
  53892. */
  53893. parallaxScaleBias: number;
  53894. /**
  53895. * If sets to true, disables all the lights affecting the material.
  53896. */
  53897. disableLighting: boolean;
  53898. /**
  53899. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53900. */
  53901. forceIrradianceInFragment: boolean;
  53902. /**
  53903. * Number of Simultaneous lights allowed on the material.
  53904. */
  53905. maxSimultaneousLights: number;
  53906. /**
  53907. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53908. */
  53909. invertNormalMapX: boolean;
  53910. /**
  53911. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53912. */
  53913. invertNormalMapY: boolean;
  53914. /**
  53915. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53916. */
  53917. twoSidedLighting: boolean;
  53918. /**
  53919. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53920. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53921. */
  53922. useAlphaFresnel: boolean;
  53923. /**
  53924. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53925. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53926. */
  53927. useLinearAlphaFresnel: boolean;
  53928. /**
  53929. * Let user defines the brdf lookup texture used for IBL.
  53930. * A default 8bit version is embedded but you could point at :
  53931. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53932. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53933. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53934. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53935. */
  53936. environmentBRDFTexture: Nullable<BaseTexture>;
  53937. /**
  53938. * Force normal to face away from face.
  53939. */
  53940. forceNormalForward: boolean;
  53941. /**
  53942. * Enables specular anti aliasing in the PBR shader.
  53943. * It will both interacts on the Geometry for analytical and IBL lighting.
  53944. * It also prefilter the roughness map based on the bump values.
  53945. */
  53946. enableSpecularAntiAliasing: boolean;
  53947. /**
  53948. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53949. * makes the reflect vector face the model (under horizon).
  53950. */
  53951. useHorizonOcclusion: boolean;
  53952. /**
  53953. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53954. * too much the area relying on ambient texture to define their ambient occlusion.
  53955. */
  53956. useRadianceOcclusion: boolean;
  53957. /**
  53958. * If set to true, no lighting calculations will be applied.
  53959. */
  53960. unlit: boolean;
  53961. /**
  53962. * Gets the image processing configuration used either in this material.
  53963. */
  53964. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53965. /**
  53966. * Sets the Default image processing configuration used either in the this material.
  53967. *
  53968. * If sets to null, the scene one is in use.
  53969. */
  53970. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53971. /**
  53972. * Gets wether the color curves effect is enabled.
  53973. */
  53974. get cameraColorCurvesEnabled(): boolean;
  53975. /**
  53976. * Sets wether the color curves effect is enabled.
  53977. */
  53978. set cameraColorCurvesEnabled(value: boolean);
  53979. /**
  53980. * Gets wether the color grading effect is enabled.
  53981. */
  53982. get cameraColorGradingEnabled(): boolean;
  53983. /**
  53984. * Gets wether the color grading effect is enabled.
  53985. */
  53986. set cameraColorGradingEnabled(value: boolean);
  53987. /**
  53988. * Gets wether tonemapping is enabled or not.
  53989. */
  53990. get cameraToneMappingEnabled(): boolean;
  53991. /**
  53992. * Sets wether tonemapping is enabled or not
  53993. */
  53994. set cameraToneMappingEnabled(value: boolean);
  53995. /**
  53996. * The camera exposure used on this material.
  53997. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53998. * This corresponds to a photographic exposure.
  53999. */
  54000. get cameraExposure(): number;
  54001. /**
  54002. * The camera exposure used on this material.
  54003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54004. * This corresponds to a photographic exposure.
  54005. */
  54006. set cameraExposure(value: number);
  54007. /**
  54008. * Gets The camera contrast used on this material.
  54009. */
  54010. get cameraContrast(): number;
  54011. /**
  54012. * Sets The camera contrast used on this material.
  54013. */
  54014. set cameraContrast(value: number);
  54015. /**
  54016. * Gets the Color Grading 2D Lookup Texture.
  54017. */
  54018. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54019. /**
  54020. * Sets the Color Grading 2D Lookup Texture.
  54021. */
  54022. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54023. /**
  54024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54026. * 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;
  54027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54028. */
  54029. get cameraColorCurves(): Nullable<ColorCurves>;
  54030. /**
  54031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54033. * 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;
  54034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54035. */
  54036. set cameraColorCurves(value: Nullable<ColorCurves>);
  54037. /**
  54038. * Instantiates a new PBRMaterial instance.
  54039. *
  54040. * @param name The material name
  54041. * @param scene The scene the material will be use in.
  54042. */
  54043. constructor(name: string, scene: Scene);
  54044. /**
  54045. * Returns the name of this material class.
  54046. */
  54047. getClassName(): string;
  54048. /**
  54049. * Makes a duplicate of the current material.
  54050. * @param name - name to use for the new material.
  54051. */
  54052. clone(name: string): PBRMaterial;
  54053. /**
  54054. * Serializes this PBR Material.
  54055. * @returns - An object with the serialized material.
  54056. */
  54057. serialize(): any;
  54058. /**
  54059. * Parses a PBR Material from a serialized object.
  54060. * @param source - Serialized object.
  54061. * @param scene - BJS scene instance.
  54062. * @param rootUrl - url for the scene object
  54063. * @returns - PBRMaterial
  54064. */
  54065. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54066. }
  54067. }
  54068. declare module "babylonjs/Misc/dds" {
  54069. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54070. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54071. import { Nullable } from "babylonjs/types";
  54072. import { Scene } from "babylonjs/scene";
  54073. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54074. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54075. /**
  54076. * Direct draw surface info
  54077. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54078. */
  54079. export interface DDSInfo {
  54080. /**
  54081. * Width of the texture
  54082. */
  54083. width: number;
  54084. /**
  54085. * Width of the texture
  54086. */
  54087. height: number;
  54088. /**
  54089. * Number of Mipmaps for the texture
  54090. * @see https://en.wikipedia.org/wiki/Mipmap
  54091. */
  54092. mipmapCount: number;
  54093. /**
  54094. * If the textures format is a known fourCC format
  54095. * @see https://www.fourcc.org/
  54096. */
  54097. isFourCC: boolean;
  54098. /**
  54099. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54100. */
  54101. isRGB: boolean;
  54102. /**
  54103. * If the texture is a lumincance format
  54104. */
  54105. isLuminance: boolean;
  54106. /**
  54107. * If this is a cube texture
  54108. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54109. */
  54110. isCube: boolean;
  54111. /**
  54112. * If the texture is a compressed format eg. FOURCC_DXT1
  54113. */
  54114. isCompressed: boolean;
  54115. /**
  54116. * The dxgiFormat of the texture
  54117. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54118. */
  54119. dxgiFormat: number;
  54120. /**
  54121. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54122. */
  54123. textureType: number;
  54124. /**
  54125. * Sphericle polynomial created for the dds texture
  54126. */
  54127. sphericalPolynomial?: SphericalPolynomial;
  54128. }
  54129. /**
  54130. * Class used to provide DDS decompression tools
  54131. */
  54132. export class DDSTools {
  54133. /**
  54134. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54135. */
  54136. static StoreLODInAlphaChannel: boolean;
  54137. /**
  54138. * Gets DDS information from an array buffer
  54139. * @param data defines the array buffer view to read data from
  54140. * @returns the DDS information
  54141. */
  54142. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54143. private static _FloatView;
  54144. private static _Int32View;
  54145. private static _ToHalfFloat;
  54146. private static _FromHalfFloat;
  54147. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54148. private static _GetHalfFloatRGBAArrayBuffer;
  54149. private static _GetFloatRGBAArrayBuffer;
  54150. private static _GetFloatAsUIntRGBAArrayBuffer;
  54151. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54152. private static _GetRGBAArrayBuffer;
  54153. private static _ExtractLongWordOrder;
  54154. private static _GetRGBArrayBuffer;
  54155. private static _GetLuminanceArrayBuffer;
  54156. /**
  54157. * Uploads DDS Levels to a Babylon Texture
  54158. * @hidden
  54159. */
  54160. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54161. }
  54162. module "babylonjs/Engines/thinEngine" {
  54163. interface ThinEngine {
  54164. /**
  54165. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54166. * @param rootUrl defines the url where the file to load is located
  54167. * @param scene defines the current scene
  54168. * @param lodScale defines scale to apply to the mip map selection
  54169. * @param lodOffset defines offset to apply to the mip map selection
  54170. * @param onLoad defines an optional callback raised when the texture is loaded
  54171. * @param onError defines an optional callback raised if there is an issue to load the texture
  54172. * @param format defines the format of the data
  54173. * @param forcedExtension defines the extension to use to pick the right loader
  54174. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54175. * @returns the cube texture as an InternalTexture
  54176. */
  54177. 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;
  54178. }
  54179. }
  54180. }
  54181. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54182. import { Nullable } from "babylonjs/types";
  54183. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54184. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54185. /**
  54186. * Implementation of the DDS Texture Loader.
  54187. * @hidden
  54188. */
  54189. export class _DDSTextureLoader implements IInternalTextureLoader {
  54190. /**
  54191. * Defines wether the loader supports cascade loading the different faces.
  54192. */
  54193. readonly supportCascades: boolean;
  54194. /**
  54195. * This returns if the loader support the current file information.
  54196. * @param extension defines the file extension of the file being loaded
  54197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54198. * @param fallback defines the fallback internal texture if any
  54199. * @param isBase64 defines whether the texture is encoded as a base64
  54200. * @param isBuffer defines whether the texture data are stored as a buffer
  54201. * @returns true if the loader can load the specified file
  54202. */
  54203. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54204. /**
  54205. * Transform the url before loading if required.
  54206. * @param rootUrl the url of the texture
  54207. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54208. * @returns the transformed texture
  54209. */
  54210. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54211. /**
  54212. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54213. * @param rootUrl the url of the texture
  54214. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54215. * @returns the fallback texture
  54216. */
  54217. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54218. /**
  54219. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54220. * @param data contains the texture data
  54221. * @param texture defines the BabylonJS internal texture
  54222. * @param createPolynomials will be true if polynomials have been requested
  54223. * @param onLoad defines the callback to trigger once the texture is ready
  54224. * @param onError defines the callback to trigger in case of error
  54225. */
  54226. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54227. /**
  54228. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54229. * @param data contains the texture data
  54230. * @param texture defines the BabylonJS internal texture
  54231. * @param callback defines the method to call once ready to upload
  54232. */
  54233. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54234. }
  54235. }
  54236. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54237. import { Nullable } from "babylonjs/types";
  54238. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54239. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54240. /**
  54241. * Implementation of the ENV Texture Loader.
  54242. * @hidden
  54243. */
  54244. export class _ENVTextureLoader implements IInternalTextureLoader {
  54245. /**
  54246. * Defines wether the loader supports cascade loading the different faces.
  54247. */
  54248. readonly supportCascades: boolean;
  54249. /**
  54250. * This returns if the loader support the current file information.
  54251. * @param extension defines the file extension of the file being loaded
  54252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54253. * @param fallback defines the fallback internal texture if any
  54254. * @param isBase64 defines whether the texture is encoded as a base64
  54255. * @param isBuffer defines whether the texture data are stored as a buffer
  54256. * @returns true if the loader can load the specified file
  54257. */
  54258. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54259. /**
  54260. * Transform the url before loading if required.
  54261. * @param rootUrl the url of the texture
  54262. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54263. * @returns the transformed texture
  54264. */
  54265. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54266. /**
  54267. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54268. * @param rootUrl the url of the texture
  54269. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54270. * @returns the fallback texture
  54271. */
  54272. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54273. /**
  54274. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54275. * @param data contains the texture data
  54276. * @param texture defines the BabylonJS internal texture
  54277. * @param createPolynomials will be true if polynomials have been requested
  54278. * @param onLoad defines the callback to trigger once the texture is ready
  54279. * @param onError defines the callback to trigger in case of error
  54280. */
  54281. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54282. /**
  54283. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54284. * @param data contains the texture data
  54285. * @param texture defines the BabylonJS internal texture
  54286. * @param callback defines the method to call once ready to upload
  54287. */
  54288. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54289. }
  54290. }
  54291. declare module "babylonjs/Misc/khronosTextureContainer" {
  54292. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54293. /**
  54294. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54295. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54296. */
  54297. export class KhronosTextureContainer {
  54298. /** contents of the KTX container file */
  54299. data: ArrayBufferView;
  54300. private static HEADER_LEN;
  54301. private static COMPRESSED_2D;
  54302. private static COMPRESSED_3D;
  54303. private static TEX_2D;
  54304. private static TEX_3D;
  54305. /**
  54306. * Gets the openGL type
  54307. */
  54308. glType: number;
  54309. /**
  54310. * Gets the openGL type size
  54311. */
  54312. glTypeSize: number;
  54313. /**
  54314. * Gets the openGL format
  54315. */
  54316. glFormat: number;
  54317. /**
  54318. * Gets the openGL internal format
  54319. */
  54320. glInternalFormat: number;
  54321. /**
  54322. * Gets the base internal format
  54323. */
  54324. glBaseInternalFormat: number;
  54325. /**
  54326. * Gets image width in pixel
  54327. */
  54328. pixelWidth: number;
  54329. /**
  54330. * Gets image height in pixel
  54331. */
  54332. pixelHeight: number;
  54333. /**
  54334. * Gets image depth in pixels
  54335. */
  54336. pixelDepth: number;
  54337. /**
  54338. * Gets the number of array elements
  54339. */
  54340. numberOfArrayElements: number;
  54341. /**
  54342. * Gets the number of faces
  54343. */
  54344. numberOfFaces: number;
  54345. /**
  54346. * Gets the number of mipmap levels
  54347. */
  54348. numberOfMipmapLevels: number;
  54349. /**
  54350. * Gets the bytes of key value data
  54351. */
  54352. bytesOfKeyValueData: number;
  54353. /**
  54354. * Gets the load type
  54355. */
  54356. loadType: number;
  54357. /**
  54358. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54359. */
  54360. isInvalid: boolean;
  54361. /**
  54362. * Creates a new KhronosTextureContainer
  54363. * @param data contents of the KTX container file
  54364. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54365. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54366. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54367. */
  54368. constructor(
  54369. /** contents of the KTX container file */
  54370. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54371. /**
  54372. * Uploads KTX content to a Babylon Texture.
  54373. * It is assumed that the texture has already been created & is currently bound
  54374. * @hidden
  54375. */
  54376. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54377. private _upload2DCompressedLevels;
  54378. }
  54379. }
  54380. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54381. import { Nullable } from "babylonjs/types";
  54382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54383. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54384. /**
  54385. * Implementation of the KTX Texture Loader.
  54386. * @hidden
  54387. */
  54388. export class _KTXTextureLoader implements IInternalTextureLoader {
  54389. /**
  54390. * Defines wether the loader supports cascade loading the different faces.
  54391. */
  54392. readonly supportCascades: boolean;
  54393. /**
  54394. * This returns if the loader support the current file information.
  54395. * @param extension defines the file extension of the file being loaded
  54396. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54397. * @param fallback defines the fallback internal texture if any
  54398. * @param isBase64 defines whether the texture is encoded as a base64
  54399. * @param isBuffer defines whether the texture data are stored as a buffer
  54400. * @returns true if the loader can load the specified file
  54401. */
  54402. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54403. /**
  54404. * Transform the url before loading if required.
  54405. * @param rootUrl the url of the texture
  54406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54407. * @returns the transformed texture
  54408. */
  54409. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54410. /**
  54411. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54412. * @param rootUrl the url of the texture
  54413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54414. * @returns the fallback texture
  54415. */
  54416. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54417. /**
  54418. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54419. * @param data contains the texture data
  54420. * @param texture defines the BabylonJS internal texture
  54421. * @param createPolynomials will be true if polynomials have been requested
  54422. * @param onLoad defines the callback to trigger once the texture is ready
  54423. * @param onError defines the callback to trigger in case of error
  54424. */
  54425. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54426. /**
  54427. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54428. * @param data contains the texture data
  54429. * @param texture defines the BabylonJS internal texture
  54430. * @param callback defines the method to call once ready to upload
  54431. */
  54432. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54433. }
  54434. }
  54435. declare module "babylonjs/Helpers/sceneHelpers" {
  54436. import { Nullable } from "babylonjs/types";
  54437. import { Mesh } from "babylonjs/Meshes/mesh";
  54438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54439. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54440. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54441. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54442. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54443. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54444. import "babylonjs/Meshes/Builders/boxBuilder";
  54445. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54446. /** @hidden */
  54447. export var _forceSceneHelpersToBundle: boolean;
  54448. module "babylonjs/scene" {
  54449. interface Scene {
  54450. /**
  54451. * Creates a default light for the scene.
  54452. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54453. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54454. */
  54455. createDefaultLight(replace?: boolean): void;
  54456. /**
  54457. * Creates a default camera for the scene.
  54458. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54459. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54460. * @param replace has default false, when true replaces the active camera in the scene
  54461. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54462. */
  54463. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54464. /**
  54465. * Creates a default camera and a default light.
  54466. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54467. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54468. * @param replace has the default false, when true replaces the active camera/light in the scene
  54469. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54470. */
  54471. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54472. /**
  54473. * Creates a new sky box
  54474. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54475. * @param environmentTexture defines the texture to use as environment texture
  54476. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54477. * @param scale defines the overall scale of the skybox
  54478. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54479. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54480. * @returns a new mesh holding the sky box
  54481. */
  54482. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54483. /**
  54484. * Creates a new environment
  54485. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54486. * @param options defines the options you can use to configure the environment
  54487. * @returns the new EnvironmentHelper
  54488. */
  54489. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54490. /**
  54491. * Creates a new VREXperienceHelper
  54492. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54493. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54494. * @returns a new VREXperienceHelper
  54495. */
  54496. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54497. /**
  54498. * Creates a new WebXRDefaultExperience
  54499. * @see http://doc.babylonjs.com/how_to/webxr
  54500. * @param options experience options
  54501. * @returns a promise for a new WebXRDefaultExperience
  54502. */
  54503. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54504. }
  54505. }
  54506. }
  54507. declare module "babylonjs/Helpers/videoDome" {
  54508. import { Scene } from "babylonjs/scene";
  54509. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54510. import { Mesh } from "babylonjs/Meshes/mesh";
  54511. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54512. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54513. import "babylonjs/Meshes/Builders/sphereBuilder";
  54514. /**
  54515. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54516. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54517. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54518. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54519. */
  54520. export class VideoDome extends TransformNode {
  54521. /**
  54522. * Define the video source as a Monoscopic panoramic 360 video.
  54523. */
  54524. static readonly MODE_MONOSCOPIC: number;
  54525. /**
  54526. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54527. */
  54528. static readonly MODE_TOPBOTTOM: number;
  54529. /**
  54530. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54531. */
  54532. static readonly MODE_SIDEBYSIDE: number;
  54533. private _halfDome;
  54534. private _useDirectMapping;
  54535. /**
  54536. * The video texture being displayed on the sphere
  54537. */
  54538. protected _videoTexture: VideoTexture;
  54539. /**
  54540. * Gets the video texture being displayed on the sphere
  54541. */
  54542. get videoTexture(): VideoTexture;
  54543. /**
  54544. * The skybox material
  54545. */
  54546. protected _material: BackgroundMaterial;
  54547. /**
  54548. * The surface used for the skybox
  54549. */
  54550. protected _mesh: Mesh;
  54551. /**
  54552. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54553. */
  54554. private _halfDomeMask;
  54555. /**
  54556. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54557. * Also see the options.resolution property.
  54558. */
  54559. get fovMultiplier(): number;
  54560. set fovMultiplier(value: number);
  54561. private _videoMode;
  54562. /**
  54563. * Gets or set the current video mode for the video. It can be:
  54564. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54565. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54566. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54567. */
  54568. get videoMode(): number;
  54569. set videoMode(value: number);
  54570. /**
  54571. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54572. *
  54573. */
  54574. get halfDome(): boolean;
  54575. /**
  54576. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54577. */
  54578. set halfDome(enabled: boolean);
  54579. /**
  54580. * Oberserver used in Stereoscopic VR Mode.
  54581. */
  54582. private _onBeforeCameraRenderObserver;
  54583. /**
  54584. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54585. * @param name Element's name, child elements will append suffixes for their own names.
  54586. * @param urlsOrVideo defines the url(s) or the video element to use
  54587. * @param options An object containing optional or exposed sub element properties
  54588. */
  54589. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54590. resolution?: number;
  54591. clickToPlay?: boolean;
  54592. autoPlay?: boolean;
  54593. loop?: boolean;
  54594. size?: number;
  54595. poster?: string;
  54596. faceForward?: boolean;
  54597. useDirectMapping?: boolean;
  54598. halfDomeMode?: boolean;
  54599. }, scene: Scene);
  54600. private _changeVideoMode;
  54601. /**
  54602. * Releases resources associated with this node.
  54603. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54604. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54605. */
  54606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54607. }
  54608. }
  54609. declare module "babylonjs/Helpers/index" {
  54610. export * from "babylonjs/Helpers/environmentHelper";
  54611. export * from "babylonjs/Helpers/photoDome";
  54612. export * from "babylonjs/Helpers/sceneHelpers";
  54613. export * from "babylonjs/Helpers/videoDome";
  54614. }
  54615. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54616. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54617. import { IDisposable } from "babylonjs/scene";
  54618. import { Engine } from "babylonjs/Engines/engine";
  54619. /**
  54620. * This class can be used to get instrumentation data from a Babylon engine
  54621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54622. */
  54623. export class EngineInstrumentation implements IDisposable {
  54624. /**
  54625. * Define the instrumented engine.
  54626. */
  54627. engine: Engine;
  54628. private _captureGPUFrameTime;
  54629. private _gpuFrameTimeToken;
  54630. private _gpuFrameTime;
  54631. private _captureShaderCompilationTime;
  54632. private _shaderCompilationTime;
  54633. private _onBeginFrameObserver;
  54634. private _onEndFrameObserver;
  54635. private _onBeforeShaderCompilationObserver;
  54636. private _onAfterShaderCompilationObserver;
  54637. /**
  54638. * Gets the perf counter used for GPU frame time
  54639. */
  54640. get gpuFrameTimeCounter(): PerfCounter;
  54641. /**
  54642. * Gets the GPU frame time capture status
  54643. */
  54644. get captureGPUFrameTime(): boolean;
  54645. /**
  54646. * Enable or disable the GPU frame time capture
  54647. */
  54648. set captureGPUFrameTime(value: boolean);
  54649. /**
  54650. * Gets the perf counter used for shader compilation time
  54651. */
  54652. get shaderCompilationTimeCounter(): PerfCounter;
  54653. /**
  54654. * Gets the shader compilation time capture status
  54655. */
  54656. get captureShaderCompilationTime(): boolean;
  54657. /**
  54658. * Enable or disable the shader compilation time capture
  54659. */
  54660. set captureShaderCompilationTime(value: boolean);
  54661. /**
  54662. * Instantiates a new engine instrumentation.
  54663. * This class can be used to get instrumentation data from a Babylon engine
  54664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54665. * @param engine Defines the engine to instrument
  54666. */
  54667. constructor(
  54668. /**
  54669. * Define the instrumented engine.
  54670. */
  54671. engine: Engine);
  54672. /**
  54673. * Dispose and release associated resources.
  54674. */
  54675. dispose(): void;
  54676. }
  54677. }
  54678. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54679. import { Scene, IDisposable } from "babylonjs/scene";
  54680. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54681. /**
  54682. * This class can be used to get instrumentation data from a Babylon engine
  54683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54684. */
  54685. export class SceneInstrumentation implements IDisposable {
  54686. /**
  54687. * Defines the scene to instrument
  54688. */
  54689. scene: Scene;
  54690. private _captureActiveMeshesEvaluationTime;
  54691. private _activeMeshesEvaluationTime;
  54692. private _captureRenderTargetsRenderTime;
  54693. private _renderTargetsRenderTime;
  54694. private _captureFrameTime;
  54695. private _frameTime;
  54696. private _captureRenderTime;
  54697. private _renderTime;
  54698. private _captureInterFrameTime;
  54699. private _interFrameTime;
  54700. private _captureParticlesRenderTime;
  54701. private _particlesRenderTime;
  54702. private _captureSpritesRenderTime;
  54703. private _spritesRenderTime;
  54704. private _capturePhysicsTime;
  54705. private _physicsTime;
  54706. private _captureAnimationsTime;
  54707. private _animationsTime;
  54708. private _captureCameraRenderTime;
  54709. private _cameraRenderTime;
  54710. private _onBeforeActiveMeshesEvaluationObserver;
  54711. private _onAfterActiveMeshesEvaluationObserver;
  54712. private _onBeforeRenderTargetsRenderObserver;
  54713. private _onAfterRenderTargetsRenderObserver;
  54714. private _onAfterRenderObserver;
  54715. private _onBeforeDrawPhaseObserver;
  54716. private _onAfterDrawPhaseObserver;
  54717. private _onBeforeAnimationsObserver;
  54718. private _onBeforeParticlesRenderingObserver;
  54719. private _onAfterParticlesRenderingObserver;
  54720. private _onBeforeSpritesRenderingObserver;
  54721. private _onAfterSpritesRenderingObserver;
  54722. private _onBeforePhysicsObserver;
  54723. private _onAfterPhysicsObserver;
  54724. private _onAfterAnimationsObserver;
  54725. private _onBeforeCameraRenderObserver;
  54726. private _onAfterCameraRenderObserver;
  54727. /**
  54728. * Gets the perf counter used for active meshes evaluation time
  54729. */
  54730. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54731. /**
  54732. * Gets the active meshes evaluation time capture status
  54733. */
  54734. get captureActiveMeshesEvaluationTime(): boolean;
  54735. /**
  54736. * Enable or disable the active meshes evaluation time capture
  54737. */
  54738. set captureActiveMeshesEvaluationTime(value: boolean);
  54739. /**
  54740. * Gets the perf counter used for render targets render time
  54741. */
  54742. get renderTargetsRenderTimeCounter(): PerfCounter;
  54743. /**
  54744. * Gets the render targets render time capture status
  54745. */
  54746. get captureRenderTargetsRenderTime(): boolean;
  54747. /**
  54748. * Enable or disable the render targets render time capture
  54749. */
  54750. set captureRenderTargetsRenderTime(value: boolean);
  54751. /**
  54752. * Gets the perf counter used for particles render time
  54753. */
  54754. get particlesRenderTimeCounter(): PerfCounter;
  54755. /**
  54756. * Gets the particles render time capture status
  54757. */
  54758. get captureParticlesRenderTime(): boolean;
  54759. /**
  54760. * Enable or disable the particles render time capture
  54761. */
  54762. set captureParticlesRenderTime(value: boolean);
  54763. /**
  54764. * Gets the perf counter used for sprites render time
  54765. */
  54766. get spritesRenderTimeCounter(): PerfCounter;
  54767. /**
  54768. * Gets the sprites render time capture status
  54769. */
  54770. get captureSpritesRenderTime(): boolean;
  54771. /**
  54772. * Enable or disable the sprites render time capture
  54773. */
  54774. set captureSpritesRenderTime(value: boolean);
  54775. /**
  54776. * Gets the perf counter used for physics time
  54777. */
  54778. get physicsTimeCounter(): PerfCounter;
  54779. /**
  54780. * Gets the physics time capture status
  54781. */
  54782. get capturePhysicsTime(): boolean;
  54783. /**
  54784. * Enable or disable the physics time capture
  54785. */
  54786. set capturePhysicsTime(value: boolean);
  54787. /**
  54788. * Gets the perf counter used for animations time
  54789. */
  54790. get animationsTimeCounter(): PerfCounter;
  54791. /**
  54792. * Gets the animations time capture status
  54793. */
  54794. get captureAnimationsTime(): boolean;
  54795. /**
  54796. * Enable or disable the animations time capture
  54797. */
  54798. set captureAnimationsTime(value: boolean);
  54799. /**
  54800. * Gets the perf counter used for frame time capture
  54801. */
  54802. get frameTimeCounter(): PerfCounter;
  54803. /**
  54804. * Gets the frame time capture status
  54805. */
  54806. get captureFrameTime(): boolean;
  54807. /**
  54808. * Enable or disable the frame time capture
  54809. */
  54810. set captureFrameTime(value: boolean);
  54811. /**
  54812. * Gets the perf counter used for inter-frames time capture
  54813. */
  54814. get interFrameTimeCounter(): PerfCounter;
  54815. /**
  54816. * Gets the inter-frames time capture status
  54817. */
  54818. get captureInterFrameTime(): boolean;
  54819. /**
  54820. * Enable or disable the inter-frames time capture
  54821. */
  54822. set captureInterFrameTime(value: boolean);
  54823. /**
  54824. * Gets the perf counter used for render time capture
  54825. */
  54826. get renderTimeCounter(): PerfCounter;
  54827. /**
  54828. * Gets the render time capture status
  54829. */
  54830. get captureRenderTime(): boolean;
  54831. /**
  54832. * Enable or disable the render time capture
  54833. */
  54834. set captureRenderTime(value: boolean);
  54835. /**
  54836. * Gets the perf counter used for camera render time capture
  54837. */
  54838. get cameraRenderTimeCounter(): PerfCounter;
  54839. /**
  54840. * Gets the camera render time capture status
  54841. */
  54842. get captureCameraRenderTime(): boolean;
  54843. /**
  54844. * Enable or disable the camera render time capture
  54845. */
  54846. set captureCameraRenderTime(value: boolean);
  54847. /**
  54848. * Gets the perf counter used for draw calls
  54849. */
  54850. get drawCallsCounter(): PerfCounter;
  54851. /**
  54852. * Instantiates a new scene instrumentation.
  54853. * This class can be used to get instrumentation data from a Babylon engine
  54854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54855. * @param scene Defines the scene to instrument
  54856. */
  54857. constructor(
  54858. /**
  54859. * Defines the scene to instrument
  54860. */
  54861. scene: Scene);
  54862. /**
  54863. * Dispose and release associated resources.
  54864. */
  54865. dispose(): void;
  54866. }
  54867. }
  54868. declare module "babylonjs/Instrumentation/index" {
  54869. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54870. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54871. export * from "babylonjs/Instrumentation/timeToken";
  54872. }
  54873. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54874. /** @hidden */
  54875. export var glowMapGenerationPixelShader: {
  54876. name: string;
  54877. shader: string;
  54878. };
  54879. }
  54880. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54881. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54882. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54883. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54884. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54886. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54887. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54888. /** @hidden */
  54889. export var glowMapGenerationVertexShader: {
  54890. name: string;
  54891. shader: string;
  54892. };
  54893. }
  54894. declare module "babylonjs/Layers/effectLayer" {
  54895. import { Observable } from "babylonjs/Misc/observable";
  54896. import { Nullable } from "babylonjs/types";
  54897. import { Camera } from "babylonjs/Cameras/camera";
  54898. import { Scene } from "babylonjs/scene";
  54899. import { ISize } from "babylonjs/Maths/math.size";
  54900. import { Color4 } from "babylonjs/Maths/math.color";
  54901. import { Engine } from "babylonjs/Engines/engine";
  54902. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54904. import { Mesh } from "babylonjs/Meshes/mesh";
  54905. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54908. import { Effect } from "babylonjs/Materials/effect";
  54909. import { Material } from "babylonjs/Materials/material";
  54910. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54911. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54912. /**
  54913. * Effect layer options. This helps customizing the behaviour
  54914. * of the effect layer.
  54915. */
  54916. export interface IEffectLayerOptions {
  54917. /**
  54918. * Multiplication factor apply to the canvas size to compute the render target size
  54919. * used to generated the objects (the smaller the faster).
  54920. */
  54921. mainTextureRatio: number;
  54922. /**
  54923. * Enforces a fixed size texture to ensure effect stability across devices.
  54924. */
  54925. mainTextureFixedSize?: number;
  54926. /**
  54927. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54928. */
  54929. alphaBlendingMode: number;
  54930. /**
  54931. * The camera attached to the layer.
  54932. */
  54933. camera: Nullable<Camera>;
  54934. /**
  54935. * The rendering group to draw the layer in.
  54936. */
  54937. renderingGroupId: number;
  54938. }
  54939. /**
  54940. * The effect layer Helps adding post process effect blended with the main pass.
  54941. *
  54942. * This can be for instance use to generate glow or higlight effects on the scene.
  54943. *
  54944. * The effect layer class can not be used directly and is intented to inherited from to be
  54945. * customized per effects.
  54946. */
  54947. export abstract class EffectLayer {
  54948. private _vertexBuffers;
  54949. private _indexBuffer;
  54950. private _cachedDefines;
  54951. private _effectLayerMapGenerationEffect;
  54952. private _effectLayerOptions;
  54953. private _mergeEffect;
  54954. protected _scene: Scene;
  54955. protected _engine: Engine;
  54956. protected _maxSize: number;
  54957. protected _mainTextureDesiredSize: ISize;
  54958. protected _mainTexture: RenderTargetTexture;
  54959. protected _shouldRender: boolean;
  54960. protected _postProcesses: PostProcess[];
  54961. protected _textures: BaseTexture[];
  54962. protected _emissiveTextureAndColor: {
  54963. texture: Nullable<BaseTexture>;
  54964. color: Color4;
  54965. };
  54966. /**
  54967. * The name of the layer
  54968. */
  54969. name: string;
  54970. /**
  54971. * The clear color of the texture used to generate the glow map.
  54972. */
  54973. neutralColor: Color4;
  54974. /**
  54975. * Specifies whether the highlight layer is enabled or not.
  54976. */
  54977. isEnabled: boolean;
  54978. /**
  54979. * Gets the camera attached to the layer.
  54980. */
  54981. get camera(): Nullable<Camera>;
  54982. /**
  54983. * Gets the rendering group id the layer should render in.
  54984. */
  54985. get renderingGroupId(): number;
  54986. set renderingGroupId(renderingGroupId: number);
  54987. /**
  54988. * An event triggered when the effect layer has been disposed.
  54989. */
  54990. onDisposeObservable: Observable<EffectLayer>;
  54991. /**
  54992. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54993. */
  54994. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54995. /**
  54996. * An event triggered when the generated texture is being merged in the scene.
  54997. */
  54998. onBeforeComposeObservable: Observable<EffectLayer>;
  54999. /**
  55000. * An event triggered when the mesh is rendered into the effect render target.
  55001. */
  55002. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55003. /**
  55004. * An event triggered after the mesh has been rendered into the effect render target.
  55005. */
  55006. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55007. /**
  55008. * An event triggered when the generated texture has been merged in the scene.
  55009. */
  55010. onAfterComposeObservable: Observable<EffectLayer>;
  55011. /**
  55012. * An event triggered when the efffect layer changes its size.
  55013. */
  55014. onSizeChangedObservable: Observable<EffectLayer>;
  55015. /** @hidden */
  55016. static _SceneComponentInitialization: (scene: Scene) => void;
  55017. /**
  55018. * Instantiates a new effect Layer and references it in the scene.
  55019. * @param name The name of the layer
  55020. * @param scene The scene to use the layer in
  55021. */
  55022. constructor(
  55023. /** The Friendly of the effect in the scene */
  55024. name: string, scene: Scene);
  55025. /**
  55026. * Get the effect name of the layer.
  55027. * @return The effect name
  55028. */
  55029. abstract getEffectName(): string;
  55030. /**
  55031. * Checks for the readiness of the element composing the layer.
  55032. * @param subMesh the mesh to check for
  55033. * @param useInstances specify whether or not to use instances to render the mesh
  55034. * @return true if ready otherwise, false
  55035. */
  55036. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55037. /**
  55038. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55039. * @returns true if the effect requires stencil during the main canvas render pass.
  55040. */
  55041. abstract needStencil(): boolean;
  55042. /**
  55043. * Create the merge effect. This is the shader use to blit the information back
  55044. * to the main canvas at the end of the scene rendering.
  55045. * @returns The effect containing the shader used to merge the effect on the main canvas
  55046. */
  55047. protected abstract _createMergeEffect(): Effect;
  55048. /**
  55049. * Creates the render target textures and post processes used in the effect layer.
  55050. */
  55051. protected abstract _createTextureAndPostProcesses(): void;
  55052. /**
  55053. * Implementation specific of rendering the generating effect on the main canvas.
  55054. * @param effect The effect used to render through
  55055. */
  55056. protected abstract _internalRender(effect: Effect): void;
  55057. /**
  55058. * Sets the required values for both the emissive texture and and the main color.
  55059. */
  55060. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55061. /**
  55062. * Free any resources and references associated to a mesh.
  55063. * Internal use
  55064. * @param mesh The mesh to free.
  55065. */
  55066. abstract _disposeMesh(mesh: Mesh): void;
  55067. /**
  55068. * Serializes this layer (Glow or Highlight for example)
  55069. * @returns a serialized layer object
  55070. */
  55071. abstract serialize?(): any;
  55072. /**
  55073. * Initializes the effect layer with the required options.
  55074. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55075. */
  55076. protected _init(options: Partial<IEffectLayerOptions>): void;
  55077. /**
  55078. * Generates the index buffer of the full screen quad blending to the main canvas.
  55079. */
  55080. private _generateIndexBuffer;
  55081. /**
  55082. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55083. */
  55084. private _generateVertexBuffer;
  55085. /**
  55086. * Sets the main texture desired size which is the closest power of two
  55087. * of the engine canvas size.
  55088. */
  55089. private _setMainTextureSize;
  55090. /**
  55091. * Creates the main texture for the effect layer.
  55092. */
  55093. protected _createMainTexture(): void;
  55094. /**
  55095. * Adds specific effects defines.
  55096. * @param defines The defines to add specifics to.
  55097. */
  55098. protected _addCustomEffectDefines(defines: string[]): void;
  55099. /**
  55100. * Checks for the readiness of the element composing the layer.
  55101. * @param subMesh the mesh to check for
  55102. * @param useInstances specify whether or not to use instances to render the mesh
  55103. * @param emissiveTexture the associated emissive texture used to generate the glow
  55104. * @return true if ready otherwise, false
  55105. */
  55106. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55107. /**
  55108. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55109. */
  55110. render(): void;
  55111. /**
  55112. * Determine if a given mesh will be used in the current effect.
  55113. * @param mesh mesh to test
  55114. * @returns true if the mesh will be used
  55115. */
  55116. hasMesh(mesh: AbstractMesh): boolean;
  55117. /**
  55118. * Returns true if the layer contains information to display, otherwise false.
  55119. * @returns true if the glow layer should be rendered
  55120. */
  55121. shouldRender(): boolean;
  55122. /**
  55123. * Returns true if the mesh should render, otherwise false.
  55124. * @param mesh The mesh to render
  55125. * @returns true if it should render otherwise false
  55126. */
  55127. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55128. /**
  55129. * Returns true if the mesh can be rendered, otherwise false.
  55130. * @param mesh The mesh to render
  55131. * @param material The material used on the mesh
  55132. * @returns true if it can be rendered otherwise false
  55133. */
  55134. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55135. /**
  55136. * Returns true if the mesh should render, otherwise false.
  55137. * @param mesh The mesh to render
  55138. * @returns true if it should render otherwise false
  55139. */
  55140. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55141. /**
  55142. * Renders the submesh passed in parameter to the generation map.
  55143. */
  55144. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55145. /**
  55146. * Defines whether the current material of the mesh should be use to render the effect.
  55147. * @param mesh defines the current mesh to render
  55148. */
  55149. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55150. /**
  55151. * Rebuild the required buffers.
  55152. * @hidden Internal use only.
  55153. */
  55154. _rebuild(): void;
  55155. /**
  55156. * Dispose only the render target textures and post process.
  55157. */
  55158. private _disposeTextureAndPostProcesses;
  55159. /**
  55160. * Dispose the highlight layer and free resources.
  55161. */
  55162. dispose(): void;
  55163. /**
  55164. * Gets the class name of the effect layer
  55165. * @returns the string with the class name of the effect layer
  55166. */
  55167. getClassName(): string;
  55168. /**
  55169. * Creates an effect layer from parsed effect layer data
  55170. * @param parsedEffectLayer defines effect layer data
  55171. * @param scene defines the current scene
  55172. * @param rootUrl defines the root URL containing the effect layer information
  55173. * @returns a parsed effect Layer
  55174. */
  55175. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55176. }
  55177. }
  55178. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55179. import { Scene } from "babylonjs/scene";
  55180. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55181. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55182. import { AbstractScene } from "babylonjs/abstractScene";
  55183. module "babylonjs/abstractScene" {
  55184. interface AbstractScene {
  55185. /**
  55186. * The list of effect layers (highlights/glow) added to the scene
  55187. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55188. * @see http://doc.babylonjs.com/how_to/glow_layer
  55189. */
  55190. effectLayers: Array<EffectLayer>;
  55191. /**
  55192. * Removes the given effect layer from this scene.
  55193. * @param toRemove defines the effect layer to remove
  55194. * @returns the index of the removed effect layer
  55195. */
  55196. removeEffectLayer(toRemove: EffectLayer): number;
  55197. /**
  55198. * Adds the given effect layer to this scene
  55199. * @param newEffectLayer defines the effect layer to add
  55200. */
  55201. addEffectLayer(newEffectLayer: EffectLayer): void;
  55202. }
  55203. }
  55204. /**
  55205. * Defines the layer scene component responsible to manage any effect layers
  55206. * in a given scene.
  55207. */
  55208. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55209. /**
  55210. * The component name helpfull to identify the component in the list of scene components.
  55211. */
  55212. readonly name: string;
  55213. /**
  55214. * The scene the component belongs to.
  55215. */
  55216. scene: Scene;
  55217. private _engine;
  55218. private _renderEffects;
  55219. private _needStencil;
  55220. private _previousStencilState;
  55221. /**
  55222. * Creates a new instance of the component for the given scene
  55223. * @param scene Defines the scene to register the component in
  55224. */
  55225. constructor(scene: Scene);
  55226. /**
  55227. * Registers the component in a given scene
  55228. */
  55229. register(): void;
  55230. /**
  55231. * Rebuilds the elements related to this component in case of
  55232. * context lost for instance.
  55233. */
  55234. rebuild(): void;
  55235. /**
  55236. * Serializes the component data to the specified json object
  55237. * @param serializationObject The object to serialize to
  55238. */
  55239. serialize(serializationObject: any): void;
  55240. /**
  55241. * Adds all the elements from the container to the scene
  55242. * @param container the container holding the elements
  55243. */
  55244. addFromContainer(container: AbstractScene): void;
  55245. /**
  55246. * Removes all the elements in the container from the scene
  55247. * @param container contains the elements to remove
  55248. * @param dispose if the removed element should be disposed (default: false)
  55249. */
  55250. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55251. /**
  55252. * Disposes the component and the associated ressources.
  55253. */
  55254. dispose(): void;
  55255. private _isReadyForMesh;
  55256. private _renderMainTexture;
  55257. private _setStencil;
  55258. private _setStencilBack;
  55259. private _draw;
  55260. private _drawCamera;
  55261. private _drawRenderingGroup;
  55262. }
  55263. }
  55264. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55265. /** @hidden */
  55266. export var glowMapMergePixelShader: {
  55267. name: string;
  55268. shader: string;
  55269. };
  55270. }
  55271. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55272. /** @hidden */
  55273. export var glowMapMergeVertexShader: {
  55274. name: string;
  55275. shader: string;
  55276. };
  55277. }
  55278. declare module "babylonjs/Layers/glowLayer" {
  55279. import { Nullable } from "babylonjs/types";
  55280. import { Camera } from "babylonjs/Cameras/camera";
  55281. import { Scene } from "babylonjs/scene";
  55282. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55284. import { Mesh } from "babylonjs/Meshes/mesh";
  55285. import { Texture } from "babylonjs/Materials/Textures/texture";
  55286. import { Effect } from "babylonjs/Materials/effect";
  55287. import { Material } from "babylonjs/Materials/material";
  55288. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55289. import { Color4 } from "babylonjs/Maths/math.color";
  55290. import "babylonjs/Shaders/glowMapMerge.fragment";
  55291. import "babylonjs/Shaders/glowMapMerge.vertex";
  55292. import "babylonjs/Layers/effectLayerSceneComponent";
  55293. module "babylonjs/abstractScene" {
  55294. interface AbstractScene {
  55295. /**
  55296. * Return a the first highlight layer of the scene with a given name.
  55297. * @param name The name of the highlight layer to look for.
  55298. * @return The highlight layer if found otherwise null.
  55299. */
  55300. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55301. }
  55302. }
  55303. /**
  55304. * Glow layer options. This helps customizing the behaviour
  55305. * of the glow layer.
  55306. */
  55307. export interface IGlowLayerOptions {
  55308. /**
  55309. * Multiplication factor apply to the canvas size to compute the render target size
  55310. * used to generated the glowing objects (the smaller the faster).
  55311. */
  55312. mainTextureRatio: number;
  55313. /**
  55314. * Enforces a fixed size texture to ensure resize independant blur.
  55315. */
  55316. mainTextureFixedSize?: number;
  55317. /**
  55318. * How big is the kernel of the blur texture.
  55319. */
  55320. blurKernelSize: number;
  55321. /**
  55322. * The camera attached to the layer.
  55323. */
  55324. camera: Nullable<Camera>;
  55325. /**
  55326. * Enable MSAA by chosing the number of samples.
  55327. */
  55328. mainTextureSamples?: number;
  55329. /**
  55330. * The rendering group to draw the layer in.
  55331. */
  55332. renderingGroupId: number;
  55333. }
  55334. /**
  55335. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55336. *
  55337. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55338. *
  55339. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55340. */
  55341. export class GlowLayer extends EffectLayer {
  55342. /**
  55343. * Effect Name of the layer.
  55344. */
  55345. static readonly EffectName: string;
  55346. /**
  55347. * The default blur kernel size used for the glow.
  55348. */
  55349. static DefaultBlurKernelSize: number;
  55350. /**
  55351. * The default texture size ratio used for the glow.
  55352. */
  55353. static DefaultTextureRatio: number;
  55354. /**
  55355. * Sets the kernel size of the blur.
  55356. */
  55357. set blurKernelSize(value: number);
  55358. /**
  55359. * Gets the kernel size of the blur.
  55360. */
  55361. get blurKernelSize(): number;
  55362. /**
  55363. * Sets the glow intensity.
  55364. */
  55365. set intensity(value: number);
  55366. /**
  55367. * Gets the glow intensity.
  55368. */
  55369. get intensity(): number;
  55370. private _options;
  55371. private _intensity;
  55372. private _horizontalBlurPostprocess1;
  55373. private _verticalBlurPostprocess1;
  55374. private _horizontalBlurPostprocess2;
  55375. private _verticalBlurPostprocess2;
  55376. private _blurTexture1;
  55377. private _blurTexture2;
  55378. private _postProcesses1;
  55379. private _postProcesses2;
  55380. private _includedOnlyMeshes;
  55381. private _excludedMeshes;
  55382. private _meshesUsingTheirOwnMaterials;
  55383. /**
  55384. * Callback used to let the user override the color selection on a per mesh basis
  55385. */
  55386. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55387. /**
  55388. * Callback used to let the user override the texture selection on a per mesh basis
  55389. */
  55390. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55391. /**
  55392. * Instantiates a new glow Layer and references it to the scene.
  55393. * @param name The name of the layer
  55394. * @param scene The scene to use the layer in
  55395. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55396. */
  55397. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55398. /**
  55399. * Get the effect name of the layer.
  55400. * @return The effect name
  55401. */
  55402. getEffectName(): string;
  55403. /**
  55404. * Create the merge effect. This is the shader use to blit the information back
  55405. * to the main canvas at the end of the scene rendering.
  55406. */
  55407. protected _createMergeEffect(): Effect;
  55408. /**
  55409. * Creates the render target textures and post processes used in the glow layer.
  55410. */
  55411. protected _createTextureAndPostProcesses(): void;
  55412. /**
  55413. * Checks for the readiness of the element composing the layer.
  55414. * @param subMesh the mesh to check for
  55415. * @param useInstances specify wether or not to use instances to render the mesh
  55416. * @param emissiveTexture the associated emissive texture used to generate the glow
  55417. * @return true if ready otherwise, false
  55418. */
  55419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55420. /**
  55421. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55422. */
  55423. needStencil(): boolean;
  55424. /**
  55425. * Returns true if the mesh can be rendered, otherwise false.
  55426. * @param mesh The mesh to render
  55427. * @param material The material used on the mesh
  55428. * @returns true if it can be rendered otherwise false
  55429. */
  55430. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55431. /**
  55432. * Implementation specific of rendering the generating effect on the main canvas.
  55433. * @param effect The effect used to render through
  55434. */
  55435. protected _internalRender(effect: Effect): void;
  55436. /**
  55437. * Sets the required values for both the emissive texture and and the main color.
  55438. */
  55439. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55440. /**
  55441. * Returns true if the mesh should render, otherwise false.
  55442. * @param mesh The mesh to render
  55443. * @returns true if it should render otherwise false
  55444. */
  55445. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55446. /**
  55447. * Adds specific effects defines.
  55448. * @param defines The defines to add specifics to.
  55449. */
  55450. protected _addCustomEffectDefines(defines: string[]): void;
  55451. /**
  55452. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55453. * @param mesh The mesh to exclude from the glow layer
  55454. */
  55455. addExcludedMesh(mesh: Mesh): void;
  55456. /**
  55457. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55458. * @param mesh The mesh to remove
  55459. */
  55460. removeExcludedMesh(mesh: Mesh): void;
  55461. /**
  55462. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55463. * @param mesh The mesh to include in the glow layer
  55464. */
  55465. addIncludedOnlyMesh(mesh: Mesh): void;
  55466. /**
  55467. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55468. * @param mesh The mesh to remove
  55469. */
  55470. removeIncludedOnlyMesh(mesh: Mesh): void;
  55471. /**
  55472. * Determine if a given mesh will be used in the glow layer
  55473. * @param mesh The mesh to test
  55474. * @returns true if the mesh will be highlighted by the current glow layer
  55475. */
  55476. hasMesh(mesh: AbstractMesh): boolean;
  55477. /**
  55478. * Defines whether the current material of the mesh should be use to render the effect.
  55479. * @param mesh defines the current mesh to render
  55480. */
  55481. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55482. /**
  55483. * Add a mesh to be rendered through its own material and not with emissive only.
  55484. * @param mesh The mesh for which we need to use its material
  55485. */
  55486. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55487. /**
  55488. * Remove a mesh from being rendered through its own material and not with emissive only.
  55489. * @param mesh The mesh for which we need to not use its material
  55490. */
  55491. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55492. /**
  55493. * Free any resources and references associated to a mesh.
  55494. * Internal use
  55495. * @param mesh The mesh to free.
  55496. * @hidden
  55497. */
  55498. _disposeMesh(mesh: Mesh): void;
  55499. /**
  55500. * Gets the class name of the effect layer
  55501. * @returns the string with the class name of the effect layer
  55502. */
  55503. getClassName(): string;
  55504. /**
  55505. * Serializes this glow layer
  55506. * @returns a serialized glow layer object
  55507. */
  55508. serialize(): any;
  55509. /**
  55510. * Creates a Glow Layer from parsed glow layer data
  55511. * @param parsedGlowLayer defines glow layer data
  55512. * @param scene defines the current scene
  55513. * @param rootUrl defines the root URL containing the glow layer information
  55514. * @returns a parsed Glow Layer
  55515. */
  55516. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55517. }
  55518. }
  55519. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55520. /** @hidden */
  55521. export var glowBlurPostProcessPixelShader: {
  55522. name: string;
  55523. shader: string;
  55524. };
  55525. }
  55526. declare module "babylonjs/Layers/highlightLayer" {
  55527. import { Observable } from "babylonjs/Misc/observable";
  55528. import { Nullable } from "babylonjs/types";
  55529. import { Camera } from "babylonjs/Cameras/camera";
  55530. import { Scene } from "babylonjs/scene";
  55531. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55533. import { Mesh } from "babylonjs/Meshes/mesh";
  55534. import { Effect } from "babylonjs/Materials/effect";
  55535. import { Material } from "babylonjs/Materials/material";
  55536. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55537. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55538. import "babylonjs/Shaders/glowMapMerge.fragment";
  55539. import "babylonjs/Shaders/glowMapMerge.vertex";
  55540. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55541. module "babylonjs/abstractScene" {
  55542. interface AbstractScene {
  55543. /**
  55544. * Return a the first highlight layer of the scene with a given name.
  55545. * @param name The name of the highlight layer to look for.
  55546. * @return The highlight layer if found otherwise null.
  55547. */
  55548. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55549. }
  55550. }
  55551. /**
  55552. * Highlight layer options. This helps customizing the behaviour
  55553. * of the highlight layer.
  55554. */
  55555. export interface IHighlightLayerOptions {
  55556. /**
  55557. * Multiplication factor apply to the canvas size to compute the render target size
  55558. * used to generated the glowing objects (the smaller the faster).
  55559. */
  55560. mainTextureRatio: number;
  55561. /**
  55562. * Enforces a fixed size texture to ensure resize independant blur.
  55563. */
  55564. mainTextureFixedSize?: number;
  55565. /**
  55566. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55567. * of the picture to blur (the smaller the faster).
  55568. */
  55569. blurTextureSizeRatio: number;
  55570. /**
  55571. * How big in texel of the blur texture is the vertical blur.
  55572. */
  55573. blurVerticalSize: number;
  55574. /**
  55575. * How big in texel of the blur texture is the horizontal blur.
  55576. */
  55577. blurHorizontalSize: number;
  55578. /**
  55579. * Alpha blending mode used to apply the blur. Default is combine.
  55580. */
  55581. alphaBlendingMode: number;
  55582. /**
  55583. * The camera attached to the layer.
  55584. */
  55585. camera: Nullable<Camera>;
  55586. /**
  55587. * Should we display highlight as a solid stroke?
  55588. */
  55589. isStroke?: boolean;
  55590. /**
  55591. * The rendering group to draw the layer in.
  55592. */
  55593. renderingGroupId: number;
  55594. }
  55595. /**
  55596. * The highlight layer Helps adding a glow effect around a mesh.
  55597. *
  55598. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55599. * glowy meshes to your scene.
  55600. *
  55601. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55602. */
  55603. export class HighlightLayer extends EffectLayer {
  55604. name: string;
  55605. /**
  55606. * Effect Name of the highlight layer.
  55607. */
  55608. static readonly EffectName: string;
  55609. /**
  55610. * The neutral color used during the preparation of the glow effect.
  55611. * This is black by default as the blend operation is a blend operation.
  55612. */
  55613. static NeutralColor: Color4;
  55614. /**
  55615. * Stencil value used for glowing meshes.
  55616. */
  55617. static GlowingMeshStencilReference: number;
  55618. /**
  55619. * Stencil value used for the other meshes in the scene.
  55620. */
  55621. static NormalMeshStencilReference: number;
  55622. /**
  55623. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55624. */
  55625. innerGlow: boolean;
  55626. /**
  55627. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55628. */
  55629. outerGlow: boolean;
  55630. /**
  55631. * Specifies the horizontal size of the blur.
  55632. */
  55633. set blurHorizontalSize(value: number);
  55634. /**
  55635. * Specifies the vertical size of the blur.
  55636. */
  55637. set blurVerticalSize(value: number);
  55638. /**
  55639. * Gets the horizontal size of the blur.
  55640. */
  55641. get blurHorizontalSize(): number;
  55642. /**
  55643. * Gets the vertical size of the blur.
  55644. */
  55645. get blurVerticalSize(): number;
  55646. /**
  55647. * An event triggered when the highlight layer is being blurred.
  55648. */
  55649. onBeforeBlurObservable: Observable<HighlightLayer>;
  55650. /**
  55651. * An event triggered when the highlight layer has been blurred.
  55652. */
  55653. onAfterBlurObservable: Observable<HighlightLayer>;
  55654. private _instanceGlowingMeshStencilReference;
  55655. private _options;
  55656. private _downSamplePostprocess;
  55657. private _horizontalBlurPostprocess;
  55658. private _verticalBlurPostprocess;
  55659. private _blurTexture;
  55660. private _meshes;
  55661. private _excludedMeshes;
  55662. /**
  55663. * Instantiates a new highlight Layer and references it to the scene..
  55664. * @param name The name of the layer
  55665. * @param scene The scene to use the layer in
  55666. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55667. */
  55668. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55669. /**
  55670. * Get the effect name of the layer.
  55671. * @return The effect name
  55672. */
  55673. getEffectName(): string;
  55674. /**
  55675. * Create the merge effect. This is the shader use to blit the information back
  55676. * to the main canvas at the end of the scene rendering.
  55677. */
  55678. protected _createMergeEffect(): Effect;
  55679. /**
  55680. * Creates the render target textures and post processes used in the highlight layer.
  55681. */
  55682. protected _createTextureAndPostProcesses(): void;
  55683. /**
  55684. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55685. */
  55686. needStencil(): boolean;
  55687. /**
  55688. * Checks for the readiness of the element composing the layer.
  55689. * @param subMesh the mesh to check for
  55690. * @param useInstances specify wether or not to use instances to render the mesh
  55691. * @param emissiveTexture the associated emissive texture used to generate the glow
  55692. * @return true if ready otherwise, false
  55693. */
  55694. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55695. /**
  55696. * Implementation specific of rendering the generating effect on the main canvas.
  55697. * @param effect The effect used to render through
  55698. */
  55699. protected _internalRender(effect: Effect): void;
  55700. /**
  55701. * Returns true if the layer contains information to display, otherwise false.
  55702. */
  55703. shouldRender(): boolean;
  55704. /**
  55705. * Returns true if the mesh should render, otherwise false.
  55706. * @param mesh The mesh to render
  55707. * @returns true if it should render otherwise false
  55708. */
  55709. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55710. /**
  55711. * Sets the required values for both the emissive texture and and the main color.
  55712. */
  55713. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55714. /**
  55715. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55716. * @param mesh The mesh to exclude from the highlight layer
  55717. */
  55718. addExcludedMesh(mesh: Mesh): void;
  55719. /**
  55720. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55721. * @param mesh The mesh to highlight
  55722. */
  55723. removeExcludedMesh(mesh: Mesh): void;
  55724. /**
  55725. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55726. * @param mesh mesh to test
  55727. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55728. */
  55729. hasMesh(mesh: AbstractMesh): boolean;
  55730. /**
  55731. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55732. * @param mesh The mesh to highlight
  55733. * @param color The color of the highlight
  55734. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55735. */
  55736. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55737. /**
  55738. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55739. * @param mesh The mesh to highlight
  55740. */
  55741. removeMesh(mesh: Mesh): void;
  55742. /**
  55743. * Force the stencil to the normal expected value for none glowing parts
  55744. */
  55745. private _defaultStencilReference;
  55746. /**
  55747. * Free any resources and references associated to a mesh.
  55748. * Internal use
  55749. * @param mesh The mesh to free.
  55750. * @hidden
  55751. */
  55752. _disposeMesh(mesh: Mesh): void;
  55753. /**
  55754. * Dispose the highlight layer and free resources.
  55755. */
  55756. dispose(): void;
  55757. /**
  55758. * Gets the class name of the effect layer
  55759. * @returns the string with the class name of the effect layer
  55760. */
  55761. getClassName(): string;
  55762. /**
  55763. * Serializes this Highlight layer
  55764. * @returns a serialized Highlight layer object
  55765. */
  55766. serialize(): any;
  55767. /**
  55768. * Creates a Highlight layer from parsed Highlight layer data
  55769. * @param parsedHightlightLayer defines the Highlight layer data
  55770. * @param scene defines the current scene
  55771. * @param rootUrl defines the root URL containing the Highlight layer information
  55772. * @returns a parsed Highlight layer
  55773. */
  55774. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55775. }
  55776. }
  55777. declare module "babylonjs/Layers/layerSceneComponent" {
  55778. import { Scene } from "babylonjs/scene";
  55779. import { ISceneComponent } from "babylonjs/sceneComponent";
  55780. import { Layer } from "babylonjs/Layers/layer";
  55781. import { AbstractScene } from "babylonjs/abstractScene";
  55782. module "babylonjs/abstractScene" {
  55783. interface AbstractScene {
  55784. /**
  55785. * The list of layers (background and foreground) of the scene
  55786. */
  55787. layers: Array<Layer>;
  55788. }
  55789. }
  55790. /**
  55791. * Defines the layer scene component responsible to manage any layers
  55792. * in a given scene.
  55793. */
  55794. export class LayerSceneComponent implements ISceneComponent {
  55795. /**
  55796. * The component name helpfull to identify the component in the list of scene components.
  55797. */
  55798. readonly name: string;
  55799. /**
  55800. * The scene the component belongs to.
  55801. */
  55802. scene: Scene;
  55803. private _engine;
  55804. /**
  55805. * Creates a new instance of the component for the given scene
  55806. * @param scene Defines the scene to register the component in
  55807. */
  55808. constructor(scene: Scene);
  55809. /**
  55810. * Registers the component in a given scene
  55811. */
  55812. register(): void;
  55813. /**
  55814. * Rebuilds the elements related to this component in case of
  55815. * context lost for instance.
  55816. */
  55817. rebuild(): void;
  55818. /**
  55819. * Disposes the component and the associated ressources.
  55820. */
  55821. dispose(): void;
  55822. private _draw;
  55823. private _drawCameraPredicate;
  55824. private _drawCameraBackground;
  55825. private _drawCameraForeground;
  55826. private _drawRenderTargetPredicate;
  55827. private _drawRenderTargetBackground;
  55828. private _drawRenderTargetForeground;
  55829. /**
  55830. * Adds all the elements from the container to the scene
  55831. * @param container the container holding the elements
  55832. */
  55833. addFromContainer(container: AbstractScene): void;
  55834. /**
  55835. * Removes all the elements in the container from the scene
  55836. * @param container contains the elements to remove
  55837. * @param dispose if the removed element should be disposed (default: false)
  55838. */
  55839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55840. }
  55841. }
  55842. declare module "babylonjs/Shaders/layer.fragment" {
  55843. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55844. /** @hidden */
  55845. export var layerPixelShader: {
  55846. name: string;
  55847. shader: string;
  55848. };
  55849. }
  55850. declare module "babylonjs/Shaders/layer.vertex" {
  55851. /** @hidden */
  55852. export var layerVertexShader: {
  55853. name: string;
  55854. shader: string;
  55855. };
  55856. }
  55857. declare module "babylonjs/Layers/layer" {
  55858. import { Observable } from "babylonjs/Misc/observable";
  55859. import { Nullable } from "babylonjs/types";
  55860. import { Scene } from "babylonjs/scene";
  55861. import { Vector2 } from "babylonjs/Maths/math.vector";
  55862. import { Color4 } from "babylonjs/Maths/math.color";
  55863. import { Texture } from "babylonjs/Materials/Textures/texture";
  55864. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55865. import "babylonjs/Shaders/layer.fragment";
  55866. import "babylonjs/Shaders/layer.vertex";
  55867. /**
  55868. * This represents a full screen 2d layer.
  55869. * This can be useful to display a picture in the background of your scene for instance.
  55870. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55871. */
  55872. export class Layer {
  55873. /**
  55874. * Define the name of the layer.
  55875. */
  55876. name: string;
  55877. /**
  55878. * Define the texture the layer should display.
  55879. */
  55880. texture: Nullable<Texture>;
  55881. /**
  55882. * Is the layer in background or foreground.
  55883. */
  55884. isBackground: boolean;
  55885. /**
  55886. * Define the color of the layer (instead of texture).
  55887. */
  55888. color: Color4;
  55889. /**
  55890. * Define the scale of the layer in order to zoom in out of the texture.
  55891. */
  55892. scale: Vector2;
  55893. /**
  55894. * Define an offset for the layer in order to shift the texture.
  55895. */
  55896. offset: Vector2;
  55897. /**
  55898. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55899. */
  55900. alphaBlendingMode: number;
  55901. /**
  55902. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55903. * Alpha test will not mix with the background color in case of transparency.
  55904. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55905. */
  55906. alphaTest: boolean;
  55907. /**
  55908. * Define a mask to restrict the layer to only some of the scene cameras.
  55909. */
  55910. layerMask: number;
  55911. /**
  55912. * Define the list of render target the layer is visible into.
  55913. */
  55914. renderTargetTextures: RenderTargetTexture[];
  55915. /**
  55916. * Define if the layer is only used in renderTarget or if it also
  55917. * renders in the main frame buffer of the canvas.
  55918. */
  55919. renderOnlyInRenderTargetTextures: boolean;
  55920. private _scene;
  55921. private _vertexBuffers;
  55922. private _indexBuffer;
  55923. private _effect;
  55924. private _previousDefines;
  55925. /**
  55926. * An event triggered when the layer is disposed.
  55927. */
  55928. onDisposeObservable: Observable<Layer>;
  55929. private _onDisposeObserver;
  55930. /**
  55931. * Back compatibility with callback before the onDisposeObservable existed.
  55932. * The set callback will be triggered when the layer has been disposed.
  55933. */
  55934. set onDispose(callback: () => void);
  55935. /**
  55936. * An event triggered before rendering the scene
  55937. */
  55938. onBeforeRenderObservable: Observable<Layer>;
  55939. private _onBeforeRenderObserver;
  55940. /**
  55941. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55942. * The set callback will be triggered just before rendering the layer.
  55943. */
  55944. set onBeforeRender(callback: () => void);
  55945. /**
  55946. * An event triggered after rendering the scene
  55947. */
  55948. onAfterRenderObservable: Observable<Layer>;
  55949. private _onAfterRenderObserver;
  55950. /**
  55951. * Back compatibility with callback before the onAfterRenderObservable existed.
  55952. * The set callback will be triggered just after rendering the layer.
  55953. */
  55954. set onAfterRender(callback: () => void);
  55955. /**
  55956. * Instantiates a new layer.
  55957. * This represents a full screen 2d layer.
  55958. * This can be useful to display a picture in the background of your scene for instance.
  55959. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55960. * @param name Define the name of the layer in the scene
  55961. * @param imgUrl Define the url of the texture to display in the layer
  55962. * @param scene Define the scene the layer belongs to
  55963. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55964. * @param color Defines a color for the layer
  55965. */
  55966. constructor(
  55967. /**
  55968. * Define the name of the layer.
  55969. */
  55970. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55971. private _createIndexBuffer;
  55972. /** @hidden */
  55973. _rebuild(): void;
  55974. /**
  55975. * Renders the layer in the scene.
  55976. */
  55977. render(): void;
  55978. /**
  55979. * Disposes and releases the associated ressources.
  55980. */
  55981. dispose(): void;
  55982. }
  55983. }
  55984. declare module "babylonjs/Layers/index" {
  55985. export * from "babylonjs/Layers/effectLayer";
  55986. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55987. export * from "babylonjs/Layers/glowLayer";
  55988. export * from "babylonjs/Layers/highlightLayer";
  55989. export * from "babylonjs/Layers/layer";
  55990. export * from "babylonjs/Layers/layerSceneComponent";
  55991. }
  55992. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55993. /** @hidden */
  55994. export var lensFlarePixelShader: {
  55995. name: string;
  55996. shader: string;
  55997. };
  55998. }
  55999. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56000. /** @hidden */
  56001. export var lensFlareVertexShader: {
  56002. name: string;
  56003. shader: string;
  56004. };
  56005. }
  56006. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56007. import { Scene } from "babylonjs/scene";
  56008. import { Vector3 } from "babylonjs/Maths/math.vector";
  56009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56010. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56011. import "babylonjs/Shaders/lensFlare.fragment";
  56012. import "babylonjs/Shaders/lensFlare.vertex";
  56013. import { Viewport } from "babylonjs/Maths/math.viewport";
  56014. /**
  56015. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56016. * It is usually composed of several `lensFlare`.
  56017. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56018. */
  56019. export class LensFlareSystem {
  56020. /**
  56021. * Define the name of the lens flare system
  56022. */
  56023. name: string;
  56024. /**
  56025. * List of lens flares used in this system.
  56026. */
  56027. lensFlares: LensFlare[];
  56028. /**
  56029. * Define a limit from the border the lens flare can be visible.
  56030. */
  56031. borderLimit: number;
  56032. /**
  56033. * Define a viewport border we do not want to see the lens flare in.
  56034. */
  56035. viewportBorder: number;
  56036. /**
  56037. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56038. */
  56039. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56040. /**
  56041. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56042. */
  56043. layerMask: number;
  56044. /**
  56045. * Define the id of the lens flare system in the scene.
  56046. * (equal to name by default)
  56047. */
  56048. id: string;
  56049. private _scene;
  56050. private _emitter;
  56051. private _vertexBuffers;
  56052. private _indexBuffer;
  56053. private _effect;
  56054. private _positionX;
  56055. private _positionY;
  56056. private _isEnabled;
  56057. /** @hidden */
  56058. static _SceneComponentInitialization: (scene: Scene) => void;
  56059. /**
  56060. * Instantiates a lens flare system.
  56061. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56062. * It is usually composed of several `lensFlare`.
  56063. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56064. * @param name Define the name of the lens flare system in the scene
  56065. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56066. * @param scene Define the scene the lens flare system belongs to
  56067. */
  56068. constructor(
  56069. /**
  56070. * Define the name of the lens flare system
  56071. */
  56072. name: string, emitter: any, scene: Scene);
  56073. /**
  56074. * Define if the lens flare system is enabled.
  56075. */
  56076. get isEnabled(): boolean;
  56077. set isEnabled(value: boolean);
  56078. /**
  56079. * Get the scene the effects belongs to.
  56080. * @returns the scene holding the lens flare system
  56081. */
  56082. getScene(): Scene;
  56083. /**
  56084. * Get the emitter of the lens flare system.
  56085. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56086. * @returns the emitter of the lens flare system
  56087. */
  56088. getEmitter(): any;
  56089. /**
  56090. * Set the emitter of the lens flare system.
  56091. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56092. * @param newEmitter Define the new emitter of the system
  56093. */
  56094. setEmitter(newEmitter: any): void;
  56095. /**
  56096. * Get the lens flare system emitter position.
  56097. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56098. * @returns the position
  56099. */
  56100. getEmitterPosition(): Vector3;
  56101. /**
  56102. * @hidden
  56103. */
  56104. computeEffectivePosition(globalViewport: Viewport): boolean;
  56105. /** @hidden */
  56106. _isVisible(): boolean;
  56107. /**
  56108. * @hidden
  56109. */
  56110. render(): boolean;
  56111. /**
  56112. * Dispose and release the lens flare with its associated resources.
  56113. */
  56114. dispose(): void;
  56115. /**
  56116. * Parse a lens flare system from a JSON repressentation
  56117. * @param parsedLensFlareSystem Define the JSON to parse
  56118. * @param scene Define the scene the parsed system should be instantiated in
  56119. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56120. * @returns the parsed system
  56121. */
  56122. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56123. /**
  56124. * Serialize the current Lens Flare System into a JSON representation.
  56125. * @returns the serialized JSON
  56126. */
  56127. serialize(): any;
  56128. }
  56129. }
  56130. declare module "babylonjs/LensFlares/lensFlare" {
  56131. import { Nullable } from "babylonjs/types";
  56132. import { Color3 } from "babylonjs/Maths/math.color";
  56133. import { Texture } from "babylonjs/Materials/Textures/texture";
  56134. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56135. /**
  56136. * This represents one of the lens effect in a `lensFlareSystem`.
  56137. * It controls one of the indiviual texture used in the effect.
  56138. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56139. */
  56140. export class LensFlare {
  56141. /**
  56142. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56143. */
  56144. size: number;
  56145. /**
  56146. * 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.
  56147. */
  56148. position: number;
  56149. /**
  56150. * Define the lens color.
  56151. */
  56152. color: Color3;
  56153. /**
  56154. * Define the lens texture.
  56155. */
  56156. texture: Nullable<Texture>;
  56157. /**
  56158. * Define the alpha mode to render this particular lens.
  56159. */
  56160. alphaMode: number;
  56161. private _system;
  56162. /**
  56163. * Creates a new Lens Flare.
  56164. * This represents one of the lens effect in a `lensFlareSystem`.
  56165. * It controls one of the indiviual texture used in the effect.
  56166. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56167. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56168. * @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.
  56169. * @param color Define the lens color
  56170. * @param imgUrl Define the lens texture url
  56171. * @param system Define the `lensFlareSystem` this flare is part of
  56172. * @returns The newly created Lens Flare
  56173. */
  56174. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56175. /**
  56176. * Instantiates a new Lens Flare.
  56177. * This represents one of the lens effect in a `lensFlareSystem`.
  56178. * It controls one of the indiviual texture used in the effect.
  56179. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56180. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56181. * @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.
  56182. * @param color Define the lens color
  56183. * @param imgUrl Define the lens texture url
  56184. * @param system Define the `lensFlareSystem` this flare is part of
  56185. */
  56186. constructor(
  56187. /**
  56188. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56189. */
  56190. size: number,
  56191. /**
  56192. * 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.
  56193. */
  56194. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56195. /**
  56196. * Dispose and release the lens flare with its associated resources.
  56197. */
  56198. dispose(): void;
  56199. }
  56200. }
  56201. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56202. import { Nullable } from "babylonjs/types";
  56203. import { Scene } from "babylonjs/scene";
  56204. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56205. import { AbstractScene } from "babylonjs/abstractScene";
  56206. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56207. module "babylonjs/abstractScene" {
  56208. interface AbstractScene {
  56209. /**
  56210. * The list of lens flare system added to the scene
  56211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56212. */
  56213. lensFlareSystems: Array<LensFlareSystem>;
  56214. /**
  56215. * Removes the given lens flare system from this scene.
  56216. * @param toRemove The lens flare system to remove
  56217. * @returns The index of the removed lens flare system
  56218. */
  56219. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56220. /**
  56221. * Adds the given lens flare system to this scene
  56222. * @param newLensFlareSystem The lens flare system to add
  56223. */
  56224. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56225. /**
  56226. * Gets a lens flare system using its name
  56227. * @param name defines the name to look for
  56228. * @returns the lens flare system or null if not found
  56229. */
  56230. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56231. /**
  56232. * Gets a lens flare system using its id
  56233. * @param id defines the id to look for
  56234. * @returns the lens flare system or null if not found
  56235. */
  56236. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56237. }
  56238. }
  56239. /**
  56240. * Defines the lens flare scene component responsible to manage any lens flares
  56241. * in a given scene.
  56242. */
  56243. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56244. /**
  56245. * The component name helpfull to identify the component in the list of scene components.
  56246. */
  56247. readonly name: string;
  56248. /**
  56249. * The scene the component belongs to.
  56250. */
  56251. scene: Scene;
  56252. /**
  56253. * Creates a new instance of the component for the given scene
  56254. * @param scene Defines the scene to register the component in
  56255. */
  56256. constructor(scene: Scene);
  56257. /**
  56258. * Registers the component in a given scene
  56259. */
  56260. register(): void;
  56261. /**
  56262. * Rebuilds the elements related to this component in case of
  56263. * context lost for instance.
  56264. */
  56265. rebuild(): void;
  56266. /**
  56267. * Adds all the elements from the container to the scene
  56268. * @param container the container holding the elements
  56269. */
  56270. addFromContainer(container: AbstractScene): void;
  56271. /**
  56272. * Removes all the elements in the container from the scene
  56273. * @param container contains the elements to remove
  56274. * @param dispose if the removed element should be disposed (default: false)
  56275. */
  56276. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56277. /**
  56278. * Serializes the component data to the specified json object
  56279. * @param serializationObject The object to serialize to
  56280. */
  56281. serialize(serializationObject: any): void;
  56282. /**
  56283. * Disposes the component and the associated ressources.
  56284. */
  56285. dispose(): void;
  56286. private _draw;
  56287. }
  56288. }
  56289. declare module "babylonjs/LensFlares/index" {
  56290. export * from "babylonjs/LensFlares/lensFlare";
  56291. export * from "babylonjs/LensFlares/lensFlareSystem";
  56292. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56293. }
  56294. declare module "babylonjs/Shaders/depth.fragment" {
  56295. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56296. /** @hidden */
  56297. export var depthPixelShader: {
  56298. name: string;
  56299. shader: string;
  56300. };
  56301. }
  56302. declare module "babylonjs/Shaders/depth.vertex" {
  56303. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56304. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56305. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56306. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56308. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56309. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56310. /** @hidden */
  56311. export var depthVertexShader: {
  56312. name: string;
  56313. shader: string;
  56314. };
  56315. }
  56316. declare module "babylonjs/Rendering/depthRenderer" {
  56317. import { Nullable } from "babylonjs/types";
  56318. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56319. import { Scene } from "babylonjs/scene";
  56320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56321. import { Camera } from "babylonjs/Cameras/camera";
  56322. import "babylonjs/Shaders/depth.fragment";
  56323. import "babylonjs/Shaders/depth.vertex";
  56324. /**
  56325. * This represents a depth renderer in Babylon.
  56326. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56327. */
  56328. export class DepthRenderer {
  56329. private _scene;
  56330. private _depthMap;
  56331. private _effect;
  56332. private readonly _storeNonLinearDepth;
  56333. private readonly _clearColor;
  56334. /** Get if the depth renderer is using packed depth or not */
  56335. readonly isPacked: boolean;
  56336. private _cachedDefines;
  56337. private _camera;
  56338. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56339. enabled: boolean;
  56340. /**
  56341. * Specifiess that the depth renderer will only be used within
  56342. * the camera it is created for.
  56343. * This can help forcing its rendering during the camera processing.
  56344. */
  56345. useOnlyInActiveCamera: boolean;
  56346. /** @hidden */
  56347. static _SceneComponentInitialization: (scene: Scene) => void;
  56348. /**
  56349. * Instantiates a depth renderer
  56350. * @param scene The scene the renderer belongs to
  56351. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56352. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56353. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56354. */
  56355. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56356. /**
  56357. * Creates the depth rendering effect and checks if the effect is ready.
  56358. * @param subMesh The submesh to be used to render the depth map of
  56359. * @param useInstances If multiple world instances should be used
  56360. * @returns if the depth renderer is ready to render the depth map
  56361. */
  56362. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56363. /**
  56364. * Gets the texture which the depth map will be written to.
  56365. * @returns The depth map texture
  56366. */
  56367. getDepthMap(): RenderTargetTexture;
  56368. /**
  56369. * Disposes of the depth renderer.
  56370. */
  56371. dispose(): void;
  56372. }
  56373. }
  56374. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56375. /** @hidden */
  56376. export var minmaxReduxPixelShader: {
  56377. name: string;
  56378. shader: string;
  56379. };
  56380. }
  56381. declare module "babylonjs/Misc/minMaxReducer" {
  56382. import { Nullable } from "babylonjs/types";
  56383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56384. import { Camera } from "babylonjs/Cameras/camera";
  56385. import { Observer } from "babylonjs/Misc/observable";
  56386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56387. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56388. import { Observable } from "babylonjs/Misc/observable";
  56389. import "babylonjs/Shaders/minmaxRedux.fragment";
  56390. /**
  56391. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56392. * and maximum values from all values of the texture.
  56393. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56394. * The source values are read from the red channel of the texture.
  56395. */
  56396. export class MinMaxReducer {
  56397. /**
  56398. * Observable triggered when the computation has been performed
  56399. */
  56400. onAfterReductionPerformed: Observable<{
  56401. min: number;
  56402. max: number;
  56403. }>;
  56404. protected _camera: Camera;
  56405. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56406. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56407. protected _postProcessManager: PostProcessManager;
  56408. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56409. protected _forceFullscreenViewport: boolean;
  56410. /**
  56411. * Creates a min/max reducer
  56412. * @param camera The camera to use for the post processes
  56413. */
  56414. constructor(camera: Camera);
  56415. /**
  56416. * Gets the texture used to read the values from.
  56417. */
  56418. get sourceTexture(): Nullable<RenderTargetTexture>;
  56419. /**
  56420. * Sets the source texture to read the values from.
  56421. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56422. * because in such textures '1' value must not be taken into account to compute the maximum
  56423. * as this value is used to clear the texture.
  56424. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56425. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56426. * @param depthRedux Indicates if the texture is a depth texture or not
  56427. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56428. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56429. */
  56430. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56431. /**
  56432. * Defines the refresh rate of the computation.
  56433. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56434. */
  56435. get refreshRate(): number;
  56436. set refreshRate(value: number);
  56437. protected _activated: boolean;
  56438. /**
  56439. * Gets the activation status of the reducer
  56440. */
  56441. get activated(): boolean;
  56442. /**
  56443. * Activates the reduction computation.
  56444. * When activated, the observers registered in onAfterReductionPerformed are
  56445. * called after the compuation is performed
  56446. */
  56447. activate(): void;
  56448. /**
  56449. * Deactivates the reduction computation.
  56450. */
  56451. deactivate(): void;
  56452. /**
  56453. * Disposes the min/max reducer
  56454. * @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.
  56455. */
  56456. dispose(disposeAll?: boolean): void;
  56457. }
  56458. }
  56459. declare module "babylonjs/Misc/depthReducer" {
  56460. import { Nullable } from "babylonjs/types";
  56461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56462. import { Camera } from "babylonjs/Cameras/camera";
  56463. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56464. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56465. /**
  56466. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56467. */
  56468. export class DepthReducer extends MinMaxReducer {
  56469. private _depthRenderer;
  56470. private _depthRendererId;
  56471. /**
  56472. * Gets the depth renderer used for the computation.
  56473. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56474. */
  56475. get depthRenderer(): Nullable<DepthRenderer>;
  56476. /**
  56477. * Creates a depth reducer
  56478. * @param camera The camera used to render the depth texture
  56479. */
  56480. constructor(camera: Camera);
  56481. /**
  56482. * Sets the depth renderer to use to generate the depth map
  56483. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56484. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56485. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56486. */
  56487. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56488. /** @hidden */
  56489. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56490. /**
  56491. * Activates the reduction computation.
  56492. * When activated, the observers registered in onAfterReductionPerformed are
  56493. * called after the compuation is performed
  56494. */
  56495. activate(): void;
  56496. /**
  56497. * Deactivates the reduction computation.
  56498. */
  56499. deactivate(): void;
  56500. /**
  56501. * Disposes the depth reducer
  56502. * @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.
  56503. */
  56504. dispose(disposeAll?: boolean): void;
  56505. }
  56506. }
  56507. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56508. import { Nullable } from "babylonjs/types";
  56509. import { Scene } from "babylonjs/scene";
  56510. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56511. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56512. import { Effect } from "babylonjs/Materials/effect";
  56513. import "babylonjs/Shaders/shadowMap.fragment";
  56514. import "babylonjs/Shaders/shadowMap.vertex";
  56515. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56516. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56517. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56518. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56519. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56520. /**
  56521. * A CSM implementation allowing casting shadows on large scenes.
  56522. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56523. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56524. */
  56525. export class CascadedShadowGenerator extends ShadowGenerator {
  56526. private static readonly frustumCornersNDCSpace;
  56527. /**
  56528. * Name of the CSM class
  56529. */
  56530. static CLASSNAME: string;
  56531. /**
  56532. * Defines the default number of cascades used by the CSM.
  56533. */
  56534. static readonly DEFAULT_CASCADES_COUNT: number;
  56535. /**
  56536. * Defines the minimum number of cascades used by the CSM.
  56537. */
  56538. static readonly MIN_CASCADES_COUNT: number;
  56539. /**
  56540. * Defines the maximum number of cascades used by the CSM.
  56541. */
  56542. static readonly MAX_CASCADES_COUNT: number;
  56543. protected _validateFilter(filter: number): number;
  56544. /**
  56545. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56546. */
  56547. penumbraDarkness: number;
  56548. private _numCascades;
  56549. /**
  56550. * Gets or set the number of cascades used by the CSM.
  56551. */
  56552. get numCascades(): number;
  56553. set numCascades(value: number);
  56554. /**
  56555. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56556. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56557. */
  56558. stabilizeCascades: boolean;
  56559. private _freezeShadowCastersBoundingInfo;
  56560. private _freezeShadowCastersBoundingInfoObservable;
  56561. /**
  56562. * Enables or disables the shadow casters bounding info computation.
  56563. * If your shadow casters don't move, you can disable this feature.
  56564. * If it is enabled, the bounding box computation is done every frame.
  56565. */
  56566. get freezeShadowCastersBoundingInfo(): boolean;
  56567. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56568. private _scbiMin;
  56569. private _scbiMax;
  56570. protected _computeShadowCastersBoundingInfo(): void;
  56571. protected _shadowCastersBoundingInfo: BoundingInfo;
  56572. /**
  56573. * Gets or sets the shadow casters bounding info.
  56574. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56575. * so that the system won't overwrite the bounds you provide
  56576. */
  56577. get shadowCastersBoundingInfo(): BoundingInfo;
  56578. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56579. protected _breaksAreDirty: boolean;
  56580. protected _minDistance: number;
  56581. protected _maxDistance: number;
  56582. /**
  56583. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56584. *
  56585. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56586. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56587. * @param min minimal distance for the breaks (default to 0.)
  56588. * @param max maximal distance for the breaks (default to 1.)
  56589. */
  56590. setMinMaxDistance(min: number, max: number): void;
  56591. /** Gets the minimal distance used in the cascade break computation */
  56592. get minDistance(): number;
  56593. /** Gets the maximal distance used in the cascade break computation */
  56594. get maxDistance(): number;
  56595. /**
  56596. * Gets the class name of that object
  56597. * @returns "CascadedShadowGenerator"
  56598. */
  56599. getClassName(): string;
  56600. private _cascadeMinExtents;
  56601. private _cascadeMaxExtents;
  56602. /**
  56603. * Gets a cascade minimum extents
  56604. * @param cascadeIndex index of the cascade
  56605. * @returns the minimum cascade extents
  56606. */
  56607. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56608. /**
  56609. * Gets a cascade maximum extents
  56610. * @param cascadeIndex index of the cascade
  56611. * @returns the maximum cascade extents
  56612. */
  56613. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56614. private _cascades;
  56615. private _currentLayer;
  56616. private _viewSpaceFrustumsZ;
  56617. private _viewMatrices;
  56618. private _projectionMatrices;
  56619. private _transformMatrices;
  56620. private _transformMatricesAsArray;
  56621. private _frustumLengths;
  56622. private _lightSizeUVCorrection;
  56623. private _depthCorrection;
  56624. private _frustumCornersWorldSpace;
  56625. private _frustumCenter;
  56626. private _shadowCameraPos;
  56627. private _shadowMaxZ;
  56628. /**
  56629. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56630. * It defaults to camera.maxZ
  56631. */
  56632. get shadowMaxZ(): number;
  56633. /**
  56634. * Sets the shadow max z distance.
  56635. */
  56636. set shadowMaxZ(value: number);
  56637. protected _debug: boolean;
  56638. /**
  56639. * Gets or sets the debug flag.
  56640. * When enabled, the cascades are materialized by different colors on the screen.
  56641. */
  56642. get debug(): boolean;
  56643. set debug(dbg: boolean);
  56644. private _depthClamp;
  56645. /**
  56646. * Gets or sets the depth clamping value.
  56647. *
  56648. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56649. * to account for the shadow casters far away.
  56650. *
  56651. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56652. */
  56653. get depthClamp(): boolean;
  56654. set depthClamp(value: boolean);
  56655. private _cascadeBlendPercentage;
  56656. /**
  56657. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56658. * It defaults to 0.1 (10% blending).
  56659. */
  56660. get cascadeBlendPercentage(): number;
  56661. set cascadeBlendPercentage(value: number);
  56662. private _lambda;
  56663. /**
  56664. * Gets or set the lambda parameter.
  56665. * This parameter is used to split the camera frustum and create the cascades.
  56666. * 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.
  56667. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56668. */
  56669. get lambda(): number;
  56670. set lambda(value: number);
  56671. /**
  56672. * Gets the view matrix corresponding to a given cascade
  56673. * @param cascadeNum cascade to retrieve the view matrix from
  56674. * @returns the cascade view matrix
  56675. */
  56676. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56677. /**
  56678. * Gets the projection matrix corresponding to a given cascade
  56679. * @param cascadeNum cascade to retrieve the projection matrix from
  56680. * @returns the cascade projection matrix
  56681. */
  56682. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56683. /**
  56684. * Gets the transformation matrix corresponding to a given cascade
  56685. * @param cascadeNum cascade to retrieve the transformation matrix from
  56686. * @returns the cascade transformation matrix
  56687. */
  56688. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56689. private _depthRenderer;
  56690. /**
  56691. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56692. *
  56693. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56694. *
  56695. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56696. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56697. * @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
  56698. */
  56699. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56700. private _depthReducer;
  56701. private _autoCalcDepthBounds;
  56702. /**
  56703. * Gets or sets the autoCalcDepthBounds property.
  56704. *
  56705. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56706. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56707. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56708. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56709. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56710. */
  56711. get autoCalcDepthBounds(): boolean;
  56712. set autoCalcDepthBounds(value: boolean);
  56713. /**
  56714. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56715. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56716. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56717. * for setting the refresh rate on the renderer yourself!
  56718. */
  56719. get autoCalcDepthBoundsRefreshRate(): number;
  56720. set autoCalcDepthBoundsRefreshRate(value: number);
  56721. /**
  56722. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56723. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56724. * you change the camera near/far planes!
  56725. */
  56726. splitFrustum(): void;
  56727. private _splitFrustum;
  56728. private _computeMatrices;
  56729. private _computeFrustumInWorldSpace;
  56730. private _computeCascadeFrustum;
  56731. /** @hidden */
  56732. static _SceneComponentInitialization: (scene: Scene) => void;
  56733. /**
  56734. * Creates a Cascaded Shadow Generator object.
  56735. * A ShadowGenerator is the required tool to use the shadows.
  56736. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56737. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56738. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56739. * @param light The directional light object generating the shadows.
  56740. * @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.
  56741. */
  56742. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56743. protected _initializeGenerator(): void;
  56744. protected _createTargetRenderTexture(): void;
  56745. protected _initializeShadowMap(): void;
  56746. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56747. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56748. /**
  56749. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56750. * @param defines Defines of the material we want to update
  56751. * @param lightIndex Index of the light in the enabled light list of the material
  56752. */
  56753. prepareDefines(defines: any, lightIndex: number): void;
  56754. /**
  56755. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56756. * defined in the generator but impacting the effect).
  56757. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56758. * @param effect The effect we are binfing the information for
  56759. */
  56760. bindShadowLight(lightIndex: string, effect: Effect): void;
  56761. /**
  56762. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56763. * (eq to view projection * shadow projection matrices)
  56764. * @returns The transform matrix used to create the shadow map
  56765. */
  56766. getTransformMatrix(): Matrix;
  56767. /**
  56768. * Disposes the ShadowGenerator.
  56769. * Returns nothing.
  56770. */
  56771. dispose(): void;
  56772. /**
  56773. * Serializes the shadow generator setup to a json object.
  56774. * @returns The serialized JSON object
  56775. */
  56776. serialize(): any;
  56777. /**
  56778. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56779. * @param parsedShadowGenerator The JSON object to parse
  56780. * @param scene The scene to create the shadow map for
  56781. * @returns The parsed shadow generator
  56782. */
  56783. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56784. }
  56785. }
  56786. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56787. import { Scene } from "babylonjs/scene";
  56788. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56789. import { AbstractScene } from "babylonjs/abstractScene";
  56790. /**
  56791. * Defines the shadow generator component responsible to manage any shadow generators
  56792. * in a given scene.
  56793. */
  56794. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56795. /**
  56796. * The component name helpfull to identify the component in the list of scene components.
  56797. */
  56798. readonly name: string;
  56799. /**
  56800. * The scene the component belongs to.
  56801. */
  56802. scene: Scene;
  56803. /**
  56804. * Creates a new instance of the component for the given scene
  56805. * @param scene Defines the scene to register the component in
  56806. */
  56807. constructor(scene: Scene);
  56808. /**
  56809. * Registers the component in a given scene
  56810. */
  56811. register(): void;
  56812. /**
  56813. * Rebuilds the elements related to this component in case of
  56814. * context lost for instance.
  56815. */
  56816. rebuild(): void;
  56817. /**
  56818. * Serializes the component data to the specified json object
  56819. * @param serializationObject The object to serialize to
  56820. */
  56821. serialize(serializationObject: any): void;
  56822. /**
  56823. * Adds all the elements from the container to the scene
  56824. * @param container the container holding the elements
  56825. */
  56826. addFromContainer(container: AbstractScene): void;
  56827. /**
  56828. * Removes all the elements in the container from the scene
  56829. * @param container contains the elements to remove
  56830. * @param dispose if the removed element should be disposed (default: false)
  56831. */
  56832. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56833. /**
  56834. * Rebuilds the elements related to this component in case of
  56835. * context lost for instance.
  56836. */
  56837. dispose(): void;
  56838. private _gatherRenderTargets;
  56839. }
  56840. }
  56841. declare module "babylonjs/Lights/Shadows/index" {
  56842. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56843. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56844. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56845. }
  56846. declare module "babylonjs/Lights/pointLight" {
  56847. import { Scene } from "babylonjs/scene";
  56848. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56850. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56851. import { Effect } from "babylonjs/Materials/effect";
  56852. /**
  56853. * A point light is a light defined by an unique point in world space.
  56854. * The light is emitted in every direction from this point.
  56855. * A good example of a point light is a standard light bulb.
  56856. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56857. */
  56858. export class PointLight extends ShadowLight {
  56859. private _shadowAngle;
  56860. /**
  56861. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56862. * This specifies what angle the shadow will use to be created.
  56863. *
  56864. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56865. */
  56866. get shadowAngle(): number;
  56867. /**
  56868. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56869. * This specifies what angle the shadow will use to be created.
  56870. *
  56871. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56872. */
  56873. set shadowAngle(value: number);
  56874. /**
  56875. * Gets the direction if it has been set.
  56876. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56877. */
  56878. get direction(): Vector3;
  56879. /**
  56880. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56881. */
  56882. set direction(value: Vector3);
  56883. /**
  56884. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56885. * A PointLight emits the light in every direction.
  56886. * It can cast shadows.
  56887. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56888. * ```javascript
  56889. * var pointLight = new PointLight("pl", camera.position, scene);
  56890. * ```
  56891. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56892. * @param name The light friendly name
  56893. * @param position The position of the point light in the scene
  56894. * @param scene The scene the lights belongs to
  56895. */
  56896. constructor(name: string, position: Vector3, scene: Scene);
  56897. /**
  56898. * Returns the string "PointLight"
  56899. * @returns the class name
  56900. */
  56901. getClassName(): string;
  56902. /**
  56903. * Returns the integer 0.
  56904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56905. */
  56906. getTypeID(): number;
  56907. /**
  56908. * Specifies wether or not the shadowmap should be a cube texture.
  56909. * @returns true if the shadowmap needs to be a cube texture.
  56910. */
  56911. needCube(): boolean;
  56912. /**
  56913. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56914. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56915. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56916. */
  56917. getShadowDirection(faceIndex?: number): Vector3;
  56918. /**
  56919. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56920. * - fov = PI / 2
  56921. * - aspect ratio : 1.0
  56922. * - z-near and far equal to the active camera minZ and maxZ.
  56923. * Returns the PointLight.
  56924. */
  56925. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56926. protected _buildUniformLayout(): void;
  56927. /**
  56928. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56929. * @param effect The effect to update
  56930. * @param lightIndex The index of the light in the effect to update
  56931. * @returns The point light
  56932. */
  56933. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56934. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56935. /**
  56936. * Prepares the list of defines specific to the light type.
  56937. * @param defines the list of defines
  56938. * @param lightIndex defines the index of the light for the effect
  56939. */
  56940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56941. }
  56942. }
  56943. declare module "babylonjs/Lights/index" {
  56944. export * from "babylonjs/Lights/light";
  56945. export * from "babylonjs/Lights/shadowLight";
  56946. export * from "babylonjs/Lights/Shadows/index";
  56947. export * from "babylonjs/Lights/directionalLight";
  56948. export * from "babylonjs/Lights/hemisphericLight";
  56949. export * from "babylonjs/Lights/pointLight";
  56950. export * from "babylonjs/Lights/spotLight";
  56951. }
  56952. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56953. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56954. /**
  56955. * Header information of HDR texture files.
  56956. */
  56957. export interface HDRInfo {
  56958. /**
  56959. * The height of the texture in pixels.
  56960. */
  56961. height: number;
  56962. /**
  56963. * The width of the texture in pixels.
  56964. */
  56965. width: number;
  56966. /**
  56967. * The index of the beginning of the data in the binary file.
  56968. */
  56969. dataPosition: number;
  56970. }
  56971. /**
  56972. * This groups tools to convert HDR texture to native colors array.
  56973. */
  56974. export class HDRTools {
  56975. private static Ldexp;
  56976. private static Rgbe2float;
  56977. private static readStringLine;
  56978. /**
  56979. * Reads header information from an RGBE texture stored in a native array.
  56980. * More information on this format are available here:
  56981. * https://en.wikipedia.org/wiki/RGBE_image_format
  56982. *
  56983. * @param uint8array The binary file stored in native array.
  56984. * @return The header information.
  56985. */
  56986. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56987. /**
  56988. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56989. * This RGBE texture needs to store the information as a panorama.
  56990. *
  56991. * More information on this format are available here:
  56992. * https://en.wikipedia.org/wiki/RGBE_image_format
  56993. *
  56994. * @param buffer The binary file stored in an array buffer.
  56995. * @param size The expected size of the extracted cubemap.
  56996. * @return The Cube Map information.
  56997. */
  56998. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56999. /**
  57000. * Returns the pixels data extracted from an RGBE texture.
  57001. * This pixels will be stored left to right up to down in the R G B order in one array.
  57002. *
  57003. * More information on this format are available here:
  57004. * https://en.wikipedia.org/wiki/RGBE_image_format
  57005. *
  57006. * @param uint8array The binary file stored in an array buffer.
  57007. * @param hdrInfo The header information of the file.
  57008. * @return The pixels data in RGB right to left up to down order.
  57009. */
  57010. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57011. private static RGBE_ReadPixels_RLE;
  57012. }
  57013. }
  57014. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57015. import { Nullable } from "babylonjs/types";
  57016. import { Scene } from "babylonjs/scene";
  57017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57019. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57020. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57021. /**
  57022. * This represents a texture coming from an HDR input.
  57023. *
  57024. * The only supported format is currently panorama picture stored in RGBE format.
  57025. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57026. */
  57027. export class HDRCubeTexture extends BaseTexture {
  57028. private static _facesMapping;
  57029. private _generateHarmonics;
  57030. private _noMipmap;
  57031. private _textureMatrix;
  57032. private _size;
  57033. private _onLoad;
  57034. private _onError;
  57035. /**
  57036. * The texture URL.
  57037. */
  57038. url: string;
  57039. /**
  57040. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57041. */
  57042. coordinatesMode: number;
  57043. protected _isBlocking: boolean;
  57044. /**
  57045. * Sets wether or not the texture is blocking during loading.
  57046. */
  57047. set isBlocking(value: boolean);
  57048. /**
  57049. * Gets wether or not the texture is blocking during loading.
  57050. */
  57051. get isBlocking(): boolean;
  57052. protected _rotationY: number;
  57053. /**
  57054. * Sets texture matrix rotation angle around Y axis in radians.
  57055. */
  57056. set rotationY(value: number);
  57057. /**
  57058. * Gets texture matrix rotation angle around Y axis radians.
  57059. */
  57060. get rotationY(): number;
  57061. /**
  57062. * Gets or sets the center of the bounding box associated with the cube texture
  57063. * It must define where the camera used to render the texture was set
  57064. */
  57065. boundingBoxPosition: Vector3;
  57066. private _boundingBoxSize;
  57067. /**
  57068. * Gets or sets the size of the bounding box associated with the cube texture
  57069. * When defined, the cubemap will switch to local mode
  57070. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57071. * @example https://www.babylonjs-playground.com/#RNASML
  57072. */
  57073. set boundingBoxSize(value: Vector3);
  57074. get boundingBoxSize(): Vector3;
  57075. /**
  57076. * Instantiates an HDRTexture from the following parameters.
  57077. *
  57078. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57079. * @param scene The scene the texture will be used in
  57080. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57081. * @param noMipmap Forces to not generate the mipmap if true
  57082. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57083. * @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)
  57084. * @param reserved Reserved flag for internal use.
  57085. */
  57086. 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>);
  57087. /**
  57088. * Get the current class name of the texture useful for serialization or dynamic coding.
  57089. * @returns "HDRCubeTexture"
  57090. */
  57091. getClassName(): string;
  57092. /**
  57093. * Occurs when the file is raw .hdr file.
  57094. */
  57095. private loadTexture;
  57096. clone(): HDRCubeTexture;
  57097. delayLoad(): void;
  57098. /**
  57099. * Get the texture reflection matrix used to rotate/transform the reflection.
  57100. * @returns the reflection matrix
  57101. */
  57102. getReflectionTextureMatrix(): Matrix;
  57103. /**
  57104. * Set the texture reflection matrix used to rotate/transform the reflection.
  57105. * @param value Define the reflection matrix to set
  57106. */
  57107. setReflectionTextureMatrix(value: Matrix): void;
  57108. /**
  57109. * Parses a JSON representation of an HDR Texture in order to create the texture
  57110. * @param parsedTexture Define the JSON representation
  57111. * @param scene Define the scene the texture should be created in
  57112. * @param rootUrl Define the root url in case we need to load relative dependencies
  57113. * @returns the newly created texture after parsing
  57114. */
  57115. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57116. serialize(): any;
  57117. }
  57118. }
  57119. declare module "babylonjs/Physics/physicsEngine" {
  57120. import { Nullable } from "babylonjs/types";
  57121. import { Vector3 } from "babylonjs/Maths/math.vector";
  57122. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57123. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57124. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57125. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57126. /**
  57127. * Class used to control physics engine
  57128. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57129. */
  57130. export class PhysicsEngine implements IPhysicsEngine {
  57131. private _physicsPlugin;
  57132. /**
  57133. * Global value used to control the smallest number supported by the simulation
  57134. */
  57135. static Epsilon: number;
  57136. private _impostors;
  57137. private _joints;
  57138. private _subTimeStep;
  57139. /**
  57140. * Gets the gravity vector used by the simulation
  57141. */
  57142. gravity: Vector3;
  57143. /**
  57144. * Factory used to create the default physics plugin.
  57145. * @returns The default physics plugin
  57146. */
  57147. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57148. /**
  57149. * Creates a new Physics Engine
  57150. * @param gravity defines the gravity vector used by the simulation
  57151. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57152. */
  57153. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57154. /**
  57155. * Sets the gravity vector used by the simulation
  57156. * @param gravity defines the gravity vector to use
  57157. */
  57158. setGravity(gravity: Vector3): void;
  57159. /**
  57160. * Set the time step of the physics engine.
  57161. * Default is 1/60.
  57162. * To slow it down, enter 1/600 for example.
  57163. * To speed it up, 1/30
  57164. * @param newTimeStep defines the new timestep to apply to this world.
  57165. */
  57166. setTimeStep(newTimeStep?: number): void;
  57167. /**
  57168. * Get the time step of the physics engine.
  57169. * @returns the current time step
  57170. */
  57171. getTimeStep(): number;
  57172. /**
  57173. * Set the sub time step of the physics engine.
  57174. * Default is 0 meaning there is no sub steps
  57175. * To increase physics resolution precision, set a small value (like 1 ms)
  57176. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57177. */
  57178. setSubTimeStep(subTimeStep?: number): void;
  57179. /**
  57180. * Get the sub time step of the physics engine.
  57181. * @returns the current sub time step
  57182. */
  57183. getSubTimeStep(): number;
  57184. /**
  57185. * Release all resources
  57186. */
  57187. dispose(): void;
  57188. /**
  57189. * Gets the name of the current physics plugin
  57190. * @returns the name of the plugin
  57191. */
  57192. getPhysicsPluginName(): string;
  57193. /**
  57194. * Adding a new impostor for the impostor tracking.
  57195. * This will be done by the impostor itself.
  57196. * @param impostor the impostor to add
  57197. */
  57198. addImpostor(impostor: PhysicsImpostor): void;
  57199. /**
  57200. * Remove an impostor from the engine.
  57201. * This impostor and its mesh will not longer be updated by the physics engine.
  57202. * @param impostor the impostor to remove
  57203. */
  57204. removeImpostor(impostor: PhysicsImpostor): void;
  57205. /**
  57206. * Add a joint to the physics engine
  57207. * @param mainImpostor defines the main impostor to which the joint is added.
  57208. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57209. * @param joint defines the joint that will connect both impostors.
  57210. */
  57211. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57212. /**
  57213. * Removes a joint from the simulation
  57214. * @param mainImpostor defines the impostor used with the joint
  57215. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57216. * @param joint defines the joint to remove
  57217. */
  57218. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57219. /**
  57220. * Called by the scene. No need to call it.
  57221. * @param delta defines the timespam between frames
  57222. */
  57223. _step(delta: number): void;
  57224. /**
  57225. * Gets the current plugin used to run the simulation
  57226. * @returns current plugin
  57227. */
  57228. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57229. /**
  57230. * Gets the list of physic impostors
  57231. * @returns an array of PhysicsImpostor
  57232. */
  57233. getImpostors(): Array<PhysicsImpostor>;
  57234. /**
  57235. * Gets the impostor for a physics enabled object
  57236. * @param object defines the object impersonated by the impostor
  57237. * @returns the PhysicsImpostor or null if not found
  57238. */
  57239. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57240. /**
  57241. * Gets the impostor for a physics body object
  57242. * @param body defines physics body used by the impostor
  57243. * @returns the PhysicsImpostor or null if not found
  57244. */
  57245. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57246. /**
  57247. * Does a raycast in the physics world
  57248. * @param from when should the ray start?
  57249. * @param to when should the ray end?
  57250. * @returns PhysicsRaycastResult
  57251. */
  57252. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57253. }
  57254. }
  57255. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57256. import { Nullable } from "babylonjs/types";
  57257. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57259. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57260. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57261. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57262. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57263. /** @hidden */
  57264. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57265. private _useDeltaForWorldStep;
  57266. world: any;
  57267. name: string;
  57268. private _physicsMaterials;
  57269. private _fixedTimeStep;
  57270. private _cannonRaycastResult;
  57271. private _raycastResult;
  57272. private _physicsBodysToRemoveAfterStep;
  57273. BJSCANNON: any;
  57274. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57275. setGravity(gravity: Vector3): void;
  57276. setTimeStep(timeStep: number): void;
  57277. getTimeStep(): number;
  57278. executeStep(delta: number): void;
  57279. private _removeMarkedPhysicsBodiesFromWorld;
  57280. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57281. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57282. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57283. private _processChildMeshes;
  57284. removePhysicsBody(impostor: PhysicsImpostor): void;
  57285. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57286. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57287. private _addMaterial;
  57288. private _checkWithEpsilon;
  57289. private _createShape;
  57290. private _createHeightmap;
  57291. private _minus90X;
  57292. private _plus90X;
  57293. private _tmpPosition;
  57294. private _tmpDeltaPosition;
  57295. private _tmpUnityRotation;
  57296. private _updatePhysicsBodyTransformation;
  57297. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57298. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57299. isSupported(): boolean;
  57300. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57301. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57302. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57303. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57304. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57305. getBodyMass(impostor: PhysicsImpostor): number;
  57306. getBodyFriction(impostor: PhysicsImpostor): number;
  57307. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57308. getBodyRestitution(impostor: PhysicsImpostor): number;
  57309. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57310. sleepBody(impostor: PhysicsImpostor): void;
  57311. wakeUpBody(impostor: PhysicsImpostor): void;
  57312. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57313. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57314. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57315. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57316. getRadius(impostor: PhysicsImpostor): number;
  57317. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57318. dispose(): void;
  57319. private _extendNamespace;
  57320. /**
  57321. * Does a raycast in the physics world
  57322. * @param from when should the ray start?
  57323. * @param to when should the ray end?
  57324. * @returns PhysicsRaycastResult
  57325. */
  57326. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57327. }
  57328. }
  57329. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57330. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57331. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57332. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57334. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57335. import { Nullable } from "babylonjs/types";
  57336. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57337. /** @hidden */
  57338. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57339. world: any;
  57340. name: string;
  57341. BJSOIMO: any;
  57342. private _raycastResult;
  57343. constructor(iterations?: number, oimoInjection?: any);
  57344. setGravity(gravity: Vector3): void;
  57345. setTimeStep(timeStep: number): void;
  57346. getTimeStep(): number;
  57347. private _tmpImpostorsArray;
  57348. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57349. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57350. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57351. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57352. private _tmpPositionVector;
  57353. removePhysicsBody(impostor: PhysicsImpostor): void;
  57354. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57355. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57356. isSupported(): boolean;
  57357. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57358. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57359. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57360. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57361. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57362. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57363. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57364. getBodyMass(impostor: PhysicsImpostor): number;
  57365. getBodyFriction(impostor: PhysicsImpostor): number;
  57366. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57367. getBodyRestitution(impostor: PhysicsImpostor): number;
  57368. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57369. sleepBody(impostor: PhysicsImpostor): void;
  57370. wakeUpBody(impostor: PhysicsImpostor): void;
  57371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57372. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57373. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57374. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57375. getRadius(impostor: PhysicsImpostor): number;
  57376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57377. dispose(): void;
  57378. /**
  57379. * Does a raycast in the physics world
  57380. * @param from when should the ray start?
  57381. * @param to when should the ray end?
  57382. * @returns PhysicsRaycastResult
  57383. */
  57384. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57385. }
  57386. }
  57387. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57388. import { Nullable } from "babylonjs/types";
  57389. import { Scene } from "babylonjs/scene";
  57390. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57391. import { Color4 } from "babylonjs/Maths/math.color";
  57392. import { Mesh } from "babylonjs/Meshes/mesh";
  57393. /**
  57394. * Class containing static functions to help procedurally build meshes
  57395. */
  57396. export class RibbonBuilder {
  57397. /**
  57398. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57399. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57400. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57401. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57402. * * 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
  57403. * * 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
  57404. * * 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
  57405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57407. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57408. * * 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
  57409. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57410. * * 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
  57411. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57413. * @param name defines the name of the mesh
  57414. * @param options defines the options used to create the mesh
  57415. * @param scene defines the hosting scene
  57416. * @returns the ribbon mesh
  57417. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57419. */
  57420. static CreateRibbon(name: string, options: {
  57421. pathArray: Vector3[][];
  57422. closeArray?: boolean;
  57423. closePath?: boolean;
  57424. offset?: number;
  57425. updatable?: boolean;
  57426. sideOrientation?: number;
  57427. frontUVs?: Vector4;
  57428. backUVs?: Vector4;
  57429. instance?: Mesh;
  57430. invertUV?: boolean;
  57431. uvs?: Vector2[];
  57432. colors?: Color4[];
  57433. }, scene?: Nullable<Scene>): Mesh;
  57434. }
  57435. }
  57436. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57437. import { Nullable } from "babylonjs/types";
  57438. import { Scene } from "babylonjs/scene";
  57439. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57440. import { Mesh } from "babylonjs/Meshes/mesh";
  57441. /**
  57442. * Class containing static functions to help procedurally build meshes
  57443. */
  57444. export class ShapeBuilder {
  57445. /**
  57446. * 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.
  57447. * * 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.
  57448. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57449. * * 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.
  57450. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57451. * * 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
  57452. * * 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
  57453. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57458. * @param name defines the name of the mesh
  57459. * @param options defines the options used to create the mesh
  57460. * @param scene defines the hosting scene
  57461. * @returns the extruded shape mesh
  57462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57464. */
  57465. static ExtrudeShape(name: string, options: {
  57466. shape: Vector3[];
  57467. path: Vector3[];
  57468. scale?: number;
  57469. rotation?: number;
  57470. cap?: number;
  57471. updatable?: boolean;
  57472. sideOrientation?: number;
  57473. frontUVs?: Vector4;
  57474. backUVs?: Vector4;
  57475. instance?: Mesh;
  57476. invertUV?: boolean;
  57477. }, scene?: Nullable<Scene>): Mesh;
  57478. /**
  57479. * Creates an custom extruded shape mesh.
  57480. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57481. * * 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.
  57482. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57483. * * 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
  57484. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57485. * * 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
  57486. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57487. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57488. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57489. * * 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
  57490. * * 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
  57491. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57496. * @param name defines the name of the mesh
  57497. * @param options defines the options used to create the mesh
  57498. * @param scene defines the hosting scene
  57499. * @returns the custom extruded shape mesh
  57500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57503. */
  57504. static ExtrudeShapeCustom(name: string, options: {
  57505. shape: Vector3[];
  57506. path: Vector3[];
  57507. scaleFunction?: any;
  57508. rotationFunction?: any;
  57509. ribbonCloseArray?: boolean;
  57510. ribbonClosePath?: boolean;
  57511. cap?: number;
  57512. updatable?: boolean;
  57513. sideOrientation?: number;
  57514. frontUVs?: Vector4;
  57515. backUVs?: Vector4;
  57516. instance?: Mesh;
  57517. invertUV?: boolean;
  57518. }, scene?: Nullable<Scene>): Mesh;
  57519. private static _ExtrudeShapeGeneric;
  57520. }
  57521. }
  57522. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57523. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57524. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57525. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57526. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57527. import { Nullable } from "babylonjs/types";
  57528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57529. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57530. /**
  57531. * AmmoJS Physics plugin
  57532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57533. * @see https://github.com/kripken/ammo.js/
  57534. */
  57535. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57536. private _useDeltaForWorldStep;
  57537. /**
  57538. * Reference to the Ammo library
  57539. */
  57540. bjsAMMO: any;
  57541. /**
  57542. * Created ammoJS world which physics bodies are added to
  57543. */
  57544. world: any;
  57545. /**
  57546. * Name of the plugin
  57547. */
  57548. name: string;
  57549. private _timeStep;
  57550. private _fixedTimeStep;
  57551. private _maxSteps;
  57552. private _tmpQuaternion;
  57553. private _tmpAmmoTransform;
  57554. private _tmpAmmoQuaternion;
  57555. private _tmpAmmoConcreteContactResultCallback;
  57556. private _collisionConfiguration;
  57557. private _dispatcher;
  57558. private _overlappingPairCache;
  57559. private _solver;
  57560. private _softBodySolver;
  57561. private _tmpAmmoVectorA;
  57562. private _tmpAmmoVectorB;
  57563. private _tmpAmmoVectorC;
  57564. private _tmpAmmoVectorD;
  57565. private _tmpContactCallbackResult;
  57566. private _tmpAmmoVectorRCA;
  57567. private _tmpAmmoVectorRCB;
  57568. private _raycastResult;
  57569. private static readonly DISABLE_COLLISION_FLAG;
  57570. private static readonly KINEMATIC_FLAG;
  57571. private static readonly DISABLE_DEACTIVATION_FLAG;
  57572. /**
  57573. * Initializes the ammoJS plugin
  57574. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57575. * @param ammoInjection can be used to inject your own ammo reference
  57576. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57577. */
  57578. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57579. /**
  57580. * Sets the gravity of the physics world (m/(s^2))
  57581. * @param gravity Gravity to set
  57582. */
  57583. setGravity(gravity: Vector3): void;
  57584. /**
  57585. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57586. * @param timeStep timestep to use in seconds
  57587. */
  57588. setTimeStep(timeStep: number): void;
  57589. /**
  57590. * 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)
  57591. * @param fixedTimeStep fixedTimeStep to use in seconds
  57592. */
  57593. setFixedTimeStep(fixedTimeStep: number): void;
  57594. /**
  57595. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57596. * @param maxSteps the maximum number of steps by the physics engine per frame
  57597. */
  57598. setMaxSteps(maxSteps: number): void;
  57599. /**
  57600. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57601. * @returns the current timestep in seconds
  57602. */
  57603. getTimeStep(): number;
  57604. /**
  57605. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57606. */
  57607. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57608. private _isImpostorInContact;
  57609. private _isImpostorPairInContact;
  57610. private _stepSimulation;
  57611. /**
  57612. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57613. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57614. * After the step the babylon meshes are set to the position of the physics imposters
  57615. * @param delta amount of time to step forward
  57616. * @param impostors array of imposters to update before/after the step
  57617. */
  57618. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57619. /**
  57620. * Update babylon mesh to match physics world object
  57621. * @param impostor imposter to match
  57622. */
  57623. private _afterSoftStep;
  57624. /**
  57625. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57626. * @param impostor imposter to match
  57627. */
  57628. private _ropeStep;
  57629. /**
  57630. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57631. * @param impostor imposter to match
  57632. */
  57633. private _softbodyOrClothStep;
  57634. private _tmpVector;
  57635. private _tmpMatrix;
  57636. /**
  57637. * Applies an impulse on the imposter
  57638. * @param impostor imposter to apply impulse to
  57639. * @param force amount of force to be applied to the imposter
  57640. * @param contactPoint the location to apply the impulse on the imposter
  57641. */
  57642. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57643. /**
  57644. * Applies a force on the imposter
  57645. * @param impostor imposter to apply force
  57646. * @param force amount of force to be applied to the imposter
  57647. * @param contactPoint the location to apply the force on the imposter
  57648. */
  57649. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57650. /**
  57651. * Creates a physics body using the plugin
  57652. * @param impostor the imposter to create the physics body on
  57653. */
  57654. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57655. /**
  57656. * Removes the physics body from the imposter and disposes of the body's memory
  57657. * @param impostor imposter to remove the physics body from
  57658. */
  57659. removePhysicsBody(impostor: PhysicsImpostor): void;
  57660. /**
  57661. * Generates a joint
  57662. * @param impostorJoint the imposter joint to create the joint with
  57663. */
  57664. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57665. /**
  57666. * Removes a joint
  57667. * @param impostorJoint the imposter joint to remove the joint from
  57668. */
  57669. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57670. private _addMeshVerts;
  57671. /**
  57672. * Initialise the soft body vertices to match its object's (mesh) vertices
  57673. * Softbody vertices (nodes) are in world space and to match this
  57674. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57675. * @param impostor to create the softbody for
  57676. */
  57677. private _softVertexData;
  57678. /**
  57679. * Create an impostor's soft body
  57680. * @param impostor to create the softbody for
  57681. */
  57682. private _createSoftbody;
  57683. /**
  57684. * Create cloth for an impostor
  57685. * @param impostor to create the softbody for
  57686. */
  57687. private _createCloth;
  57688. /**
  57689. * Create rope for an impostor
  57690. * @param impostor to create the softbody for
  57691. */
  57692. private _createRope;
  57693. /**
  57694. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57695. * @param impostor to create the custom physics shape for
  57696. */
  57697. private _createCustom;
  57698. private _addHullVerts;
  57699. private _createShape;
  57700. /**
  57701. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57702. * @param impostor imposter containing the physics body and babylon object
  57703. */
  57704. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57705. /**
  57706. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57707. * @param impostor imposter containing the physics body and babylon object
  57708. * @param newPosition new position
  57709. * @param newRotation new rotation
  57710. */
  57711. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57712. /**
  57713. * If this plugin is supported
  57714. * @returns true if its supported
  57715. */
  57716. isSupported(): boolean;
  57717. /**
  57718. * Sets the linear velocity of the physics body
  57719. * @param impostor imposter to set the velocity on
  57720. * @param velocity velocity to set
  57721. */
  57722. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57723. /**
  57724. * Sets the angular velocity of the physics body
  57725. * @param impostor imposter to set the velocity on
  57726. * @param velocity velocity to set
  57727. */
  57728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57729. /**
  57730. * gets the linear velocity
  57731. * @param impostor imposter to get linear velocity from
  57732. * @returns linear velocity
  57733. */
  57734. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57735. /**
  57736. * gets the angular velocity
  57737. * @param impostor imposter to get angular velocity from
  57738. * @returns angular velocity
  57739. */
  57740. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57741. /**
  57742. * Sets the mass of physics body
  57743. * @param impostor imposter to set the mass on
  57744. * @param mass mass to set
  57745. */
  57746. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57747. /**
  57748. * Gets the mass of the physics body
  57749. * @param impostor imposter to get the mass from
  57750. * @returns mass
  57751. */
  57752. getBodyMass(impostor: PhysicsImpostor): number;
  57753. /**
  57754. * Gets friction of the impostor
  57755. * @param impostor impostor to get friction from
  57756. * @returns friction value
  57757. */
  57758. getBodyFriction(impostor: PhysicsImpostor): number;
  57759. /**
  57760. * Sets friction of the impostor
  57761. * @param impostor impostor to set friction on
  57762. * @param friction friction value
  57763. */
  57764. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57765. /**
  57766. * Gets restitution of the impostor
  57767. * @param impostor impostor to get restitution from
  57768. * @returns restitution value
  57769. */
  57770. getBodyRestitution(impostor: PhysicsImpostor): number;
  57771. /**
  57772. * Sets resitution of the impostor
  57773. * @param impostor impostor to set resitution on
  57774. * @param restitution resitution value
  57775. */
  57776. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57777. /**
  57778. * Gets pressure inside the impostor
  57779. * @param impostor impostor to get pressure from
  57780. * @returns pressure value
  57781. */
  57782. getBodyPressure(impostor: PhysicsImpostor): number;
  57783. /**
  57784. * Sets pressure inside a soft body impostor
  57785. * Cloth and rope must remain 0 pressure
  57786. * @param impostor impostor to set pressure on
  57787. * @param pressure pressure value
  57788. */
  57789. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57790. /**
  57791. * Gets stiffness of the impostor
  57792. * @param impostor impostor to get stiffness from
  57793. * @returns pressure value
  57794. */
  57795. getBodyStiffness(impostor: PhysicsImpostor): number;
  57796. /**
  57797. * Sets stiffness of the impostor
  57798. * @param impostor impostor to set stiffness on
  57799. * @param stiffness stiffness value from 0 to 1
  57800. */
  57801. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57802. /**
  57803. * Gets velocityIterations of the impostor
  57804. * @param impostor impostor to get velocity iterations from
  57805. * @returns velocityIterations value
  57806. */
  57807. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57808. /**
  57809. * Sets velocityIterations of the impostor
  57810. * @param impostor impostor to set velocity iterations on
  57811. * @param velocityIterations velocityIterations value
  57812. */
  57813. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57814. /**
  57815. * Gets positionIterations of the impostor
  57816. * @param impostor impostor to get position iterations from
  57817. * @returns positionIterations value
  57818. */
  57819. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57820. /**
  57821. * Sets positionIterations of the impostor
  57822. * @param impostor impostor to set position on
  57823. * @param positionIterations positionIterations value
  57824. */
  57825. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57826. /**
  57827. * Append an anchor to a cloth object
  57828. * @param impostor is the cloth impostor to add anchor to
  57829. * @param otherImpostor is the rigid impostor to anchor to
  57830. * @param width ratio across width from 0 to 1
  57831. * @param height ratio up height from 0 to 1
  57832. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57833. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57834. */
  57835. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57836. /**
  57837. * Append an hook to a rope object
  57838. * @param impostor is the rope impostor to add hook to
  57839. * @param otherImpostor is the rigid impostor to hook to
  57840. * @param length ratio along the rope from 0 to 1
  57841. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57842. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57843. */
  57844. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57845. /**
  57846. * Sleeps the physics body and stops it from being active
  57847. * @param impostor impostor to sleep
  57848. */
  57849. sleepBody(impostor: PhysicsImpostor): void;
  57850. /**
  57851. * Activates the physics body
  57852. * @param impostor impostor to activate
  57853. */
  57854. wakeUpBody(impostor: PhysicsImpostor): void;
  57855. /**
  57856. * Updates the distance parameters of the joint
  57857. * @param joint joint to update
  57858. * @param maxDistance maximum distance of the joint
  57859. * @param minDistance minimum distance of the joint
  57860. */
  57861. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57862. /**
  57863. * Sets a motor on the joint
  57864. * @param joint joint to set motor on
  57865. * @param speed speed of the motor
  57866. * @param maxForce maximum force of the motor
  57867. * @param motorIndex index of the motor
  57868. */
  57869. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57870. /**
  57871. * Sets the motors limit
  57872. * @param joint joint to set limit on
  57873. * @param upperLimit upper limit
  57874. * @param lowerLimit lower limit
  57875. */
  57876. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57877. /**
  57878. * Syncs the position and rotation of a mesh with the impostor
  57879. * @param mesh mesh to sync
  57880. * @param impostor impostor to update the mesh with
  57881. */
  57882. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57883. /**
  57884. * Gets the radius of the impostor
  57885. * @param impostor impostor to get radius from
  57886. * @returns the radius
  57887. */
  57888. getRadius(impostor: PhysicsImpostor): number;
  57889. /**
  57890. * Gets the box size of the impostor
  57891. * @param impostor impostor to get box size from
  57892. * @param result the resulting box size
  57893. */
  57894. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57895. /**
  57896. * Disposes of the impostor
  57897. */
  57898. dispose(): void;
  57899. /**
  57900. * Does a raycast in the physics world
  57901. * @param from when should the ray start?
  57902. * @param to when should the ray end?
  57903. * @returns PhysicsRaycastResult
  57904. */
  57905. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57906. }
  57907. }
  57908. declare module "babylonjs/Probes/reflectionProbe" {
  57909. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57910. import { Vector3 } from "babylonjs/Maths/math.vector";
  57911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57912. import { Nullable } from "babylonjs/types";
  57913. import { Scene } from "babylonjs/scene";
  57914. module "babylonjs/abstractScene" {
  57915. interface AbstractScene {
  57916. /**
  57917. * The list of reflection probes added to the scene
  57918. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57919. */
  57920. reflectionProbes: Array<ReflectionProbe>;
  57921. /**
  57922. * Removes the given reflection probe from this scene.
  57923. * @param toRemove The reflection probe to remove
  57924. * @returns The index of the removed reflection probe
  57925. */
  57926. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57927. /**
  57928. * Adds the given reflection probe to this scene.
  57929. * @param newReflectionProbe The reflection probe to add
  57930. */
  57931. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57932. }
  57933. }
  57934. /**
  57935. * Class used to generate realtime reflection / refraction cube textures
  57936. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57937. */
  57938. export class ReflectionProbe {
  57939. /** defines the name of the probe */
  57940. name: string;
  57941. private _scene;
  57942. private _renderTargetTexture;
  57943. private _projectionMatrix;
  57944. private _viewMatrix;
  57945. private _target;
  57946. private _add;
  57947. private _attachedMesh;
  57948. private _invertYAxis;
  57949. /** Gets or sets probe position (center of the cube map) */
  57950. position: Vector3;
  57951. /**
  57952. * Creates a new reflection probe
  57953. * @param name defines the name of the probe
  57954. * @param size defines the texture resolution (for each face)
  57955. * @param scene defines the hosting scene
  57956. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57957. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57958. */
  57959. constructor(
  57960. /** defines the name of the probe */
  57961. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57962. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57963. get samples(): number;
  57964. set samples(value: number);
  57965. /** Gets or sets the refresh rate to use (on every frame by default) */
  57966. get refreshRate(): number;
  57967. set refreshRate(value: number);
  57968. /**
  57969. * Gets the hosting scene
  57970. * @returns a Scene
  57971. */
  57972. getScene(): Scene;
  57973. /** Gets the internal CubeTexture used to render to */
  57974. get cubeTexture(): RenderTargetTexture;
  57975. /** Gets the list of meshes to render */
  57976. get renderList(): Nullable<AbstractMesh[]>;
  57977. /**
  57978. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57979. * @param mesh defines the mesh to attach to
  57980. */
  57981. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57982. /**
  57983. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57984. * @param renderingGroupId The rendering group id corresponding to its index
  57985. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57986. */
  57987. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57988. /**
  57989. * Clean all associated resources
  57990. */
  57991. dispose(): void;
  57992. /**
  57993. * Converts the reflection probe information to a readable string for debug purpose.
  57994. * @param fullDetails Supports for multiple levels of logging within scene loading
  57995. * @returns the human readable reflection probe info
  57996. */
  57997. toString(fullDetails?: boolean): string;
  57998. /**
  57999. * Get the class name of the relfection probe.
  58000. * @returns "ReflectionProbe"
  58001. */
  58002. getClassName(): string;
  58003. /**
  58004. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58005. * @returns The JSON representation of the texture
  58006. */
  58007. serialize(): any;
  58008. /**
  58009. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58010. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58011. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58012. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58013. * @returns The parsed reflection probe if successful
  58014. */
  58015. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58016. }
  58017. }
  58018. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58019. /** @hidden */
  58020. export var _BabylonLoaderRegistered: boolean;
  58021. /**
  58022. * Helps setting up some configuration for the babylon file loader.
  58023. */
  58024. export class BabylonFileLoaderConfiguration {
  58025. /**
  58026. * The loader does not allow injecting custom physix engine into the plugins.
  58027. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58028. * So you could set this variable to your engine import to make it work.
  58029. */
  58030. static LoaderInjectedPhysicsEngine: any;
  58031. }
  58032. }
  58033. declare module "babylonjs/Loading/Plugins/index" {
  58034. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58035. }
  58036. declare module "babylonjs/Loading/index" {
  58037. export * from "babylonjs/Loading/loadingScreen";
  58038. export * from "babylonjs/Loading/Plugins/index";
  58039. export * from "babylonjs/Loading/sceneLoader";
  58040. export * from "babylonjs/Loading/sceneLoaderFlags";
  58041. }
  58042. declare module "babylonjs/Materials/Background/index" {
  58043. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58044. }
  58045. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58046. import { Scene } from "babylonjs/scene";
  58047. import { Color3 } from "babylonjs/Maths/math.color";
  58048. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58050. /**
  58051. * The Physically based simple base material of BJS.
  58052. *
  58053. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58054. * It is used as the base class for both the specGloss and metalRough conventions.
  58055. */
  58056. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58057. /**
  58058. * Number of Simultaneous lights allowed on the material.
  58059. */
  58060. maxSimultaneousLights: number;
  58061. /**
  58062. * If sets to true, disables all the lights affecting the material.
  58063. */
  58064. disableLighting: boolean;
  58065. /**
  58066. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58067. */
  58068. environmentTexture: BaseTexture;
  58069. /**
  58070. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58071. */
  58072. invertNormalMapX: boolean;
  58073. /**
  58074. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58075. */
  58076. invertNormalMapY: boolean;
  58077. /**
  58078. * Normal map used in the model.
  58079. */
  58080. normalTexture: BaseTexture;
  58081. /**
  58082. * Emissivie color used to self-illuminate the model.
  58083. */
  58084. emissiveColor: Color3;
  58085. /**
  58086. * Emissivie texture used to self-illuminate the model.
  58087. */
  58088. emissiveTexture: BaseTexture;
  58089. /**
  58090. * Occlusion Channel Strenght.
  58091. */
  58092. occlusionStrength: number;
  58093. /**
  58094. * Occlusion Texture of the material (adding extra occlusion effects).
  58095. */
  58096. occlusionTexture: BaseTexture;
  58097. /**
  58098. * Defines the alpha limits in alpha test mode.
  58099. */
  58100. alphaCutOff: number;
  58101. /**
  58102. * Gets the current double sided mode.
  58103. */
  58104. get doubleSided(): boolean;
  58105. /**
  58106. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58107. */
  58108. set doubleSided(value: boolean);
  58109. /**
  58110. * Stores the pre-calculated light information of a mesh in a texture.
  58111. */
  58112. lightmapTexture: BaseTexture;
  58113. /**
  58114. * If true, the light map contains occlusion information instead of lighting info.
  58115. */
  58116. useLightmapAsShadowmap: boolean;
  58117. /**
  58118. * Instantiates a new PBRMaterial instance.
  58119. *
  58120. * @param name The material name
  58121. * @param scene The scene the material will be use in.
  58122. */
  58123. constructor(name: string, scene: Scene);
  58124. getClassName(): string;
  58125. }
  58126. }
  58127. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58128. import { Scene } from "babylonjs/scene";
  58129. import { Color3 } from "babylonjs/Maths/math.color";
  58130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58131. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58132. /**
  58133. * The PBR material of BJS following the metal roughness convention.
  58134. *
  58135. * This fits to the PBR convention in the GLTF definition:
  58136. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58137. */
  58138. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58139. /**
  58140. * The base color has two different interpretations depending on the value of metalness.
  58141. * When the material is a metal, the base color is the specific measured reflectance value
  58142. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58143. * of the material.
  58144. */
  58145. baseColor: Color3;
  58146. /**
  58147. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58148. * well as opacity information in the alpha channel.
  58149. */
  58150. baseTexture: BaseTexture;
  58151. /**
  58152. * Specifies the metallic scalar value of the material.
  58153. * Can also be used to scale the metalness values of the metallic texture.
  58154. */
  58155. metallic: number;
  58156. /**
  58157. * Specifies the roughness scalar value of the material.
  58158. * Can also be used to scale the roughness values of the metallic texture.
  58159. */
  58160. roughness: number;
  58161. /**
  58162. * Texture containing both the metallic value in the B channel and the
  58163. * roughness value in the G channel to keep better precision.
  58164. */
  58165. metallicRoughnessTexture: BaseTexture;
  58166. /**
  58167. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58168. *
  58169. * @param name The material name
  58170. * @param scene The scene the material will be use in.
  58171. */
  58172. constructor(name: string, scene: Scene);
  58173. /**
  58174. * Return the currrent class name of the material.
  58175. */
  58176. getClassName(): string;
  58177. /**
  58178. * Makes a duplicate of the current material.
  58179. * @param name - name to use for the new material.
  58180. */
  58181. clone(name: string): PBRMetallicRoughnessMaterial;
  58182. /**
  58183. * Serialize the material to a parsable JSON object.
  58184. */
  58185. serialize(): any;
  58186. /**
  58187. * Parses a JSON object correponding to the serialize function.
  58188. */
  58189. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58190. }
  58191. }
  58192. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58193. import { Scene } from "babylonjs/scene";
  58194. import { Color3 } from "babylonjs/Maths/math.color";
  58195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58196. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58197. /**
  58198. * The PBR material of BJS following the specular glossiness convention.
  58199. *
  58200. * This fits to the PBR convention in the GLTF definition:
  58201. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58202. */
  58203. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58204. /**
  58205. * Specifies the diffuse color of the material.
  58206. */
  58207. diffuseColor: Color3;
  58208. /**
  58209. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58210. * channel.
  58211. */
  58212. diffuseTexture: BaseTexture;
  58213. /**
  58214. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58215. */
  58216. specularColor: Color3;
  58217. /**
  58218. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58219. */
  58220. glossiness: number;
  58221. /**
  58222. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58223. */
  58224. specularGlossinessTexture: BaseTexture;
  58225. /**
  58226. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58227. *
  58228. * @param name The material name
  58229. * @param scene The scene the material will be use in.
  58230. */
  58231. constructor(name: string, scene: Scene);
  58232. /**
  58233. * Return the currrent class name of the material.
  58234. */
  58235. getClassName(): string;
  58236. /**
  58237. * Makes a duplicate of the current material.
  58238. * @param name - name to use for the new material.
  58239. */
  58240. clone(name: string): PBRSpecularGlossinessMaterial;
  58241. /**
  58242. * Serialize the material to a parsable JSON object.
  58243. */
  58244. serialize(): any;
  58245. /**
  58246. * Parses a JSON object correponding to the serialize function.
  58247. */
  58248. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58249. }
  58250. }
  58251. declare module "babylonjs/Materials/PBR/index" {
  58252. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58253. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58254. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58255. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58256. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58257. }
  58258. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58259. import { Nullable } from "babylonjs/types";
  58260. import { Scene } from "babylonjs/scene";
  58261. import { Matrix } from "babylonjs/Maths/math.vector";
  58262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58263. /**
  58264. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58265. * It can help converting any input color in a desired output one. This can then be used to create effects
  58266. * from sepia, black and white to sixties or futuristic rendering...
  58267. *
  58268. * The only supported format is currently 3dl.
  58269. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58270. */
  58271. export class ColorGradingTexture extends BaseTexture {
  58272. /**
  58273. * The current texture matrix. (will always be identity in color grading texture)
  58274. */
  58275. private _textureMatrix;
  58276. /**
  58277. * The texture URL.
  58278. */
  58279. url: string;
  58280. /**
  58281. * Empty line regex stored for GC.
  58282. */
  58283. private static _noneEmptyLineRegex;
  58284. private _engine;
  58285. /**
  58286. * Instantiates a ColorGradingTexture from the following parameters.
  58287. *
  58288. * @param url The location of the color gradind data (currently only supporting 3dl)
  58289. * @param scene The scene the texture will be used in
  58290. */
  58291. constructor(url: string, scene: Scene);
  58292. /**
  58293. * Returns the texture matrix used in most of the material.
  58294. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58295. */
  58296. getTextureMatrix(): Matrix;
  58297. /**
  58298. * Occurs when the file being loaded is a .3dl LUT file.
  58299. */
  58300. private load3dlTexture;
  58301. /**
  58302. * Starts the loading process of the texture.
  58303. */
  58304. private loadTexture;
  58305. /**
  58306. * Clones the color gradind texture.
  58307. */
  58308. clone(): ColorGradingTexture;
  58309. /**
  58310. * Called during delayed load for textures.
  58311. */
  58312. delayLoad(): void;
  58313. /**
  58314. * Parses a color grading texture serialized by Babylon.
  58315. * @param parsedTexture The texture information being parsedTexture
  58316. * @param scene The scene to load the texture in
  58317. * @param rootUrl The root url of the data assets to load
  58318. * @return A color gradind texture
  58319. */
  58320. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58321. /**
  58322. * Serializes the LUT texture to json format.
  58323. */
  58324. serialize(): any;
  58325. }
  58326. }
  58327. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58329. import { Scene } from "babylonjs/scene";
  58330. import { Nullable } from "babylonjs/types";
  58331. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58332. /**
  58333. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58334. */
  58335. export class EquiRectangularCubeTexture extends BaseTexture {
  58336. /** The six faces of the cube. */
  58337. private static _FacesMapping;
  58338. private _noMipmap;
  58339. private _onLoad;
  58340. private _onError;
  58341. /** The size of the cubemap. */
  58342. private _size;
  58343. /** The buffer of the image. */
  58344. private _buffer;
  58345. /** The width of the input image. */
  58346. private _width;
  58347. /** The height of the input image. */
  58348. private _height;
  58349. /** The URL to the image. */
  58350. url: string;
  58351. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58352. coordinatesMode: number;
  58353. /**
  58354. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58355. * @param url The location of the image
  58356. * @param scene The scene the texture will be used in
  58357. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58358. * @param noMipmap Forces to not generate the mipmap if true
  58359. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58360. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58361. * @param onLoad — defines a callback called when texture is loaded
  58362. * @param onError — defines a callback called if there is an error
  58363. */
  58364. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58365. /**
  58366. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58367. */
  58368. private loadImage;
  58369. /**
  58370. * Convert the image buffer into a cubemap and create a CubeTexture.
  58371. */
  58372. private loadTexture;
  58373. /**
  58374. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58375. * @param buffer The ArrayBuffer that should be converted.
  58376. * @returns The buffer as Float32Array.
  58377. */
  58378. private getFloat32ArrayFromArrayBuffer;
  58379. /**
  58380. * Get the current class name of the texture useful for serialization or dynamic coding.
  58381. * @returns "EquiRectangularCubeTexture"
  58382. */
  58383. getClassName(): string;
  58384. /**
  58385. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58386. * @returns A clone of the current EquiRectangularCubeTexture.
  58387. */
  58388. clone(): EquiRectangularCubeTexture;
  58389. }
  58390. }
  58391. declare module "babylonjs/Misc/tga" {
  58392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58393. /**
  58394. * Based on jsTGALoader - Javascript loader for TGA file
  58395. * By Vincent Thibault
  58396. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58397. */
  58398. export class TGATools {
  58399. private static _TYPE_INDEXED;
  58400. private static _TYPE_RGB;
  58401. private static _TYPE_GREY;
  58402. private static _TYPE_RLE_INDEXED;
  58403. private static _TYPE_RLE_RGB;
  58404. private static _TYPE_RLE_GREY;
  58405. private static _ORIGIN_MASK;
  58406. private static _ORIGIN_SHIFT;
  58407. private static _ORIGIN_BL;
  58408. private static _ORIGIN_BR;
  58409. private static _ORIGIN_UL;
  58410. private static _ORIGIN_UR;
  58411. /**
  58412. * Gets the header of a TGA file
  58413. * @param data defines the TGA data
  58414. * @returns the header
  58415. */
  58416. static GetTGAHeader(data: Uint8Array): any;
  58417. /**
  58418. * Uploads TGA content to a Babylon Texture
  58419. * @hidden
  58420. */
  58421. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58422. /** @hidden */
  58423. 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;
  58424. /** @hidden */
  58425. 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;
  58426. /** @hidden */
  58427. 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;
  58428. /** @hidden */
  58429. 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;
  58430. /** @hidden */
  58431. 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;
  58432. /** @hidden */
  58433. 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;
  58434. }
  58435. }
  58436. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58437. import { Nullable } from "babylonjs/types";
  58438. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58439. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58440. /**
  58441. * Implementation of the TGA Texture Loader.
  58442. * @hidden
  58443. */
  58444. export class _TGATextureLoader implements IInternalTextureLoader {
  58445. /**
  58446. * Defines wether the loader supports cascade loading the different faces.
  58447. */
  58448. readonly supportCascades: boolean;
  58449. /**
  58450. * This returns if the loader support the current file information.
  58451. * @param extension defines the file extension of the file being loaded
  58452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58453. * @param fallback defines the fallback internal texture if any
  58454. * @param isBase64 defines whether the texture is encoded as a base64
  58455. * @param isBuffer defines whether the texture data are stored as a buffer
  58456. * @returns true if the loader can load the specified file
  58457. */
  58458. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58459. /**
  58460. * Transform the url before loading if required.
  58461. * @param rootUrl the url of the texture
  58462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58463. * @returns the transformed texture
  58464. */
  58465. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58466. /**
  58467. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58468. * @param rootUrl the url of the texture
  58469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58470. * @returns the fallback texture
  58471. */
  58472. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58473. /**
  58474. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58475. * @param data contains the texture data
  58476. * @param texture defines the BabylonJS internal texture
  58477. * @param createPolynomials will be true if polynomials have been requested
  58478. * @param onLoad defines the callback to trigger once the texture is ready
  58479. * @param onError defines the callback to trigger in case of error
  58480. */
  58481. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58482. /**
  58483. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58484. * @param data contains the texture data
  58485. * @param texture defines the BabylonJS internal texture
  58486. * @param callback defines the method to call once ready to upload
  58487. */
  58488. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58489. }
  58490. }
  58491. declare module "babylonjs/Misc/basis" {
  58492. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58493. /**
  58494. * Info about the .basis files
  58495. */
  58496. class BasisFileInfo {
  58497. /**
  58498. * If the file has alpha
  58499. */
  58500. hasAlpha: boolean;
  58501. /**
  58502. * Info about each image of the basis file
  58503. */
  58504. images: Array<{
  58505. levels: Array<{
  58506. width: number;
  58507. height: number;
  58508. transcodedPixels: ArrayBufferView;
  58509. }>;
  58510. }>;
  58511. }
  58512. /**
  58513. * Result of transcoding a basis file
  58514. */
  58515. class TranscodeResult {
  58516. /**
  58517. * Info about the .basis file
  58518. */
  58519. fileInfo: BasisFileInfo;
  58520. /**
  58521. * Format to use when loading the file
  58522. */
  58523. format: number;
  58524. }
  58525. /**
  58526. * Configuration options for the Basis transcoder
  58527. */
  58528. export class BasisTranscodeConfiguration {
  58529. /**
  58530. * Supported compression formats used to determine the supported output format of the transcoder
  58531. */
  58532. supportedCompressionFormats?: {
  58533. /**
  58534. * etc1 compression format
  58535. */
  58536. etc1?: boolean;
  58537. /**
  58538. * s3tc compression format
  58539. */
  58540. s3tc?: boolean;
  58541. /**
  58542. * pvrtc compression format
  58543. */
  58544. pvrtc?: boolean;
  58545. /**
  58546. * etc2 compression format
  58547. */
  58548. etc2?: boolean;
  58549. };
  58550. /**
  58551. * If mipmap levels should be loaded for transcoded images (Default: true)
  58552. */
  58553. loadMipmapLevels?: boolean;
  58554. /**
  58555. * Index of a single image to load (Default: all images)
  58556. */
  58557. loadSingleImage?: number;
  58558. }
  58559. /**
  58560. * Used to load .Basis files
  58561. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58562. */
  58563. export class BasisTools {
  58564. private static _IgnoreSupportedFormats;
  58565. /**
  58566. * URL to use when loading the basis transcoder
  58567. */
  58568. static JSModuleURL: string;
  58569. /**
  58570. * URL to use when loading the wasm module for the transcoder
  58571. */
  58572. static WasmModuleURL: string;
  58573. /**
  58574. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58575. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58576. * @returns internal format corresponding to the Basis format
  58577. */
  58578. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58579. private static _WorkerPromise;
  58580. private static _Worker;
  58581. private static _actionId;
  58582. private static _CreateWorkerAsync;
  58583. /**
  58584. * Transcodes a loaded image file to compressed pixel data
  58585. * @param data image data to transcode
  58586. * @param config configuration options for the transcoding
  58587. * @returns a promise resulting in the transcoded image
  58588. */
  58589. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58590. /**
  58591. * Loads a texture from the transcode result
  58592. * @param texture texture load to
  58593. * @param transcodeResult the result of transcoding the basis file to load from
  58594. */
  58595. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58596. }
  58597. }
  58598. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58599. import { Nullable } from "babylonjs/types";
  58600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58601. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58602. /**
  58603. * Loader for .basis file format
  58604. */
  58605. export class _BasisTextureLoader implements IInternalTextureLoader {
  58606. /**
  58607. * Defines whether the loader supports cascade loading the different faces.
  58608. */
  58609. readonly supportCascades: boolean;
  58610. /**
  58611. * This returns if the loader support the current file information.
  58612. * @param extension defines the file extension of the file being loaded
  58613. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58614. * @param fallback defines the fallback internal texture if any
  58615. * @param isBase64 defines whether the texture is encoded as a base64
  58616. * @param isBuffer defines whether the texture data are stored as a buffer
  58617. * @returns true if the loader can load the specified file
  58618. */
  58619. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58620. /**
  58621. * Transform the url before loading if required.
  58622. * @param rootUrl the url of the texture
  58623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58624. * @returns the transformed texture
  58625. */
  58626. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58627. /**
  58628. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58629. * @param rootUrl the url of the texture
  58630. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58631. * @returns the fallback texture
  58632. */
  58633. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58634. /**
  58635. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58636. * @param data contains the texture data
  58637. * @param texture defines the BabylonJS internal texture
  58638. * @param createPolynomials will be true if polynomials have been requested
  58639. * @param onLoad defines the callback to trigger once the texture is ready
  58640. * @param onError defines the callback to trigger in case of error
  58641. */
  58642. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58643. /**
  58644. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58645. * @param data contains the texture data
  58646. * @param texture defines the BabylonJS internal texture
  58647. * @param callback defines the method to call once ready to upload
  58648. */
  58649. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58650. }
  58651. }
  58652. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58653. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58654. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58655. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58656. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58657. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58658. }
  58659. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58660. import { Scene } from "babylonjs/scene";
  58661. import { Texture } from "babylonjs/Materials/Textures/texture";
  58662. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58663. /**
  58664. * 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.
  58665. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58666. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58667. */
  58668. export class CustomProceduralTexture extends ProceduralTexture {
  58669. private _animate;
  58670. private _time;
  58671. private _config;
  58672. private _texturePath;
  58673. /**
  58674. * Instantiates a new Custom Procedural Texture.
  58675. * 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.
  58676. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58678. * @param name Define the name of the texture
  58679. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58680. * @param size Define the size of the texture to create
  58681. * @param scene Define the scene the texture belongs to
  58682. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58683. * @param generateMipMaps Define if the texture should creates mip maps or not
  58684. */
  58685. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58686. private _loadJson;
  58687. /**
  58688. * Is the texture ready to be used ? (rendered at least once)
  58689. * @returns true if ready, otherwise, false.
  58690. */
  58691. isReady(): boolean;
  58692. /**
  58693. * Render the texture to its associated render target.
  58694. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58695. */
  58696. render(useCameraPostProcess?: boolean): void;
  58697. /**
  58698. * Update the list of dependant textures samplers in the shader.
  58699. */
  58700. updateTextures(): void;
  58701. /**
  58702. * Update the uniform values of the procedural texture in the shader.
  58703. */
  58704. updateShaderUniforms(): void;
  58705. /**
  58706. * Define if the texture animates or not.
  58707. */
  58708. get animate(): boolean;
  58709. set animate(value: boolean);
  58710. }
  58711. }
  58712. declare module "babylonjs/Shaders/noise.fragment" {
  58713. /** @hidden */
  58714. export var noisePixelShader: {
  58715. name: string;
  58716. shader: string;
  58717. };
  58718. }
  58719. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58720. import { Nullable } from "babylonjs/types";
  58721. import { Scene } from "babylonjs/scene";
  58722. import { Texture } from "babylonjs/Materials/Textures/texture";
  58723. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58724. import "babylonjs/Shaders/noise.fragment";
  58725. /**
  58726. * Class used to generate noise procedural textures
  58727. */
  58728. export class NoiseProceduralTexture extends ProceduralTexture {
  58729. private _time;
  58730. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58731. brightness: number;
  58732. /** Defines the number of octaves to process */
  58733. octaves: number;
  58734. /** Defines the level of persistence (0.8 by default) */
  58735. persistence: number;
  58736. /** Gets or sets animation speed factor (default is 1) */
  58737. animationSpeedFactor: number;
  58738. /**
  58739. * Creates a new NoiseProceduralTexture
  58740. * @param name defines the name fo the texture
  58741. * @param size defines the size of the texture (default is 256)
  58742. * @param scene defines the hosting scene
  58743. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58744. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58745. */
  58746. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58747. private _updateShaderUniforms;
  58748. protected _getDefines(): string;
  58749. /** Generate the current state of the procedural texture */
  58750. render(useCameraPostProcess?: boolean): void;
  58751. /**
  58752. * Serializes this noise procedural texture
  58753. * @returns a serialized noise procedural texture object
  58754. */
  58755. serialize(): any;
  58756. /**
  58757. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58758. * @param parsedTexture defines parsed texture data
  58759. * @param scene defines the current scene
  58760. * @param rootUrl defines the root URL containing noise procedural texture information
  58761. * @returns a parsed NoiseProceduralTexture
  58762. */
  58763. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58764. }
  58765. }
  58766. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58767. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58768. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58769. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58770. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58771. }
  58772. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58773. import { Nullable } from "babylonjs/types";
  58774. import { Scene } from "babylonjs/scene";
  58775. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58776. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58777. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58778. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58779. /**
  58780. * Raw cube texture where the raw buffers are passed in
  58781. */
  58782. export class RawCubeTexture extends CubeTexture {
  58783. /**
  58784. * Creates a cube texture where the raw buffers are passed in.
  58785. * @param scene defines the scene the texture is attached to
  58786. * @param data defines the array of data to use to create each face
  58787. * @param size defines the size of the textures
  58788. * @param format defines the format of the data
  58789. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58790. * @param generateMipMaps defines if the engine should generate the mip levels
  58791. * @param invertY defines if data must be stored with Y axis inverted
  58792. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58793. * @param compression defines the compression used (null by default)
  58794. */
  58795. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58796. /**
  58797. * Updates the raw cube texture.
  58798. * @param data defines the data to store
  58799. * @param format defines the data format
  58800. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58801. * @param invertY defines if data must be stored with Y axis inverted
  58802. * @param compression defines the compression used (null by default)
  58803. * @param level defines which level of the texture to update
  58804. */
  58805. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58806. /**
  58807. * Updates a raw cube texture with RGBD encoded data.
  58808. * @param data defines the array of data [mipmap][face] to use to create each face
  58809. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58810. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58811. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58812. * @returns a promsie that resolves when the operation is complete
  58813. */
  58814. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58815. /**
  58816. * Clones the raw cube texture.
  58817. * @return a new cube texture
  58818. */
  58819. clone(): CubeTexture;
  58820. /** @hidden */
  58821. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58822. }
  58823. }
  58824. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58825. import { Scene } from "babylonjs/scene";
  58826. import { Texture } from "babylonjs/Materials/Textures/texture";
  58827. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58828. /**
  58829. * Class used to store 3D textures containing user data
  58830. */
  58831. export class RawTexture3D extends Texture {
  58832. /** Gets or sets the texture format to use */
  58833. format: number;
  58834. private _engine;
  58835. /**
  58836. * Create a new RawTexture3D
  58837. * @param data defines the data of the texture
  58838. * @param width defines the width of the texture
  58839. * @param height defines the height of the texture
  58840. * @param depth defines the depth of the texture
  58841. * @param format defines the texture format to use
  58842. * @param scene defines the hosting scene
  58843. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58844. * @param invertY defines if texture must be stored with Y axis inverted
  58845. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58846. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58847. */
  58848. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58849. /** Gets or sets the texture format to use */
  58850. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58851. /**
  58852. * Update the texture with new data
  58853. * @param data defines the data to store in the texture
  58854. */
  58855. update(data: ArrayBufferView): void;
  58856. }
  58857. }
  58858. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58859. import { Scene } from "babylonjs/scene";
  58860. import { Texture } from "babylonjs/Materials/Textures/texture";
  58861. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58862. /**
  58863. * Class used to store 2D array textures containing user data
  58864. */
  58865. export class RawTexture2DArray extends Texture {
  58866. /** Gets or sets the texture format to use */
  58867. format: number;
  58868. private _engine;
  58869. /**
  58870. * Create a new RawTexture2DArray
  58871. * @param data defines the data of the texture
  58872. * @param width defines the width of the texture
  58873. * @param height defines the height of the texture
  58874. * @param depth defines the number of layers of the texture
  58875. * @param format defines the texture format to use
  58876. * @param scene defines the hosting scene
  58877. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58878. * @param invertY defines if texture must be stored with Y axis inverted
  58879. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58880. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58881. */
  58882. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58883. /** Gets or sets the texture format to use */
  58884. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58885. /**
  58886. * Update the texture with new data
  58887. * @param data defines the data to store in the texture
  58888. */
  58889. update(data: ArrayBufferView): void;
  58890. }
  58891. }
  58892. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58893. import { Scene } from "babylonjs/scene";
  58894. import { Plane } from "babylonjs/Maths/math.plane";
  58895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58896. /**
  58897. * Creates a refraction texture used by refraction channel of the standard material.
  58898. * It is like a mirror but to see through a material.
  58899. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58900. */
  58901. export class RefractionTexture extends RenderTargetTexture {
  58902. /**
  58903. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58904. * 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.
  58905. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58906. */
  58907. refractionPlane: Plane;
  58908. /**
  58909. * Define how deep under the surface we should see.
  58910. */
  58911. depth: number;
  58912. /**
  58913. * Creates a refraction texture used by refraction channel of the standard material.
  58914. * It is like a mirror but to see through a material.
  58915. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58916. * @param name Define the texture name
  58917. * @param size Define the size of the underlying texture
  58918. * @param scene Define the scene the refraction belongs to
  58919. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58920. */
  58921. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58922. /**
  58923. * Clone the refraction texture.
  58924. * @returns the cloned texture
  58925. */
  58926. clone(): RefractionTexture;
  58927. /**
  58928. * Serialize the texture to a JSON representation you could use in Parse later on
  58929. * @returns the serialized JSON representation
  58930. */
  58931. serialize(): any;
  58932. }
  58933. }
  58934. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58935. import { Nullable } from "babylonjs/types";
  58936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58937. import { Matrix } from "babylonjs/Maths/math.vector";
  58938. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58939. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58940. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58941. import { Scene } from "babylonjs/scene";
  58942. /**
  58943. * Defines the options related to the creation of an HtmlElementTexture
  58944. */
  58945. export interface IHtmlElementTextureOptions {
  58946. /**
  58947. * Defines wether mip maps should be created or not.
  58948. */
  58949. generateMipMaps?: boolean;
  58950. /**
  58951. * Defines the sampling mode of the texture.
  58952. */
  58953. samplingMode?: number;
  58954. /**
  58955. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58956. */
  58957. engine: Nullable<ThinEngine>;
  58958. /**
  58959. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58960. */
  58961. scene: Nullable<Scene>;
  58962. }
  58963. /**
  58964. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58965. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58966. * is automatically managed.
  58967. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58968. * in your application.
  58969. *
  58970. * As the update is not automatic, you need to call them manually.
  58971. */
  58972. export class HtmlElementTexture extends BaseTexture {
  58973. /**
  58974. * The texture URL.
  58975. */
  58976. element: HTMLVideoElement | HTMLCanvasElement;
  58977. private static readonly DefaultOptions;
  58978. private _textureMatrix;
  58979. private _engine;
  58980. private _isVideo;
  58981. private _generateMipMaps;
  58982. private _samplingMode;
  58983. /**
  58984. * Instantiates a HtmlElementTexture from the following parameters.
  58985. *
  58986. * @param name Defines the name of the texture
  58987. * @param element Defines the video or canvas the texture is filled with
  58988. * @param options Defines the other none mandatory texture creation options
  58989. */
  58990. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58991. private _createInternalTexture;
  58992. /**
  58993. * Returns the texture matrix used in most of the material.
  58994. */
  58995. getTextureMatrix(): Matrix;
  58996. /**
  58997. * Updates the content of the texture.
  58998. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58999. */
  59000. update(invertY?: Nullable<boolean>): void;
  59001. }
  59002. }
  59003. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59004. import { Vector2 } from "babylonjs/Maths/math.vector";
  59005. /**
  59006. * Defines the basic options interface of a TexturePacker Frame
  59007. */
  59008. export interface ITexturePackerFrame {
  59009. /**
  59010. * The frame ID
  59011. */
  59012. id: number;
  59013. /**
  59014. * The frames Scale
  59015. */
  59016. scale: Vector2;
  59017. /**
  59018. * The Frames offset
  59019. */
  59020. offset: Vector2;
  59021. }
  59022. /**
  59023. * This is a support class for frame Data on texture packer sets.
  59024. */
  59025. export class TexturePackerFrame implements ITexturePackerFrame {
  59026. /**
  59027. * The frame ID
  59028. */
  59029. id: number;
  59030. /**
  59031. * The frames Scale
  59032. */
  59033. scale: Vector2;
  59034. /**
  59035. * The Frames offset
  59036. */
  59037. offset: Vector2;
  59038. /**
  59039. * Initializes a texture package frame.
  59040. * @param id The numerical frame identifier
  59041. * @param scale Scalar Vector2 for UV frame
  59042. * @param offset Vector2 for the frame position in UV units.
  59043. * @returns TexturePackerFrame
  59044. */
  59045. constructor(id: number, scale: Vector2, offset: Vector2);
  59046. }
  59047. }
  59048. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59050. import { Scene } from "babylonjs/scene";
  59051. import { Nullable } from "babylonjs/types";
  59052. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59053. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59054. /**
  59055. * Defines the basic options interface of a TexturePacker
  59056. */
  59057. export interface ITexturePackerOptions {
  59058. /**
  59059. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59060. */
  59061. map?: string[];
  59062. /**
  59063. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59064. */
  59065. uvsIn?: string;
  59066. /**
  59067. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59068. */
  59069. uvsOut?: string;
  59070. /**
  59071. * number representing the layout style. Defaults to LAYOUT_STRIP
  59072. */
  59073. layout?: number;
  59074. /**
  59075. * number of columns if using custom column count layout(2). This defaults to 4.
  59076. */
  59077. colnum?: number;
  59078. /**
  59079. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59080. */
  59081. updateInputMeshes?: boolean;
  59082. /**
  59083. * boolean flag to dispose all the source textures. Defaults to true.
  59084. */
  59085. disposeSources?: boolean;
  59086. /**
  59087. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59088. */
  59089. fillBlanks?: boolean;
  59090. /**
  59091. * string value representing the context fill style color. Defaults to 'black'.
  59092. */
  59093. customFillColor?: string;
  59094. /**
  59095. * Width and Height Value of each Frame in the TexturePacker Sets
  59096. */
  59097. frameSize?: number;
  59098. /**
  59099. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59100. */
  59101. paddingRatio?: number;
  59102. /**
  59103. * Number that declares the fill method for the padding gutter.
  59104. */
  59105. paddingMode?: number;
  59106. /**
  59107. * If in SUBUV_COLOR padding mode what color to use.
  59108. */
  59109. paddingColor?: Color3 | Color4;
  59110. }
  59111. /**
  59112. * Defines the basic interface of a TexturePacker JSON File
  59113. */
  59114. export interface ITexturePackerJSON {
  59115. /**
  59116. * The frame ID
  59117. */
  59118. name: string;
  59119. /**
  59120. * The base64 channel data
  59121. */
  59122. sets: any;
  59123. /**
  59124. * The options of the Packer
  59125. */
  59126. options: ITexturePackerOptions;
  59127. /**
  59128. * The frame data of the Packer
  59129. */
  59130. frames: Array<number>;
  59131. }
  59132. /**
  59133. * This is a support class that generates a series of packed texture sets.
  59134. * @see https://doc.babylonjs.com/babylon101/materials
  59135. */
  59136. export class TexturePacker {
  59137. /** Packer Layout Constant 0 */
  59138. static readonly LAYOUT_STRIP: number;
  59139. /** Packer Layout Constant 1 */
  59140. static readonly LAYOUT_POWER2: number;
  59141. /** Packer Layout Constant 2 */
  59142. static readonly LAYOUT_COLNUM: number;
  59143. /** Packer Layout Constant 0 */
  59144. static readonly SUBUV_WRAP: number;
  59145. /** Packer Layout Constant 1 */
  59146. static readonly SUBUV_EXTEND: number;
  59147. /** Packer Layout Constant 2 */
  59148. static readonly SUBUV_COLOR: number;
  59149. /** The Name of the Texture Package */
  59150. name: string;
  59151. /** The scene scope of the TexturePacker */
  59152. scene: Scene;
  59153. /** The Meshes to target */
  59154. meshes: AbstractMesh[];
  59155. /** Arguments passed with the Constructor */
  59156. options: ITexturePackerOptions;
  59157. /** The promise that is started upon initialization */
  59158. promise: Nullable<Promise<TexturePacker | string>>;
  59159. /** The Container object for the channel sets that are generated */
  59160. sets: object;
  59161. /** The Container array for the frames that are generated */
  59162. frames: TexturePackerFrame[];
  59163. /** The expected number of textures the system is parsing. */
  59164. private _expecting;
  59165. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59166. private _paddingValue;
  59167. /**
  59168. * Initializes a texture package series from an array of meshes or a single mesh.
  59169. * @param name The name of the package
  59170. * @param meshes The target meshes to compose the package from
  59171. * @param options The arguments that texture packer should follow while building.
  59172. * @param scene The scene which the textures are scoped to.
  59173. * @returns TexturePacker
  59174. */
  59175. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59176. /**
  59177. * Starts the package process
  59178. * @param resolve The promises resolution function
  59179. * @returns TexturePacker
  59180. */
  59181. private _createFrames;
  59182. /**
  59183. * Calculates the Size of the Channel Sets
  59184. * @returns Vector2
  59185. */
  59186. private _calculateSize;
  59187. /**
  59188. * Calculates the UV data for the frames.
  59189. * @param baseSize the base frameSize
  59190. * @param padding the base frame padding
  59191. * @param dtSize size of the Dynamic Texture for that channel
  59192. * @param dtUnits is 1/dtSize
  59193. * @param update flag to update the input meshes
  59194. */
  59195. private _calculateMeshUVFrames;
  59196. /**
  59197. * Calculates the frames Offset.
  59198. * @param index of the frame
  59199. * @returns Vector2
  59200. */
  59201. private _getFrameOffset;
  59202. /**
  59203. * Updates a Mesh to the frame data
  59204. * @param mesh that is the target
  59205. * @param frameID or the frame index
  59206. */
  59207. private _updateMeshUV;
  59208. /**
  59209. * Updates a Meshes materials to use the texture packer channels
  59210. * @param m is the mesh to target
  59211. * @param force all channels on the packer to be set.
  59212. */
  59213. private _updateTextureReferences;
  59214. /**
  59215. * Public method to set a Mesh to a frame
  59216. * @param m that is the target
  59217. * @param frameID or the frame index
  59218. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59219. */
  59220. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59221. /**
  59222. * Starts the async promise to compile the texture packer.
  59223. * @returns Promise<void>
  59224. */
  59225. processAsync(): Promise<void>;
  59226. /**
  59227. * Disposes all textures associated with this packer
  59228. */
  59229. dispose(): void;
  59230. /**
  59231. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59232. * @param imageType is the image type to use.
  59233. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59234. */
  59235. download(imageType?: string, quality?: number): void;
  59236. /**
  59237. * Public method to load a texturePacker JSON file.
  59238. * @param data of the JSON file in string format.
  59239. */
  59240. updateFromJSON(data: string): void;
  59241. }
  59242. }
  59243. declare module "babylonjs/Materials/Textures/Packer/index" {
  59244. export * from "babylonjs/Materials/Textures/Packer/packer";
  59245. export * from "babylonjs/Materials/Textures/Packer/frame";
  59246. }
  59247. declare module "babylonjs/Materials/Textures/index" {
  59248. export * from "babylonjs/Materials/Textures/baseTexture";
  59249. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59250. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59251. export * from "babylonjs/Materials/Textures/cubeTexture";
  59252. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59253. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59254. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59255. export * from "babylonjs/Materials/Textures/internalTexture";
  59256. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59257. export * from "babylonjs/Materials/Textures/Loaders/index";
  59258. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59259. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59260. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59261. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59262. export * from "babylonjs/Materials/Textures/rawTexture";
  59263. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59264. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59265. export * from "babylonjs/Materials/Textures/refractionTexture";
  59266. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59267. export * from "babylonjs/Materials/Textures/texture";
  59268. export * from "babylonjs/Materials/Textures/videoTexture";
  59269. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59270. export * from "babylonjs/Materials/Textures/Packer/index";
  59271. }
  59272. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59273. /**
  59274. * Enum used to define the target of a block
  59275. */
  59276. export enum NodeMaterialBlockTargets {
  59277. /** Vertex shader */
  59278. Vertex = 1,
  59279. /** Fragment shader */
  59280. Fragment = 2,
  59281. /** Neutral */
  59282. Neutral = 4,
  59283. /** Vertex and Fragment */
  59284. VertexAndFragment = 3
  59285. }
  59286. }
  59287. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59288. /**
  59289. * Defines the kind of connection point for node based material
  59290. */
  59291. export enum NodeMaterialBlockConnectionPointTypes {
  59292. /** Float */
  59293. Float = 1,
  59294. /** Int */
  59295. Int = 2,
  59296. /** Vector2 */
  59297. Vector2 = 4,
  59298. /** Vector3 */
  59299. Vector3 = 8,
  59300. /** Vector4 */
  59301. Vector4 = 16,
  59302. /** Color3 */
  59303. Color3 = 32,
  59304. /** Color4 */
  59305. Color4 = 64,
  59306. /** Matrix */
  59307. Matrix = 128,
  59308. /** Detect type based on connection */
  59309. AutoDetect = 1024,
  59310. /** Output type that will be defined by input type */
  59311. BasedOnInput = 2048
  59312. }
  59313. }
  59314. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59315. /**
  59316. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59317. */
  59318. export enum NodeMaterialBlockConnectionPointMode {
  59319. /** Value is an uniform */
  59320. Uniform = 0,
  59321. /** Value is a mesh attribute */
  59322. Attribute = 1,
  59323. /** Value is a varying between vertex and fragment shaders */
  59324. Varying = 2,
  59325. /** Mode is undefined */
  59326. Undefined = 3
  59327. }
  59328. }
  59329. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59330. /**
  59331. * Enum used to define system values e.g. values automatically provided by the system
  59332. */
  59333. export enum NodeMaterialSystemValues {
  59334. /** World */
  59335. World = 1,
  59336. /** View */
  59337. View = 2,
  59338. /** Projection */
  59339. Projection = 3,
  59340. /** ViewProjection */
  59341. ViewProjection = 4,
  59342. /** WorldView */
  59343. WorldView = 5,
  59344. /** WorldViewProjection */
  59345. WorldViewProjection = 6,
  59346. /** CameraPosition */
  59347. CameraPosition = 7,
  59348. /** Fog Color */
  59349. FogColor = 8,
  59350. /** Delta time */
  59351. DeltaTime = 9
  59352. }
  59353. }
  59354. declare module "babylonjs/Materials/Node/Enums/index" {
  59355. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59356. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59357. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59358. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59359. }
  59360. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59362. /**
  59363. * Root class for all node material optimizers
  59364. */
  59365. export class NodeMaterialOptimizer {
  59366. /**
  59367. * Function used to optimize a NodeMaterial graph
  59368. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59369. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59370. */
  59371. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59372. }
  59373. }
  59374. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59378. import { Scene } from "babylonjs/scene";
  59379. /**
  59380. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59381. */
  59382. export class TransformBlock extends NodeMaterialBlock {
  59383. /**
  59384. * Defines the value to use to complement W value to transform it to a Vector4
  59385. */
  59386. complementW: number;
  59387. /**
  59388. * Defines the value to use to complement z value to transform it to a Vector4
  59389. */
  59390. complementZ: number;
  59391. /**
  59392. * Creates a new TransformBlock
  59393. * @param name defines the block name
  59394. */
  59395. constructor(name: string);
  59396. /**
  59397. * Gets the current class name
  59398. * @returns the class name
  59399. */
  59400. getClassName(): string;
  59401. /**
  59402. * Gets the vector input
  59403. */
  59404. get vector(): NodeMaterialConnectionPoint;
  59405. /**
  59406. * Gets the output component
  59407. */
  59408. get output(): NodeMaterialConnectionPoint;
  59409. /**
  59410. * Gets the matrix transform input
  59411. */
  59412. get transform(): NodeMaterialConnectionPoint;
  59413. protected _buildBlock(state: NodeMaterialBuildState): this;
  59414. serialize(): any;
  59415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59416. protected _dumpPropertiesCode(): string;
  59417. }
  59418. }
  59419. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59423. /**
  59424. * Block used to output the vertex position
  59425. */
  59426. export class VertexOutputBlock extends NodeMaterialBlock {
  59427. /**
  59428. * Creates a new VertexOutputBlock
  59429. * @param name defines the block name
  59430. */
  59431. constructor(name: string);
  59432. /**
  59433. * Gets the current class name
  59434. * @returns the class name
  59435. */
  59436. getClassName(): string;
  59437. /**
  59438. * Gets the vector input component
  59439. */
  59440. get vector(): NodeMaterialConnectionPoint;
  59441. protected _buildBlock(state: NodeMaterialBuildState): this;
  59442. }
  59443. }
  59444. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59448. /**
  59449. * Block used to output the final color
  59450. */
  59451. export class FragmentOutputBlock extends NodeMaterialBlock {
  59452. /**
  59453. * Create a new FragmentOutputBlock
  59454. * @param name defines the block name
  59455. */
  59456. constructor(name: string);
  59457. /**
  59458. * Gets the current class name
  59459. * @returns the class name
  59460. */
  59461. getClassName(): string;
  59462. /**
  59463. * Gets the rgba input component
  59464. */
  59465. get rgba(): NodeMaterialConnectionPoint;
  59466. /**
  59467. * Gets the rgb input component
  59468. */
  59469. get rgb(): NodeMaterialConnectionPoint;
  59470. /**
  59471. * Gets the a input component
  59472. */
  59473. get a(): NodeMaterialConnectionPoint;
  59474. protected _buildBlock(state: NodeMaterialBuildState): this;
  59475. }
  59476. }
  59477. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59483. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59484. import { Effect } from "babylonjs/Materials/effect";
  59485. import { Mesh } from "babylonjs/Meshes/mesh";
  59486. import { Nullable } from "babylonjs/types";
  59487. import { Scene } from "babylonjs/scene";
  59488. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59489. /**
  59490. * Block used to read a reflection texture from a sampler
  59491. */
  59492. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59493. private _define3DName;
  59494. private _defineCubicName;
  59495. private _defineExplicitName;
  59496. private _defineProjectionName;
  59497. private _defineLocalCubicName;
  59498. private _defineSphericalName;
  59499. private _definePlanarName;
  59500. private _defineEquirectangularName;
  59501. private _defineMirroredEquirectangularFixedName;
  59502. private _defineEquirectangularFixedName;
  59503. private _defineSkyboxName;
  59504. private _cubeSamplerName;
  59505. private _2DSamplerName;
  59506. private _positionUVWName;
  59507. private _directionWName;
  59508. private _reflectionCoordsName;
  59509. private _reflection2DCoordsName;
  59510. private _reflectionColorName;
  59511. private _reflectionMatrixName;
  59512. /**
  59513. * Gets or sets the texture associated with the node
  59514. */
  59515. texture: Nullable<BaseTexture>;
  59516. /**
  59517. * Create a new TextureBlock
  59518. * @param name defines the block name
  59519. */
  59520. constructor(name: string);
  59521. /**
  59522. * Gets the current class name
  59523. * @returns the class name
  59524. */
  59525. getClassName(): string;
  59526. /**
  59527. * Gets the world position input component
  59528. */
  59529. get position(): NodeMaterialConnectionPoint;
  59530. /**
  59531. * Gets the world position input component
  59532. */
  59533. get worldPosition(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the world normal input component
  59536. */
  59537. get worldNormal(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the world input component
  59540. */
  59541. get world(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the camera (or eye) position component
  59544. */
  59545. get cameraPosition(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the view input component
  59548. */
  59549. get view(): NodeMaterialConnectionPoint;
  59550. /**
  59551. * Gets the rgb output component
  59552. */
  59553. get rgb(): NodeMaterialConnectionPoint;
  59554. /**
  59555. * Gets the r output component
  59556. */
  59557. get r(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the g output component
  59560. */
  59561. get g(): NodeMaterialConnectionPoint;
  59562. /**
  59563. * Gets the b output component
  59564. */
  59565. get b(): NodeMaterialConnectionPoint;
  59566. autoConfigure(material: NodeMaterial): void;
  59567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59568. isReady(): boolean;
  59569. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59570. private _injectVertexCode;
  59571. private _writeOutput;
  59572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59573. protected _dumpPropertiesCode(): string;
  59574. serialize(): any;
  59575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59576. }
  59577. }
  59578. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59580. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59581. import { Scene } from "babylonjs/scene";
  59582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59583. import { Matrix } from "babylonjs/Maths/math.vector";
  59584. import { Mesh } from "babylonjs/Meshes/mesh";
  59585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59586. import { Observable } from "babylonjs/Misc/observable";
  59587. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59588. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59589. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59590. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59591. import { Nullable } from "babylonjs/types";
  59592. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59593. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59594. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59595. /**
  59596. * Interface used to configure the node material editor
  59597. */
  59598. export interface INodeMaterialEditorOptions {
  59599. /** Define the URl to load node editor script */
  59600. editorURL?: string;
  59601. }
  59602. /** @hidden */
  59603. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59604. NORMAL: boolean;
  59605. TANGENT: boolean;
  59606. UV1: boolean;
  59607. /** BONES */
  59608. NUM_BONE_INFLUENCERS: number;
  59609. BonesPerMesh: number;
  59610. BONETEXTURE: boolean;
  59611. /** MORPH TARGETS */
  59612. MORPHTARGETS: boolean;
  59613. MORPHTARGETS_NORMAL: boolean;
  59614. MORPHTARGETS_TANGENT: boolean;
  59615. MORPHTARGETS_UV: boolean;
  59616. NUM_MORPH_INFLUENCERS: number;
  59617. /** IMAGE PROCESSING */
  59618. IMAGEPROCESSING: boolean;
  59619. VIGNETTE: boolean;
  59620. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59621. VIGNETTEBLENDMODEOPAQUE: boolean;
  59622. TONEMAPPING: boolean;
  59623. TONEMAPPING_ACES: boolean;
  59624. CONTRAST: boolean;
  59625. EXPOSURE: boolean;
  59626. COLORCURVES: boolean;
  59627. COLORGRADING: boolean;
  59628. COLORGRADING3D: boolean;
  59629. SAMPLER3DGREENDEPTH: boolean;
  59630. SAMPLER3DBGRMAP: boolean;
  59631. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59632. /** MISC. */
  59633. BUMPDIRECTUV: number;
  59634. constructor();
  59635. setValue(name: string, value: boolean): void;
  59636. }
  59637. /**
  59638. * Class used to configure NodeMaterial
  59639. */
  59640. export interface INodeMaterialOptions {
  59641. /**
  59642. * Defines if blocks should emit comments
  59643. */
  59644. emitComments: boolean;
  59645. }
  59646. /**
  59647. * Class used to create a node based material built by assembling shader blocks
  59648. */
  59649. export class NodeMaterial extends PushMaterial {
  59650. private static _BuildIdGenerator;
  59651. private _options;
  59652. private _vertexCompilationState;
  59653. private _fragmentCompilationState;
  59654. private _sharedData;
  59655. private _buildId;
  59656. private _buildWasSuccessful;
  59657. private _cachedWorldViewMatrix;
  59658. private _cachedWorldViewProjectionMatrix;
  59659. private _optimizers;
  59660. private _animationFrame;
  59661. /** Define the Url to load node editor script */
  59662. static EditorURL: string;
  59663. /** Define the Url to load snippets */
  59664. static SnippetUrl: string;
  59665. private BJSNODEMATERIALEDITOR;
  59666. /** Get the inspector from bundle or global */
  59667. private _getGlobalNodeMaterialEditor;
  59668. /**
  59669. * Gets or sets data used by visual editor
  59670. * @see https://nme.babylonjs.com
  59671. */
  59672. editorData: any;
  59673. /**
  59674. * 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)
  59675. */
  59676. ignoreAlpha: boolean;
  59677. /**
  59678. * Defines the maximum number of lights that can be used in the material
  59679. */
  59680. maxSimultaneousLights: number;
  59681. /**
  59682. * Observable raised when the material is built
  59683. */
  59684. onBuildObservable: Observable<NodeMaterial>;
  59685. /**
  59686. * Gets or sets the root nodes of the material vertex shader
  59687. */
  59688. _vertexOutputNodes: NodeMaterialBlock[];
  59689. /**
  59690. * Gets or sets the root nodes of the material fragment (pixel) shader
  59691. */
  59692. _fragmentOutputNodes: NodeMaterialBlock[];
  59693. /** Gets or sets options to control the node material overall behavior */
  59694. get options(): INodeMaterialOptions;
  59695. set options(options: INodeMaterialOptions);
  59696. /**
  59697. * Default configuration related to image processing available in the standard Material.
  59698. */
  59699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59700. /**
  59701. * Gets the image processing configuration used either in this material.
  59702. */
  59703. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59704. /**
  59705. * Sets the Default image processing configuration used either in the this material.
  59706. *
  59707. * If sets to null, the scene one is in use.
  59708. */
  59709. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59710. /**
  59711. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59712. */
  59713. attachedBlocks: NodeMaterialBlock[];
  59714. /**
  59715. * Create a new node based material
  59716. * @param name defines the material name
  59717. * @param scene defines the hosting scene
  59718. * @param options defines creation option
  59719. */
  59720. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59721. /**
  59722. * Gets the current class name of the material e.g. "NodeMaterial"
  59723. * @returns the class name
  59724. */
  59725. getClassName(): string;
  59726. /**
  59727. * Keep track of the image processing observer to allow dispose and replace.
  59728. */
  59729. private _imageProcessingObserver;
  59730. /**
  59731. * Attaches a new image processing configuration to the Standard Material.
  59732. * @param configuration
  59733. */
  59734. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59735. /**
  59736. * Get a block by its name
  59737. * @param name defines the name of the block to retrieve
  59738. * @returns the required block or null if not found
  59739. */
  59740. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59741. /**
  59742. * Get a block by its name
  59743. * @param predicate defines the predicate used to find the good candidate
  59744. * @returns the required block or null if not found
  59745. */
  59746. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59747. /**
  59748. * Get an input block by its name
  59749. * @param predicate defines the predicate used to find the good candidate
  59750. * @returns the required input block or null if not found
  59751. */
  59752. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59753. /**
  59754. * Gets the list of input blocks attached to this material
  59755. * @returns an array of InputBlocks
  59756. */
  59757. getInputBlocks(): InputBlock[];
  59758. /**
  59759. * Adds a new optimizer to the list of optimizers
  59760. * @param optimizer defines the optimizers to add
  59761. * @returns the current material
  59762. */
  59763. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59764. /**
  59765. * Remove an optimizer from the list of optimizers
  59766. * @param optimizer defines the optimizers to remove
  59767. * @returns the current material
  59768. */
  59769. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59770. /**
  59771. * Add a new block to the list of output nodes
  59772. * @param node defines the node to add
  59773. * @returns the current material
  59774. */
  59775. addOutputNode(node: NodeMaterialBlock): this;
  59776. /**
  59777. * Remove a block from the list of root nodes
  59778. * @param node defines the node to remove
  59779. * @returns the current material
  59780. */
  59781. removeOutputNode(node: NodeMaterialBlock): this;
  59782. private _addVertexOutputNode;
  59783. private _removeVertexOutputNode;
  59784. private _addFragmentOutputNode;
  59785. private _removeFragmentOutputNode;
  59786. /**
  59787. * Specifies if the material will require alpha blending
  59788. * @returns a boolean specifying if alpha blending is needed
  59789. */
  59790. needAlphaBlending(): boolean;
  59791. /**
  59792. * Specifies if this material should be rendered in alpha test mode
  59793. * @returns a boolean specifying if an alpha test is needed.
  59794. */
  59795. needAlphaTesting(): boolean;
  59796. private _initializeBlock;
  59797. private _resetDualBlocks;
  59798. /**
  59799. * Remove a block from the current node material
  59800. * @param block defines the block to remove
  59801. */
  59802. removeBlock(block: NodeMaterialBlock): void;
  59803. /**
  59804. * Build the material and generates the inner effect
  59805. * @param verbose defines if the build should log activity
  59806. */
  59807. build(verbose?: boolean): void;
  59808. /**
  59809. * Runs an otpimization phase to try to improve the shader code
  59810. */
  59811. optimize(): void;
  59812. private _prepareDefinesForAttributes;
  59813. /**
  59814. * Get if the submesh is ready to be used and all its information available.
  59815. * Child classes can use it to update shaders
  59816. * @param mesh defines the mesh to check
  59817. * @param subMesh defines which submesh to check
  59818. * @param useInstances specifies that instances should be used
  59819. * @returns a boolean indicating that the submesh is ready or not
  59820. */
  59821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59822. /**
  59823. * Get a string representing the shaders built by the current node graph
  59824. */
  59825. get compiledShaders(): string;
  59826. /**
  59827. * Binds the world matrix to the material
  59828. * @param world defines the world transformation matrix
  59829. */
  59830. bindOnlyWorldMatrix(world: Matrix): void;
  59831. /**
  59832. * Binds the submesh to this material by preparing the effect and shader to draw
  59833. * @param world defines the world transformation matrix
  59834. * @param mesh defines the mesh containing the submesh
  59835. * @param subMesh defines the submesh to bind the material to
  59836. */
  59837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59838. /**
  59839. * Gets the active textures from the material
  59840. * @returns an array of textures
  59841. */
  59842. getActiveTextures(): BaseTexture[];
  59843. /**
  59844. * Gets the list of texture blocks
  59845. * @returns an array of texture blocks
  59846. */
  59847. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59848. /**
  59849. * Specifies if the material uses a texture
  59850. * @param texture defines the texture to check against the material
  59851. * @returns a boolean specifying if the material uses the texture
  59852. */
  59853. hasTexture(texture: BaseTexture): boolean;
  59854. /**
  59855. * Disposes the material
  59856. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59857. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59858. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59859. */
  59860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59861. /** Creates the node editor window. */
  59862. private _createNodeEditor;
  59863. /**
  59864. * Launch the node material editor
  59865. * @param config Define the configuration of the editor
  59866. * @return a promise fulfilled when the node editor is visible
  59867. */
  59868. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59869. /**
  59870. * Clear the current material
  59871. */
  59872. clear(): void;
  59873. /**
  59874. * Clear the current material and set it to a default state
  59875. */
  59876. setToDefault(): void;
  59877. /**
  59878. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59879. * @param url defines the url to load from
  59880. * @returns a promise that will fullfil when the material is fully loaded
  59881. */
  59882. loadAsync(url: string): Promise<void>;
  59883. private _gatherBlocks;
  59884. /**
  59885. * Generate a string containing the code declaration required to create an equivalent of this material
  59886. * @returns a string
  59887. */
  59888. generateCode(): string;
  59889. /**
  59890. * Serializes this material in a JSON representation
  59891. * @returns the serialized material object
  59892. */
  59893. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59894. private _restoreConnections;
  59895. /**
  59896. * Clear the current graph and load a new one from a serialization object
  59897. * @param source defines the JSON representation of the material
  59898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59899. */
  59900. loadFromSerialization(source: any, rootUrl?: string): void;
  59901. /**
  59902. * Creates a node material from parsed material data
  59903. * @param source defines the JSON representation of the material
  59904. * @param scene defines the hosting scene
  59905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59906. * @returns a new node material
  59907. */
  59908. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59909. /**
  59910. * Creates a node material from a snippet saved in a remote file
  59911. * @param name defines the name of the material to create
  59912. * @param url defines the url to load from
  59913. * @param scene defines the hosting scene
  59914. * @returns a promise that will resolve to the new node material
  59915. */
  59916. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59917. /**
  59918. * Creates a node material from a snippet saved by the node material editor
  59919. * @param snippetId defines the snippet to load
  59920. * @param scene defines the hosting scene
  59921. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59922. * @returns a promise that will resolve to the new node material
  59923. */
  59924. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59925. /**
  59926. * Creates a new node material set to default basic configuration
  59927. * @param name defines the name of the material
  59928. * @param scene defines the hosting scene
  59929. * @returns a new NodeMaterial
  59930. */
  59931. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59932. }
  59933. }
  59934. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59937. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59940. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59941. import { Effect } from "babylonjs/Materials/effect";
  59942. import { Mesh } from "babylonjs/Meshes/mesh";
  59943. import { Nullable } from "babylonjs/types";
  59944. import { Texture } from "babylonjs/Materials/Textures/texture";
  59945. import { Scene } from "babylonjs/scene";
  59946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59947. /**
  59948. * Block used to read a texture from a sampler
  59949. */
  59950. export class TextureBlock extends NodeMaterialBlock {
  59951. private _defineName;
  59952. private _linearDefineName;
  59953. private _tempTextureRead;
  59954. private _samplerName;
  59955. private _transformedUVName;
  59956. private _textureTransformName;
  59957. private _textureInfoName;
  59958. private _mainUVName;
  59959. private _mainUVDefineName;
  59960. /**
  59961. * Gets or sets the texture associated with the node
  59962. */
  59963. texture: Nullable<Texture>;
  59964. /**
  59965. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59966. */
  59967. convertToGammaSpace: boolean;
  59968. /**
  59969. * Create a new TextureBlock
  59970. * @param name defines the block name
  59971. */
  59972. constructor(name: string);
  59973. /**
  59974. * Gets the current class name
  59975. * @returns the class name
  59976. */
  59977. getClassName(): string;
  59978. /**
  59979. * Gets the uv input component
  59980. */
  59981. get uv(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the rgba output component
  59984. */
  59985. get rgba(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the rgb output component
  59988. */
  59989. get rgb(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the r output component
  59992. */
  59993. get r(): NodeMaterialConnectionPoint;
  59994. /**
  59995. * Gets the g output component
  59996. */
  59997. get g(): NodeMaterialConnectionPoint;
  59998. /**
  59999. * Gets the b output component
  60000. */
  60001. get b(): NodeMaterialConnectionPoint;
  60002. /**
  60003. * Gets the a output component
  60004. */
  60005. get a(): NodeMaterialConnectionPoint;
  60006. get target(): NodeMaterialBlockTargets;
  60007. autoConfigure(material: NodeMaterial): void;
  60008. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60010. isReady(): boolean;
  60011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60012. private get _isMixed();
  60013. private _injectVertexCode;
  60014. private _writeTextureRead;
  60015. private _writeOutput;
  60016. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60017. protected _dumpPropertiesCode(): string;
  60018. serialize(): any;
  60019. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60020. }
  60021. }
  60022. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60025. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60026. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60027. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60028. import { Scene } from "babylonjs/scene";
  60029. /**
  60030. * Class used to store shared data between 2 NodeMaterialBuildState
  60031. */
  60032. export class NodeMaterialBuildStateSharedData {
  60033. /**
  60034. * Gets the list of emitted varyings
  60035. */
  60036. temps: string[];
  60037. /**
  60038. * Gets the list of emitted varyings
  60039. */
  60040. varyings: string[];
  60041. /**
  60042. * Gets the varying declaration string
  60043. */
  60044. varyingDeclaration: string;
  60045. /**
  60046. * Input blocks
  60047. */
  60048. inputBlocks: InputBlock[];
  60049. /**
  60050. * Input blocks
  60051. */
  60052. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60053. /**
  60054. * Bindable blocks (Blocks that need to set data to the effect)
  60055. */
  60056. bindableBlocks: NodeMaterialBlock[];
  60057. /**
  60058. * List of blocks that can provide a compilation fallback
  60059. */
  60060. blocksWithFallbacks: NodeMaterialBlock[];
  60061. /**
  60062. * List of blocks that can provide a define update
  60063. */
  60064. blocksWithDefines: NodeMaterialBlock[];
  60065. /**
  60066. * List of blocks that can provide a repeatable content
  60067. */
  60068. repeatableContentBlocks: NodeMaterialBlock[];
  60069. /**
  60070. * List of blocks that can provide a dynamic list of uniforms
  60071. */
  60072. dynamicUniformBlocks: NodeMaterialBlock[];
  60073. /**
  60074. * List of blocks that can block the isReady function for the material
  60075. */
  60076. blockingBlocks: NodeMaterialBlock[];
  60077. /**
  60078. * Gets the list of animated inputs
  60079. */
  60080. animatedInputs: InputBlock[];
  60081. /**
  60082. * Build Id used to avoid multiple recompilations
  60083. */
  60084. buildId: number;
  60085. /** List of emitted variables */
  60086. variableNames: {
  60087. [key: string]: number;
  60088. };
  60089. /** List of emitted defines */
  60090. defineNames: {
  60091. [key: string]: number;
  60092. };
  60093. /** Should emit comments? */
  60094. emitComments: boolean;
  60095. /** Emit build activity */
  60096. verbose: boolean;
  60097. /** Gets or sets the hosting scene */
  60098. scene: Scene;
  60099. /**
  60100. * Gets the compilation hints emitted at compilation time
  60101. */
  60102. hints: {
  60103. needWorldViewMatrix: boolean;
  60104. needWorldViewProjectionMatrix: boolean;
  60105. needAlphaBlending: boolean;
  60106. needAlphaTesting: boolean;
  60107. };
  60108. /**
  60109. * List of compilation checks
  60110. */
  60111. checks: {
  60112. emitVertex: boolean;
  60113. emitFragment: boolean;
  60114. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60115. };
  60116. /** Creates a new shared data */
  60117. constructor();
  60118. /**
  60119. * Emits console errors and exceptions if there is a failing check
  60120. */
  60121. emitErrors(): void;
  60122. }
  60123. }
  60124. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60125. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60126. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60127. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60128. /**
  60129. * Class used to store node based material build state
  60130. */
  60131. export class NodeMaterialBuildState {
  60132. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60133. supportUniformBuffers: boolean;
  60134. /**
  60135. * Gets the list of emitted attributes
  60136. */
  60137. attributes: string[];
  60138. /**
  60139. * Gets the list of emitted uniforms
  60140. */
  60141. uniforms: string[];
  60142. /**
  60143. * Gets the list of emitted constants
  60144. */
  60145. constants: string[];
  60146. /**
  60147. * Gets the list of emitted samplers
  60148. */
  60149. samplers: string[];
  60150. /**
  60151. * Gets the list of emitted functions
  60152. */
  60153. functions: {
  60154. [key: string]: string;
  60155. };
  60156. /**
  60157. * Gets the list of emitted extensions
  60158. */
  60159. extensions: {
  60160. [key: string]: string;
  60161. };
  60162. /**
  60163. * Gets the target of the compilation state
  60164. */
  60165. target: NodeMaterialBlockTargets;
  60166. /**
  60167. * Gets the list of emitted counters
  60168. */
  60169. counters: {
  60170. [key: string]: number;
  60171. };
  60172. /**
  60173. * Shared data between multiple NodeMaterialBuildState instances
  60174. */
  60175. sharedData: NodeMaterialBuildStateSharedData;
  60176. /** @hidden */
  60177. _vertexState: NodeMaterialBuildState;
  60178. /** @hidden */
  60179. _attributeDeclaration: string;
  60180. /** @hidden */
  60181. _uniformDeclaration: string;
  60182. /** @hidden */
  60183. _constantDeclaration: string;
  60184. /** @hidden */
  60185. _samplerDeclaration: string;
  60186. /** @hidden */
  60187. _varyingTransfer: string;
  60188. private _repeatableContentAnchorIndex;
  60189. /** @hidden */
  60190. _builtCompilationString: string;
  60191. /**
  60192. * Gets the emitted compilation strings
  60193. */
  60194. compilationString: string;
  60195. /**
  60196. * Finalize the compilation strings
  60197. * @param state defines the current compilation state
  60198. */
  60199. finalize(state: NodeMaterialBuildState): void;
  60200. /** @hidden */
  60201. get _repeatableContentAnchor(): string;
  60202. /** @hidden */
  60203. _getFreeVariableName(prefix: string): string;
  60204. /** @hidden */
  60205. _getFreeDefineName(prefix: string): string;
  60206. /** @hidden */
  60207. _excludeVariableName(name: string): void;
  60208. /** @hidden */
  60209. _emit2DSampler(name: string): void;
  60210. /** @hidden */
  60211. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60212. /** @hidden */
  60213. _emitExtension(name: string, extension: string): void;
  60214. /** @hidden */
  60215. _emitFunction(name: string, code: string, comments: string): void;
  60216. /** @hidden */
  60217. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60218. replaceStrings?: {
  60219. search: RegExp;
  60220. replace: string;
  60221. }[];
  60222. repeatKey?: string;
  60223. }): string;
  60224. /** @hidden */
  60225. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60226. repeatKey?: string;
  60227. removeAttributes?: boolean;
  60228. removeUniforms?: boolean;
  60229. removeVaryings?: boolean;
  60230. removeIfDef?: boolean;
  60231. replaceStrings?: {
  60232. search: RegExp;
  60233. replace: string;
  60234. }[];
  60235. }, storeKey?: string): void;
  60236. /** @hidden */
  60237. _registerTempVariable(name: string): boolean;
  60238. /** @hidden */
  60239. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60240. /** @hidden */
  60241. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60242. /** @hidden */
  60243. _emitFloat(value: number): string;
  60244. }
  60245. }
  60246. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60247. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60249. import { Nullable } from "babylonjs/types";
  60250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60251. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60252. import { Effect } from "babylonjs/Materials/effect";
  60253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60254. import { Mesh } from "babylonjs/Meshes/mesh";
  60255. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60256. import { Scene } from "babylonjs/scene";
  60257. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60258. /**
  60259. * Defines a block that can be used inside a node based material
  60260. */
  60261. export class NodeMaterialBlock {
  60262. private _buildId;
  60263. private _buildTarget;
  60264. private _target;
  60265. private _isFinalMerger;
  60266. private _isInput;
  60267. protected _isUnique: boolean;
  60268. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60269. inputsAreExclusive: boolean;
  60270. /** @hidden */
  60271. _codeVariableName: string;
  60272. /** @hidden */
  60273. _inputs: NodeMaterialConnectionPoint[];
  60274. /** @hidden */
  60275. _outputs: NodeMaterialConnectionPoint[];
  60276. /** @hidden */
  60277. _preparationId: number;
  60278. /**
  60279. * Gets or sets the name of the block
  60280. */
  60281. name: string;
  60282. /**
  60283. * Gets or sets the unique id of the node
  60284. */
  60285. uniqueId: number;
  60286. /**
  60287. * Gets or sets the comments associated with this block
  60288. */
  60289. comments: string;
  60290. /**
  60291. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60292. */
  60293. get isUnique(): boolean;
  60294. /**
  60295. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60296. */
  60297. get isFinalMerger(): boolean;
  60298. /**
  60299. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60300. */
  60301. get isInput(): boolean;
  60302. /**
  60303. * Gets or sets the build Id
  60304. */
  60305. get buildId(): number;
  60306. set buildId(value: number);
  60307. /**
  60308. * Gets or sets the target of the block
  60309. */
  60310. get target(): NodeMaterialBlockTargets;
  60311. set target(value: NodeMaterialBlockTargets);
  60312. /**
  60313. * Gets the list of input points
  60314. */
  60315. get inputs(): NodeMaterialConnectionPoint[];
  60316. /** Gets the list of output points */
  60317. get outputs(): NodeMaterialConnectionPoint[];
  60318. /**
  60319. * Find an input by its name
  60320. * @param name defines the name of the input to look for
  60321. * @returns the input or null if not found
  60322. */
  60323. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60324. /**
  60325. * Find an output by its name
  60326. * @param name defines the name of the outputto look for
  60327. * @returns the output or null if not found
  60328. */
  60329. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60330. /**
  60331. * Creates a new NodeMaterialBlock
  60332. * @param name defines the block name
  60333. * @param target defines the target of that block (Vertex by default)
  60334. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60335. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60336. */
  60337. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60338. /**
  60339. * Initialize the block and prepare the context for build
  60340. * @param state defines the state that will be used for the build
  60341. */
  60342. initialize(state: NodeMaterialBuildState): void;
  60343. /**
  60344. * Bind data to effect. Will only be called for blocks with isBindable === true
  60345. * @param effect defines the effect to bind data to
  60346. * @param nodeMaterial defines the hosting NodeMaterial
  60347. * @param mesh defines the mesh that will be rendered
  60348. */
  60349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60350. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60351. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60352. protected _writeFloat(value: number): string;
  60353. /**
  60354. * Gets the current class name e.g. "NodeMaterialBlock"
  60355. * @returns the class name
  60356. */
  60357. getClassName(): string;
  60358. /**
  60359. * Register a new input. Must be called inside a block constructor
  60360. * @param name defines the connection point name
  60361. * @param type defines the connection point type
  60362. * @param isOptional defines a boolean indicating that this input can be omitted
  60363. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60364. * @returns the current block
  60365. */
  60366. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60367. /**
  60368. * Register a new output. Must be called inside a block constructor
  60369. * @param name defines the connection point name
  60370. * @param type defines the connection point type
  60371. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60372. * @returns the current block
  60373. */
  60374. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60375. /**
  60376. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60377. * @param forOutput defines an optional connection point to check compatibility with
  60378. * @returns the first available input or null
  60379. */
  60380. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60381. /**
  60382. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60383. * @param forBlock defines an optional block to check compatibility with
  60384. * @returns the first available input or null
  60385. */
  60386. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60387. /**
  60388. * Gets the sibling of the given output
  60389. * @param current defines the current output
  60390. * @returns the next output in the list or null
  60391. */
  60392. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60393. /**
  60394. * Connect current block with another block
  60395. * @param other defines the block to connect with
  60396. * @param options define the various options to help pick the right connections
  60397. * @returns the current block
  60398. */
  60399. connectTo(other: NodeMaterialBlock, options?: {
  60400. input?: string;
  60401. output?: string;
  60402. outputSwizzle?: string;
  60403. }): this | undefined;
  60404. protected _buildBlock(state: NodeMaterialBuildState): void;
  60405. /**
  60406. * Add uniforms, samplers and uniform buffers at compilation time
  60407. * @param state defines the state to update
  60408. * @param nodeMaterial defines the node material requesting the update
  60409. * @param defines defines the material defines to update
  60410. * @param uniformBuffers defines the list of uniform buffer names
  60411. */
  60412. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60413. /**
  60414. * Add potential fallbacks if shader compilation fails
  60415. * @param mesh defines the mesh to be rendered
  60416. * @param fallbacks defines the current prioritized list of fallbacks
  60417. */
  60418. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60419. /**
  60420. * Initialize defines for shader compilation
  60421. * @param mesh defines the mesh to be rendered
  60422. * @param nodeMaterial defines the node material requesting the update
  60423. * @param defines defines the material defines to update
  60424. * @param useInstances specifies that instances should be used
  60425. */
  60426. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60427. /**
  60428. * Update defines for shader compilation
  60429. * @param mesh defines the mesh to be rendered
  60430. * @param nodeMaterial defines the node material requesting the update
  60431. * @param defines defines the material defines to update
  60432. * @param useInstances specifies that instances should be used
  60433. */
  60434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60435. /**
  60436. * Lets the block try to connect some inputs automatically
  60437. * @param material defines the hosting NodeMaterial
  60438. */
  60439. autoConfigure(material: NodeMaterial): void;
  60440. /**
  60441. * Function called when a block is declared as repeatable content generator
  60442. * @param vertexShaderState defines the current compilation state for the vertex shader
  60443. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60444. * @param mesh defines the mesh to be rendered
  60445. * @param defines defines the material defines to update
  60446. */
  60447. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60448. /**
  60449. * Checks if the block is ready
  60450. * @param mesh defines the mesh to be rendered
  60451. * @param nodeMaterial defines the node material requesting the update
  60452. * @param defines defines the material defines to update
  60453. * @param useInstances specifies that instances should be used
  60454. * @returns true if the block is ready
  60455. */
  60456. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60457. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60458. private _processBuild;
  60459. /**
  60460. * Compile the current node and generate the shader code
  60461. * @param state defines the current compilation state (uniforms, samplers, current string)
  60462. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60463. * @returns true if already built
  60464. */
  60465. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60466. protected _inputRename(name: string): string;
  60467. protected _outputRename(name: string): string;
  60468. protected _dumpPropertiesCode(): string;
  60469. /** @hidden */
  60470. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60471. /** @hidden */
  60472. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60473. /**
  60474. * Clone the current block to a new identical block
  60475. * @param scene defines the hosting scene
  60476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60477. * @returns a copy of the current block
  60478. */
  60479. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60480. /**
  60481. * Serializes this block in a JSON representation
  60482. * @returns the serialized block object
  60483. */
  60484. serialize(): any;
  60485. /** @hidden */
  60486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60487. /**
  60488. * Release resources
  60489. */
  60490. dispose(): void;
  60491. }
  60492. }
  60493. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60494. /**
  60495. * Enum defining the type of animations supported by InputBlock
  60496. */
  60497. export enum AnimatedInputBlockTypes {
  60498. /** No animation */
  60499. None = 0,
  60500. /** Time based animation. Will only work for floats */
  60501. Time = 1
  60502. }
  60503. }
  60504. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60506. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60507. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60508. import { Nullable } from "babylonjs/types";
  60509. import { Effect } from "babylonjs/Materials/effect";
  60510. import { Matrix } from "babylonjs/Maths/math.vector";
  60511. import { Scene } from "babylonjs/scene";
  60512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60514. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60515. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  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. /**
  60543. * Gets or sets the connection point type (default is float)
  60544. */
  60545. get type(): NodeMaterialBlockConnectionPointTypes;
  60546. /**
  60547. * Creates a new InputBlock
  60548. * @param name defines the block name
  60549. * @param target defines the target of that block (Vertex by default)
  60550. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60551. */
  60552. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60553. /**
  60554. * Gets the output component
  60555. */
  60556. get output(): NodeMaterialConnectionPoint;
  60557. /**
  60558. * Set the source of this connection point to a vertex attribute
  60559. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60560. * @returns the current connection point
  60561. */
  60562. setAsAttribute(attributeName?: string): InputBlock;
  60563. /**
  60564. * Set the source of this connection point to a system value
  60565. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60566. * @returns the current connection point
  60567. */
  60568. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60569. /**
  60570. * Gets or sets the value of that point.
  60571. * Please note that this value will be ignored if valueCallback is defined
  60572. */
  60573. get value(): any;
  60574. set value(value: any);
  60575. /**
  60576. * Gets or sets a callback used to get the value of that point.
  60577. * Please note that setting this value will force the connection point to ignore the value property
  60578. */
  60579. get valueCallback(): () => any;
  60580. set valueCallback(value: () => any);
  60581. /**
  60582. * Gets or sets the associated variable name in the shader
  60583. */
  60584. get associatedVariableName(): string;
  60585. set associatedVariableName(value: string);
  60586. /** Gets or sets the type of animation applied to the input */
  60587. get animationType(): AnimatedInputBlockTypes;
  60588. set animationType(value: AnimatedInputBlockTypes);
  60589. /**
  60590. * Gets a boolean indicating that this connection point not defined yet
  60591. */
  60592. get isUndefined(): boolean;
  60593. /**
  60594. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60595. * In this case the connection point name must be the name of the uniform to use.
  60596. * Can only be set on inputs
  60597. */
  60598. get isUniform(): boolean;
  60599. set isUniform(value: boolean);
  60600. /**
  60601. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60602. * In this case the connection point name must be the name of the attribute to use
  60603. * Can only be set on inputs
  60604. */
  60605. get isAttribute(): boolean;
  60606. set isAttribute(value: boolean);
  60607. /**
  60608. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60609. * Can only be set on exit points
  60610. */
  60611. get isVarying(): boolean;
  60612. set isVarying(value: boolean);
  60613. /**
  60614. * Gets a boolean indicating that the current connection point is a system value
  60615. */
  60616. get isSystemValue(): boolean;
  60617. /**
  60618. * Gets or sets the current well known value or null if not defined as a system value
  60619. */
  60620. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60621. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60622. /**
  60623. * Gets the current class name
  60624. * @returns the class name
  60625. */
  60626. getClassName(): string;
  60627. /**
  60628. * Animate the input if animationType !== None
  60629. * @param scene defines the rendering scene
  60630. */
  60631. animate(scene: Scene): void;
  60632. private _emitDefine;
  60633. initialize(state: NodeMaterialBuildState): void;
  60634. /**
  60635. * Set the input block to its default value (based on its type)
  60636. */
  60637. setDefaultValue(): void;
  60638. private _emitConstant;
  60639. private _emit;
  60640. /** @hidden */
  60641. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60642. /** @hidden */
  60643. _transmit(effect: Effect, scene: Scene): void;
  60644. protected _buildBlock(state: NodeMaterialBuildState): void;
  60645. protected _dumpPropertiesCode(): string;
  60646. serialize(): any;
  60647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60648. }
  60649. }
  60650. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60651. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60652. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60653. import { Nullable } from "babylonjs/types";
  60654. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60655. import { Observable } from "babylonjs/Misc/observable";
  60656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60657. /**
  60658. * Enum used to define the compatibility state between two connection points
  60659. */
  60660. export enum NodeMaterialConnectionPointCompatibilityStates {
  60661. /** Points are compatibles */
  60662. Compatible = 0,
  60663. /** Points are incompatible because of their types */
  60664. TypeIncompatible = 1,
  60665. /** Points are incompatible because of their targets (vertex vs fragment) */
  60666. TargetIncompatible = 2
  60667. }
  60668. /**
  60669. * Defines the direction of a connection point
  60670. */
  60671. export enum NodeMaterialConnectionPointDirection {
  60672. /** Input */
  60673. Input = 0,
  60674. /** Output */
  60675. Output = 1
  60676. }
  60677. /**
  60678. * Defines a connection point for a block
  60679. */
  60680. export class NodeMaterialConnectionPoint {
  60681. /** @hidden */
  60682. _ownerBlock: NodeMaterialBlock;
  60683. /** @hidden */
  60684. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60685. private _endpoints;
  60686. private _associatedVariableName;
  60687. private _direction;
  60688. /** @hidden */
  60689. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60690. /** @hidden */
  60691. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60692. private _type;
  60693. /** @hidden */
  60694. _enforceAssociatedVariableName: boolean;
  60695. /** Gets the direction of the point */
  60696. get direction(): NodeMaterialConnectionPointDirection;
  60697. /**
  60698. * Gets or sets the additional types supported by this connection point
  60699. */
  60700. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60701. /**
  60702. * Gets or sets the additional types excluded by this connection point
  60703. */
  60704. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60705. /**
  60706. * Observable triggered when this point is connected
  60707. */
  60708. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60709. /**
  60710. * Gets or sets the associated variable name in the shader
  60711. */
  60712. get associatedVariableName(): string;
  60713. set associatedVariableName(value: string);
  60714. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60715. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60716. /**
  60717. * Gets or sets the connection point type (default is float)
  60718. */
  60719. get type(): NodeMaterialBlockConnectionPointTypes;
  60720. set type(value: NodeMaterialBlockConnectionPointTypes);
  60721. /**
  60722. * Gets or sets the connection point name
  60723. */
  60724. name: string;
  60725. /**
  60726. * Gets or sets a boolean indicating that this connection point can be omitted
  60727. */
  60728. isOptional: boolean;
  60729. /**
  60730. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60731. */
  60732. define: string;
  60733. /** @hidden */
  60734. _prioritizeVertex: boolean;
  60735. private _target;
  60736. /** Gets or sets the target of that connection point */
  60737. get target(): NodeMaterialBlockTargets;
  60738. set target(value: NodeMaterialBlockTargets);
  60739. /**
  60740. * Gets a boolean indicating that the current point is connected
  60741. */
  60742. get isConnected(): boolean;
  60743. /**
  60744. * Gets a boolean indicating that the current point is connected to an input block
  60745. */
  60746. get isConnectedToInputBlock(): boolean;
  60747. /**
  60748. * Gets a the connected input block (if any)
  60749. */
  60750. get connectInputBlock(): Nullable<InputBlock>;
  60751. /** Get the other side of the connection (if any) */
  60752. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60753. /** Get the block that owns this connection point */
  60754. get ownerBlock(): NodeMaterialBlock;
  60755. /** Get the block connected on the other side of this connection (if any) */
  60756. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60757. /** Get the block connected on the endpoints of this connection (if any) */
  60758. get connectedBlocks(): Array<NodeMaterialBlock>;
  60759. /** Gets the list of connected endpoints */
  60760. get endpoints(): NodeMaterialConnectionPoint[];
  60761. /** Gets a boolean indicating if that output point is connected to at least one input */
  60762. get hasEndpoints(): boolean;
  60763. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60764. get isConnectedInVertexShader(): boolean;
  60765. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60766. get isConnectedInFragmentShader(): boolean;
  60767. /**
  60768. * Creates a new connection point
  60769. * @param name defines the connection point name
  60770. * @param ownerBlock defines the block hosting this connection point
  60771. * @param direction defines the direction of the connection point
  60772. */
  60773. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60774. /**
  60775. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60776. * @returns the class name
  60777. */
  60778. getClassName(): string;
  60779. /**
  60780. * Gets a boolean indicating if the current point can be connected to another point
  60781. * @param connectionPoint defines the other connection point
  60782. * @returns a boolean
  60783. */
  60784. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60785. /**
  60786. * Gets a number indicating if the current point can be connected to another point
  60787. * @param connectionPoint defines the other connection point
  60788. * @returns a number defining the compatibility state
  60789. */
  60790. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60791. /**
  60792. * Connect this point to another connection point
  60793. * @param connectionPoint defines the other connection point
  60794. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60795. * @returns the current connection point
  60796. */
  60797. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60798. /**
  60799. * Disconnect this point from one of his endpoint
  60800. * @param endpoint defines the other connection point
  60801. * @returns the current connection point
  60802. */
  60803. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60804. /**
  60805. * Serializes this point in a JSON representation
  60806. * @returns the serialized point object
  60807. */
  60808. serialize(): any;
  60809. /**
  60810. * Release resources
  60811. */
  60812. dispose(): void;
  60813. }
  60814. }
  60815. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60819. import { Mesh } from "babylonjs/Meshes/mesh";
  60820. import { Effect } from "babylonjs/Materials/effect";
  60821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60822. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60823. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60824. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60825. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60826. /**
  60827. * Block used to add support for vertex skinning (bones)
  60828. */
  60829. export class BonesBlock extends NodeMaterialBlock {
  60830. /**
  60831. * Creates a new BonesBlock
  60832. * @param name defines the block name
  60833. */
  60834. constructor(name: string);
  60835. /**
  60836. * Initialize the block and prepare the context for build
  60837. * @param state defines the state that will be used for the build
  60838. */
  60839. initialize(state: NodeMaterialBuildState): void;
  60840. /**
  60841. * Gets the current class name
  60842. * @returns the class name
  60843. */
  60844. getClassName(): string;
  60845. /**
  60846. * Gets the matrix indices input component
  60847. */
  60848. get matricesIndices(): NodeMaterialConnectionPoint;
  60849. /**
  60850. * Gets the matrix weights input component
  60851. */
  60852. get matricesWeights(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the extra matrix indices input component
  60855. */
  60856. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the extra matrix weights input component
  60859. */
  60860. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the world input component
  60863. */
  60864. get world(): NodeMaterialConnectionPoint;
  60865. /**
  60866. * Gets the output component
  60867. */
  60868. get output(): NodeMaterialConnectionPoint;
  60869. autoConfigure(material: NodeMaterial): void;
  60870. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60873. protected _buildBlock(state: NodeMaterialBuildState): this;
  60874. }
  60875. }
  60876. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60881. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60882. /**
  60883. * Block used to add support for instances
  60884. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60885. */
  60886. export class InstancesBlock extends NodeMaterialBlock {
  60887. /**
  60888. * Creates a new InstancesBlock
  60889. * @param name defines the block name
  60890. */
  60891. constructor(name: string);
  60892. /**
  60893. * Gets the current class name
  60894. * @returns the class name
  60895. */
  60896. getClassName(): string;
  60897. /**
  60898. * Gets the first world row input component
  60899. */
  60900. get world0(): NodeMaterialConnectionPoint;
  60901. /**
  60902. * Gets the second world row input component
  60903. */
  60904. get world1(): NodeMaterialConnectionPoint;
  60905. /**
  60906. * Gets the third world row input component
  60907. */
  60908. get world2(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the forth world row input component
  60911. */
  60912. get world3(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the world input component
  60915. */
  60916. get world(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the output component
  60919. */
  60920. get output(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the isntanceID component
  60923. */
  60924. get instanceID(): NodeMaterialConnectionPoint;
  60925. autoConfigure(material: NodeMaterial): void;
  60926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60927. protected _buildBlock(state: NodeMaterialBuildState): this;
  60928. }
  60929. }
  60930. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60935. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60936. import { Effect } from "babylonjs/Materials/effect";
  60937. import { Mesh } from "babylonjs/Meshes/mesh";
  60938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60940. /**
  60941. * Block used to add morph targets support to vertex shader
  60942. */
  60943. export class MorphTargetsBlock extends NodeMaterialBlock {
  60944. private _repeatableContentAnchor;
  60945. /**
  60946. * Create a new MorphTargetsBlock
  60947. * @param name defines the block name
  60948. */
  60949. constructor(name: string);
  60950. /**
  60951. * Gets the current class name
  60952. * @returns the class name
  60953. */
  60954. getClassName(): string;
  60955. /**
  60956. * Gets the position input component
  60957. */
  60958. get position(): NodeMaterialConnectionPoint;
  60959. /**
  60960. * Gets the normal input component
  60961. */
  60962. get normal(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the tangent input component
  60965. */
  60966. get tangent(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the tangent input component
  60969. */
  60970. get uv(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the position output component
  60973. */
  60974. get positionOutput(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the normal output component
  60977. */
  60978. get normalOutput(): NodeMaterialConnectionPoint;
  60979. /**
  60980. * Gets the tangent output component
  60981. */
  60982. get tangentOutput(): NodeMaterialConnectionPoint;
  60983. /**
  60984. * Gets the tangent output component
  60985. */
  60986. get uvOutput(): NodeMaterialConnectionPoint;
  60987. initialize(state: NodeMaterialBuildState): void;
  60988. autoConfigure(material: NodeMaterial): void;
  60989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60991. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60992. protected _buildBlock(state: NodeMaterialBuildState): this;
  60993. }
  60994. }
  60995. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60999. import { Nullable } from "babylonjs/types";
  61000. import { Scene } from "babylonjs/scene";
  61001. import { Effect } from "babylonjs/Materials/effect";
  61002. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61003. import { Mesh } from "babylonjs/Meshes/mesh";
  61004. import { Light } from "babylonjs/Lights/light";
  61005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61006. /**
  61007. * Block used to get data information from a light
  61008. */
  61009. export class LightInformationBlock extends NodeMaterialBlock {
  61010. private _lightDataUniformName;
  61011. private _lightColorUniformName;
  61012. private _lightTypeDefineName;
  61013. /**
  61014. * Gets or sets the light associated with this block
  61015. */
  61016. light: Nullable<Light>;
  61017. /**
  61018. * Creates a new LightInformationBlock
  61019. * @param name defines the block name
  61020. */
  61021. constructor(name: string);
  61022. /**
  61023. * Gets the current class name
  61024. * @returns the class name
  61025. */
  61026. getClassName(): string;
  61027. /**
  61028. * Gets the world position input component
  61029. */
  61030. get worldPosition(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the direction output component
  61033. */
  61034. get direction(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the direction output component
  61037. */
  61038. get color(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the direction output component
  61041. */
  61042. get intensity(): NodeMaterialConnectionPoint;
  61043. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61045. protected _buildBlock(state: NodeMaterialBuildState): this;
  61046. serialize(): any;
  61047. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61048. }
  61049. }
  61050. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61051. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61052. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61053. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61054. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61055. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61056. }
  61057. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61062. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61063. import { Effect } from "babylonjs/Materials/effect";
  61064. import { Mesh } from "babylonjs/Meshes/mesh";
  61065. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61066. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61067. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61068. /**
  61069. * Block used to add image processing support to fragment shader
  61070. */
  61071. export class ImageProcessingBlock extends NodeMaterialBlock {
  61072. /**
  61073. * Create a new ImageProcessingBlock
  61074. * @param name defines the block name
  61075. */
  61076. constructor(name: string);
  61077. /**
  61078. * Gets the current class name
  61079. * @returns the class name
  61080. */
  61081. getClassName(): string;
  61082. /**
  61083. * Gets the color input component
  61084. */
  61085. get color(): NodeMaterialConnectionPoint;
  61086. /**
  61087. * Gets the output component
  61088. */
  61089. get output(): NodeMaterialConnectionPoint;
  61090. /**
  61091. * Initialize the block and prepare the context for build
  61092. * @param state defines the state that will be used for the build
  61093. */
  61094. initialize(state: NodeMaterialBuildState): void;
  61095. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61098. protected _buildBlock(state: NodeMaterialBuildState): this;
  61099. }
  61100. }
  61101. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61103. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61104. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61105. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61107. import { Effect } from "babylonjs/Materials/effect";
  61108. import { Mesh } from "babylonjs/Meshes/mesh";
  61109. import { Scene } from "babylonjs/scene";
  61110. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61111. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61112. /**
  61113. * Block used to pertub normals based on a normal map
  61114. */
  61115. export class PerturbNormalBlock extends NodeMaterialBlock {
  61116. private _tangentSpaceParameterName;
  61117. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61118. invertX: boolean;
  61119. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61120. invertY: boolean;
  61121. /**
  61122. * Create a new PerturbNormalBlock
  61123. * @param name defines the block name
  61124. */
  61125. constructor(name: string);
  61126. /**
  61127. * Gets the current class name
  61128. * @returns the class name
  61129. */
  61130. getClassName(): string;
  61131. /**
  61132. * Gets the world position input component
  61133. */
  61134. get worldPosition(): NodeMaterialConnectionPoint;
  61135. /**
  61136. * Gets the world normal input component
  61137. */
  61138. get worldNormal(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the world tangent input component
  61141. */
  61142. get worldTangent(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the uv input component
  61145. */
  61146. get uv(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the normal map color input component
  61149. */
  61150. get normalMapColor(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the strength input component
  61153. */
  61154. get strength(): NodeMaterialConnectionPoint;
  61155. /**
  61156. * Gets the output component
  61157. */
  61158. get output(): NodeMaterialConnectionPoint;
  61159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61161. autoConfigure(material: NodeMaterial): void;
  61162. protected _buildBlock(state: NodeMaterialBuildState): this;
  61163. protected _dumpPropertiesCode(): string;
  61164. serialize(): any;
  61165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61166. }
  61167. }
  61168. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61172. /**
  61173. * Block used to discard a pixel if a value is smaller than a cutoff
  61174. */
  61175. export class DiscardBlock extends NodeMaterialBlock {
  61176. /**
  61177. * Create a new DiscardBlock
  61178. * @param name defines the block name
  61179. */
  61180. constructor(name: string);
  61181. /**
  61182. * Gets the current class name
  61183. * @returns the class name
  61184. */
  61185. getClassName(): string;
  61186. /**
  61187. * Gets the color input component
  61188. */
  61189. get value(): NodeMaterialConnectionPoint;
  61190. /**
  61191. * Gets the cutoff input component
  61192. */
  61193. get cutoff(): NodeMaterialConnectionPoint;
  61194. protected _buildBlock(state: NodeMaterialBuildState): this;
  61195. }
  61196. }
  61197. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61201. /**
  61202. * Block used to test if the fragment shader is front facing
  61203. */
  61204. export class FrontFacingBlock extends NodeMaterialBlock {
  61205. /**
  61206. * Creates a new FrontFacingBlock
  61207. * @param name defines the block name
  61208. */
  61209. constructor(name: string);
  61210. /**
  61211. * Gets the current class name
  61212. * @returns the class name
  61213. */
  61214. getClassName(): string;
  61215. /**
  61216. * Gets the output component
  61217. */
  61218. get output(): NodeMaterialConnectionPoint;
  61219. protected _buildBlock(state: NodeMaterialBuildState): this;
  61220. }
  61221. }
  61222. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61226. /**
  61227. * Block used to get the derivative value on x and y of a given input
  61228. */
  61229. export class DerivativeBlock extends NodeMaterialBlock {
  61230. /**
  61231. * Create a new DerivativeBlock
  61232. * @param name defines the block name
  61233. */
  61234. constructor(name: string);
  61235. /**
  61236. * Gets the current class name
  61237. * @returns the class name
  61238. */
  61239. getClassName(): string;
  61240. /**
  61241. * Gets the input component
  61242. */
  61243. get input(): NodeMaterialConnectionPoint;
  61244. /**
  61245. * Gets the derivative output on x
  61246. */
  61247. get dx(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the derivative output on y
  61250. */
  61251. get dy(): NodeMaterialConnectionPoint;
  61252. protected _buildBlock(state: NodeMaterialBuildState): this;
  61253. }
  61254. }
  61255. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61256. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61257. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61258. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61259. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61260. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61261. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61262. }
  61263. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61266. import { Mesh } from "babylonjs/Meshes/mesh";
  61267. import { Effect } from "babylonjs/Materials/effect";
  61268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61270. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61271. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61272. /**
  61273. * Block used to add support for scene fog
  61274. */
  61275. export class FogBlock extends NodeMaterialBlock {
  61276. private _fogDistanceName;
  61277. private _fogParameters;
  61278. /**
  61279. * Create a new FogBlock
  61280. * @param name defines the block name
  61281. */
  61282. constructor(name: string);
  61283. /**
  61284. * Gets the current class name
  61285. * @returns the class name
  61286. */
  61287. getClassName(): string;
  61288. /**
  61289. * Gets the world position input component
  61290. */
  61291. get worldPosition(): NodeMaterialConnectionPoint;
  61292. /**
  61293. * Gets the view input component
  61294. */
  61295. get view(): NodeMaterialConnectionPoint;
  61296. /**
  61297. * Gets the color input component
  61298. */
  61299. get input(): NodeMaterialConnectionPoint;
  61300. /**
  61301. * Gets the fog color input component
  61302. */
  61303. get fogColor(): NodeMaterialConnectionPoint;
  61304. /**
  61305. * Gets the output component
  61306. */
  61307. get output(): NodeMaterialConnectionPoint;
  61308. autoConfigure(material: NodeMaterial): void;
  61309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61310. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61311. protected _buildBlock(state: NodeMaterialBuildState): this;
  61312. }
  61313. }
  61314. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61319. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61320. import { Effect } from "babylonjs/Materials/effect";
  61321. import { Mesh } from "babylonjs/Meshes/mesh";
  61322. import { Light } from "babylonjs/Lights/light";
  61323. import { Nullable } from "babylonjs/types";
  61324. import { Scene } from "babylonjs/scene";
  61325. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61326. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61327. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61328. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61329. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61330. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61331. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61332. /**
  61333. * Block used to add light in the fragment shader
  61334. */
  61335. export class LightBlock extends NodeMaterialBlock {
  61336. private _lightId;
  61337. /**
  61338. * Gets or sets the light associated with this block
  61339. */
  61340. light: Nullable<Light>;
  61341. /**
  61342. * Create a new LightBlock
  61343. * @param name defines the block name
  61344. */
  61345. constructor(name: string);
  61346. /**
  61347. * Gets the current class name
  61348. * @returns the class name
  61349. */
  61350. getClassName(): string;
  61351. /**
  61352. * Gets the world position input component
  61353. */
  61354. get worldPosition(): NodeMaterialConnectionPoint;
  61355. /**
  61356. * Gets the world normal input component
  61357. */
  61358. get worldNormal(): NodeMaterialConnectionPoint;
  61359. /**
  61360. * Gets the camera (or eye) position component
  61361. */
  61362. get cameraPosition(): NodeMaterialConnectionPoint;
  61363. /**
  61364. * Gets the glossiness component
  61365. */
  61366. get glossiness(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the glossinness power component
  61369. */
  61370. get glossPower(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the diffuse color component
  61373. */
  61374. get diffuseColor(): NodeMaterialConnectionPoint;
  61375. /**
  61376. * Gets the specular color component
  61377. */
  61378. get specularColor(): NodeMaterialConnectionPoint;
  61379. /**
  61380. * Gets the diffuse output component
  61381. */
  61382. get diffuseOutput(): NodeMaterialConnectionPoint;
  61383. /**
  61384. * Gets the specular output component
  61385. */
  61386. get specularOutput(): NodeMaterialConnectionPoint;
  61387. /**
  61388. * Gets the shadow output component
  61389. */
  61390. get shadow(): NodeMaterialConnectionPoint;
  61391. autoConfigure(material: NodeMaterial): void;
  61392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61393. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61394. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61395. private _injectVertexCode;
  61396. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61397. serialize(): any;
  61398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61399. }
  61400. }
  61401. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61402. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61403. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61404. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61405. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61406. }
  61407. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61408. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61409. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61410. }
  61411. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61415. /**
  61416. * Block used to multiply 2 values
  61417. */
  61418. export class MultiplyBlock extends NodeMaterialBlock {
  61419. /**
  61420. * Creates a new MultiplyBlock
  61421. * @param name defines the block name
  61422. */
  61423. constructor(name: string);
  61424. /**
  61425. * Gets the current class name
  61426. * @returns the class name
  61427. */
  61428. getClassName(): string;
  61429. /**
  61430. * Gets the left operand input component
  61431. */
  61432. get left(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the right operand input component
  61435. */
  61436. get right(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the output component
  61439. */
  61440. get output(): NodeMaterialConnectionPoint;
  61441. protected _buildBlock(state: NodeMaterialBuildState): this;
  61442. }
  61443. }
  61444. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61448. /**
  61449. * Block used to add 2 vectors
  61450. */
  61451. export class AddBlock extends NodeMaterialBlock {
  61452. /**
  61453. * Creates a new AddBlock
  61454. * @param name defines the block name
  61455. */
  61456. constructor(name: string);
  61457. /**
  61458. * Gets the current class name
  61459. * @returns the class name
  61460. */
  61461. getClassName(): string;
  61462. /**
  61463. * Gets the left operand input component
  61464. */
  61465. get left(): NodeMaterialConnectionPoint;
  61466. /**
  61467. * Gets the right operand input component
  61468. */
  61469. get right(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the output component
  61472. */
  61473. get output(): NodeMaterialConnectionPoint;
  61474. protected _buildBlock(state: NodeMaterialBuildState): this;
  61475. }
  61476. }
  61477. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61481. /**
  61482. * Block used to scale a vector by a float
  61483. */
  61484. export class ScaleBlock extends NodeMaterialBlock {
  61485. /**
  61486. * Creates a new ScaleBlock
  61487. * @param name defines the block name
  61488. */
  61489. constructor(name: string);
  61490. /**
  61491. * Gets the current class name
  61492. * @returns the class name
  61493. */
  61494. getClassName(): string;
  61495. /**
  61496. * Gets the input component
  61497. */
  61498. get input(): NodeMaterialConnectionPoint;
  61499. /**
  61500. * Gets the factor input component
  61501. */
  61502. get factor(): NodeMaterialConnectionPoint;
  61503. /**
  61504. * Gets the output component
  61505. */
  61506. get output(): NodeMaterialConnectionPoint;
  61507. protected _buildBlock(state: NodeMaterialBuildState): this;
  61508. }
  61509. }
  61510. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61514. import { Scene } from "babylonjs/scene";
  61515. /**
  61516. * Block used to clamp a float
  61517. */
  61518. export class ClampBlock extends NodeMaterialBlock {
  61519. /** Gets or sets the minimum range */
  61520. minimum: number;
  61521. /** Gets or sets the maximum range */
  61522. maximum: number;
  61523. /**
  61524. * Creates a new ClampBlock
  61525. * @param name defines the block name
  61526. */
  61527. constructor(name: string);
  61528. /**
  61529. * Gets the current class name
  61530. * @returns the class name
  61531. */
  61532. getClassName(): string;
  61533. /**
  61534. * Gets the value input component
  61535. */
  61536. get value(): NodeMaterialConnectionPoint;
  61537. /**
  61538. * Gets the output component
  61539. */
  61540. get output(): NodeMaterialConnectionPoint;
  61541. protected _buildBlock(state: NodeMaterialBuildState): this;
  61542. protected _dumpPropertiesCode(): string;
  61543. serialize(): any;
  61544. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61545. }
  61546. }
  61547. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61551. /**
  61552. * Block used to apply a cross product between 2 vectors
  61553. */
  61554. export class CrossBlock extends NodeMaterialBlock {
  61555. /**
  61556. * Creates a new CrossBlock
  61557. * @param name defines the block name
  61558. */
  61559. constructor(name: string);
  61560. /**
  61561. * Gets the current class name
  61562. * @returns the class name
  61563. */
  61564. getClassName(): string;
  61565. /**
  61566. * Gets the left operand input component
  61567. */
  61568. get left(): NodeMaterialConnectionPoint;
  61569. /**
  61570. * Gets the right operand input component
  61571. */
  61572. get right(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the output component
  61575. */
  61576. get output(): NodeMaterialConnectionPoint;
  61577. protected _buildBlock(state: NodeMaterialBuildState): this;
  61578. }
  61579. }
  61580. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61584. /**
  61585. * Block used to apply a dot product between 2 vectors
  61586. */
  61587. export class DotBlock extends NodeMaterialBlock {
  61588. /**
  61589. * Creates a new DotBlock
  61590. * @param name defines the block name
  61591. */
  61592. constructor(name: string);
  61593. /**
  61594. * Gets the current class name
  61595. * @returns the class name
  61596. */
  61597. getClassName(): string;
  61598. /**
  61599. * Gets the left operand input component
  61600. */
  61601. get left(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the right operand input component
  61604. */
  61605. get right(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the output component
  61608. */
  61609. get output(): NodeMaterialConnectionPoint;
  61610. protected _buildBlock(state: NodeMaterialBuildState): this;
  61611. }
  61612. }
  61613. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61617. import { Vector2 } from "babylonjs/Maths/math.vector";
  61618. import { Scene } from "babylonjs/scene";
  61619. /**
  61620. * Block used to remap a float from a range to a new one
  61621. */
  61622. export class RemapBlock extends NodeMaterialBlock {
  61623. /**
  61624. * Gets or sets the source range
  61625. */
  61626. sourceRange: Vector2;
  61627. /**
  61628. * Gets or sets the target range
  61629. */
  61630. targetRange: Vector2;
  61631. /**
  61632. * Creates a new RemapBlock
  61633. * @param name defines the block name
  61634. */
  61635. constructor(name: string);
  61636. /**
  61637. * Gets the current class name
  61638. * @returns the class name
  61639. */
  61640. getClassName(): string;
  61641. /**
  61642. * Gets the input component
  61643. */
  61644. get input(): NodeMaterialConnectionPoint;
  61645. /**
  61646. * Gets the source min input component
  61647. */
  61648. get sourceMin(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the source max input component
  61651. */
  61652. get sourceMax(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the target min input component
  61655. */
  61656. get targetMin(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the target max input component
  61659. */
  61660. get targetMax(): NodeMaterialConnectionPoint;
  61661. /**
  61662. * Gets the output component
  61663. */
  61664. get output(): NodeMaterialConnectionPoint;
  61665. protected _buildBlock(state: NodeMaterialBuildState): this;
  61666. protected _dumpPropertiesCode(): string;
  61667. serialize(): any;
  61668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61669. }
  61670. }
  61671. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61675. /**
  61676. * Block used to normalize a vector
  61677. */
  61678. export class NormalizeBlock extends NodeMaterialBlock {
  61679. /**
  61680. * Creates a new NormalizeBlock
  61681. * @param name defines the block name
  61682. */
  61683. constructor(name: string);
  61684. /**
  61685. * Gets the current class name
  61686. * @returns the class name
  61687. */
  61688. getClassName(): string;
  61689. /**
  61690. * Gets the input component
  61691. */
  61692. get input(): NodeMaterialConnectionPoint;
  61693. /**
  61694. * Gets the output component
  61695. */
  61696. get output(): NodeMaterialConnectionPoint;
  61697. protected _buildBlock(state: NodeMaterialBuildState): this;
  61698. }
  61699. }
  61700. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61704. import { Scene } from "babylonjs/scene";
  61705. /**
  61706. * Operations supported by the Trigonometry block
  61707. */
  61708. export enum TrigonometryBlockOperations {
  61709. /** Cos */
  61710. Cos = 0,
  61711. /** Sin */
  61712. Sin = 1,
  61713. /** Abs */
  61714. Abs = 2,
  61715. /** Exp */
  61716. Exp = 3,
  61717. /** Exp2 */
  61718. Exp2 = 4,
  61719. /** Round */
  61720. Round = 5,
  61721. /** Floor */
  61722. Floor = 6,
  61723. /** Ceiling */
  61724. Ceiling = 7,
  61725. /** Square root */
  61726. Sqrt = 8,
  61727. /** Log */
  61728. Log = 9,
  61729. /** Tangent */
  61730. Tan = 10,
  61731. /** Arc tangent */
  61732. ArcTan = 11,
  61733. /** Arc cosinus */
  61734. ArcCos = 12,
  61735. /** Arc sinus */
  61736. ArcSin = 13,
  61737. /** Fraction */
  61738. Fract = 14,
  61739. /** Sign */
  61740. Sign = 15,
  61741. /** To radians (from degrees) */
  61742. Radians = 16,
  61743. /** To degrees (from radians) */
  61744. Degrees = 17
  61745. }
  61746. /**
  61747. * Block used to apply trigonometry operation to floats
  61748. */
  61749. export class TrigonometryBlock extends NodeMaterialBlock {
  61750. /**
  61751. * Gets or sets the operation applied by the block
  61752. */
  61753. operation: TrigonometryBlockOperations;
  61754. /**
  61755. * Creates a new TrigonometryBlock
  61756. * @param name defines the block name
  61757. */
  61758. constructor(name: string);
  61759. /**
  61760. * Gets the current class name
  61761. * @returns the class name
  61762. */
  61763. getClassName(): string;
  61764. /**
  61765. * Gets the input component
  61766. */
  61767. get input(): NodeMaterialConnectionPoint;
  61768. /**
  61769. * Gets the output component
  61770. */
  61771. get output(): NodeMaterialConnectionPoint;
  61772. protected _buildBlock(state: NodeMaterialBuildState): this;
  61773. serialize(): any;
  61774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61775. protected _dumpPropertiesCode(): string;
  61776. }
  61777. }
  61778. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61782. /**
  61783. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61784. */
  61785. export class ColorMergerBlock extends NodeMaterialBlock {
  61786. /**
  61787. * Create a new ColorMergerBlock
  61788. * @param name defines the block name
  61789. */
  61790. constructor(name: string);
  61791. /**
  61792. * Gets the current class name
  61793. * @returns the class name
  61794. */
  61795. getClassName(): string;
  61796. /**
  61797. * Gets the rgb component (input)
  61798. */
  61799. get rgbIn(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the r component (input)
  61802. */
  61803. get r(): NodeMaterialConnectionPoint;
  61804. /**
  61805. * Gets the g component (input)
  61806. */
  61807. get g(): NodeMaterialConnectionPoint;
  61808. /**
  61809. * Gets the b component (input)
  61810. */
  61811. get b(): NodeMaterialConnectionPoint;
  61812. /**
  61813. * Gets the a component (input)
  61814. */
  61815. get a(): NodeMaterialConnectionPoint;
  61816. /**
  61817. * Gets the rgba component (output)
  61818. */
  61819. get rgba(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the rgb component (output)
  61822. */
  61823. get rgbOut(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the rgb component (output)
  61826. * @deprecated Please use rgbOut instead.
  61827. */
  61828. get rgb(): NodeMaterialConnectionPoint;
  61829. protected _buildBlock(state: NodeMaterialBuildState): this;
  61830. }
  61831. }
  61832. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61836. /**
  61837. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61838. */
  61839. export class VectorMergerBlock extends NodeMaterialBlock {
  61840. /**
  61841. * Create a new VectorMergerBlock
  61842. * @param name defines the block name
  61843. */
  61844. constructor(name: string);
  61845. /**
  61846. * Gets the current class name
  61847. * @returns the class name
  61848. */
  61849. getClassName(): string;
  61850. /**
  61851. * Gets the xyz component (input)
  61852. */
  61853. get xyzIn(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the xy component (input)
  61856. */
  61857. get xyIn(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the x component (input)
  61860. */
  61861. get x(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the y component (input)
  61864. */
  61865. get y(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the z component (input)
  61868. */
  61869. get z(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the w component (input)
  61872. */
  61873. get w(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the xyzw component (output)
  61876. */
  61877. get xyzw(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the xyz component (output)
  61880. */
  61881. get xyzOut(): NodeMaterialConnectionPoint;
  61882. /**
  61883. * Gets the xy component (output)
  61884. */
  61885. get xyOut(): NodeMaterialConnectionPoint;
  61886. /**
  61887. * Gets the xy component (output)
  61888. * @deprecated Please use xyOut instead.
  61889. */
  61890. get xy(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the xyz component (output)
  61893. * @deprecated Please use xyzOut instead.
  61894. */
  61895. get xyz(): NodeMaterialConnectionPoint;
  61896. protected _buildBlock(state: NodeMaterialBuildState): this;
  61897. }
  61898. }
  61899. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61903. /**
  61904. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61905. */
  61906. export class ColorSplitterBlock extends NodeMaterialBlock {
  61907. /**
  61908. * Create a new ColorSplitterBlock
  61909. * @param name defines the block name
  61910. */
  61911. constructor(name: string);
  61912. /**
  61913. * Gets the current class name
  61914. * @returns the class name
  61915. */
  61916. getClassName(): string;
  61917. /**
  61918. * Gets the rgba component (input)
  61919. */
  61920. get rgba(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the rgb component (input)
  61923. */
  61924. get rgbIn(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the rgb component (output)
  61927. */
  61928. get rgbOut(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the r component (output)
  61931. */
  61932. get r(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the g component (output)
  61935. */
  61936. get g(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the b component (output)
  61939. */
  61940. get b(): NodeMaterialConnectionPoint;
  61941. /**
  61942. * Gets the a component (output)
  61943. */
  61944. get a(): NodeMaterialConnectionPoint;
  61945. protected _inputRename(name: string): string;
  61946. protected _outputRename(name: string): string;
  61947. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61948. }
  61949. }
  61950. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61954. /**
  61955. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61956. */
  61957. export class VectorSplitterBlock extends NodeMaterialBlock {
  61958. /**
  61959. * Create a new VectorSplitterBlock
  61960. * @param name defines the block name
  61961. */
  61962. constructor(name: string);
  61963. /**
  61964. * Gets the current class name
  61965. * @returns the class name
  61966. */
  61967. getClassName(): string;
  61968. /**
  61969. * Gets the xyzw component (input)
  61970. */
  61971. get xyzw(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the xyz component (input)
  61974. */
  61975. get xyzIn(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the xy component (input)
  61978. */
  61979. get xyIn(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the xyz component (output)
  61982. */
  61983. get xyzOut(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the xy component (output)
  61986. */
  61987. get xyOut(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the x component (output)
  61990. */
  61991. get x(): NodeMaterialConnectionPoint;
  61992. /**
  61993. * Gets the y component (output)
  61994. */
  61995. get y(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the z component (output)
  61998. */
  61999. get z(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the w component (output)
  62002. */
  62003. get w(): NodeMaterialConnectionPoint;
  62004. protected _inputRename(name: string): string;
  62005. protected _outputRename(name: string): string;
  62006. protected _buildBlock(state: NodeMaterialBuildState): this;
  62007. }
  62008. }
  62009. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62013. /**
  62014. * Block used to lerp between 2 values
  62015. */
  62016. export class LerpBlock extends NodeMaterialBlock {
  62017. /**
  62018. * Creates a new LerpBlock
  62019. * @param name defines the block name
  62020. */
  62021. constructor(name: string);
  62022. /**
  62023. * Gets the current class name
  62024. * @returns the class name
  62025. */
  62026. getClassName(): string;
  62027. /**
  62028. * Gets the left operand input component
  62029. */
  62030. get left(): NodeMaterialConnectionPoint;
  62031. /**
  62032. * Gets the right operand input component
  62033. */
  62034. get right(): NodeMaterialConnectionPoint;
  62035. /**
  62036. * Gets the gradient operand input component
  62037. */
  62038. get gradient(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the output component
  62041. */
  62042. get output(): NodeMaterialConnectionPoint;
  62043. protected _buildBlock(state: NodeMaterialBuildState): this;
  62044. }
  62045. }
  62046. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62050. /**
  62051. * Block used to divide 2 vectors
  62052. */
  62053. export class DivideBlock extends NodeMaterialBlock {
  62054. /**
  62055. * Creates a new DivideBlock
  62056. * @param name defines the block name
  62057. */
  62058. constructor(name: string);
  62059. /**
  62060. * Gets the current class name
  62061. * @returns the class name
  62062. */
  62063. getClassName(): string;
  62064. /**
  62065. * Gets the left operand input component
  62066. */
  62067. get left(): NodeMaterialConnectionPoint;
  62068. /**
  62069. * Gets the right operand input component
  62070. */
  62071. get right(): NodeMaterialConnectionPoint;
  62072. /**
  62073. * Gets the output component
  62074. */
  62075. get output(): NodeMaterialConnectionPoint;
  62076. protected _buildBlock(state: NodeMaterialBuildState): this;
  62077. }
  62078. }
  62079. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62083. /**
  62084. * Block used to subtract 2 vectors
  62085. */
  62086. export class SubtractBlock extends NodeMaterialBlock {
  62087. /**
  62088. * Creates a new SubtractBlock
  62089. * @param name defines the block name
  62090. */
  62091. constructor(name: string);
  62092. /**
  62093. * Gets the current class name
  62094. * @returns the class name
  62095. */
  62096. getClassName(): string;
  62097. /**
  62098. * Gets the left operand input component
  62099. */
  62100. get left(): NodeMaterialConnectionPoint;
  62101. /**
  62102. * Gets the right operand input component
  62103. */
  62104. get right(): NodeMaterialConnectionPoint;
  62105. /**
  62106. * Gets the output component
  62107. */
  62108. get output(): NodeMaterialConnectionPoint;
  62109. protected _buildBlock(state: NodeMaterialBuildState): this;
  62110. }
  62111. }
  62112. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62116. /**
  62117. * Block used to step a value
  62118. */
  62119. export class StepBlock extends NodeMaterialBlock {
  62120. /**
  62121. * Creates a new StepBlock
  62122. * @param name defines the block name
  62123. */
  62124. constructor(name: string);
  62125. /**
  62126. * Gets the current class name
  62127. * @returns the class name
  62128. */
  62129. getClassName(): string;
  62130. /**
  62131. * Gets the value operand input component
  62132. */
  62133. get value(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the edge operand input component
  62136. */
  62137. get edge(): NodeMaterialConnectionPoint;
  62138. /**
  62139. * Gets the output component
  62140. */
  62141. get output(): NodeMaterialConnectionPoint;
  62142. protected _buildBlock(state: NodeMaterialBuildState): this;
  62143. }
  62144. }
  62145. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62149. /**
  62150. * Block used to get the opposite (1 - x) of a value
  62151. */
  62152. export class OneMinusBlock extends NodeMaterialBlock {
  62153. /**
  62154. * Creates a new OneMinusBlock
  62155. * @param name defines the block name
  62156. */
  62157. constructor(name: string);
  62158. /**
  62159. * Gets the current class name
  62160. * @returns the class name
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Gets the input component
  62165. */
  62166. get input(): NodeMaterialConnectionPoint;
  62167. /**
  62168. * Gets the output component
  62169. */
  62170. get output(): NodeMaterialConnectionPoint;
  62171. protected _buildBlock(state: NodeMaterialBuildState): this;
  62172. }
  62173. }
  62174. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62178. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62179. /**
  62180. * Block used to get the view direction
  62181. */
  62182. export class ViewDirectionBlock extends NodeMaterialBlock {
  62183. /**
  62184. * Creates a new ViewDirectionBlock
  62185. * @param name defines the block name
  62186. */
  62187. constructor(name: string);
  62188. /**
  62189. * Gets the current class name
  62190. * @returns the class name
  62191. */
  62192. getClassName(): string;
  62193. /**
  62194. * Gets the world position component
  62195. */
  62196. get worldPosition(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the camera position component
  62199. */
  62200. get cameraPosition(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the output component
  62203. */
  62204. get output(): NodeMaterialConnectionPoint;
  62205. autoConfigure(material: NodeMaterial): void;
  62206. protected _buildBlock(state: NodeMaterialBuildState): this;
  62207. }
  62208. }
  62209. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62213. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62214. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62215. /**
  62216. * Block used to compute fresnel value
  62217. */
  62218. export class FresnelBlock extends NodeMaterialBlock {
  62219. /**
  62220. * Create a new FresnelBlock
  62221. * @param name defines the block name
  62222. */
  62223. constructor(name: string);
  62224. /**
  62225. * Gets the current class name
  62226. * @returns the class name
  62227. */
  62228. getClassName(): string;
  62229. /**
  62230. * Gets the world normal input component
  62231. */
  62232. get worldNormal(): NodeMaterialConnectionPoint;
  62233. /**
  62234. * Gets the view direction input component
  62235. */
  62236. get viewDirection(): NodeMaterialConnectionPoint;
  62237. /**
  62238. * Gets the bias input component
  62239. */
  62240. get bias(): NodeMaterialConnectionPoint;
  62241. /**
  62242. * Gets the camera (or eye) position component
  62243. */
  62244. get power(): NodeMaterialConnectionPoint;
  62245. /**
  62246. * Gets the fresnel output component
  62247. */
  62248. get fresnel(): NodeMaterialConnectionPoint;
  62249. autoConfigure(material: NodeMaterial): void;
  62250. protected _buildBlock(state: NodeMaterialBuildState): this;
  62251. }
  62252. }
  62253. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62257. /**
  62258. * Block used to get the max of 2 values
  62259. */
  62260. export class MaxBlock extends NodeMaterialBlock {
  62261. /**
  62262. * Creates a new MaxBlock
  62263. * @param name defines the block name
  62264. */
  62265. constructor(name: string);
  62266. /**
  62267. * Gets the current class name
  62268. * @returns the class name
  62269. */
  62270. getClassName(): string;
  62271. /**
  62272. * Gets the left operand input component
  62273. */
  62274. get left(): NodeMaterialConnectionPoint;
  62275. /**
  62276. * Gets the right operand input component
  62277. */
  62278. get right(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the output component
  62281. */
  62282. get output(): NodeMaterialConnectionPoint;
  62283. protected _buildBlock(state: NodeMaterialBuildState): this;
  62284. }
  62285. }
  62286. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62290. /**
  62291. * Block used to get the min of 2 values
  62292. */
  62293. export class MinBlock extends NodeMaterialBlock {
  62294. /**
  62295. * Creates a new MinBlock
  62296. * @param name defines the block name
  62297. */
  62298. constructor(name: string);
  62299. /**
  62300. * Gets the current class name
  62301. * @returns the class name
  62302. */
  62303. getClassName(): string;
  62304. /**
  62305. * Gets the left operand input component
  62306. */
  62307. get left(): NodeMaterialConnectionPoint;
  62308. /**
  62309. * Gets the right operand input component
  62310. */
  62311. get right(): NodeMaterialConnectionPoint;
  62312. /**
  62313. * Gets the output component
  62314. */
  62315. get output(): NodeMaterialConnectionPoint;
  62316. protected _buildBlock(state: NodeMaterialBuildState): this;
  62317. }
  62318. }
  62319. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62323. /**
  62324. * Block used to get the distance between 2 values
  62325. */
  62326. export class DistanceBlock extends NodeMaterialBlock {
  62327. /**
  62328. * Creates a new DistanceBlock
  62329. * @param name defines the block name
  62330. */
  62331. constructor(name: string);
  62332. /**
  62333. * Gets the current class name
  62334. * @returns the class name
  62335. */
  62336. getClassName(): string;
  62337. /**
  62338. * Gets the left operand input component
  62339. */
  62340. get left(): NodeMaterialConnectionPoint;
  62341. /**
  62342. * Gets the right operand input component
  62343. */
  62344. get right(): NodeMaterialConnectionPoint;
  62345. /**
  62346. * Gets the output component
  62347. */
  62348. get output(): NodeMaterialConnectionPoint;
  62349. protected _buildBlock(state: NodeMaterialBuildState): this;
  62350. }
  62351. }
  62352. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62356. /**
  62357. * Block used to get the length of a vector
  62358. */
  62359. export class LengthBlock extends NodeMaterialBlock {
  62360. /**
  62361. * Creates a new LengthBlock
  62362. * @param name defines the block name
  62363. */
  62364. constructor(name: string);
  62365. /**
  62366. * Gets the current class name
  62367. * @returns the class name
  62368. */
  62369. getClassName(): string;
  62370. /**
  62371. * Gets the value input component
  62372. */
  62373. get value(): NodeMaterialConnectionPoint;
  62374. /**
  62375. * Gets the output component
  62376. */
  62377. get output(): NodeMaterialConnectionPoint;
  62378. protected _buildBlock(state: NodeMaterialBuildState): this;
  62379. }
  62380. }
  62381. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62385. /**
  62386. * Block used to get negative version of a value (i.e. x * -1)
  62387. */
  62388. export class NegateBlock extends NodeMaterialBlock {
  62389. /**
  62390. * Creates a new NegateBlock
  62391. * @param name defines the block name
  62392. */
  62393. constructor(name: string);
  62394. /**
  62395. * Gets the current class name
  62396. * @returns the class name
  62397. */
  62398. getClassName(): string;
  62399. /**
  62400. * Gets the value input component
  62401. */
  62402. get value(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the output component
  62405. */
  62406. get output(): NodeMaterialConnectionPoint;
  62407. protected _buildBlock(state: NodeMaterialBuildState): this;
  62408. }
  62409. }
  62410. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62414. /**
  62415. * Block used to get the value of the first parameter raised to the power of the second
  62416. */
  62417. export class PowBlock extends NodeMaterialBlock {
  62418. /**
  62419. * Creates a new PowBlock
  62420. * @param name defines the block name
  62421. */
  62422. constructor(name: string);
  62423. /**
  62424. * Gets the current class name
  62425. * @returns the class name
  62426. */
  62427. getClassName(): string;
  62428. /**
  62429. * Gets the value operand input component
  62430. */
  62431. get value(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the power operand input component
  62434. */
  62435. get power(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the output component
  62438. */
  62439. get output(): NodeMaterialConnectionPoint;
  62440. protected _buildBlock(state: NodeMaterialBuildState): this;
  62441. }
  62442. }
  62443. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62448. /**
  62449. * Block used to get a random number
  62450. */
  62451. export class RandomNumberBlock extends NodeMaterialBlock {
  62452. /**
  62453. * Creates a new RandomNumberBlock
  62454. * @param name defines the block name
  62455. */
  62456. constructor(name: string);
  62457. /**
  62458. * Gets the current class name
  62459. * @returns the class name
  62460. */
  62461. getClassName(): string;
  62462. /**
  62463. * Gets the seed input component
  62464. */
  62465. get seed(): NodeMaterialConnectionPoint;
  62466. /**
  62467. * Gets the output component
  62468. */
  62469. get output(): NodeMaterialConnectionPoint;
  62470. protected _buildBlock(state: NodeMaterialBuildState): this;
  62471. }
  62472. }
  62473. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62477. /**
  62478. * Block used to compute arc tangent of 2 values
  62479. */
  62480. export class ArcTan2Block extends NodeMaterialBlock {
  62481. /**
  62482. * Creates a new ArcTan2Block
  62483. * @param name defines the block name
  62484. */
  62485. constructor(name: string);
  62486. /**
  62487. * Gets the current class name
  62488. * @returns the class name
  62489. */
  62490. getClassName(): string;
  62491. /**
  62492. * Gets the x operand input component
  62493. */
  62494. get x(): NodeMaterialConnectionPoint;
  62495. /**
  62496. * Gets the y operand input component
  62497. */
  62498. get y(): NodeMaterialConnectionPoint;
  62499. /**
  62500. * Gets the output component
  62501. */
  62502. get output(): NodeMaterialConnectionPoint;
  62503. protected _buildBlock(state: NodeMaterialBuildState): this;
  62504. }
  62505. }
  62506. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62510. /**
  62511. * Block used to smooth step a value
  62512. */
  62513. export class SmoothStepBlock extends NodeMaterialBlock {
  62514. /**
  62515. * Creates a new SmoothStepBlock
  62516. * @param name defines the block name
  62517. */
  62518. constructor(name: string);
  62519. /**
  62520. * Gets the current class name
  62521. * @returns the class name
  62522. */
  62523. getClassName(): string;
  62524. /**
  62525. * Gets the value operand input component
  62526. */
  62527. get value(): NodeMaterialConnectionPoint;
  62528. /**
  62529. * Gets the first edge operand input component
  62530. */
  62531. get edge0(): NodeMaterialConnectionPoint;
  62532. /**
  62533. * Gets the second edge operand input component
  62534. */
  62535. get edge1(): NodeMaterialConnectionPoint;
  62536. /**
  62537. * Gets the output component
  62538. */
  62539. get output(): NodeMaterialConnectionPoint;
  62540. protected _buildBlock(state: NodeMaterialBuildState): this;
  62541. }
  62542. }
  62543. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62547. /**
  62548. * Block used to get the reciprocal (1 / x) of a value
  62549. */
  62550. export class ReciprocalBlock extends NodeMaterialBlock {
  62551. /**
  62552. * Creates a new ReciprocalBlock
  62553. * @param name defines the block name
  62554. */
  62555. constructor(name: string);
  62556. /**
  62557. * Gets the current class name
  62558. * @returns the class name
  62559. */
  62560. getClassName(): string;
  62561. /**
  62562. * Gets the input component
  62563. */
  62564. get input(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the output component
  62567. */
  62568. get output(): NodeMaterialConnectionPoint;
  62569. protected _buildBlock(state: NodeMaterialBuildState): this;
  62570. }
  62571. }
  62572. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62576. /**
  62577. * Block used to replace a color by another one
  62578. */
  62579. export class ReplaceColorBlock extends NodeMaterialBlock {
  62580. /**
  62581. * Creates a new ReplaceColorBlock
  62582. * @param name defines the block name
  62583. */
  62584. constructor(name: string);
  62585. /**
  62586. * Gets the current class name
  62587. * @returns the class name
  62588. */
  62589. getClassName(): string;
  62590. /**
  62591. * Gets the value input component
  62592. */
  62593. get value(): NodeMaterialConnectionPoint;
  62594. /**
  62595. * Gets the reference input component
  62596. */
  62597. get reference(): NodeMaterialConnectionPoint;
  62598. /**
  62599. * Gets the distance input component
  62600. */
  62601. get distance(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the replacement input component
  62604. */
  62605. get replacement(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the output component
  62608. */
  62609. get output(): NodeMaterialConnectionPoint;
  62610. protected _buildBlock(state: NodeMaterialBuildState): this;
  62611. }
  62612. }
  62613. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62617. /**
  62618. * Block used to posterize a value
  62619. * @see https://en.wikipedia.org/wiki/Posterization
  62620. */
  62621. export class PosterizeBlock extends NodeMaterialBlock {
  62622. /**
  62623. * Creates a new PosterizeBlock
  62624. * @param name defines the block name
  62625. */
  62626. constructor(name: string);
  62627. /**
  62628. * Gets the current class name
  62629. * @returns the class name
  62630. */
  62631. getClassName(): string;
  62632. /**
  62633. * Gets the value input component
  62634. */
  62635. get value(): NodeMaterialConnectionPoint;
  62636. /**
  62637. * Gets the steps input component
  62638. */
  62639. get steps(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the output component
  62642. */
  62643. get output(): NodeMaterialConnectionPoint;
  62644. protected _buildBlock(state: NodeMaterialBuildState): this;
  62645. }
  62646. }
  62647. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62651. import { Scene } from "babylonjs/scene";
  62652. /**
  62653. * Operations supported by the Wave block
  62654. */
  62655. export enum WaveBlockKind {
  62656. /** SawTooth */
  62657. SawTooth = 0,
  62658. /** Square */
  62659. Square = 1,
  62660. /** Triangle */
  62661. Triangle = 2
  62662. }
  62663. /**
  62664. * Block used to apply wave operation to floats
  62665. */
  62666. export class WaveBlock extends NodeMaterialBlock {
  62667. /**
  62668. * Gets or sets the kibnd of wave to be applied by the block
  62669. */
  62670. kind: WaveBlockKind;
  62671. /**
  62672. * Creates a new WaveBlock
  62673. * @param name defines the block name
  62674. */
  62675. constructor(name: string);
  62676. /**
  62677. * Gets the current class name
  62678. * @returns the class name
  62679. */
  62680. getClassName(): string;
  62681. /**
  62682. * Gets the input component
  62683. */
  62684. get input(): NodeMaterialConnectionPoint;
  62685. /**
  62686. * Gets the output component
  62687. */
  62688. get output(): NodeMaterialConnectionPoint;
  62689. protected _buildBlock(state: NodeMaterialBuildState): this;
  62690. serialize(): any;
  62691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62692. }
  62693. }
  62694. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62698. import { Color3 } from "babylonjs/Maths/math.color";
  62699. import { Scene } from "babylonjs/scene";
  62700. /**
  62701. * Class used to store a color step for the GradientBlock
  62702. */
  62703. export class GradientBlockColorStep {
  62704. /**
  62705. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62706. */
  62707. step: number;
  62708. /**
  62709. * Gets or sets the color associated with this step
  62710. */
  62711. color: Color3;
  62712. /**
  62713. * Creates a new GradientBlockColorStep
  62714. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62715. * @param color defines the color associated with this step
  62716. */
  62717. constructor(
  62718. /**
  62719. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62720. */
  62721. step: number,
  62722. /**
  62723. * Gets or sets the color associated with this step
  62724. */
  62725. color: Color3);
  62726. }
  62727. /**
  62728. * Block used to return a color from a gradient based on an input value between 0 and 1
  62729. */
  62730. export class GradientBlock extends NodeMaterialBlock {
  62731. /**
  62732. * Gets or sets the list of color steps
  62733. */
  62734. colorSteps: GradientBlockColorStep[];
  62735. /**
  62736. * Creates a new GradientBlock
  62737. * @param name defines the block name
  62738. */
  62739. constructor(name: string);
  62740. /**
  62741. * Gets the current class name
  62742. * @returns the class name
  62743. */
  62744. getClassName(): string;
  62745. /**
  62746. * Gets the gradient input component
  62747. */
  62748. get gradient(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the output component
  62751. */
  62752. get output(): NodeMaterialConnectionPoint;
  62753. private _writeColorConstant;
  62754. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62755. serialize(): any;
  62756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62757. protected _dumpPropertiesCode(): string;
  62758. }
  62759. }
  62760. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62764. /**
  62765. * Block used to normalize lerp between 2 values
  62766. */
  62767. export class NLerpBlock extends NodeMaterialBlock {
  62768. /**
  62769. * Creates a new NLerpBlock
  62770. * @param name defines the block name
  62771. */
  62772. constructor(name: string);
  62773. /**
  62774. * Gets the current class name
  62775. * @returns the class name
  62776. */
  62777. getClassName(): string;
  62778. /**
  62779. * Gets the left operand input component
  62780. */
  62781. get left(): NodeMaterialConnectionPoint;
  62782. /**
  62783. * Gets the right operand input component
  62784. */
  62785. get right(): NodeMaterialConnectionPoint;
  62786. /**
  62787. * Gets the gradient operand input component
  62788. */
  62789. get gradient(): NodeMaterialConnectionPoint;
  62790. /**
  62791. * Gets the output component
  62792. */
  62793. get output(): NodeMaterialConnectionPoint;
  62794. protected _buildBlock(state: NodeMaterialBuildState): this;
  62795. }
  62796. }
  62797. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62801. import { Scene } from "babylonjs/scene";
  62802. /**
  62803. * block used to Generate a Worley Noise 3D Noise Pattern
  62804. */
  62805. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62806. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62807. manhattanDistance: boolean;
  62808. /**
  62809. * Creates a new WorleyNoise3DBlock
  62810. * @param name defines the block name
  62811. */
  62812. constructor(name: string);
  62813. /**
  62814. * Gets the current class name
  62815. * @returns the class name
  62816. */
  62817. getClassName(): string;
  62818. /**
  62819. * Gets the seed input component
  62820. */
  62821. get seed(): NodeMaterialConnectionPoint;
  62822. /**
  62823. * Gets the jitter input component
  62824. */
  62825. get jitter(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the output component
  62828. */
  62829. get output(): NodeMaterialConnectionPoint;
  62830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62831. /**
  62832. * Exposes the properties to the UI?
  62833. */
  62834. protected _dumpPropertiesCode(): string;
  62835. /**
  62836. * Exposes the properties to the Seralize?
  62837. */
  62838. serialize(): any;
  62839. /**
  62840. * Exposes the properties to the deseralize?
  62841. */
  62842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62843. }
  62844. }
  62845. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62849. /**
  62850. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62851. */
  62852. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62853. /**
  62854. * Creates a new SimplexPerlin3DBlock
  62855. * @param name defines the block name
  62856. */
  62857. constructor(name: string);
  62858. /**
  62859. * Gets the current class name
  62860. * @returns the class name
  62861. */
  62862. getClassName(): string;
  62863. /**
  62864. * Gets the seed operand input component
  62865. */
  62866. get seed(): NodeMaterialConnectionPoint;
  62867. /**
  62868. * Gets the output component
  62869. */
  62870. get output(): NodeMaterialConnectionPoint;
  62871. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62872. }
  62873. }
  62874. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62878. /**
  62879. * Block used to blend normals
  62880. */
  62881. export class NormalBlendBlock extends NodeMaterialBlock {
  62882. /**
  62883. * Creates a new NormalBlendBlock
  62884. * @param name defines the block name
  62885. */
  62886. constructor(name: string);
  62887. /**
  62888. * Gets the current class name
  62889. * @returns the class name
  62890. */
  62891. getClassName(): string;
  62892. /**
  62893. * Gets the first input component
  62894. */
  62895. get normalMap0(): NodeMaterialConnectionPoint;
  62896. /**
  62897. * Gets the second input component
  62898. */
  62899. get normalMap1(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the output component
  62902. */
  62903. get output(): NodeMaterialConnectionPoint;
  62904. protected _buildBlock(state: NodeMaterialBuildState): this;
  62905. }
  62906. }
  62907. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62911. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62912. /**
  62913. * Block used to rotate a 2d vector by a given angle
  62914. */
  62915. export class Rotate2dBlock extends NodeMaterialBlock {
  62916. /**
  62917. * Creates a new Rotate2dBlock
  62918. * @param name defines the block name
  62919. */
  62920. constructor(name: string);
  62921. /**
  62922. * Gets the current class name
  62923. * @returns the class name
  62924. */
  62925. getClassName(): string;
  62926. /**
  62927. * Gets the input vector
  62928. */
  62929. get input(): NodeMaterialConnectionPoint;
  62930. /**
  62931. * Gets the input angle
  62932. */
  62933. get angle(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the output component
  62936. */
  62937. get output(): NodeMaterialConnectionPoint;
  62938. autoConfigure(material: NodeMaterial): void;
  62939. protected _buildBlock(state: NodeMaterialBuildState): this;
  62940. }
  62941. }
  62942. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62946. /**
  62947. * Block used to get the reflected vector from a direction and a normal
  62948. */
  62949. export class ReflectBlock extends NodeMaterialBlock {
  62950. /**
  62951. * Creates a new ReflectBlock
  62952. * @param name defines the block name
  62953. */
  62954. constructor(name: string);
  62955. /**
  62956. * Gets the current class name
  62957. * @returns the class name
  62958. */
  62959. getClassName(): string;
  62960. /**
  62961. * Gets the incident component
  62962. */
  62963. get incident(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the normal component
  62966. */
  62967. get normal(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the output component
  62970. */
  62971. get output(): NodeMaterialConnectionPoint;
  62972. protected _buildBlock(state: NodeMaterialBuildState): this;
  62973. }
  62974. }
  62975. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62979. /**
  62980. * Block used to get the refracted vector from a direction and a normal
  62981. */
  62982. export class RefractBlock extends NodeMaterialBlock {
  62983. /**
  62984. * Creates a new RefractBlock
  62985. * @param name defines the block name
  62986. */
  62987. constructor(name: string);
  62988. /**
  62989. * Gets the current class name
  62990. * @returns the class name
  62991. */
  62992. getClassName(): string;
  62993. /**
  62994. * Gets the incident component
  62995. */
  62996. get incident(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the normal component
  62999. */
  63000. get normal(): NodeMaterialConnectionPoint;
  63001. /**
  63002. * Gets the index of refraction component
  63003. */
  63004. get ior(): NodeMaterialConnectionPoint;
  63005. /**
  63006. * Gets the output component
  63007. */
  63008. get output(): NodeMaterialConnectionPoint;
  63009. protected _buildBlock(state: NodeMaterialBuildState): this;
  63010. }
  63011. }
  63012. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63016. /**
  63017. * Block used to desaturate a color
  63018. */
  63019. export class DesaturateBlock extends NodeMaterialBlock {
  63020. /**
  63021. * Creates a new DesaturateBlock
  63022. * @param name defines the block name
  63023. */
  63024. constructor(name: string);
  63025. /**
  63026. * Gets the current class name
  63027. * @returns the class name
  63028. */
  63029. getClassName(): string;
  63030. /**
  63031. * Gets the color operand input component
  63032. */
  63033. get color(): NodeMaterialConnectionPoint;
  63034. /**
  63035. * Gets the level operand input component
  63036. */
  63037. get level(): NodeMaterialConnectionPoint;
  63038. /**
  63039. * Gets the output component
  63040. */
  63041. get output(): NodeMaterialConnectionPoint;
  63042. protected _buildBlock(state: NodeMaterialBuildState): this;
  63043. }
  63044. }
  63045. declare module "babylonjs/Materials/Node/Blocks/index" {
  63046. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63047. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63048. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63049. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63050. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63051. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63052. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63053. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63054. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63055. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63079. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63086. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63087. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63093. }
  63094. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63095. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63096. }
  63097. declare module "babylonjs/Materials/Node/index" {
  63098. export * from "babylonjs/Materials/Node/Enums/index";
  63099. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63100. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63101. export * from "babylonjs/Materials/Node/nodeMaterial";
  63102. export * from "babylonjs/Materials/Node/Blocks/index";
  63103. export * from "babylonjs/Materials/Node/Optimizers/index";
  63104. }
  63105. declare module "babylonjs/Materials/effectRenderer" {
  63106. import { Nullable } from "babylonjs/types";
  63107. import { Texture } from "babylonjs/Materials/Textures/texture";
  63108. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63109. import { Viewport } from "babylonjs/Maths/math.viewport";
  63110. import { Observable } from "babylonjs/Misc/observable";
  63111. import { Effect } from "babylonjs/Materials/effect";
  63112. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63113. import "babylonjs/Shaders/postprocess.vertex";
  63114. /**
  63115. * Effect Render Options
  63116. */
  63117. export interface IEffectRendererOptions {
  63118. /**
  63119. * Defines the vertices positions.
  63120. */
  63121. positions?: number[];
  63122. /**
  63123. * Defines the indices.
  63124. */
  63125. indices?: number[];
  63126. }
  63127. /**
  63128. * Helper class to render one or more effects
  63129. */
  63130. export class EffectRenderer {
  63131. private engine;
  63132. private static _DefaultOptions;
  63133. private _vertexBuffers;
  63134. private _indexBuffer;
  63135. private _ringBufferIndex;
  63136. private _ringScreenBuffer;
  63137. private _fullscreenViewport;
  63138. private _getNextFrameBuffer;
  63139. /**
  63140. * Creates an effect renderer
  63141. * @param engine the engine to use for rendering
  63142. * @param options defines the options of the effect renderer
  63143. */
  63144. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63145. /**
  63146. * Sets the current viewport in normalized coordinates 0-1
  63147. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63148. */
  63149. setViewport(viewport?: Viewport): void;
  63150. /**
  63151. * Binds the embedded attributes buffer to the effect.
  63152. * @param effect Defines the effect to bind the attributes for
  63153. */
  63154. bindBuffers(effect: Effect): void;
  63155. /**
  63156. * Sets the current effect wrapper to use during draw.
  63157. * The effect needs to be ready before calling this api.
  63158. * This also sets the default full screen position attribute.
  63159. * @param effectWrapper Defines the effect to draw with
  63160. */
  63161. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63162. /**
  63163. * Draws a full screen quad.
  63164. */
  63165. draw(): void;
  63166. /**
  63167. * renders one or more effects to a specified texture
  63168. * @param effectWrappers list of effects to renderer
  63169. * @param outputTexture texture to draw to, if null it will render to the screen
  63170. */
  63171. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63172. /**
  63173. * Disposes of the effect renderer
  63174. */
  63175. dispose(): void;
  63176. }
  63177. /**
  63178. * Options to create an EffectWrapper
  63179. */
  63180. interface EffectWrapperCreationOptions {
  63181. /**
  63182. * Engine to use to create the effect
  63183. */
  63184. engine: ThinEngine;
  63185. /**
  63186. * Fragment shader for the effect
  63187. */
  63188. fragmentShader: string;
  63189. /**
  63190. * Vertex shader for the effect
  63191. */
  63192. vertexShader?: string;
  63193. /**
  63194. * Attributes to use in the shader
  63195. */
  63196. attributeNames?: Array<string>;
  63197. /**
  63198. * Uniforms to use in the shader
  63199. */
  63200. uniformNames?: Array<string>;
  63201. /**
  63202. * Texture sampler names to use in the shader
  63203. */
  63204. samplerNames?: Array<string>;
  63205. /**
  63206. * The friendly name of the effect displayed in Spector.
  63207. */
  63208. name?: string;
  63209. }
  63210. /**
  63211. * Wraps an effect to be used for rendering
  63212. */
  63213. export class EffectWrapper {
  63214. /**
  63215. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63216. */
  63217. onApplyObservable: Observable<{}>;
  63218. /**
  63219. * The underlying effect
  63220. */
  63221. effect: Effect;
  63222. /**
  63223. * Creates an effect to be renderer
  63224. * @param creationOptions options to create the effect
  63225. */
  63226. constructor(creationOptions: EffectWrapperCreationOptions);
  63227. /**
  63228. * Disposes of the effect wrapper
  63229. */
  63230. dispose(): void;
  63231. }
  63232. }
  63233. declare module "babylonjs/Materials/index" {
  63234. export * from "babylonjs/Materials/Background/index";
  63235. export * from "babylonjs/Materials/colorCurves";
  63236. export * from "babylonjs/Materials/iEffectFallbacks";
  63237. export * from "babylonjs/Materials/effectFallbacks";
  63238. export * from "babylonjs/Materials/effect";
  63239. export * from "babylonjs/Materials/fresnelParameters";
  63240. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63241. export * from "babylonjs/Materials/material";
  63242. export * from "babylonjs/Materials/materialDefines";
  63243. export * from "babylonjs/Materials/materialHelper";
  63244. export * from "babylonjs/Materials/multiMaterial";
  63245. export * from "babylonjs/Materials/PBR/index";
  63246. export * from "babylonjs/Materials/pushMaterial";
  63247. export * from "babylonjs/Materials/shaderMaterial";
  63248. export * from "babylonjs/Materials/standardMaterial";
  63249. export * from "babylonjs/Materials/Textures/index";
  63250. export * from "babylonjs/Materials/uniformBuffer";
  63251. export * from "babylonjs/Materials/materialFlags";
  63252. export * from "babylonjs/Materials/Node/index";
  63253. export * from "babylonjs/Materials/effectRenderer";
  63254. }
  63255. declare module "babylonjs/Maths/index" {
  63256. export * from "babylonjs/Maths/math.scalar";
  63257. export * from "babylonjs/Maths/math";
  63258. export * from "babylonjs/Maths/sphericalPolynomial";
  63259. }
  63260. declare module "babylonjs/Misc/workerPool" {
  63261. import { IDisposable } from "babylonjs/scene";
  63262. /**
  63263. * Helper class to push actions to a pool of workers.
  63264. */
  63265. export class WorkerPool implements IDisposable {
  63266. private _workerInfos;
  63267. private _pendingActions;
  63268. /**
  63269. * Constructor
  63270. * @param workers Array of workers to use for actions
  63271. */
  63272. constructor(workers: Array<Worker>);
  63273. /**
  63274. * Terminates all workers and clears any pending actions.
  63275. */
  63276. dispose(): void;
  63277. /**
  63278. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63279. * pended until a worker has completed its action.
  63280. * @param action The action to perform. Call onComplete when the action is complete.
  63281. */
  63282. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63283. private _execute;
  63284. }
  63285. }
  63286. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63287. import { IDisposable } from "babylonjs/scene";
  63288. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63289. /**
  63290. * Configuration for Draco compression
  63291. */
  63292. export interface IDracoCompressionConfiguration {
  63293. /**
  63294. * Configuration for the decoder.
  63295. */
  63296. decoder: {
  63297. /**
  63298. * The url to the WebAssembly module.
  63299. */
  63300. wasmUrl?: string;
  63301. /**
  63302. * The url to the WebAssembly binary.
  63303. */
  63304. wasmBinaryUrl?: string;
  63305. /**
  63306. * The url to the fallback JavaScript module.
  63307. */
  63308. fallbackUrl?: string;
  63309. };
  63310. }
  63311. /**
  63312. * Draco compression (https://google.github.io/draco/)
  63313. *
  63314. * This class wraps the Draco module.
  63315. *
  63316. * **Encoder**
  63317. *
  63318. * The encoder is not currently implemented.
  63319. *
  63320. * **Decoder**
  63321. *
  63322. * 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.
  63323. *
  63324. * To update the configuration, use the following code:
  63325. * ```javascript
  63326. * DracoCompression.Configuration = {
  63327. * decoder: {
  63328. * wasmUrl: "<url to the WebAssembly library>",
  63329. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63330. * fallbackUrl: "<url to the fallback JavaScript library>",
  63331. * }
  63332. * };
  63333. * ```
  63334. *
  63335. * 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.
  63336. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63337. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63338. *
  63339. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63340. * ```javascript
  63341. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63342. * ```
  63343. *
  63344. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63345. */
  63346. export class DracoCompression implements IDisposable {
  63347. private _workerPoolPromise?;
  63348. private _decoderModulePromise?;
  63349. /**
  63350. * The configuration. Defaults to the following urls:
  63351. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63352. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63353. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63354. */
  63355. static Configuration: IDracoCompressionConfiguration;
  63356. /**
  63357. * Returns true if the decoder configuration is available.
  63358. */
  63359. static get DecoderAvailable(): boolean;
  63360. /**
  63361. * Default number of workers to create when creating the draco compression object.
  63362. */
  63363. static DefaultNumWorkers: number;
  63364. private static GetDefaultNumWorkers;
  63365. private static _Default;
  63366. /**
  63367. * Default instance for the draco compression object.
  63368. */
  63369. static get Default(): DracoCompression;
  63370. /**
  63371. * Constructor
  63372. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63373. */
  63374. constructor(numWorkers?: number);
  63375. /**
  63376. * Stop all async operations and release resources.
  63377. */
  63378. dispose(): void;
  63379. /**
  63380. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63381. * @returns a promise that resolves when ready
  63382. */
  63383. whenReadyAsync(): Promise<void>;
  63384. /**
  63385. * Decode Draco compressed mesh data to vertex data.
  63386. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63387. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63388. * @returns A promise that resolves with the decoded vertex data
  63389. */
  63390. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63391. [kind: string]: number;
  63392. }): Promise<VertexData>;
  63393. }
  63394. }
  63395. declare module "babylonjs/Meshes/Compression/index" {
  63396. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63397. }
  63398. declare module "babylonjs/Meshes/csg" {
  63399. import { Nullable } from "babylonjs/types";
  63400. import { Scene } from "babylonjs/scene";
  63401. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63402. import { Mesh } from "babylonjs/Meshes/mesh";
  63403. import { Material } from "babylonjs/Materials/material";
  63404. /**
  63405. * Class for building Constructive Solid Geometry
  63406. */
  63407. export class CSG {
  63408. private polygons;
  63409. /**
  63410. * The world matrix
  63411. */
  63412. matrix: Matrix;
  63413. /**
  63414. * Stores the position
  63415. */
  63416. position: Vector3;
  63417. /**
  63418. * Stores the rotation
  63419. */
  63420. rotation: Vector3;
  63421. /**
  63422. * Stores the rotation quaternion
  63423. */
  63424. rotationQuaternion: Nullable<Quaternion>;
  63425. /**
  63426. * Stores the scaling vector
  63427. */
  63428. scaling: Vector3;
  63429. /**
  63430. * Convert the Mesh to CSG
  63431. * @param mesh The Mesh to convert to CSG
  63432. * @returns A new CSG from the Mesh
  63433. */
  63434. static FromMesh(mesh: Mesh): CSG;
  63435. /**
  63436. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63437. * @param polygons Polygons used to construct a CSG solid
  63438. */
  63439. private static FromPolygons;
  63440. /**
  63441. * Clones, or makes a deep copy, of the CSG
  63442. * @returns A new CSG
  63443. */
  63444. clone(): CSG;
  63445. /**
  63446. * Unions this CSG with another CSG
  63447. * @param csg The CSG to union against this CSG
  63448. * @returns The unioned CSG
  63449. */
  63450. union(csg: CSG): CSG;
  63451. /**
  63452. * Unions this CSG with another CSG in place
  63453. * @param csg The CSG to union against this CSG
  63454. */
  63455. unionInPlace(csg: CSG): void;
  63456. /**
  63457. * Subtracts this CSG with another CSG
  63458. * @param csg The CSG to subtract against this CSG
  63459. * @returns A new CSG
  63460. */
  63461. subtract(csg: CSG): CSG;
  63462. /**
  63463. * Subtracts this CSG with another CSG in place
  63464. * @param csg The CSG to subtact against this CSG
  63465. */
  63466. subtractInPlace(csg: CSG): void;
  63467. /**
  63468. * Intersect this CSG with another CSG
  63469. * @param csg The CSG to intersect against this CSG
  63470. * @returns A new CSG
  63471. */
  63472. intersect(csg: CSG): CSG;
  63473. /**
  63474. * Intersects this CSG with another CSG in place
  63475. * @param csg The CSG to intersect against this CSG
  63476. */
  63477. intersectInPlace(csg: CSG): void;
  63478. /**
  63479. * Return a new CSG solid with solid and empty space switched. This solid is
  63480. * not modified.
  63481. * @returns A new CSG solid with solid and empty space switched
  63482. */
  63483. inverse(): CSG;
  63484. /**
  63485. * Inverses the CSG in place
  63486. */
  63487. inverseInPlace(): void;
  63488. /**
  63489. * This is used to keep meshes transformations so they can be restored
  63490. * when we build back a Babylon Mesh
  63491. * NB : All CSG operations are performed in world coordinates
  63492. * @param csg The CSG to copy the transform attributes from
  63493. * @returns This CSG
  63494. */
  63495. copyTransformAttributes(csg: CSG): CSG;
  63496. /**
  63497. * Build Raw mesh from CSG
  63498. * Coordinates here are in world space
  63499. * @param name The name of the mesh geometry
  63500. * @param scene The Scene
  63501. * @param keepSubMeshes Specifies if the submeshes should be kept
  63502. * @returns A new Mesh
  63503. */
  63504. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63505. /**
  63506. * Build Mesh from CSG taking material and transforms into account
  63507. * @param name The name of the Mesh
  63508. * @param material The material of the Mesh
  63509. * @param scene The Scene
  63510. * @param keepSubMeshes Specifies if submeshes should be kept
  63511. * @returns The new Mesh
  63512. */
  63513. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63514. }
  63515. }
  63516. declare module "babylonjs/Meshes/trailMesh" {
  63517. import { Mesh } from "babylonjs/Meshes/mesh";
  63518. import { Scene } from "babylonjs/scene";
  63519. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63520. /**
  63521. * Class used to create a trail following a mesh
  63522. */
  63523. export class TrailMesh extends Mesh {
  63524. private _generator;
  63525. private _autoStart;
  63526. private _running;
  63527. private _diameter;
  63528. private _length;
  63529. private _sectionPolygonPointsCount;
  63530. private _sectionVectors;
  63531. private _sectionNormalVectors;
  63532. private _beforeRenderObserver;
  63533. /**
  63534. * @constructor
  63535. * @param name The value used by scene.getMeshByName() to do a lookup.
  63536. * @param generator The mesh or transform node to generate a trail.
  63537. * @param scene The scene to add this mesh to.
  63538. * @param diameter Diameter of trailing mesh. Default is 1.
  63539. * @param length Length of trailing mesh. Default is 60.
  63540. * @param autoStart Automatically start trailing mesh. Default true.
  63541. */
  63542. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63543. /**
  63544. * "TrailMesh"
  63545. * @returns "TrailMesh"
  63546. */
  63547. getClassName(): string;
  63548. private _createMesh;
  63549. /**
  63550. * Start trailing mesh.
  63551. */
  63552. start(): void;
  63553. /**
  63554. * Stop trailing mesh.
  63555. */
  63556. stop(): void;
  63557. /**
  63558. * Update trailing mesh geometry.
  63559. */
  63560. update(): void;
  63561. /**
  63562. * Returns a new TrailMesh object.
  63563. * @param name is a string, the name given to the new mesh
  63564. * @param newGenerator use new generator object for cloned trail mesh
  63565. * @returns a new mesh
  63566. */
  63567. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63568. /**
  63569. * Serializes this trail mesh
  63570. * @param serializationObject object to write serialization to
  63571. */
  63572. serialize(serializationObject: any): void;
  63573. /**
  63574. * Parses a serialized trail mesh
  63575. * @param parsedMesh the serialized mesh
  63576. * @param scene the scene to create the trail mesh in
  63577. * @returns the created trail mesh
  63578. */
  63579. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63580. }
  63581. }
  63582. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63583. import { Nullable } from "babylonjs/types";
  63584. import { Scene } from "babylonjs/scene";
  63585. import { Vector4 } from "babylonjs/Maths/math.vector";
  63586. import { Color4 } from "babylonjs/Maths/math.color";
  63587. import { Mesh } from "babylonjs/Meshes/mesh";
  63588. /**
  63589. * Class containing static functions to help procedurally build meshes
  63590. */
  63591. export class TiledBoxBuilder {
  63592. /**
  63593. * Creates a box mesh
  63594. * 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)
  63595. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63599. * @param name defines the name of the mesh
  63600. * @param options defines the options used to create the mesh
  63601. * @param scene defines the hosting scene
  63602. * @returns the box mesh
  63603. */
  63604. static CreateTiledBox(name: string, options: {
  63605. pattern?: number;
  63606. width?: number;
  63607. height?: number;
  63608. depth?: number;
  63609. tileSize?: number;
  63610. tileWidth?: number;
  63611. tileHeight?: number;
  63612. alignHorizontal?: number;
  63613. alignVertical?: number;
  63614. faceUV?: Vector4[];
  63615. faceColors?: Color4[];
  63616. sideOrientation?: number;
  63617. updatable?: boolean;
  63618. }, scene?: Nullable<Scene>): Mesh;
  63619. }
  63620. }
  63621. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63622. import { Vector4 } from "babylonjs/Maths/math.vector";
  63623. import { Mesh } from "babylonjs/Meshes/mesh";
  63624. /**
  63625. * Class containing static functions to help procedurally build meshes
  63626. */
  63627. export class TorusKnotBuilder {
  63628. /**
  63629. * Creates a torus knot mesh
  63630. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63631. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63632. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63633. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63637. * @param name defines the name of the mesh
  63638. * @param options defines the options used to create the mesh
  63639. * @param scene defines the hosting scene
  63640. * @returns the torus knot mesh
  63641. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63642. */
  63643. static CreateTorusKnot(name: string, options: {
  63644. radius?: number;
  63645. tube?: number;
  63646. radialSegments?: number;
  63647. tubularSegments?: number;
  63648. p?: number;
  63649. q?: number;
  63650. updatable?: boolean;
  63651. sideOrientation?: number;
  63652. frontUVs?: Vector4;
  63653. backUVs?: Vector4;
  63654. }, scene: any): Mesh;
  63655. }
  63656. }
  63657. declare module "babylonjs/Meshes/polygonMesh" {
  63658. import { Scene } from "babylonjs/scene";
  63659. import { Vector2 } from "babylonjs/Maths/math.vector";
  63660. import { Mesh } from "babylonjs/Meshes/mesh";
  63661. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63662. import { Path2 } from "babylonjs/Maths/math.path";
  63663. /**
  63664. * Polygon
  63665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63666. */
  63667. export class Polygon {
  63668. /**
  63669. * Creates a rectangle
  63670. * @param xmin bottom X coord
  63671. * @param ymin bottom Y coord
  63672. * @param xmax top X coord
  63673. * @param ymax top Y coord
  63674. * @returns points that make the resulting rectation
  63675. */
  63676. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63677. /**
  63678. * Creates a circle
  63679. * @param radius radius of circle
  63680. * @param cx scale in x
  63681. * @param cy scale in y
  63682. * @param numberOfSides number of sides that make up the circle
  63683. * @returns points that make the resulting circle
  63684. */
  63685. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63686. /**
  63687. * Creates a polygon from input string
  63688. * @param input Input polygon data
  63689. * @returns the parsed points
  63690. */
  63691. static Parse(input: string): Vector2[];
  63692. /**
  63693. * Starts building a polygon from x and y coordinates
  63694. * @param x x coordinate
  63695. * @param y y coordinate
  63696. * @returns the started path2
  63697. */
  63698. static StartingAt(x: number, y: number): Path2;
  63699. }
  63700. /**
  63701. * Builds a polygon
  63702. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63703. */
  63704. export class PolygonMeshBuilder {
  63705. private _points;
  63706. private _outlinepoints;
  63707. private _holes;
  63708. private _name;
  63709. private _scene;
  63710. private _epoints;
  63711. private _eholes;
  63712. private _addToepoint;
  63713. /**
  63714. * Babylon reference to the earcut plugin.
  63715. */
  63716. bjsEarcut: any;
  63717. /**
  63718. * Creates a PolygonMeshBuilder
  63719. * @param name name of the builder
  63720. * @param contours Path of the polygon
  63721. * @param scene scene to add to when creating the mesh
  63722. * @param earcutInjection can be used to inject your own earcut reference
  63723. */
  63724. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63725. /**
  63726. * Adds a whole within the polygon
  63727. * @param hole Array of points defining the hole
  63728. * @returns this
  63729. */
  63730. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63731. /**
  63732. * Creates the polygon
  63733. * @param updatable If the mesh should be updatable
  63734. * @param depth The depth of the mesh created
  63735. * @returns the created mesh
  63736. */
  63737. build(updatable?: boolean, depth?: number): Mesh;
  63738. /**
  63739. * Creates the polygon
  63740. * @param depth The depth of the mesh created
  63741. * @returns the created VertexData
  63742. */
  63743. buildVertexData(depth?: number): VertexData;
  63744. /**
  63745. * Adds a side to the polygon
  63746. * @param positions points that make the polygon
  63747. * @param normals normals of the polygon
  63748. * @param uvs uvs of the polygon
  63749. * @param indices indices of the polygon
  63750. * @param bounds bounds of the polygon
  63751. * @param points points of the polygon
  63752. * @param depth depth of the polygon
  63753. * @param flip flip of the polygon
  63754. */
  63755. private addSide;
  63756. }
  63757. }
  63758. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63759. import { Scene } from "babylonjs/scene";
  63760. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63761. import { Color4 } from "babylonjs/Maths/math.color";
  63762. import { Mesh } from "babylonjs/Meshes/mesh";
  63763. import { Nullable } from "babylonjs/types";
  63764. /**
  63765. * Class containing static functions to help procedurally build meshes
  63766. */
  63767. export class PolygonBuilder {
  63768. /**
  63769. * Creates a polygon mesh
  63770. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63771. * * 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
  63772. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63775. * * Remember you can only change the shape positions, not their number when updating a polygon
  63776. * @param name defines the name of the mesh
  63777. * @param options defines the options used to create the mesh
  63778. * @param scene defines the hosting scene
  63779. * @param earcutInjection can be used to inject your own earcut reference
  63780. * @returns the polygon mesh
  63781. */
  63782. static CreatePolygon(name: string, options: {
  63783. shape: Vector3[];
  63784. holes?: Vector3[][];
  63785. depth?: number;
  63786. faceUV?: Vector4[];
  63787. faceColors?: Color4[];
  63788. updatable?: boolean;
  63789. sideOrientation?: number;
  63790. frontUVs?: Vector4;
  63791. backUVs?: Vector4;
  63792. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63793. /**
  63794. * Creates an extruded polygon mesh, with depth in the Y direction.
  63795. * * 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)
  63796. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63797. * @param name defines the name of the mesh
  63798. * @param options defines the options used to create the mesh
  63799. * @param scene defines the hosting scene
  63800. * @param earcutInjection can be used to inject your own earcut reference
  63801. * @returns the polygon mesh
  63802. */
  63803. static ExtrudePolygon(name: string, options: {
  63804. shape: Vector3[];
  63805. holes?: Vector3[][];
  63806. depth?: number;
  63807. faceUV?: Vector4[];
  63808. faceColors?: Color4[];
  63809. updatable?: boolean;
  63810. sideOrientation?: number;
  63811. frontUVs?: Vector4;
  63812. backUVs?: Vector4;
  63813. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63814. }
  63815. }
  63816. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63817. import { Scene } from "babylonjs/scene";
  63818. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63819. import { Mesh } from "babylonjs/Meshes/mesh";
  63820. import { Nullable } from "babylonjs/types";
  63821. /**
  63822. * Class containing static functions to help procedurally build meshes
  63823. */
  63824. export class LatheBuilder {
  63825. /**
  63826. * Creates lathe mesh.
  63827. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63828. * * 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
  63829. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63830. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63831. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63832. * * 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
  63833. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63834. * * 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
  63835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63837. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63839. * @param name defines the name of the mesh
  63840. * @param options defines the options used to create the mesh
  63841. * @param scene defines the hosting scene
  63842. * @returns the lathe mesh
  63843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63844. */
  63845. static CreateLathe(name: string, options: {
  63846. shape: Vector3[];
  63847. radius?: number;
  63848. tessellation?: number;
  63849. clip?: number;
  63850. arc?: number;
  63851. closed?: boolean;
  63852. updatable?: boolean;
  63853. sideOrientation?: number;
  63854. frontUVs?: Vector4;
  63855. backUVs?: Vector4;
  63856. cap?: number;
  63857. invertUV?: boolean;
  63858. }, scene?: Nullable<Scene>): Mesh;
  63859. }
  63860. }
  63861. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63862. import { Nullable } from "babylonjs/types";
  63863. import { Scene } from "babylonjs/scene";
  63864. import { Vector4 } from "babylonjs/Maths/math.vector";
  63865. import { Mesh } from "babylonjs/Meshes/mesh";
  63866. /**
  63867. * Class containing static functions to help procedurally build meshes
  63868. */
  63869. export class TiledPlaneBuilder {
  63870. /**
  63871. * Creates a tiled plane mesh
  63872. * * The parameter `pattern` will, depending on value, do nothing or
  63873. * * * flip (reflect about central vertical) alternate tiles across and up
  63874. * * * flip every tile on alternate rows
  63875. * * * rotate (180 degs) alternate tiles across and up
  63876. * * * rotate every tile on alternate rows
  63877. * * * flip and rotate alternate tiles across and up
  63878. * * * flip and rotate every tile on alternate rows
  63879. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63880. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63883. * * 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)
  63884. * * 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)
  63885. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63886. * @param name defines the name of the mesh
  63887. * @param options defines the options used to create the mesh
  63888. * @param scene defines the hosting scene
  63889. * @returns the box mesh
  63890. */
  63891. static CreateTiledPlane(name: string, options: {
  63892. pattern?: number;
  63893. tileSize?: number;
  63894. tileWidth?: number;
  63895. tileHeight?: number;
  63896. size?: number;
  63897. width?: number;
  63898. height?: number;
  63899. alignHorizontal?: number;
  63900. alignVertical?: number;
  63901. sideOrientation?: number;
  63902. frontUVs?: Vector4;
  63903. backUVs?: Vector4;
  63904. updatable?: boolean;
  63905. }, scene?: Nullable<Scene>): Mesh;
  63906. }
  63907. }
  63908. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63909. import { Nullable } from "babylonjs/types";
  63910. import { Scene } from "babylonjs/scene";
  63911. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63912. import { Mesh } from "babylonjs/Meshes/mesh";
  63913. /**
  63914. * Class containing static functions to help procedurally build meshes
  63915. */
  63916. export class TubeBuilder {
  63917. /**
  63918. * Creates a tube mesh.
  63919. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63920. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63921. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63922. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63923. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63924. * * 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)
  63925. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63926. * * 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
  63927. * * 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
  63928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63932. * @param name defines the name of the mesh
  63933. * @param options defines the options used to create the mesh
  63934. * @param scene defines the hosting scene
  63935. * @returns the tube mesh
  63936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63937. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63938. */
  63939. static CreateTube(name: string, options: {
  63940. path: Vector3[];
  63941. radius?: number;
  63942. tessellation?: number;
  63943. radiusFunction?: {
  63944. (i: number, distance: number): number;
  63945. };
  63946. cap?: number;
  63947. arc?: number;
  63948. updatable?: boolean;
  63949. sideOrientation?: number;
  63950. frontUVs?: Vector4;
  63951. backUVs?: Vector4;
  63952. instance?: Mesh;
  63953. invertUV?: boolean;
  63954. }, scene?: Nullable<Scene>): Mesh;
  63955. }
  63956. }
  63957. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63958. import { Scene } from "babylonjs/scene";
  63959. import { Vector4 } from "babylonjs/Maths/math.vector";
  63960. import { Mesh } from "babylonjs/Meshes/mesh";
  63961. import { Nullable } from "babylonjs/types";
  63962. /**
  63963. * Class containing static functions to help procedurally build meshes
  63964. */
  63965. export class IcoSphereBuilder {
  63966. /**
  63967. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63968. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63969. * * 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`)
  63970. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63971. * * 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
  63972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63975. * @param name defines the name of the mesh
  63976. * @param options defines the options used to create the mesh
  63977. * @param scene defines the hosting scene
  63978. * @returns the icosahedron mesh
  63979. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63980. */
  63981. static CreateIcoSphere(name: string, options: {
  63982. radius?: number;
  63983. radiusX?: number;
  63984. radiusY?: number;
  63985. radiusZ?: number;
  63986. flat?: boolean;
  63987. subdivisions?: number;
  63988. sideOrientation?: number;
  63989. frontUVs?: Vector4;
  63990. backUVs?: Vector4;
  63991. updatable?: boolean;
  63992. }, scene?: Nullable<Scene>): Mesh;
  63993. }
  63994. }
  63995. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63996. import { Vector3 } from "babylonjs/Maths/math.vector";
  63997. import { Mesh } from "babylonjs/Meshes/mesh";
  63998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63999. /**
  64000. * Class containing static functions to help procedurally build meshes
  64001. */
  64002. export class DecalBuilder {
  64003. /**
  64004. * Creates a decal mesh.
  64005. * 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
  64006. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64007. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64008. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64009. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64010. * @param name defines the name of the mesh
  64011. * @param sourceMesh defines the mesh where the decal must be applied
  64012. * @param options defines the options used to create the mesh
  64013. * @param scene defines the hosting scene
  64014. * @returns the decal mesh
  64015. * @see https://doc.babylonjs.com/how_to/decals
  64016. */
  64017. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64018. position?: Vector3;
  64019. normal?: Vector3;
  64020. size?: Vector3;
  64021. angle?: number;
  64022. }): Mesh;
  64023. }
  64024. }
  64025. declare module "babylonjs/Meshes/meshBuilder" {
  64026. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64027. import { Nullable } from "babylonjs/types";
  64028. import { Scene } from "babylonjs/scene";
  64029. import { Mesh } from "babylonjs/Meshes/mesh";
  64030. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64031. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64033. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64034. import { Plane } from "babylonjs/Maths/math.plane";
  64035. /**
  64036. * Class containing static functions to help procedurally build meshes
  64037. */
  64038. export class MeshBuilder {
  64039. /**
  64040. * Creates a box mesh
  64041. * * The parameter `size` sets the size (float) of each box side (default 1)
  64042. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64043. * * 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)
  64044. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64048. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64049. * @param name defines the name of the mesh
  64050. * @param options defines the options used to create the mesh
  64051. * @param scene defines the hosting scene
  64052. * @returns the box mesh
  64053. */
  64054. static CreateBox(name: string, options: {
  64055. size?: number;
  64056. width?: number;
  64057. height?: number;
  64058. depth?: number;
  64059. faceUV?: Vector4[];
  64060. faceColors?: Color4[];
  64061. sideOrientation?: number;
  64062. frontUVs?: Vector4;
  64063. backUVs?: Vector4;
  64064. updatable?: boolean;
  64065. }, scene?: Nullable<Scene>): Mesh;
  64066. /**
  64067. * Creates a tiled box mesh
  64068. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64070. * @param name defines the name of the mesh
  64071. * @param options defines the options used to create the mesh
  64072. * @param scene defines the hosting scene
  64073. * @returns the tiled box mesh
  64074. */
  64075. static CreateTiledBox(name: string, options: {
  64076. pattern?: number;
  64077. size?: number;
  64078. width?: number;
  64079. height?: number;
  64080. depth: number;
  64081. tileSize?: number;
  64082. tileWidth?: number;
  64083. tileHeight?: number;
  64084. faceUV?: Vector4[];
  64085. faceColors?: Color4[];
  64086. alignHorizontal?: number;
  64087. alignVertical?: number;
  64088. sideOrientation?: number;
  64089. updatable?: boolean;
  64090. }, scene?: Nullable<Scene>): Mesh;
  64091. /**
  64092. * Creates a sphere mesh
  64093. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64094. * * 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`)
  64095. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64096. * * 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
  64097. * * 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)
  64098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64101. * @param name defines the name of the mesh
  64102. * @param options defines the options used to create the mesh
  64103. * @param scene defines the hosting scene
  64104. * @returns the sphere mesh
  64105. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64106. */
  64107. static CreateSphere(name: string, options: {
  64108. segments?: number;
  64109. diameter?: number;
  64110. diameterX?: number;
  64111. diameterY?: number;
  64112. diameterZ?: number;
  64113. arc?: number;
  64114. slice?: number;
  64115. sideOrientation?: number;
  64116. frontUVs?: Vector4;
  64117. backUVs?: Vector4;
  64118. updatable?: boolean;
  64119. }, scene?: Nullable<Scene>): Mesh;
  64120. /**
  64121. * Creates a plane polygonal mesh. By default, this is a disc
  64122. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64123. * * 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
  64124. * * 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
  64125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64128. * @param name defines the name of the mesh
  64129. * @param options defines the options used to create the mesh
  64130. * @param scene defines the hosting scene
  64131. * @returns the plane polygonal mesh
  64132. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64133. */
  64134. static CreateDisc(name: string, options: {
  64135. radius?: number;
  64136. tessellation?: number;
  64137. arc?: number;
  64138. updatable?: boolean;
  64139. sideOrientation?: number;
  64140. frontUVs?: Vector4;
  64141. backUVs?: Vector4;
  64142. }, scene?: Nullable<Scene>): Mesh;
  64143. /**
  64144. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64145. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64146. * * 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`)
  64147. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64148. * * 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
  64149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64152. * @param name defines the name of the mesh
  64153. * @param options defines the options used to create the mesh
  64154. * @param scene defines the hosting scene
  64155. * @returns the icosahedron mesh
  64156. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64157. */
  64158. static CreateIcoSphere(name: string, options: {
  64159. radius?: number;
  64160. radiusX?: number;
  64161. radiusY?: number;
  64162. radiusZ?: number;
  64163. flat?: boolean;
  64164. subdivisions?: number;
  64165. sideOrientation?: number;
  64166. frontUVs?: Vector4;
  64167. backUVs?: Vector4;
  64168. updatable?: boolean;
  64169. }, scene?: Nullable<Scene>): Mesh;
  64170. /**
  64171. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64172. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64173. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64174. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64175. * * 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
  64176. * * 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
  64177. * * 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
  64178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64180. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64181. * * 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
  64182. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64183. * * 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
  64184. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64186. * @param name defines the name of the mesh
  64187. * @param options defines the options used to create the mesh
  64188. * @param scene defines the hosting scene
  64189. * @returns the ribbon mesh
  64190. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64192. */
  64193. static CreateRibbon(name: string, options: {
  64194. pathArray: Vector3[][];
  64195. closeArray?: boolean;
  64196. closePath?: boolean;
  64197. offset?: number;
  64198. updatable?: boolean;
  64199. sideOrientation?: number;
  64200. frontUVs?: Vector4;
  64201. backUVs?: Vector4;
  64202. instance?: Mesh;
  64203. invertUV?: boolean;
  64204. uvs?: Vector2[];
  64205. colors?: Color4[];
  64206. }, scene?: Nullable<Scene>): Mesh;
  64207. /**
  64208. * Creates a cylinder or a cone mesh
  64209. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64210. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64211. * * 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.
  64212. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64213. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64214. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64215. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64216. * * 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).
  64217. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64218. * * 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).
  64219. * * 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
  64220. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64221. * * 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
  64222. * * 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.
  64223. * * If `enclose` is false, a ring surface is one element.
  64224. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64225. * * 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
  64226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64229. * @param name defines the name of the mesh
  64230. * @param options defines the options used to create the mesh
  64231. * @param scene defines the hosting scene
  64232. * @returns the cylinder mesh
  64233. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64234. */
  64235. static CreateCylinder(name: string, options: {
  64236. height?: number;
  64237. diameterTop?: number;
  64238. diameterBottom?: number;
  64239. diameter?: number;
  64240. tessellation?: number;
  64241. subdivisions?: number;
  64242. arc?: number;
  64243. faceColors?: Color4[];
  64244. faceUV?: Vector4[];
  64245. updatable?: boolean;
  64246. hasRings?: boolean;
  64247. enclose?: boolean;
  64248. cap?: number;
  64249. sideOrientation?: number;
  64250. frontUVs?: Vector4;
  64251. backUVs?: Vector4;
  64252. }, scene?: Nullable<Scene>): Mesh;
  64253. /**
  64254. * Creates a torus mesh
  64255. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64256. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64257. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64261. * @param name defines the name of the mesh
  64262. * @param options defines the options used to create the mesh
  64263. * @param scene defines the hosting scene
  64264. * @returns the torus mesh
  64265. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64266. */
  64267. static CreateTorus(name: string, options: {
  64268. diameter?: number;
  64269. thickness?: number;
  64270. tessellation?: number;
  64271. updatable?: boolean;
  64272. sideOrientation?: number;
  64273. frontUVs?: Vector4;
  64274. backUVs?: Vector4;
  64275. }, scene?: Nullable<Scene>): Mesh;
  64276. /**
  64277. * Creates a torus knot mesh
  64278. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64279. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64280. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64281. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64285. * @param name defines the name of the mesh
  64286. * @param options defines the options used to create the mesh
  64287. * @param scene defines the hosting scene
  64288. * @returns the torus knot mesh
  64289. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64290. */
  64291. static CreateTorusKnot(name: string, options: {
  64292. radius?: number;
  64293. tube?: number;
  64294. radialSegments?: number;
  64295. tubularSegments?: number;
  64296. p?: number;
  64297. q?: number;
  64298. updatable?: boolean;
  64299. sideOrientation?: number;
  64300. frontUVs?: Vector4;
  64301. backUVs?: Vector4;
  64302. }, scene?: Nullable<Scene>): Mesh;
  64303. /**
  64304. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64305. * * 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
  64306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64307. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64308. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64309. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64310. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64311. * * 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
  64312. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64315. * @param name defines the name of the new line system
  64316. * @param options defines the options used to create the line system
  64317. * @param scene defines the hosting scene
  64318. * @returns a new line system mesh
  64319. */
  64320. static CreateLineSystem(name: string, options: {
  64321. lines: Vector3[][];
  64322. updatable?: boolean;
  64323. instance?: Nullable<LinesMesh>;
  64324. colors?: Nullable<Color4[][]>;
  64325. useVertexAlpha?: boolean;
  64326. }, scene: Nullable<Scene>): LinesMesh;
  64327. /**
  64328. * Creates a line mesh
  64329. * 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
  64330. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64331. * * The parameter `points` is an array successive Vector3
  64332. * * 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
  64333. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64334. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64335. * * When updating an instance, remember that only point positions can change, not the number of points
  64336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64338. * @param name defines the name of the new line system
  64339. * @param options defines the options used to create the line system
  64340. * @param scene defines the hosting scene
  64341. * @returns a new line mesh
  64342. */
  64343. static CreateLines(name: string, options: {
  64344. points: Vector3[];
  64345. updatable?: boolean;
  64346. instance?: Nullable<LinesMesh>;
  64347. colors?: Color4[];
  64348. useVertexAlpha?: boolean;
  64349. }, scene?: Nullable<Scene>): LinesMesh;
  64350. /**
  64351. * Creates a dashed line mesh
  64352. * * 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
  64353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64354. * * The parameter `points` is an array successive Vector3
  64355. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64356. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64357. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64358. * * 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
  64359. * * When updating an instance, remember that only point positions can change, not the number of points
  64360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64361. * @param name defines the name of the mesh
  64362. * @param options defines the options used to create the mesh
  64363. * @param scene defines the hosting scene
  64364. * @returns the dashed line mesh
  64365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64366. */
  64367. static CreateDashedLines(name: string, options: {
  64368. points: Vector3[];
  64369. dashSize?: number;
  64370. gapSize?: number;
  64371. dashNb?: number;
  64372. updatable?: boolean;
  64373. instance?: LinesMesh;
  64374. }, scene?: Nullable<Scene>): LinesMesh;
  64375. /**
  64376. * 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.
  64377. * * 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.
  64378. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64379. * * 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.
  64380. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64381. * * 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
  64382. * * 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
  64383. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64386. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64388. * @param name defines the name of the mesh
  64389. * @param options defines the options used to create the mesh
  64390. * @param scene defines the hosting scene
  64391. * @returns the extruded shape mesh
  64392. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64394. */
  64395. static ExtrudeShape(name: string, options: {
  64396. shape: Vector3[];
  64397. path: Vector3[];
  64398. scale?: number;
  64399. rotation?: number;
  64400. cap?: number;
  64401. updatable?: boolean;
  64402. sideOrientation?: number;
  64403. frontUVs?: Vector4;
  64404. backUVs?: Vector4;
  64405. instance?: Mesh;
  64406. invertUV?: boolean;
  64407. }, scene?: Nullable<Scene>): Mesh;
  64408. /**
  64409. * Creates an custom extruded shape mesh.
  64410. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64411. * * 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.
  64412. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64413. * * 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
  64414. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64415. * * 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
  64416. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64417. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64418. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64419. * * 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
  64420. * * 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
  64421. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64426. * @param name defines the name of the mesh
  64427. * @param options defines the options used to create the mesh
  64428. * @param scene defines the hosting scene
  64429. * @returns the custom extruded shape mesh
  64430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64433. */
  64434. static ExtrudeShapeCustom(name: string, options: {
  64435. shape: Vector3[];
  64436. path: Vector3[];
  64437. scaleFunction?: any;
  64438. rotationFunction?: any;
  64439. ribbonCloseArray?: boolean;
  64440. ribbonClosePath?: boolean;
  64441. cap?: number;
  64442. updatable?: boolean;
  64443. sideOrientation?: number;
  64444. frontUVs?: Vector4;
  64445. backUVs?: Vector4;
  64446. instance?: Mesh;
  64447. invertUV?: boolean;
  64448. }, scene?: Nullable<Scene>): Mesh;
  64449. /**
  64450. * Creates lathe mesh.
  64451. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64452. * * 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
  64453. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64454. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64455. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64456. * * 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
  64457. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64458. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  64459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64463. * @param name defines the name of the mesh
  64464. * @param options defines the options used to create the mesh
  64465. * @param scene defines the hosting scene
  64466. * @returns the lathe mesh
  64467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64468. */
  64469. static CreateLathe(name: string, options: {
  64470. shape: Vector3[];
  64471. radius?: number;
  64472. tessellation?: number;
  64473. clip?: number;
  64474. arc?: number;
  64475. closed?: boolean;
  64476. updatable?: boolean;
  64477. sideOrientation?: number;
  64478. frontUVs?: Vector4;
  64479. backUVs?: Vector4;
  64480. cap?: number;
  64481. invertUV?: boolean;
  64482. }, scene?: Nullable<Scene>): Mesh;
  64483. /**
  64484. * Creates a tiled plane mesh
  64485. * * You can set a limited pattern arrangement with the tiles
  64486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64489. * @param name defines the name of the mesh
  64490. * @param options defines the options used to create the mesh
  64491. * @param scene defines the hosting scene
  64492. * @returns the plane mesh
  64493. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64494. */
  64495. static CreateTiledPlane(name: string, options: {
  64496. pattern?: number;
  64497. tileSize?: number;
  64498. tileWidth?: number;
  64499. tileHeight?: number;
  64500. size?: number;
  64501. width?: number;
  64502. height?: number;
  64503. alignHorizontal?: number;
  64504. alignVertical?: number;
  64505. sideOrientation?: number;
  64506. frontUVs?: Vector4;
  64507. backUVs?: Vector4;
  64508. updatable?: boolean;
  64509. }, scene?: Nullable<Scene>): Mesh;
  64510. /**
  64511. * Creates a plane mesh
  64512. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64513. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64514. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64518. * @param name defines the name of the mesh
  64519. * @param options defines the options used to create the mesh
  64520. * @param scene defines the hosting scene
  64521. * @returns the plane mesh
  64522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64523. */
  64524. static CreatePlane(name: string, options: {
  64525. size?: number;
  64526. width?: number;
  64527. height?: number;
  64528. sideOrientation?: number;
  64529. frontUVs?: Vector4;
  64530. backUVs?: Vector4;
  64531. updatable?: boolean;
  64532. sourcePlane?: Plane;
  64533. }, scene?: Nullable<Scene>): Mesh;
  64534. /**
  64535. * Creates a ground mesh
  64536. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64537. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64539. * @param name defines the name of the mesh
  64540. * @param options defines the options used to create the mesh
  64541. * @param scene defines the hosting scene
  64542. * @returns the ground mesh
  64543. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64544. */
  64545. static CreateGround(name: string, options: {
  64546. width?: number;
  64547. height?: number;
  64548. subdivisions?: number;
  64549. subdivisionsX?: number;
  64550. subdivisionsY?: number;
  64551. updatable?: boolean;
  64552. }, scene?: Nullable<Scene>): Mesh;
  64553. /**
  64554. * Creates a tiled ground mesh
  64555. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64556. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64557. * * 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
  64558. * * 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
  64559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64560. * @param name defines the name of the mesh
  64561. * @param options defines the options used to create the mesh
  64562. * @param scene defines the hosting scene
  64563. * @returns the tiled ground mesh
  64564. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64565. */
  64566. static CreateTiledGround(name: string, options: {
  64567. xmin: number;
  64568. zmin: number;
  64569. xmax: number;
  64570. zmax: number;
  64571. subdivisions?: {
  64572. w: number;
  64573. h: number;
  64574. };
  64575. precision?: {
  64576. w: number;
  64577. h: number;
  64578. };
  64579. updatable?: boolean;
  64580. }, scene?: Nullable<Scene>): Mesh;
  64581. /**
  64582. * Creates a ground mesh from a height map
  64583. * * The parameter `url` sets the URL of the height map image resource.
  64584. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64585. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64586. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64587. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64588. * * 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.
  64589. * * 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).
  64590. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64592. * @param name defines the name of the mesh
  64593. * @param url defines the url to the height map
  64594. * @param options defines the options used to create the mesh
  64595. * @param scene defines the hosting scene
  64596. * @returns the ground mesh
  64597. * @see https://doc.babylonjs.com/babylon101/height_map
  64598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64599. */
  64600. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64601. width?: number;
  64602. height?: number;
  64603. subdivisions?: number;
  64604. minHeight?: number;
  64605. maxHeight?: number;
  64606. colorFilter?: Color3;
  64607. alphaFilter?: number;
  64608. updatable?: boolean;
  64609. onReady?: (mesh: GroundMesh) => void;
  64610. }, scene?: Nullable<Scene>): GroundMesh;
  64611. /**
  64612. * Creates a polygon mesh
  64613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64614. * * 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
  64615. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64618. * * Remember you can only change the shape positions, not their number when updating a polygon
  64619. * @param name defines the name of the mesh
  64620. * @param options defines the options used to create the mesh
  64621. * @param scene defines the hosting scene
  64622. * @param earcutInjection can be used to inject your own earcut reference
  64623. * @returns the polygon mesh
  64624. */
  64625. static CreatePolygon(name: string, options: {
  64626. shape: Vector3[];
  64627. holes?: Vector3[][];
  64628. depth?: number;
  64629. faceUV?: Vector4[];
  64630. faceColors?: Color4[];
  64631. updatable?: boolean;
  64632. sideOrientation?: number;
  64633. frontUVs?: Vector4;
  64634. backUVs?: Vector4;
  64635. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64636. /**
  64637. * Creates an extruded polygon mesh, with depth in the Y direction.
  64638. * * 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)
  64639. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64640. * @param name defines the name of the mesh
  64641. * @param options defines the options used to create the mesh
  64642. * @param scene defines the hosting scene
  64643. * @param earcutInjection can be used to inject your own earcut reference
  64644. * @returns the polygon mesh
  64645. */
  64646. static ExtrudePolygon(name: string, options: {
  64647. shape: Vector3[];
  64648. holes?: Vector3[][];
  64649. depth?: number;
  64650. faceUV?: Vector4[];
  64651. faceColors?: Color4[];
  64652. updatable?: boolean;
  64653. sideOrientation?: number;
  64654. frontUVs?: Vector4;
  64655. backUVs?: Vector4;
  64656. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64657. /**
  64658. * Creates a tube mesh.
  64659. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64660. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64661. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64662. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64663. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64664. * * 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)
  64665. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64666. * * 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
  64667. * * 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
  64668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64672. * @param name defines the name of the mesh
  64673. * @param options defines the options used to create the mesh
  64674. * @param scene defines the hosting scene
  64675. * @returns the tube mesh
  64676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64677. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64678. */
  64679. static CreateTube(name: string, options: {
  64680. path: Vector3[];
  64681. radius?: number;
  64682. tessellation?: number;
  64683. radiusFunction?: {
  64684. (i: number, distance: number): number;
  64685. };
  64686. cap?: number;
  64687. arc?: number;
  64688. updatable?: boolean;
  64689. sideOrientation?: number;
  64690. frontUVs?: Vector4;
  64691. backUVs?: Vector4;
  64692. instance?: Mesh;
  64693. invertUV?: boolean;
  64694. }, scene?: Nullable<Scene>): Mesh;
  64695. /**
  64696. * Creates a polyhedron mesh
  64697. * * 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
  64698. * * The parameter `size` (positive float, default 1) sets the polygon size
  64699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64700. * * 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`
  64701. * * 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
  64702. * * 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)`)
  64703. * * 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
  64704. * * 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
  64705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64708. * @param name defines the name of the mesh
  64709. * @param options defines the options used to create the mesh
  64710. * @param scene defines the hosting scene
  64711. * @returns the polyhedron mesh
  64712. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64713. */
  64714. static CreatePolyhedron(name: string, options: {
  64715. type?: number;
  64716. size?: number;
  64717. sizeX?: number;
  64718. sizeY?: number;
  64719. sizeZ?: number;
  64720. custom?: any;
  64721. faceUV?: Vector4[];
  64722. faceColors?: Color4[];
  64723. flat?: boolean;
  64724. updatable?: boolean;
  64725. sideOrientation?: number;
  64726. frontUVs?: Vector4;
  64727. backUVs?: Vector4;
  64728. }, scene?: Nullable<Scene>): Mesh;
  64729. /**
  64730. * Creates a decal mesh.
  64731. * 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
  64732. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64733. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64734. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64735. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64736. * @param name defines the name of the mesh
  64737. * @param sourceMesh defines the mesh where the decal must be applied
  64738. * @param options defines the options used to create the mesh
  64739. * @param scene defines the hosting scene
  64740. * @returns the decal mesh
  64741. * @see https://doc.babylonjs.com/how_to/decals
  64742. */
  64743. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64744. position?: Vector3;
  64745. normal?: Vector3;
  64746. size?: Vector3;
  64747. angle?: number;
  64748. }): Mesh;
  64749. }
  64750. }
  64751. declare module "babylonjs/Meshes/meshSimplification" {
  64752. import { Mesh } from "babylonjs/Meshes/mesh";
  64753. /**
  64754. * A simplifier interface for future simplification implementations
  64755. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64756. */
  64757. export interface ISimplifier {
  64758. /**
  64759. * Simplification of a given mesh according to the given settings.
  64760. * Since this requires computation, it is assumed that the function runs async.
  64761. * @param settings The settings of the simplification, including quality and distance
  64762. * @param successCallback A callback that will be called after the mesh was simplified.
  64763. * @param errorCallback in case of an error, this callback will be called. optional.
  64764. */
  64765. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64766. }
  64767. /**
  64768. * Expected simplification settings.
  64769. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64770. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64771. */
  64772. export interface ISimplificationSettings {
  64773. /**
  64774. * Gets or sets the expected quality
  64775. */
  64776. quality: number;
  64777. /**
  64778. * Gets or sets the distance when this optimized version should be used
  64779. */
  64780. distance: number;
  64781. /**
  64782. * Gets an already optimized mesh
  64783. */
  64784. optimizeMesh?: boolean;
  64785. }
  64786. /**
  64787. * Class used to specify simplification options
  64788. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64789. */
  64790. export class SimplificationSettings implements ISimplificationSettings {
  64791. /** expected quality */
  64792. quality: number;
  64793. /** distance when this optimized version should be used */
  64794. distance: number;
  64795. /** already optimized mesh */
  64796. optimizeMesh?: boolean | undefined;
  64797. /**
  64798. * Creates a SimplificationSettings
  64799. * @param quality expected quality
  64800. * @param distance distance when this optimized version should be used
  64801. * @param optimizeMesh already optimized mesh
  64802. */
  64803. constructor(
  64804. /** expected quality */
  64805. quality: number,
  64806. /** distance when this optimized version should be used */
  64807. distance: number,
  64808. /** already optimized mesh */
  64809. optimizeMesh?: boolean | undefined);
  64810. }
  64811. /**
  64812. * Interface used to define a simplification task
  64813. */
  64814. export interface ISimplificationTask {
  64815. /**
  64816. * Array of settings
  64817. */
  64818. settings: Array<ISimplificationSettings>;
  64819. /**
  64820. * Simplification type
  64821. */
  64822. simplificationType: SimplificationType;
  64823. /**
  64824. * Mesh to simplify
  64825. */
  64826. mesh: Mesh;
  64827. /**
  64828. * Callback called on success
  64829. */
  64830. successCallback?: () => void;
  64831. /**
  64832. * Defines if parallel processing can be used
  64833. */
  64834. parallelProcessing: boolean;
  64835. }
  64836. /**
  64837. * Queue used to order the simplification tasks
  64838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64839. */
  64840. export class SimplificationQueue {
  64841. private _simplificationArray;
  64842. /**
  64843. * Gets a boolean indicating that the process is still running
  64844. */
  64845. running: boolean;
  64846. /**
  64847. * Creates a new queue
  64848. */
  64849. constructor();
  64850. /**
  64851. * Adds a new simplification task
  64852. * @param task defines a task to add
  64853. */
  64854. addTask(task: ISimplificationTask): void;
  64855. /**
  64856. * Execute next task
  64857. */
  64858. executeNext(): void;
  64859. /**
  64860. * Execute a simplification task
  64861. * @param task defines the task to run
  64862. */
  64863. runSimplification(task: ISimplificationTask): void;
  64864. private getSimplifier;
  64865. }
  64866. /**
  64867. * The implemented types of simplification
  64868. * At the moment only Quadratic Error Decimation is implemented
  64869. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64870. */
  64871. export enum SimplificationType {
  64872. /** Quadratic error decimation */
  64873. QUADRATIC = 0
  64874. }
  64875. }
  64876. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64877. import { Scene } from "babylonjs/scene";
  64878. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64879. import { ISceneComponent } from "babylonjs/sceneComponent";
  64880. module "babylonjs/scene" {
  64881. interface Scene {
  64882. /** @hidden (Backing field) */
  64883. _simplificationQueue: SimplificationQueue;
  64884. /**
  64885. * Gets or sets the simplification queue attached to the scene
  64886. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64887. */
  64888. simplificationQueue: SimplificationQueue;
  64889. }
  64890. }
  64891. module "babylonjs/Meshes/mesh" {
  64892. interface Mesh {
  64893. /**
  64894. * Simplify the mesh according to the given array of settings.
  64895. * Function will return immediately and will simplify async
  64896. * @param settings a collection of simplification settings
  64897. * @param parallelProcessing should all levels calculate parallel or one after the other
  64898. * @param simplificationType the type of simplification to run
  64899. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64900. * @returns the current mesh
  64901. */
  64902. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64903. }
  64904. }
  64905. /**
  64906. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64907. * created in a scene
  64908. */
  64909. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64910. /**
  64911. * The component name helpfull to identify the component in the list of scene components.
  64912. */
  64913. readonly name: string;
  64914. /**
  64915. * The scene the component belongs to.
  64916. */
  64917. scene: Scene;
  64918. /**
  64919. * Creates a new instance of the component for the given scene
  64920. * @param scene Defines the scene to register the component in
  64921. */
  64922. constructor(scene: Scene);
  64923. /**
  64924. * Registers the component in a given scene
  64925. */
  64926. register(): void;
  64927. /**
  64928. * Rebuilds the elements related to this component in case of
  64929. * context lost for instance.
  64930. */
  64931. rebuild(): void;
  64932. /**
  64933. * Disposes the component and the associated ressources
  64934. */
  64935. dispose(): void;
  64936. private _beforeCameraUpdate;
  64937. }
  64938. }
  64939. declare module "babylonjs/Meshes/Builders/index" {
  64940. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64941. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64942. export * from "babylonjs/Meshes/Builders/discBuilder";
  64943. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64944. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64945. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64946. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64947. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64948. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64949. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64950. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64951. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64952. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64953. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64954. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64955. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64956. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64957. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64958. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64959. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64960. }
  64961. declare module "babylonjs/Meshes/index" {
  64962. export * from "babylonjs/Meshes/abstractMesh";
  64963. export * from "babylonjs/Meshes/buffer";
  64964. export * from "babylonjs/Meshes/Compression/index";
  64965. export * from "babylonjs/Meshes/csg";
  64966. export * from "babylonjs/Meshes/geometry";
  64967. export * from "babylonjs/Meshes/groundMesh";
  64968. export * from "babylonjs/Meshes/trailMesh";
  64969. export * from "babylonjs/Meshes/instancedMesh";
  64970. export * from "babylonjs/Meshes/linesMesh";
  64971. export * from "babylonjs/Meshes/mesh";
  64972. export * from "babylonjs/Meshes/mesh.vertexData";
  64973. export * from "babylonjs/Meshes/meshBuilder";
  64974. export * from "babylonjs/Meshes/meshSimplification";
  64975. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64976. export * from "babylonjs/Meshes/polygonMesh";
  64977. export * from "babylonjs/Meshes/subMesh";
  64978. export * from "babylonjs/Meshes/meshLODLevel";
  64979. export * from "babylonjs/Meshes/transformNode";
  64980. export * from "babylonjs/Meshes/Builders/index";
  64981. export * from "babylonjs/Meshes/dataBuffer";
  64982. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64983. }
  64984. declare module "babylonjs/Morph/index" {
  64985. export * from "babylonjs/Morph/morphTarget";
  64986. export * from "babylonjs/Morph/morphTargetManager";
  64987. }
  64988. declare module "babylonjs/Navigation/INavigationEngine" {
  64989. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64990. import { Vector3 } from "babylonjs/Maths/math";
  64991. import { Mesh } from "babylonjs/Meshes/mesh";
  64992. import { Scene } from "babylonjs/scene";
  64993. /**
  64994. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64995. */
  64996. export interface INavigationEnginePlugin {
  64997. /**
  64998. * plugin name
  64999. */
  65000. name: string;
  65001. /**
  65002. * Creates a navigation mesh
  65003. * @param meshes array of all the geometry used to compute the navigatio mesh
  65004. * @param parameters bunch of parameters used to filter geometry
  65005. */
  65006. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65007. /**
  65008. * Create a navigation mesh debug mesh
  65009. * @param scene is where the mesh will be added
  65010. * @returns debug display mesh
  65011. */
  65012. createDebugNavMesh(scene: Scene): Mesh;
  65013. /**
  65014. * Get a navigation mesh constrained position, closest to the parameter position
  65015. * @param position world position
  65016. * @returns the closest point to position constrained by the navigation mesh
  65017. */
  65018. getClosestPoint(position: Vector3): Vector3;
  65019. /**
  65020. * Get a navigation mesh constrained position, within a particular radius
  65021. * @param position world position
  65022. * @param maxRadius the maximum distance to the constrained world position
  65023. * @returns the closest point to position constrained by the navigation mesh
  65024. */
  65025. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65026. /**
  65027. * Compute the final position from a segment made of destination-position
  65028. * @param position world position
  65029. * @param destination world position
  65030. * @returns the resulting point along the navmesh
  65031. */
  65032. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65033. /**
  65034. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65035. * @param start world position
  65036. * @param end world position
  65037. * @returns array containing world position composing the path
  65038. */
  65039. computePath(start: Vector3, end: Vector3): Vector3[];
  65040. /**
  65041. * If this plugin is supported
  65042. * @returns true if plugin is supported
  65043. */
  65044. isSupported(): boolean;
  65045. /**
  65046. * Create a new Crowd so you can add agents
  65047. * @param maxAgents the maximum agent count in the crowd
  65048. * @param maxAgentRadius the maximum radius an agent can have
  65049. * @param scene to attach the crowd to
  65050. * @returns the crowd you can add agents to
  65051. */
  65052. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65053. /**
  65054. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65055. * The queries will try to find a solution within those bounds
  65056. * default is (1,1,1)
  65057. * @param extent x,y,z value that define the extent around the queries point of reference
  65058. */
  65059. setDefaultQueryExtent(extent: Vector3): void;
  65060. /**
  65061. * Get the Bounding box extent specified by setDefaultQueryExtent
  65062. * @returns the box extent values
  65063. */
  65064. getDefaultQueryExtent(): Vector3;
  65065. /**
  65066. * Release all resources
  65067. */
  65068. dispose(): void;
  65069. }
  65070. /**
  65071. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65072. */
  65073. export interface ICrowd {
  65074. /**
  65075. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65076. * You can attach anything to that node. The node position is updated in the scene update tick.
  65077. * @param pos world position that will be constrained by the navigation mesh
  65078. * @param parameters agent parameters
  65079. * @param transform hooked to the agent that will be update by the scene
  65080. * @returns agent index
  65081. */
  65082. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65083. /**
  65084. * Returns the agent position in world space
  65085. * @param index agent index returned by addAgent
  65086. * @returns world space position
  65087. */
  65088. getAgentPosition(index: number): Vector3;
  65089. /**
  65090. * Gets the agent velocity in world space
  65091. * @param index agent index returned by addAgent
  65092. * @returns world space velocity
  65093. */
  65094. getAgentVelocity(index: number): Vector3;
  65095. /**
  65096. * remove a particular agent previously created
  65097. * @param index agent index returned by addAgent
  65098. */
  65099. removeAgent(index: number): void;
  65100. /**
  65101. * get the list of all agents attached to this crowd
  65102. * @returns list of agent indices
  65103. */
  65104. getAgents(): number[];
  65105. /**
  65106. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65107. * @param deltaTime in seconds
  65108. */
  65109. update(deltaTime: number): void;
  65110. /**
  65111. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65112. * @param index agent index returned by addAgent
  65113. * @param destination targeted world position
  65114. */
  65115. agentGoto(index: number, destination: Vector3): void;
  65116. /**
  65117. * Teleport the agent to a new position
  65118. * @param index agent index returned by addAgent
  65119. * @param destination targeted world position
  65120. */
  65121. agentTeleport(index: number, destination: Vector3): void;
  65122. /**
  65123. * Update agent parameters
  65124. * @param index agent index returned by addAgent
  65125. * @param parameters agent parameters
  65126. */
  65127. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65128. /**
  65129. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65130. * The queries will try to find a solution within those bounds
  65131. * default is (1,1,1)
  65132. * @param extent x,y,z value that define the extent around the queries point of reference
  65133. */
  65134. setDefaultQueryExtent(extent: Vector3): void;
  65135. /**
  65136. * Get the Bounding box extent specified by setDefaultQueryExtent
  65137. * @returns the box extent values
  65138. */
  65139. getDefaultQueryExtent(): Vector3;
  65140. /**
  65141. * Release all resources
  65142. */
  65143. dispose(): void;
  65144. }
  65145. /**
  65146. * Configures an agent
  65147. */
  65148. export interface IAgentParameters {
  65149. /**
  65150. * Agent radius. [Limit: >= 0]
  65151. */
  65152. radius: number;
  65153. /**
  65154. * Agent height. [Limit: > 0]
  65155. */
  65156. height: number;
  65157. /**
  65158. * Maximum allowed acceleration. [Limit: >= 0]
  65159. */
  65160. maxAcceleration: number;
  65161. /**
  65162. * Maximum allowed speed. [Limit: >= 0]
  65163. */
  65164. maxSpeed: number;
  65165. /**
  65166. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65167. */
  65168. collisionQueryRange: number;
  65169. /**
  65170. * The path visibility optimization range. [Limit: > 0]
  65171. */
  65172. pathOptimizationRange: number;
  65173. /**
  65174. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65175. */
  65176. separationWeight: number;
  65177. }
  65178. /**
  65179. * Configures the navigation mesh creation
  65180. */
  65181. export interface INavMeshParameters {
  65182. /**
  65183. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65184. */
  65185. cs: number;
  65186. /**
  65187. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65188. */
  65189. ch: number;
  65190. /**
  65191. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65192. */
  65193. walkableSlopeAngle: number;
  65194. /**
  65195. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65196. * be considered walkable. [Limit: >= 3] [Units: vx]
  65197. */
  65198. walkableHeight: number;
  65199. /**
  65200. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65201. */
  65202. walkableClimb: number;
  65203. /**
  65204. * The distance to erode/shrink the walkable area of the heightfield away from
  65205. * obstructions. [Limit: >=0] [Units: vx]
  65206. */
  65207. walkableRadius: number;
  65208. /**
  65209. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65210. */
  65211. maxEdgeLen: number;
  65212. /**
  65213. * The maximum distance a simplfied contour's border edges should deviate
  65214. * the original raw contour. [Limit: >=0] [Units: vx]
  65215. */
  65216. maxSimplificationError: number;
  65217. /**
  65218. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65219. */
  65220. minRegionArea: number;
  65221. /**
  65222. * Any regions with a span count smaller than this value will, if possible,
  65223. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65224. */
  65225. mergeRegionArea: number;
  65226. /**
  65227. * The maximum number of vertices allowed for polygons generated during the
  65228. * contour to polygon conversion process. [Limit: >= 3]
  65229. */
  65230. maxVertsPerPoly: number;
  65231. /**
  65232. * Sets the sampling distance to use when generating the detail mesh.
  65233. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65234. */
  65235. detailSampleDist: number;
  65236. /**
  65237. * The maximum distance the detail mesh surface should deviate from heightfield
  65238. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65239. */
  65240. detailSampleMaxError: number;
  65241. }
  65242. }
  65243. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65244. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65245. import { Mesh } from "babylonjs/Meshes/mesh";
  65246. import { Scene } from "babylonjs/scene";
  65247. import { Vector3 } from "babylonjs/Maths/math";
  65248. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65249. /**
  65250. * RecastJS navigation plugin
  65251. */
  65252. export class RecastJSPlugin implements INavigationEnginePlugin {
  65253. /**
  65254. * Reference to the Recast library
  65255. */
  65256. bjsRECAST: any;
  65257. /**
  65258. * plugin name
  65259. */
  65260. name: string;
  65261. /**
  65262. * the first navmesh created. We might extend this to support multiple navmeshes
  65263. */
  65264. navMesh: any;
  65265. /**
  65266. * Initializes the recastJS plugin
  65267. * @param recastInjection can be used to inject your own recast reference
  65268. */
  65269. constructor(recastInjection?: any);
  65270. /**
  65271. * Creates a navigation mesh
  65272. * @param meshes array of all the geometry used to compute the navigatio mesh
  65273. * @param parameters bunch of parameters used to filter geometry
  65274. */
  65275. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65276. /**
  65277. * Create a navigation mesh debug mesh
  65278. * @param scene is where the mesh will be added
  65279. * @returns debug display mesh
  65280. */
  65281. createDebugNavMesh(scene: Scene): Mesh;
  65282. /**
  65283. * Get a navigation mesh constrained position, closest to the parameter position
  65284. * @param position world position
  65285. * @returns the closest point to position constrained by the navigation mesh
  65286. */
  65287. getClosestPoint(position: Vector3): Vector3;
  65288. /**
  65289. * Get a navigation mesh constrained position, within a particular radius
  65290. * @param position world position
  65291. * @param maxRadius the maximum distance to the constrained world position
  65292. * @returns the closest point to position constrained by the navigation mesh
  65293. */
  65294. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65295. /**
  65296. * Compute the final position from a segment made of destination-position
  65297. * @param position world position
  65298. * @param destination world position
  65299. * @returns the resulting point along the navmesh
  65300. */
  65301. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65302. /**
  65303. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65304. * @param start world position
  65305. * @param end world position
  65306. * @returns array containing world position composing the path
  65307. */
  65308. computePath(start: Vector3, end: Vector3): Vector3[];
  65309. /**
  65310. * Create a new Crowd so you can add agents
  65311. * @param maxAgents the maximum agent count in the crowd
  65312. * @param maxAgentRadius the maximum radius an agent can have
  65313. * @param scene to attach the crowd to
  65314. * @returns the crowd you can add agents to
  65315. */
  65316. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65317. /**
  65318. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65319. * The queries will try to find a solution within those bounds
  65320. * default is (1,1,1)
  65321. * @param extent x,y,z value that define the extent around the queries point of reference
  65322. */
  65323. setDefaultQueryExtent(extent: Vector3): void;
  65324. /**
  65325. * Get the Bounding box extent specified by setDefaultQueryExtent
  65326. * @returns the box extent values
  65327. */
  65328. getDefaultQueryExtent(): Vector3;
  65329. /**
  65330. * Disposes
  65331. */
  65332. dispose(): void;
  65333. /**
  65334. * If this plugin is supported
  65335. * @returns true if plugin is supported
  65336. */
  65337. isSupported(): boolean;
  65338. }
  65339. /**
  65340. * Recast detour crowd implementation
  65341. */
  65342. export class RecastJSCrowd implements ICrowd {
  65343. /**
  65344. * Recast/detour plugin
  65345. */
  65346. bjsRECASTPlugin: RecastJSPlugin;
  65347. /**
  65348. * Link to the detour crowd
  65349. */
  65350. recastCrowd: any;
  65351. /**
  65352. * One transform per agent
  65353. */
  65354. transforms: TransformNode[];
  65355. /**
  65356. * All agents created
  65357. */
  65358. agents: number[];
  65359. /**
  65360. * Link to the scene is kept to unregister the crowd from the scene
  65361. */
  65362. private _scene;
  65363. /**
  65364. * Observer for crowd updates
  65365. */
  65366. private _onBeforeAnimationsObserver;
  65367. /**
  65368. * Constructor
  65369. * @param plugin recastJS plugin
  65370. * @param maxAgents the maximum agent count in the crowd
  65371. * @param maxAgentRadius the maximum radius an agent can have
  65372. * @param scene to attach the crowd to
  65373. * @returns the crowd you can add agents to
  65374. */
  65375. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65376. /**
  65377. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65378. * You can attach anything to that node. The node position is updated in the scene update tick.
  65379. * @param pos world position that will be constrained by the navigation mesh
  65380. * @param parameters agent parameters
  65381. * @param transform hooked to the agent that will be update by the scene
  65382. * @returns agent index
  65383. */
  65384. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65385. /**
  65386. * Returns the agent position in world space
  65387. * @param index agent index returned by addAgent
  65388. * @returns world space position
  65389. */
  65390. getAgentPosition(index: number): Vector3;
  65391. /**
  65392. * Returns the agent velocity in world space
  65393. * @param index agent index returned by addAgent
  65394. * @returns world space velocity
  65395. */
  65396. getAgentVelocity(index: number): Vector3;
  65397. /**
  65398. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65399. * @param index agent index returned by addAgent
  65400. * @param destination targeted world position
  65401. */
  65402. agentGoto(index: number, destination: Vector3): void;
  65403. /**
  65404. * Teleport the agent to a new position
  65405. * @param index agent index returned by addAgent
  65406. * @param destination targeted world position
  65407. */
  65408. agentTeleport(index: number, destination: Vector3): void;
  65409. /**
  65410. * Update agent parameters
  65411. * @param index agent index returned by addAgent
  65412. * @param parameters agent parameters
  65413. */
  65414. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65415. /**
  65416. * remove a particular agent previously created
  65417. * @param index agent index returned by addAgent
  65418. */
  65419. removeAgent(index: number): void;
  65420. /**
  65421. * get the list of all agents attached to this crowd
  65422. * @returns list of agent indices
  65423. */
  65424. getAgents(): number[];
  65425. /**
  65426. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65427. * @param deltaTime in seconds
  65428. */
  65429. update(deltaTime: number): void;
  65430. /**
  65431. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65432. * The queries will try to find a solution within those bounds
  65433. * default is (1,1,1)
  65434. * @param extent x,y,z value that define the extent around the queries point of reference
  65435. */
  65436. setDefaultQueryExtent(extent: Vector3): void;
  65437. /**
  65438. * Get the Bounding box extent specified by setDefaultQueryExtent
  65439. * @returns the box extent values
  65440. */
  65441. getDefaultQueryExtent(): Vector3;
  65442. /**
  65443. * Release all resources
  65444. */
  65445. dispose(): void;
  65446. }
  65447. }
  65448. declare module "babylonjs/Navigation/Plugins/index" {
  65449. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65450. }
  65451. declare module "babylonjs/Navigation/index" {
  65452. export * from "babylonjs/Navigation/INavigationEngine";
  65453. export * from "babylonjs/Navigation/Plugins/index";
  65454. }
  65455. declare module "babylonjs/Offline/database" {
  65456. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65457. /**
  65458. * Class used to enable access to IndexedDB
  65459. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65460. */
  65461. export class Database implements IOfflineProvider {
  65462. private _callbackManifestChecked;
  65463. private _currentSceneUrl;
  65464. private _db;
  65465. private _enableSceneOffline;
  65466. private _enableTexturesOffline;
  65467. private _manifestVersionFound;
  65468. private _mustUpdateRessources;
  65469. private _hasReachedQuota;
  65470. private _isSupported;
  65471. private _idbFactory;
  65472. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65473. private static IsUASupportingBlobStorage;
  65474. /**
  65475. * Gets a boolean indicating if Database storate is enabled (off by default)
  65476. */
  65477. static IDBStorageEnabled: boolean;
  65478. /**
  65479. * Gets a boolean indicating if scene must be saved in the database
  65480. */
  65481. get enableSceneOffline(): boolean;
  65482. /**
  65483. * Gets a boolean indicating if textures must be saved in the database
  65484. */
  65485. get enableTexturesOffline(): boolean;
  65486. /**
  65487. * Creates a new Database
  65488. * @param urlToScene defines the url to load the scene
  65489. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65490. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65491. */
  65492. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65493. private static _ParseURL;
  65494. private static _ReturnFullUrlLocation;
  65495. private _checkManifestFile;
  65496. /**
  65497. * Open the database and make it available
  65498. * @param successCallback defines the callback to call on success
  65499. * @param errorCallback defines the callback to call on error
  65500. */
  65501. open(successCallback: () => void, errorCallback: () => void): void;
  65502. /**
  65503. * Loads an image from the database
  65504. * @param url defines the url to load from
  65505. * @param image defines the target DOM image
  65506. */
  65507. loadImage(url: string, image: HTMLImageElement): void;
  65508. private _loadImageFromDBAsync;
  65509. private _saveImageIntoDBAsync;
  65510. private _checkVersionFromDB;
  65511. private _loadVersionFromDBAsync;
  65512. private _saveVersionIntoDBAsync;
  65513. /**
  65514. * Loads a file from database
  65515. * @param url defines the URL to load from
  65516. * @param sceneLoaded defines a callback to call on success
  65517. * @param progressCallBack defines a callback to call when progress changed
  65518. * @param errorCallback defines a callback to call on error
  65519. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65520. */
  65521. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65522. private _loadFileAsync;
  65523. private _saveFileAsync;
  65524. /**
  65525. * Validates if xhr data is correct
  65526. * @param xhr defines the request to validate
  65527. * @param dataType defines the expected data type
  65528. * @returns true if data is correct
  65529. */
  65530. private static _ValidateXHRData;
  65531. }
  65532. }
  65533. declare module "babylonjs/Offline/index" {
  65534. export * from "babylonjs/Offline/database";
  65535. export * from "babylonjs/Offline/IOfflineProvider";
  65536. }
  65537. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65538. /** @hidden */
  65539. export var gpuUpdateParticlesPixelShader: {
  65540. name: string;
  65541. shader: string;
  65542. };
  65543. }
  65544. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65545. /** @hidden */
  65546. export var gpuUpdateParticlesVertexShader: {
  65547. name: string;
  65548. shader: string;
  65549. };
  65550. }
  65551. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65552. /** @hidden */
  65553. export var clipPlaneFragmentDeclaration2: {
  65554. name: string;
  65555. shader: string;
  65556. };
  65557. }
  65558. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65559. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65560. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65561. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65562. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65563. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65564. /** @hidden */
  65565. export var gpuRenderParticlesPixelShader: {
  65566. name: string;
  65567. shader: string;
  65568. };
  65569. }
  65570. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65571. /** @hidden */
  65572. export var clipPlaneVertexDeclaration2: {
  65573. name: string;
  65574. shader: string;
  65575. };
  65576. }
  65577. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65578. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65579. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65580. /** @hidden */
  65581. export var gpuRenderParticlesVertexShader: {
  65582. name: string;
  65583. shader: string;
  65584. };
  65585. }
  65586. declare module "babylonjs/Particles/gpuParticleSystem" {
  65587. import { Nullable } from "babylonjs/types";
  65588. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65589. import { Observable } from "babylonjs/Misc/observable";
  65590. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65591. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65592. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65593. import { Scene, IDisposable } from "babylonjs/scene";
  65594. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65595. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65596. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65597. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65598. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65599. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65600. /**
  65601. * This represents a GPU particle system in Babylon
  65602. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65603. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65604. */
  65605. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65606. /**
  65607. * The layer mask we are rendering the particles through.
  65608. */
  65609. layerMask: number;
  65610. private _capacity;
  65611. private _activeCount;
  65612. private _currentActiveCount;
  65613. private _accumulatedCount;
  65614. private _renderEffect;
  65615. private _updateEffect;
  65616. private _buffer0;
  65617. private _buffer1;
  65618. private _spriteBuffer;
  65619. private _updateVAO;
  65620. private _renderVAO;
  65621. private _targetIndex;
  65622. private _sourceBuffer;
  65623. private _targetBuffer;
  65624. private _engine;
  65625. private _currentRenderId;
  65626. private _started;
  65627. private _stopped;
  65628. private _timeDelta;
  65629. private _randomTexture;
  65630. private _randomTexture2;
  65631. private _attributesStrideSize;
  65632. private _updateEffectOptions;
  65633. private _randomTextureSize;
  65634. private _actualFrame;
  65635. private readonly _rawTextureWidth;
  65636. /**
  65637. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65638. */
  65639. static get IsSupported(): boolean;
  65640. /**
  65641. * An event triggered when the system is disposed.
  65642. */
  65643. onDisposeObservable: Observable<GPUParticleSystem>;
  65644. /**
  65645. * Gets the maximum number of particles active at the same time.
  65646. * @returns The max number of active particles.
  65647. */
  65648. getCapacity(): number;
  65649. /**
  65650. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65651. * to override the particles.
  65652. */
  65653. forceDepthWrite: boolean;
  65654. /**
  65655. * Gets or set the number of active particles
  65656. */
  65657. get activeParticleCount(): number;
  65658. set activeParticleCount(value: number);
  65659. private _preWarmDone;
  65660. /**
  65661. * Is this system ready to be used/rendered
  65662. * @return true if the system is ready
  65663. */
  65664. isReady(): boolean;
  65665. /**
  65666. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65667. * @returns True if it has been started, otherwise false.
  65668. */
  65669. isStarted(): boolean;
  65670. /**
  65671. * Starts the particle system and begins to emit
  65672. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65673. */
  65674. start(delay?: number): void;
  65675. /**
  65676. * Stops the particle system.
  65677. */
  65678. stop(): void;
  65679. /**
  65680. * Remove all active particles
  65681. */
  65682. reset(): void;
  65683. /**
  65684. * Returns the string "GPUParticleSystem"
  65685. * @returns a string containing the class name
  65686. */
  65687. getClassName(): string;
  65688. private _colorGradientsTexture;
  65689. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65690. /**
  65691. * Adds a new color gradient
  65692. * @param gradient defines the gradient to use (between 0 and 1)
  65693. * @param color1 defines the color to affect to the specified gradient
  65694. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65695. * @returns the current particle system
  65696. */
  65697. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65698. /**
  65699. * Remove a specific color gradient
  65700. * @param gradient defines the gradient to remove
  65701. * @returns the current particle system
  65702. */
  65703. removeColorGradient(gradient: number): GPUParticleSystem;
  65704. private _angularSpeedGradientsTexture;
  65705. private _sizeGradientsTexture;
  65706. private _velocityGradientsTexture;
  65707. private _limitVelocityGradientsTexture;
  65708. private _dragGradientsTexture;
  65709. private _addFactorGradient;
  65710. /**
  65711. * Adds a new size gradient
  65712. * @param gradient defines the gradient to use (between 0 and 1)
  65713. * @param factor defines the size factor to affect to the specified gradient
  65714. * @returns the current particle system
  65715. */
  65716. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65717. /**
  65718. * Remove a specific size gradient
  65719. * @param gradient defines the gradient to remove
  65720. * @returns the current particle system
  65721. */
  65722. removeSizeGradient(gradient: number): GPUParticleSystem;
  65723. /**
  65724. * Adds a new angular speed gradient
  65725. * @param gradient defines the gradient to use (between 0 and 1)
  65726. * @param factor defines the angular speed to affect to the specified gradient
  65727. * @returns the current particle system
  65728. */
  65729. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65730. /**
  65731. * Remove a specific angular speed gradient
  65732. * @param gradient defines the gradient to remove
  65733. * @returns the current particle system
  65734. */
  65735. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65736. /**
  65737. * Adds a new velocity gradient
  65738. * @param gradient defines the gradient to use (between 0 and 1)
  65739. * @param factor defines the velocity to affect to the specified gradient
  65740. * @returns the current particle system
  65741. */
  65742. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65743. /**
  65744. * Remove a specific velocity gradient
  65745. * @param gradient defines the gradient to remove
  65746. * @returns the current particle system
  65747. */
  65748. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65749. /**
  65750. * Adds a new limit velocity gradient
  65751. * @param gradient defines the gradient to use (between 0 and 1)
  65752. * @param factor defines the limit velocity value to affect to the specified gradient
  65753. * @returns the current particle system
  65754. */
  65755. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65756. /**
  65757. * Remove a specific limit velocity gradient
  65758. * @param gradient defines the gradient to remove
  65759. * @returns the current particle system
  65760. */
  65761. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65762. /**
  65763. * Adds a new drag gradient
  65764. * @param gradient defines the gradient to use (between 0 and 1)
  65765. * @param factor defines the drag value to affect to the specified gradient
  65766. * @returns the current particle system
  65767. */
  65768. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65769. /**
  65770. * Remove a specific drag gradient
  65771. * @param gradient defines the gradient to remove
  65772. * @returns the current particle system
  65773. */
  65774. removeDragGradient(gradient: number): GPUParticleSystem;
  65775. /**
  65776. * Not supported by GPUParticleSystem
  65777. * @param gradient defines the gradient to use (between 0 and 1)
  65778. * @param factor defines the emit rate value to affect to the specified gradient
  65779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65780. * @returns the current particle system
  65781. */
  65782. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65783. /**
  65784. * Not supported by GPUParticleSystem
  65785. * @param gradient defines the gradient to remove
  65786. * @returns the current particle system
  65787. */
  65788. removeEmitRateGradient(gradient: number): IParticleSystem;
  65789. /**
  65790. * Not supported by GPUParticleSystem
  65791. * @param gradient defines the gradient to use (between 0 and 1)
  65792. * @param factor defines the start size value to affect to the specified gradient
  65793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65794. * @returns the current particle system
  65795. */
  65796. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65797. /**
  65798. * Not supported by GPUParticleSystem
  65799. * @param gradient defines the gradient to remove
  65800. * @returns the current particle system
  65801. */
  65802. removeStartSizeGradient(gradient: number): IParticleSystem;
  65803. /**
  65804. * Not supported by GPUParticleSystem
  65805. * @param gradient defines the gradient to use (between 0 and 1)
  65806. * @param min defines the color remap minimal range
  65807. * @param max defines the color remap maximal range
  65808. * @returns the current particle system
  65809. */
  65810. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65811. /**
  65812. * Not supported by GPUParticleSystem
  65813. * @param gradient defines the gradient to remove
  65814. * @returns the current particle system
  65815. */
  65816. removeColorRemapGradient(): IParticleSystem;
  65817. /**
  65818. * Not supported by GPUParticleSystem
  65819. * @param gradient defines the gradient to use (between 0 and 1)
  65820. * @param min defines the alpha remap minimal range
  65821. * @param max defines the alpha remap maximal range
  65822. * @returns the current particle system
  65823. */
  65824. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65825. /**
  65826. * Not supported by GPUParticleSystem
  65827. * @param gradient defines the gradient to remove
  65828. * @returns the current particle system
  65829. */
  65830. removeAlphaRemapGradient(): IParticleSystem;
  65831. /**
  65832. * Not supported by GPUParticleSystem
  65833. * @param gradient defines the gradient to use (between 0 and 1)
  65834. * @param color defines the color to affect to the specified gradient
  65835. * @returns the current particle system
  65836. */
  65837. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65838. /**
  65839. * Not supported by GPUParticleSystem
  65840. * @param gradient defines the gradient to remove
  65841. * @returns the current particle system
  65842. */
  65843. removeRampGradient(): IParticleSystem;
  65844. /**
  65845. * Not supported by GPUParticleSystem
  65846. * @returns the list of ramp gradients
  65847. */
  65848. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65849. /**
  65850. * Not supported by GPUParticleSystem
  65851. * Gets or sets a boolean indicating that ramp gradients must be used
  65852. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65853. */
  65854. get useRampGradients(): boolean;
  65855. set useRampGradients(value: boolean);
  65856. /**
  65857. * Not supported by GPUParticleSystem
  65858. * @param gradient defines the gradient to use (between 0 and 1)
  65859. * @param factor defines the life time factor to affect to the specified gradient
  65860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65861. * @returns the current particle system
  65862. */
  65863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65864. /**
  65865. * Not supported by GPUParticleSystem
  65866. * @param gradient defines the gradient to remove
  65867. * @returns the current particle system
  65868. */
  65869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65870. /**
  65871. * Instantiates a GPU particle system.
  65872. * 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.
  65873. * @param name The name of the particle system
  65874. * @param options The options used to create the system
  65875. * @param scene The scene the particle system belongs to
  65876. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65877. */
  65878. constructor(name: string, options: Partial<{
  65879. capacity: number;
  65880. randomTextureSize: number;
  65881. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65882. protected _reset(): void;
  65883. private _createUpdateVAO;
  65884. private _createRenderVAO;
  65885. private _initialize;
  65886. /** @hidden */
  65887. _recreateUpdateEffect(): void;
  65888. /** @hidden */
  65889. _recreateRenderEffect(): void;
  65890. /**
  65891. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65892. * @param preWarm defines if we are in the pre-warmimg phase
  65893. */
  65894. animate(preWarm?: boolean): void;
  65895. private _createFactorGradientTexture;
  65896. private _createSizeGradientTexture;
  65897. private _createAngularSpeedGradientTexture;
  65898. private _createVelocityGradientTexture;
  65899. private _createLimitVelocityGradientTexture;
  65900. private _createDragGradientTexture;
  65901. private _createColorGradientTexture;
  65902. /**
  65903. * Renders the particle system in its current state
  65904. * @param preWarm defines if the system should only update the particles but not render them
  65905. * @returns the current number of particles
  65906. */
  65907. render(preWarm?: boolean): number;
  65908. /**
  65909. * Rebuilds the particle system
  65910. */
  65911. rebuild(): void;
  65912. private _releaseBuffers;
  65913. private _releaseVAOs;
  65914. /**
  65915. * Disposes the particle system and free the associated resources
  65916. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65917. */
  65918. dispose(disposeTexture?: boolean): void;
  65919. /**
  65920. * Clones the particle system.
  65921. * @param name The name of the cloned object
  65922. * @param newEmitter The new emitter to use
  65923. * @returns the cloned particle system
  65924. */
  65925. clone(name: string, newEmitter: any): GPUParticleSystem;
  65926. /**
  65927. * Serializes the particle system to a JSON object.
  65928. * @returns the JSON object
  65929. */
  65930. serialize(): any;
  65931. /**
  65932. * Parses a JSON object to create a GPU particle system.
  65933. * @param parsedParticleSystem The JSON object to parse
  65934. * @param scene The scene to create the particle system in
  65935. * @param rootUrl The root url to use to load external dependencies like texture
  65936. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65937. * @returns the parsed GPU particle system
  65938. */
  65939. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65940. }
  65941. }
  65942. declare module "babylonjs/Particles/particleSystemSet" {
  65943. import { Nullable } from "babylonjs/types";
  65944. import { Color3 } from "babylonjs/Maths/math.color";
  65945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65947. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65948. import { Scene, IDisposable } from "babylonjs/scene";
  65949. /**
  65950. * Represents a set of particle systems working together to create a specific effect
  65951. */
  65952. export class ParticleSystemSet implements IDisposable {
  65953. /**
  65954. * Gets or sets base Assets URL
  65955. */
  65956. static BaseAssetsUrl: string;
  65957. private _emitterCreationOptions;
  65958. private _emitterNode;
  65959. /**
  65960. * Gets the particle system list
  65961. */
  65962. systems: IParticleSystem[];
  65963. /**
  65964. * Gets the emitter node used with this set
  65965. */
  65966. get emitterNode(): Nullable<TransformNode>;
  65967. /**
  65968. * Creates a new emitter mesh as a sphere
  65969. * @param options defines the options used to create the sphere
  65970. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65971. * @param scene defines the hosting scene
  65972. */
  65973. setEmitterAsSphere(options: {
  65974. diameter: number;
  65975. segments: number;
  65976. color: Color3;
  65977. }, renderingGroupId: number, scene: Scene): void;
  65978. /**
  65979. * Starts all particle systems of the set
  65980. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65981. */
  65982. start(emitter?: AbstractMesh): void;
  65983. /**
  65984. * Release all associated resources
  65985. */
  65986. dispose(): void;
  65987. /**
  65988. * Serialize the set into a JSON compatible object
  65989. * @returns a JSON compatible representation of the set
  65990. */
  65991. serialize(): any;
  65992. /**
  65993. * Parse a new ParticleSystemSet from a serialized source
  65994. * @param data defines a JSON compatible representation of the set
  65995. * @param scene defines the hosting scene
  65996. * @param gpu defines if we want GPU particles or CPU particles
  65997. * @returns a new ParticleSystemSet
  65998. */
  65999. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66000. }
  66001. }
  66002. declare module "babylonjs/Particles/particleHelper" {
  66003. import { Nullable } from "babylonjs/types";
  66004. import { Scene } from "babylonjs/scene";
  66005. import { Vector3 } from "babylonjs/Maths/math.vector";
  66006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66007. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66008. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66009. /**
  66010. * This class is made for on one-liner static method to help creating particle system set.
  66011. */
  66012. export class ParticleHelper {
  66013. /**
  66014. * Gets or sets base Assets URL
  66015. */
  66016. static BaseAssetsUrl: string;
  66017. /**
  66018. * Create a default particle system that you can tweak
  66019. * @param emitter defines the emitter to use
  66020. * @param capacity defines the system capacity (default is 500 particles)
  66021. * @param scene defines the hosting scene
  66022. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66023. * @returns the new Particle system
  66024. */
  66025. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66026. /**
  66027. * This is the main static method (one-liner) of this helper to create different particle systems
  66028. * @param type This string represents the type to the particle system to create
  66029. * @param scene The scene where the particle system should live
  66030. * @param gpu If the system will use gpu
  66031. * @returns the ParticleSystemSet created
  66032. */
  66033. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66034. /**
  66035. * Static function used to export a particle system to a ParticleSystemSet variable.
  66036. * Please note that the emitter shape is not exported
  66037. * @param systems defines the particle systems to export
  66038. * @returns the created particle system set
  66039. */
  66040. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66041. }
  66042. }
  66043. declare module "babylonjs/Particles/particleSystemComponent" {
  66044. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66045. import { Effect } from "babylonjs/Materials/effect";
  66046. import "babylonjs/Shaders/particles.vertex";
  66047. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66048. module "babylonjs/Engines/engine" {
  66049. interface Engine {
  66050. /**
  66051. * Create an effect to use with particle systems.
  66052. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66053. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66054. * @param uniformsNames defines a list of attribute names
  66055. * @param samplers defines an array of string used to represent textures
  66056. * @param defines defines the string containing the defines to use to compile the shaders
  66057. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66058. * @param onCompiled defines a function to call when the effect creation is successful
  66059. * @param onError defines a function to call when the effect creation has failed
  66060. * @returns the new Effect
  66061. */
  66062. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66063. }
  66064. }
  66065. module "babylonjs/Meshes/mesh" {
  66066. interface Mesh {
  66067. /**
  66068. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66069. * @returns an array of IParticleSystem
  66070. */
  66071. getEmittedParticleSystems(): IParticleSystem[];
  66072. /**
  66073. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66074. * @returns an array of IParticleSystem
  66075. */
  66076. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66077. }
  66078. }
  66079. /**
  66080. * @hidden
  66081. */
  66082. export var _IDoNeedToBeInTheBuild: number;
  66083. }
  66084. declare module "babylonjs/Particles/pointsCloudSystem" {
  66085. import { Color4 } from "babylonjs/Maths/math";
  66086. import { Mesh } from "babylonjs/Meshes/mesh";
  66087. import { Scene, IDisposable } from "babylonjs/scene";
  66088. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66089. /** Defines the 4 color options */
  66090. export enum PointColor {
  66091. /** color value */
  66092. Color = 2,
  66093. /** uv value */
  66094. UV = 1,
  66095. /** random value */
  66096. Random = 0,
  66097. /** stated value */
  66098. Stated = 3
  66099. }
  66100. /**
  66101. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66102. * 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.
  66103. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66104. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66105. *
  66106. * Full documentation here : TO BE ENTERED
  66107. */
  66108. export class PointsCloudSystem implements IDisposable {
  66109. /**
  66110. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66111. * Example : var p = SPS.particles[i];
  66112. */
  66113. particles: CloudPoint[];
  66114. /**
  66115. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66116. */
  66117. nbParticles: number;
  66118. /**
  66119. * This a counter for your own usage. It's not set by any SPS functions.
  66120. */
  66121. counter: number;
  66122. /**
  66123. * The PCS name. This name is also given to the underlying mesh.
  66124. */
  66125. name: string;
  66126. /**
  66127. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66128. */
  66129. mesh: Mesh;
  66130. /**
  66131. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66132. * Please read :
  66133. */
  66134. vars: any;
  66135. /**
  66136. * @hidden
  66137. */
  66138. _size: number;
  66139. private _scene;
  66140. private _promises;
  66141. private _positions;
  66142. private _indices;
  66143. private _normals;
  66144. private _colors;
  66145. private _uvs;
  66146. private _indices32;
  66147. private _positions32;
  66148. private _colors32;
  66149. private _uvs32;
  66150. private _updatable;
  66151. private _isVisibilityBoxLocked;
  66152. private _alwaysVisible;
  66153. private _groups;
  66154. private _groupCounter;
  66155. private _computeParticleColor;
  66156. private _computeParticleTexture;
  66157. private _computeParticleRotation;
  66158. private _computeBoundingBox;
  66159. private _isReady;
  66160. /**
  66161. * Creates a PCS (Points Cloud System) object
  66162. * @param name (String) is the PCS name, this will be the underlying mesh name
  66163. * @param pointSize (number) is the size for each point
  66164. * @param scene (Scene) is the scene in which the PCS is added
  66165. * @param options defines the options of the PCS e.g.
  66166. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66167. */
  66168. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66169. updatable?: boolean;
  66170. });
  66171. /**
  66172. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66173. * If no points were added to the PCS, the returned mesh is just a single point.
  66174. * @returns a promise for the created mesh
  66175. */
  66176. buildMeshAsync(): Promise<Mesh>;
  66177. /**
  66178. * @hidden
  66179. */
  66180. private _buildMesh;
  66181. private _addParticle;
  66182. private _randomUnitVector;
  66183. private _getColorIndicesForCoord;
  66184. private _setPointsColorOrUV;
  66185. private _colorFromTexture;
  66186. private _calculateDensity;
  66187. /**
  66188. * Adds points to the PCS in random positions within a unit sphere
  66189. * @param nb (positive integer) the number of particles to be created from this model
  66190. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66191. * @returns the number of groups in the system
  66192. */
  66193. addPoints(nb: number, pointFunction?: any): number;
  66194. /**
  66195. * Adds points to the PCS from the surface of the model shape
  66196. * @param mesh is any Mesh object that will be used as a surface model for the points
  66197. * @param nb (positive integer) the number of particles to be created from this model
  66198. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66199. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66200. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66201. * @returns the number of groups in the system
  66202. */
  66203. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66204. /**
  66205. * Adds points to the PCS inside the model shape
  66206. * @param mesh is any Mesh object that will be used as a surface model for the points
  66207. * @param nb (positive integer) the number of particles to be created from this model
  66208. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66209. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66210. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66211. * @returns the number of groups in the system
  66212. */
  66213. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66214. /**
  66215. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66216. * This method calls `updateParticle()` for each particle of the SPS.
  66217. * For an animated SPS, it is usually called within the render loop.
  66218. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66219. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66220. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66221. * @returns the PCS.
  66222. */
  66223. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66224. /**
  66225. * Disposes the PCS.
  66226. */
  66227. dispose(): void;
  66228. /**
  66229. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66230. * doc :
  66231. * @returns the PCS.
  66232. */
  66233. refreshVisibleSize(): PointsCloudSystem;
  66234. /**
  66235. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66236. * @param size the size (float) of the visibility box
  66237. * note : this doesn't lock the PCS mesh bounding box.
  66238. * doc :
  66239. */
  66240. setVisibilityBox(size: number): void;
  66241. /**
  66242. * Gets whether the PCS is always visible or not
  66243. * doc :
  66244. */
  66245. get isAlwaysVisible(): boolean;
  66246. /**
  66247. * Sets the PCS as always visible or not
  66248. * doc :
  66249. */
  66250. set isAlwaysVisible(val: boolean);
  66251. /**
  66252. * Tells to `setParticles()` to compute the particle rotations or not
  66253. * Default value : false. The PCS is faster when it's set to false
  66254. * Note : particle rotations are only applied to parent particles
  66255. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66256. */
  66257. set computeParticleRotation(val: boolean);
  66258. /**
  66259. * Tells to `setParticles()` to compute the particle colors or not.
  66260. * Default value : true. The PCS is faster when it's set to false.
  66261. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66262. */
  66263. set computeParticleColor(val: boolean);
  66264. set computeParticleTexture(val: boolean);
  66265. /**
  66266. * Gets if `setParticles()` computes the particle colors or not.
  66267. * Default value : false. The PCS is faster when it's set to false.
  66268. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66269. */
  66270. get computeParticleColor(): boolean;
  66271. /**
  66272. * Gets if `setParticles()` computes the particle textures or not.
  66273. * Default value : false. The PCS is faster when it's set to false.
  66274. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66275. */
  66276. get computeParticleTexture(): boolean;
  66277. /**
  66278. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66279. */
  66280. set computeBoundingBox(val: boolean);
  66281. /**
  66282. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66283. */
  66284. get computeBoundingBox(): boolean;
  66285. /**
  66286. * This function does nothing. It may be overwritten to set all the particle first values.
  66287. * The PCS doesn't call this function, you may have to call it by your own.
  66288. * doc :
  66289. */
  66290. initParticles(): void;
  66291. /**
  66292. * This function does nothing. It may be overwritten to recycle a particle
  66293. * The PCS doesn't call this function, you can to call it
  66294. * doc :
  66295. * @param particle The particle to recycle
  66296. * @returns the recycled particle
  66297. */
  66298. recycleParticle(particle: CloudPoint): CloudPoint;
  66299. /**
  66300. * Updates a particle : this function should be overwritten by the user.
  66301. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66302. * doc :
  66303. * @example : just set a particle position or velocity and recycle conditions
  66304. * @param particle The particle to update
  66305. * @returns the updated particle
  66306. */
  66307. updateParticle(particle: CloudPoint): CloudPoint;
  66308. /**
  66309. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66310. * This does nothing and may be overwritten by the user.
  66311. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66312. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66313. * @param update the boolean update value actually passed to setParticles()
  66314. */
  66315. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66316. /**
  66317. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66318. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66325. }
  66326. }
  66327. declare module "babylonjs/Particles/cloudPoint" {
  66328. import { Nullable } from "babylonjs/types";
  66329. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66330. import { Mesh } from "babylonjs/Meshes/mesh";
  66331. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66332. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66333. /**
  66334. * Represents one particle of a points cloud system.
  66335. */
  66336. export class CloudPoint {
  66337. /**
  66338. * particle global index
  66339. */
  66340. idx: number;
  66341. /**
  66342. * The color of the particle
  66343. */
  66344. color: Nullable<Color4>;
  66345. /**
  66346. * The world space position of the particle.
  66347. */
  66348. position: Vector3;
  66349. /**
  66350. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66351. */
  66352. rotation: Vector3;
  66353. /**
  66354. * The world space rotation quaternion of the particle.
  66355. */
  66356. rotationQuaternion: Nullable<Quaternion>;
  66357. /**
  66358. * The uv of the particle.
  66359. */
  66360. uv: Nullable<Vector2>;
  66361. /**
  66362. * The current speed of the particle.
  66363. */
  66364. velocity: Vector3;
  66365. /**
  66366. * The pivot point in the particle local space.
  66367. */
  66368. pivot: Vector3;
  66369. /**
  66370. * Must the particle be translated from its pivot point in its local space ?
  66371. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66372. * Default : false
  66373. */
  66374. translateFromPivot: boolean;
  66375. /**
  66376. * Index of this particle in the global "positions" array (Internal use)
  66377. * @hidden
  66378. */
  66379. _pos: number;
  66380. /**
  66381. * @hidden Index of this particle in the global "indices" array (Internal use)
  66382. */
  66383. _ind: number;
  66384. /**
  66385. * Group this particle belongs to
  66386. */
  66387. _group: PointsGroup;
  66388. /**
  66389. * Group id of this particle
  66390. */
  66391. groupId: number;
  66392. /**
  66393. * Index of the particle in its group id (Internal use)
  66394. */
  66395. idxInGroup: number;
  66396. /**
  66397. * @hidden Particle BoundingInfo object (Internal use)
  66398. */
  66399. _boundingInfo: BoundingInfo;
  66400. /**
  66401. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66402. */
  66403. _pcs: PointsCloudSystem;
  66404. /**
  66405. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66406. */
  66407. _stillInvisible: boolean;
  66408. /**
  66409. * @hidden Last computed particle rotation matrix
  66410. */
  66411. _rotationMatrix: number[];
  66412. /**
  66413. * Parent particle Id, if any.
  66414. * Default null.
  66415. */
  66416. parentId: Nullable<number>;
  66417. /**
  66418. * @hidden Internal global position in the PCS.
  66419. */
  66420. _globalPosition: Vector3;
  66421. /**
  66422. * Creates a Point Cloud object.
  66423. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66424. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66425. * @param group (PointsGroup) is the group the particle belongs to
  66426. * @param groupId (integer) is the group identifier in the PCS.
  66427. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66428. * @param pcs defines the PCS it is associated to
  66429. */
  66430. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66431. /**
  66432. * get point size
  66433. */
  66434. get size(): Vector3;
  66435. /**
  66436. * Set point size
  66437. */
  66438. set size(scale: Vector3);
  66439. /**
  66440. * Legacy support, changed quaternion to rotationQuaternion
  66441. */
  66442. get quaternion(): Nullable<Quaternion>;
  66443. /**
  66444. * Legacy support, changed quaternion to rotationQuaternion
  66445. */
  66446. set quaternion(q: Nullable<Quaternion>);
  66447. /**
  66448. * Returns a boolean. True if the particle intersects a mesh, else false
  66449. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66450. * @param target is the object (point or mesh) what the intersection is computed against
  66451. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66452. * @returns true if it intersects
  66453. */
  66454. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66455. /**
  66456. * get the rotation matrix of the particle
  66457. * @hidden
  66458. */
  66459. getRotationMatrix(m: Matrix): void;
  66460. }
  66461. /**
  66462. * Represents a group of points in a points cloud system
  66463. * * PCS internal tool, don't use it manually.
  66464. */
  66465. export class PointsGroup {
  66466. /**
  66467. * The group id
  66468. * @hidden
  66469. */
  66470. groupID: number;
  66471. /**
  66472. * image data for group (internal use)
  66473. * @hidden
  66474. */
  66475. _groupImageData: Nullable<ArrayBufferView>;
  66476. /**
  66477. * Image Width (internal use)
  66478. * @hidden
  66479. */
  66480. _groupImgWidth: number;
  66481. /**
  66482. * Image Height (internal use)
  66483. * @hidden
  66484. */
  66485. _groupImgHeight: number;
  66486. /**
  66487. * Custom position function (internal use)
  66488. * @hidden
  66489. */
  66490. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66491. /**
  66492. * density per facet for surface points
  66493. * @hidden
  66494. */
  66495. _groupDensity: number[];
  66496. /**
  66497. * Only when points are colored by texture carries pointer to texture list array
  66498. * @hidden
  66499. */
  66500. _textureNb: number;
  66501. /**
  66502. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66503. * PCS internal tool, don't use it manually.
  66504. * @hidden
  66505. */
  66506. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66507. }
  66508. }
  66509. declare module "babylonjs/Particles/index" {
  66510. export * from "babylonjs/Particles/baseParticleSystem";
  66511. export * from "babylonjs/Particles/EmitterTypes/index";
  66512. export * from "babylonjs/Particles/gpuParticleSystem";
  66513. export * from "babylonjs/Particles/IParticleSystem";
  66514. export * from "babylonjs/Particles/particle";
  66515. export * from "babylonjs/Particles/particleHelper";
  66516. export * from "babylonjs/Particles/particleSystem";
  66517. export * from "babylonjs/Particles/particleSystemComponent";
  66518. export * from "babylonjs/Particles/particleSystemSet";
  66519. export * from "babylonjs/Particles/solidParticle";
  66520. export * from "babylonjs/Particles/solidParticleSystem";
  66521. export * from "babylonjs/Particles/cloudPoint";
  66522. export * from "babylonjs/Particles/pointsCloudSystem";
  66523. export * from "babylonjs/Particles/subEmitter";
  66524. }
  66525. declare module "babylonjs/Physics/physicsEngineComponent" {
  66526. import { Nullable } from "babylonjs/types";
  66527. import { Observable, Observer } from "babylonjs/Misc/observable";
  66528. import { Vector3 } from "babylonjs/Maths/math.vector";
  66529. import { Mesh } from "babylonjs/Meshes/mesh";
  66530. import { ISceneComponent } from "babylonjs/sceneComponent";
  66531. import { Scene } from "babylonjs/scene";
  66532. import { Node } from "babylonjs/node";
  66533. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66534. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66535. module "babylonjs/scene" {
  66536. interface Scene {
  66537. /** @hidden (Backing field) */
  66538. _physicsEngine: Nullable<IPhysicsEngine>;
  66539. /** @hidden */
  66540. _physicsTimeAccumulator: number;
  66541. /**
  66542. * Gets the current physics engine
  66543. * @returns a IPhysicsEngine or null if none attached
  66544. */
  66545. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66546. /**
  66547. * Enables physics to the current scene
  66548. * @param gravity defines the scene's gravity for the physics engine
  66549. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66550. * @return a boolean indicating if the physics engine was initialized
  66551. */
  66552. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66553. /**
  66554. * Disables and disposes the physics engine associated with the scene
  66555. */
  66556. disablePhysicsEngine(): void;
  66557. /**
  66558. * Gets a boolean indicating if there is an active physics engine
  66559. * @returns a boolean indicating if there is an active physics engine
  66560. */
  66561. isPhysicsEnabled(): boolean;
  66562. /**
  66563. * Deletes a physics compound impostor
  66564. * @param compound defines the compound to delete
  66565. */
  66566. deleteCompoundImpostor(compound: any): void;
  66567. /**
  66568. * An event triggered when physic simulation is about to be run
  66569. */
  66570. onBeforePhysicsObservable: Observable<Scene>;
  66571. /**
  66572. * An event triggered when physic simulation has been done
  66573. */
  66574. onAfterPhysicsObservable: Observable<Scene>;
  66575. }
  66576. }
  66577. module "babylonjs/Meshes/abstractMesh" {
  66578. interface AbstractMesh {
  66579. /** @hidden */
  66580. _physicsImpostor: Nullable<PhysicsImpostor>;
  66581. /**
  66582. * Gets or sets impostor used for physic simulation
  66583. * @see http://doc.babylonjs.com/features/physics_engine
  66584. */
  66585. physicsImpostor: Nullable<PhysicsImpostor>;
  66586. /**
  66587. * Gets the current physics impostor
  66588. * @see http://doc.babylonjs.com/features/physics_engine
  66589. * @returns a physics impostor or null
  66590. */
  66591. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66592. /** Apply a physic impulse to the mesh
  66593. * @param force defines the force to apply
  66594. * @param contactPoint defines where to apply the force
  66595. * @returns the current mesh
  66596. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66597. */
  66598. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66599. /**
  66600. * Creates a physic joint between two meshes
  66601. * @param otherMesh defines the other mesh to use
  66602. * @param pivot1 defines the pivot to use on this mesh
  66603. * @param pivot2 defines the pivot to use on the other mesh
  66604. * @param options defines additional options (can be plugin dependent)
  66605. * @returns the current mesh
  66606. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66607. */
  66608. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66609. /** @hidden */
  66610. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66611. }
  66612. }
  66613. /**
  66614. * Defines the physics engine scene component responsible to manage a physics engine
  66615. */
  66616. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66617. /**
  66618. * The component name helpful to identify the component in the list of scene components.
  66619. */
  66620. readonly name: string;
  66621. /**
  66622. * The scene the component belongs to.
  66623. */
  66624. scene: Scene;
  66625. /**
  66626. * Creates a new instance of the component for the given scene
  66627. * @param scene Defines the scene to register the component in
  66628. */
  66629. constructor(scene: Scene);
  66630. /**
  66631. * Registers the component in a given scene
  66632. */
  66633. register(): void;
  66634. /**
  66635. * Rebuilds the elements related to this component in case of
  66636. * context lost for instance.
  66637. */
  66638. rebuild(): void;
  66639. /**
  66640. * Disposes the component and the associated ressources
  66641. */
  66642. dispose(): void;
  66643. }
  66644. }
  66645. declare module "babylonjs/Physics/physicsHelper" {
  66646. import { Nullable } from "babylonjs/types";
  66647. import { Vector3 } from "babylonjs/Maths/math.vector";
  66648. import { Mesh } from "babylonjs/Meshes/mesh";
  66649. import { Scene } from "babylonjs/scene";
  66650. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66651. /**
  66652. * A helper for physics simulations
  66653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66654. */
  66655. export class PhysicsHelper {
  66656. private _scene;
  66657. private _physicsEngine;
  66658. /**
  66659. * Initializes the Physics helper
  66660. * @param scene Babylon.js scene
  66661. */
  66662. constructor(scene: Scene);
  66663. /**
  66664. * Applies a radial explosion impulse
  66665. * @param origin the origin of the explosion
  66666. * @param radiusOrEventOptions the radius or the options of radial explosion
  66667. * @param strength the explosion strength
  66668. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66669. * @returns A physics radial explosion event, or null
  66670. */
  66671. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66672. /**
  66673. * Applies a radial explosion force
  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. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66681. /**
  66682. * Creates a gravitational field
  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 gravitational field event, or null
  66688. */
  66689. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66690. /**
  66691. * Creates a physics updraft event
  66692. * @param origin the origin of the updraft
  66693. * @param radiusOrEventOptions the radius or the options of the updraft
  66694. * @param strength the strength of the updraft
  66695. * @param height the height of the updraft
  66696. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66697. * @returns A physics updraft event, or null
  66698. */
  66699. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66700. /**
  66701. * Creates a physics vortex event
  66702. * @param origin the of the vortex
  66703. * @param radiusOrEventOptions the radius or the options of the vortex
  66704. * @param strength the strength of the vortex
  66705. * @param height the height of the vortex
  66706. * @returns a Physics vortex event, or null
  66707. * A physics vortex event or null
  66708. */
  66709. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66710. }
  66711. /**
  66712. * Represents a physics radial explosion event
  66713. */
  66714. class PhysicsRadialExplosionEvent {
  66715. private _scene;
  66716. private _options;
  66717. private _sphere;
  66718. private _dataFetched;
  66719. /**
  66720. * Initializes a radial explosioin event
  66721. * @param _scene BabylonJS scene
  66722. * @param _options The options for the vortex event
  66723. */
  66724. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66725. /**
  66726. * Returns the data related to the radial explosion event (sphere).
  66727. * @returns The radial explosion event data
  66728. */
  66729. getData(): PhysicsRadialExplosionEventData;
  66730. /**
  66731. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66732. * @param impostor A physics imposter
  66733. * @param origin the origin of the explosion
  66734. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66735. */
  66736. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66737. /**
  66738. * Triggers affecterd impostors callbacks
  66739. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66740. */
  66741. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66742. /**
  66743. * Disposes the sphere.
  66744. * @param force Specifies if the sphere should be disposed by force
  66745. */
  66746. dispose(force?: boolean): void;
  66747. /*** Helpers ***/
  66748. private _prepareSphere;
  66749. private _intersectsWithSphere;
  66750. }
  66751. /**
  66752. * Represents a gravitational field event
  66753. */
  66754. class PhysicsGravitationalFieldEvent {
  66755. private _physicsHelper;
  66756. private _scene;
  66757. private _origin;
  66758. private _options;
  66759. private _tickCallback;
  66760. private _sphere;
  66761. private _dataFetched;
  66762. /**
  66763. * Initializes the physics gravitational field event
  66764. * @param _physicsHelper A physics helper
  66765. * @param _scene BabylonJS scene
  66766. * @param _origin The origin position of the gravitational field event
  66767. * @param _options The options for the vortex event
  66768. */
  66769. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66770. /**
  66771. * Returns the data related to the gravitational field event (sphere).
  66772. * @returns A gravitational field event
  66773. */
  66774. getData(): PhysicsGravitationalFieldEventData;
  66775. /**
  66776. * Enables the gravitational field.
  66777. */
  66778. enable(): void;
  66779. /**
  66780. * Disables the gravitational field.
  66781. */
  66782. disable(): void;
  66783. /**
  66784. * Disposes the sphere.
  66785. * @param force The force to dispose from the gravitational field event
  66786. */
  66787. dispose(force?: boolean): void;
  66788. private _tick;
  66789. }
  66790. /**
  66791. * Represents a physics updraft event
  66792. */
  66793. class PhysicsUpdraftEvent {
  66794. private _scene;
  66795. private _origin;
  66796. private _options;
  66797. private _physicsEngine;
  66798. private _originTop;
  66799. private _originDirection;
  66800. private _tickCallback;
  66801. private _cylinder;
  66802. private _cylinderPosition;
  66803. private _dataFetched;
  66804. /**
  66805. * Initializes the physics updraft event
  66806. * @param _scene BabylonJS scene
  66807. * @param _origin The origin position of the updraft
  66808. * @param _options The options for the updraft event
  66809. */
  66810. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66811. /**
  66812. * Returns the data related to the updraft event (cylinder).
  66813. * @returns A physics updraft event
  66814. */
  66815. getData(): PhysicsUpdraftEventData;
  66816. /**
  66817. * Enables the updraft.
  66818. */
  66819. enable(): void;
  66820. /**
  66821. * Disables the updraft.
  66822. */
  66823. disable(): void;
  66824. /**
  66825. * Disposes the cylinder.
  66826. * @param force Specifies if the updraft should be disposed by force
  66827. */
  66828. dispose(force?: boolean): void;
  66829. private getImpostorHitData;
  66830. private _tick;
  66831. /*** Helpers ***/
  66832. private _prepareCylinder;
  66833. private _intersectsWithCylinder;
  66834. }
  66835. /**
  66836. * Represents a physics vortex event
  66837. */
  66838. class PhysicsVortexEvent {
  66839. private _scene;
  66840. private _origin;
  66841. private _options;
  66842. private _physicsEngine;
  66843. private _originTop;
  66844. private _tickCallback;
  66845. private _cylinder;
  66846. private _cylinderPosition;
  66847. private _dataFetched;
  66848. /**
  66849. * Initializes the physics vortex event
  66850. * @param _scene The BabylonJS scene
  66851. * @param _origin The origin position of the vortex
  66852. * @param _options The options for the vortex event
  66853. */
  66854. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66855. /**
  66856. * Returns the data related to the vortex event (cylinder).
  66857. * @returns The physics vortex event data
  66858. */
  66859. getData(): PhysicsVortexEventData;
  66860. /**
  66861. * Enables the vortex.
  66862. */
  66863. enable(): void;
  66864. /**
  66865. * Disables the cortex.
  66866. */
  66867. disable(): void;
  66868. /**
  66869. * Disposes the sphere.
  66870. * @param force
  66871. */
  66872. dispose(force?: boolean): void;
  66873. private getImpostorHitData;
  66874. private _tick;
  66875. /*** Helpers ***/
  66876. private _prepareCylinder;
  66877. private _intersectsWithCylinder;
  66878. }
  66879. /**
  66880. * Options fot the radial explosion event
  66881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66882. */
  66883. export class PhysicsRadialExplosionEventOptions {
  66884. /**
  66885. * The radius of the sphere for the radial explosion.
  66886. */
  66887. radius: number;
  66888. /**
  66889. * The strenth of the explosion.
  66890. */
  66891. strength: number;
  66892. /**
  66893. * The strenght of the force in correspondence to the distance of the affected object
  66894. */
  66895. falloff: PhysicsRadialImpulseFalloff;
  66896. /**
  66897. * Sphere options for the radial explosion.
  66898. */
  66899. sphere: {
  66900. segments: number;
  66901. diameter: number;
  66902. };
  66903. /**
  66904. * Sphere options for the radial explosion.
  66905. */
  66906. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66907. }
  66908. /**
  66909. * Options fot the updraft event
  66910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66911. */
  66912. export class PhysicsUpdraftEventOptions {
  66913. /**
  66914. * The radius of the cylinder for the vortex
  66915. */
  66916. radius: number;
  66917. /**
  66918. * The strenth of the updraft.
  66919. */
  66920. strength: number;
  66921. /**
  66922. * The height of the cylinder for the updraft.
  66923. */
  66924. height: number;
  66925. /**
  66926. * The mode for the the updraft.
  66927. */
  66928. updraftMode: PhysicsUpdraftMode;
  66929. }
  66930. /**
  66931. * Options fot the vortex event
  66932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66933. */
  66934. export class PhysicsVortexEventOptions {
  66935. /**
  66936. * The radius of the cylinder for the vortex
  66937. */
  66938. radius: number;
  66939. /**
  66940. * The strenth of the vortex.
  66941. */
  66942. strength: number;
  66943. /**
  66944. * The height of the cylinder for the vortex.
  66945. */
  66946. height: number;
  66947. /**
  66948. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66949. */
  66950. centripetalForceThreshold: number;
  66951. /**
  66952. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66953. */
  66954. centripetalForceMultiplier: number;
  66955. /**
  66956. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66957. */
  66958. centrifugalForceMultiplier: number;
  66959. /**
  66960. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66961. */
  66962. updraftForceMultiplier: number;
  66963. }
  66964. /**
  66965. * The strenght of the force in correspondence to the distance of the affected object
  66966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66967. */
  66968. export enum PhysicsRadialImpulseFalloff {
  66969. /** Defines that impulse is constant in strength across it's whole radius */
  66970. Constant = 0,
  66971. /** Defines that impulse gets weaker if it's further from the origin */
  66972. Linear = 1
  66973. }
  66974. /**
  66975. * The strength of the force in correspondence to the distance of the affected object
  66976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66977. */
  66978. export enum PhysicsUpdraftMode {
  66979. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66980. Center = 0,
  66981. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66982. Perpendicular = 1
  66983. }
  66984. /**
  66985. * Interface for a physics hit data
  66986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66987. */
  66988. export interface PhysicsHitData {
  66989. /**
  66990. * The force applied at the contact point
  66991. */
  66992. force: Vector3;
  66993. /**
  66994. * The contact point
  66995. */
  66996. contactPoint: Vector3;
  66997. /**
  66998. * The distance from the origin to the contact point
  66999. */
  67000. distanceFromOrigin: number;
  67001. }
  67002. /**
  67003. * Interface for radial explosion event data
  67004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67005. */
  67006. export interface PhysicsRadialExplosionEventData {
  67007. /**
  67008. * A sphere used for the radial explosion event
  67009. */
  67010. sphere: Mesh;
  67011. }
  67012. /**
  67013. * Interface for gravitational field event data
  67014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67015. */
  67016. export interface PhysicsGravitationalFieldEventData {
  67017. /**
  67018. * A sphere mesh used for the gravitational field event
  67019. */
  67020. sphere: Mesh;
  67021. }
  67022. /**
  67023. * Interface for updraft event data
  67024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67025. */
  67026. export interface PhysicsUpdraftEventData {
  67027. /**
  67028. * A cylinder used for the updraft event
  67029. */
  67030. cylinder: Mesh;
  67031. }
  67032. /**
  67033. * Interface for vortex event data
  67034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67035. */
  67036. export interface PhysicsVortexEventData {
  67037. /**
  67038. * A cylinder used for the vortex event
  67039. */
  67040. cylinder: Mesh;
  67041. }
  67042. /**
  67043. * Interface for an affected physics impostor
  67044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67045. */
  67046. export interface PhysicsAffectedImpostorWithData {
  67047. /**
  67048. * The impostor affected by the effect
  67049. */
  67050. impostor: PhysicsImpostor;
  67051. /**
  67052. * The data about the hit/horce from the explosion
  67053. */
  67054. hitData: PhysicsHitData;
  67055. }
  67056. }
  67057. declare module "babylonjs/Physics/Plugins/index" {
  67058. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67059. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67060. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67061. }
  67062. declare module "babylonjs/Physics/index" {
  67063. export * from "babylonjs/Physics/IPhysicsEngine";
  67064. export * from "babylonjs/Physics/physicsEngine";
  67065. export * from "babylonjs/Physics/physicsEngineComponent";
  67066. export * from "babylonjs/Physics/physicsHelper";
  67067. export * from "babylonjs/Physics/physicsImpostor";
  67068. export * from "babylonjs/Physics/physicsJoint";
  67069. export * from "babylonjs/Physics/Plugins/index";
  67070. }
  67071. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67072. /** @hidden */
  67073. export var blackAndWhitePixelShader: {
  67074. name: string;
  67075. shader: string;
  67076. };
  67077. }
  67078. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67080. import { Camera } from "babylonjs/Cameras/camera";
  67081. import { Engine } from "babylonjs/Engines/engine";
  67082. import "babylonjs/Shaders/blackAndWhite.fragment";
  67083. /**
  67084. * Post process used to render in black and white
  67085. */
  67086. export class BlackAndWhitePostProcess extends PostProcess {
  67087. /**
  67088. * Linear about to convert he result to black and white (default: 1)
  67089. */
  67090. degree: number;
  67091. /**
  67092. * Creates a black and white post process
  67093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67094. * @param name The name of the effect.
  67095. * @param options The required width/height ratio to downsize to before computing the render pass.
  67096. * @param camera The camera to apply the render pass to.
  67097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67098. * @param engine The engine which the post process will be applied. (default: current engine)
  67099. * @param reusable If the post process can be reused on the same frame. (default: false)
  67100. */
  67101. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67102. }
  67103. }
  67104. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67105. import { Nullable } from "babylonjs/types";
  67106. import { Camera } from "babylonjs/Cameras/camera";
  67107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67108. import { Engine } from "babylonjs/Engines/engine";
  67109. /**
  67110. * This represents a set of one or more post processes in Babylon.
  67111. * A post process can be used to apply a shader to a texture after it is rendered.
  67112. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67113. */
  67114. export class PostProcessRenderEffect {
  67115. private _postProcesses;
  67116. private _getPostProcesses;
  67117. private _singleInstance;
  67118. private _cameras;
  67119. private _indicesForCamera;
  67120. /**
  67121. * Name of the effect
  67122. * @hidden
  67123. */
  67124. _name: string;
  67125. /**
  67126. * Instantiates a post process render effect.
  67127. * A post process can be used to apply a shader to a texture after it is rendered.
  67128. * @param engine The engine the effect is tied to
  67129. * @param name The name of the effect
  67130. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67131. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67132. */
  67133. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67134. /**
  67135. * Checks if all the post processes in the effect are supported.
  67136. */
  67137. get isSupported(): boolean;
  67138. /**
  67139. * Updates the current state of the effect
  67140. * @hidden
  67141. */
  67142. _update(): void;
  67143. /**
  67144. * Attaches the effect on cameras
  67145. * @param cameras The camera to attach to.
  67146. * @hidden
  67147. */
  67148. _attachCameras(cameras: Camera): void;
  67149. /**
  67150. * Attaches the effect on cameras
  67151. * @param cameras The camera to attach to.
  67152. * @hidden
  67153. */
  67154. _attachCameras(cameras: Camera[]): void;
  67155. /**
  67156. * Detaches the effect on cameras
  67157. * @param cameras The camera to detatch from.
  67158. * @hidden
  67159. */
  67160. _detachCameras(cameras: Camera): void;
  67161. /**
  67162. * Detatches the effect on cameras
  67163. * @param cameras The camera to detatch from.
  67164. * @hidden
  67165. */
  67166. _detachCameras(cameras: Camera[]): void;
  67167. /**
  67168. * Enables the effect on given cameras
  67169. * @param cameras The camera to enable.
  67170. * @hidden
  67171. */
  67172. _enable(cameras: Camera): void;
  67173. /**
  67174. * Enables the effect on given cameras
  67175. * @param cameras The camera to enable.
  67176. * @hidden
  67177. */
  67178. _enable(cameras: Nullable<Camera[]>): void;
  67179. /**
  67180. * Disables the effect on the given cameras
  67181. * @param cameras The camera to disable.
  67182. * @hidden
  67183. */
  67184. _disable(cameras: Camera): void;
  67185. /**
  67186. * Disables the effect on the given cameras
  67187. * @param cameras The camera to disable.
  67188. * @hidden
  67189. */
  67190. _disable(cameras: Nullable<Camera[]>): void;
  67191. /**
  67192. * Gets a list of the post processes contained in the effect.
  67193. * @param camera The camera to get the post processes on.
  67194. * @returns The list of the post processes in the effect.
  67195. */
  67196. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67197. }
  67198. }
  67199. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67201. /** @hidden */
  67202. export var extractHighlightsPixelShader: {
  67203. name: string;
  67204. shader: string;
  67205. };
  67206. }
  67207. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67208. import { Nullable } from "babylonjs/types";
  67209. import { Camera } from "babylonjs/Cameras/camera";
  67210. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67211. import { Engine } from "babylonjs/Engines/engine";
  67212. import "babylonjs/Shaders/extractHighlights.fragment";
  67213. /**
  67214. * 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.
  67215. */
  67216. export class ExtractHighlightsPostProcess extends PostProcess {
  67217. /**
  67218. * The luminance threshold, pixels below this value will be set to black.
  67219. */
  67220. threshold: number;
  67221. /** @hidden */
  67222. _exposure: number;
  67223. /**
  67224. * Post process which has the input texture to be used when performing highlight extraction
  67225. * @hidden
  67226. */
  67227. _inputPostProcess: Nullable<PostProcess>;
  67228. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67229. }
  67230. }
  67231. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67232. /** @hidden */
  67233. export var bloomMergePixelShader: {
  67234. name: string;
  67235. shader: string;
  67236. };
  67237. }
  67238. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67239. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67240. import { Nullable } from "babylonjs/types";
  67241. import { Engine } from "babylonjs/Engines/engine";
  67242. import { Camera } from "babylonjs/Cameras/camera";
  67243. import "babylonjs/Shaders/bloomMerge.fragment";
  67244. /**
  67245. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67246. */
  67247. export class BloomMergePostProcess extends PostProcess {
  67248. /** Weight of the bloom to be added to the original input. */
  67249. weight: number;
  67250. /**
  67251. * Creates a new instance of @see BloomMergePostProcess
  67252. * @param name The name of the effect.
  67253. * @param originalFromInput Post process which's input will be used for the merge.
  67254. * @param blurred Blurred highlights post process which's output will be used.
  67255. * @param weight Weight of the bloom to be added to the original input.
  67256. * @param options The required width/height ratio to downsize to before computing the render pass.
  67257. * @param camera The camera to apply the render pass to.
  67258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67259. * @param engine The engine which the post process will be applied. (default: current engine)
  67260. * @param reusable If the post process can be reused on the same frame. (default: false)
  67261. * @param textureType Type of textures used when performing the post process. (default: 0)
  67262. * @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)
  67263. */
  67264. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67265. /** Weight of the bloom to be added to the original input. */
  67266. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67267. }
  67268. }
  67269. declare module "babylonjs/PostProcesses/bloomEffect" {
  67270. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67271. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67272. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67273. import { Camera } from "babylonjs/Cameras/camera";
  67274. import { Scene } from "babylonjs/scene";
  67275. /**
  67276. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67277. */
  67278. export class BloomEffect extends PostProcessRenderEffect {
  67279. private bloomScale;
  67280. /**
  67281. * @hidden Internal
  67282. */
  67283. _effects: Array<PostProcess>;
  67284. /**
  67285. * @hidden Internal
  67286. */
  67287. _downscale: ExtractHighlightsPostProcess;
  67288. private _blurX;
  67289. private _blurY;
  67290. private _merge;
  67291. /**
  67292. * The luminance threshold to find bright areas of the image to bloom.
  67293. */
  67294. get threshold(): number;
  67295. set threshold(value: number);
  67296. /**
  67297. * The strength of the bloom.
  67298. */
  67299. get weight(): number;
  67300. set weight(value: number);
  67301. /**
  67302. * Specifies the size of the bloom blur kernel, relative to the final output size
  67303. */
  67304. get kernel(): number;
  67305. set kernel(value: number);
  67306. /**
  67307. * Creates a new instance of @see BloomEffect
  67308. * @param scene The scene the effect belongs to.
  67309. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67310. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67311. * @param bloomWeight The the strength of bloom.
  67312. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67313. * @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)
  67314. */
  67315. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67316. /**
  67317. * Disposes each of the internal effects for a given camera.
  67318. * @param camera The camera to dispose the effect on.
  67319. */
  67320. disposeEffects(camera: Camera): void;
  67321. /**
  67322. * @hidden Internal
  67323. */
  67324. _updateEffects(): void;
  67325. /**
  67326. * Internal
  67327. * @returns if all the contained post processes are ready.
  67328. * @hidden
  67329. */
  67330. _isReady(): boolean;
  67331. }
  67332. }
  67333. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67334. /** @hidden */
  67335. export var chromaticAberrationPixelShader: {
  67336. name: string;
  67337. shader: string;
  67338. };
  67339. }
  67340. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67341. import { Vector2 } from "babylonjs/Maths/math.vector";
  67342. import { Nullable } from "babylonjs/types";
  67343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67344. import { Camera } from "babylonjs/Cameras/camera";
  67345. import { Engine } from "babylonjs/Engines/engine";
  67346. import "babylonjs/Shaders/chromaticAberration.fragment";
  67347. /**
  67348. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67349. */
  67350. export class ChromaticAberrationPostProcess extends PostProcess {
  67351. /**
  67352. * The amount of seperation of rgb channels (default: 30)
  67353. */
  67354. aberrationAmount: number;
  67355. /**
  67356. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67357. */
  67358. radialIntensity: number;
  67359. /**
  67360. * 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))
  67361. */
  67362. direction: Vector2;
  67363. /**
  67364. * 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))
  67365. */
  67366. centerPosition: Vector2;
  67367. /**
  67368. * Creates a new instance ChromaticAberrationPostProcess
  67369. * @param name The name of the effect.
  67370. * @param screenWidth The width of the screen to apply the effect on.
  67371. * @param screenHeight The height of the screen to apply the effect on.
  67372. * @param options The required width/height ratio to downsize to before computing the render pass.
  67373. * @param camera The camera to apply the render pass to.
  67374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67375. * @param engine The engine which the post process will be applied. (default: current engine)
  67376. * @param reusable If the post process can be reused on the same frame. (default: false)
  67377. * @param textureType Type of textures used when performing the post process. (default: 0)
  67378. * @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)
  67379. */
  67380. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67381. }
  67382. }
  67383. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67384. /** @hidden */
  67385. export var circleOfConfusionPixelShader: {
  67386. name: string;
  67387. shader: string;
  67388. };
  67389. }
  67390. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67391. import { Nullable } from "babylonjs/types";
  67392. import { Engine } from "babylonjs/Engines/engine";
  67393. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67394. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67395. import { Camera } from "babylonjs/Cameras/camera";
  67396. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67397. /**
  67398. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67399. */
  67400. export class CircleOfConfusionPostProcess extends PostProcess {
  67401. /**
  67402. * 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.
  67403. */
  67404. lensSize: number;
  67405. /**
  67406. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67407. */
  67408. fStop: number;
  67409. /**
  67410. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67411. */
  67412. focusDistance: number;
  67413. /**
  67414. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67415. */
  67416. focalLength: number;
  67417. private _depthTexture;
  67418. /**
  67419. * Creates a new instance CircleOfConfusionPostProcess
  67420. * @param name The name of the effect.
  67421. * @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.
  67422. * @param options The required width/height ratio to downsize to before computing the render pass.
  67423. * @param camera The camera to apply the render pass to.
  67424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67425. * @param engine The engine which the post process will be applied. (default: current engine)
  67426. * @param reusable If the post process can be reused on the same frame. (default: false)
  67427. * @param textureType Type of textures used when performing the post process. (default: 0)
  67428. * @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)
  67429. */
  67430. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67431. /**
  67432. * 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.
  67433. */
  67434. set depthTexture(value: RenderTargetTexture);
  67435. }
  67436. }
  67437. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67438. /** @hidden */
  67439. export var colorCorrectionPixelShader: {
  67440. name: string;
  67441. shader: string;
  67442. };
  67443. }
  67444. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67446. import { Engine } from "babylonjs/Engines/engine";
  67447. import { Camera } from "babylonjs/Cameras/camera";
  67448. import "babylonjs/Shaders/colorCorrection.fragment";
  67449. /**
  67450. *
  67451. * This post-process allows the modification of rendered colors by using
  67452. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67453. *
  67454. * The object needs to be provided an url to a texture containing the color
  67455. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67456. * Use an image editing software to tweak the LUT to match your needs.
  67457. *
  67458. * For an example of a color LUT, see here:
  67459. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67460. * For explanations on color grading, see here:
  67461. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67462. *
  67463. */
  67464. export class ColorCorrectionPostProcess extends PostProcess {
  67465. private _colorTableTexture;
  67466. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67467. }
  67468. }
  67469. declare module "babylonjs/Shaders/convolution.fragment" {
  67470. /** @hidden */
  67471. export var convolutionPixelShader: {
  67472. name: string;
  67473. shader: string;
  67474. };
  67475. }
  67476. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67478. import { Nullable } from "babylonjs/types";
  67479. import { Camera } from "babylonjs/Cameras/camera";
  67480. import { Engine } from "babylonjs/Engines/engine";
  67481. import "babylonjs/Shaders/convolution.fragment";
  67482. /**
  67483. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67484. * input texture to perform effects such as edge detection or sharpening
  67485. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67486. */
  67487. export class ConvolutionPostProcess extends PostProcess {
  67488. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67489. kernel: number[];
  67490. /**
  67491. * Creates a new instance ConvolutionPostProcess
  67492. * @param name The name of the effect.
  67493. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67494. * @param options The required width/height ratio to downsize to before computing the render pass.
  67495. * @param camera The camera to apply the render pass to.
  67496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67497. * @param engine The engine which the post process will be applied. (default: current engine)
  67498. * @param reusable If the post process can be reused on the same frame. (default: false)
  67499. * @param textureType Type of textures used when performing the post process. (default: 0)
  67500. */
  67501. constructor(name: string,
  67502. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67503. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67504. /**
  67505. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67506. */
  67507. static EdgeDetect0Kernel: number[];
  67508. /**
  67509. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67510. */
  67511. static EdgeDetect1Kernel: number[];
  67512. /**
  67513. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67514. */
  67515. static EdgeDetect2Kernel: number[];
  67516. /**
  67517. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67518. */
  67519. static SharpenKernel: number[];
  67520. /**
  67521. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67522. */
  67523. static EmbossKernel: number[];
  67524. /**
  67525. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67526. */
  67527. static GaussianKernel: number[];
  67528. }
  67529. }
  67530. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67531. import { Nullable } from "babylonjs/types";
  67532. import { Vector2 } from "babylonjs/Maths/math.vector";
  67533. import { Camera } from "babylonjs/Cameras/camera";
  67534. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67535. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67536. import { Engine } from "babylonjs/Engines/engine";
  67537. import { Scene } from "babylonjs/scene";
  67538. /**
  67539. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67540. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67541. * based on samples that have a large difference in distance than the center pixel.
  67542. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67543. */
  67544. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67545. direction: Vector2;
  67546. /**
  67547. * Creates a new instance CircleOfConfusionPostProcess
  67548. * @param name The name of the effect.
  67549. * @param scene The scene the effect belongs to.
  67550. * @param direction The direction the blur should be applied.
  67551. * @param kernel The size of the kernel used to blur.
  67552. * @param options The required width/height ratio to downsize to before computing the render pass.
  67553. * @param camera The camera to apply the render pass to.
  67554. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67555. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67557. * @param engine The engine which the post process will be applied. (default: current engine)
  67558. * @param reusable If the post process can be reused on the same frame. (default: false)
  67559. * @param textureType Type of textures used when performing the post process. (default: 0)
  67560. * @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)
  67561. */
  67562. 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);
  67563. }
  67564. }
  67565. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67566. /** @hidden */
  67567. export var depthOfFieldMergePixelShader: {
  67568. name: string;
  67569. shader: string;
  67570. };
  67571. }
  67572. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67573. import { Nullable } from "babylonjs/types";
  67574. import { Camera } from "babylonjs/Cameras/camera";
  67575. import { Effect } from "babylonjs/Materials/effect";
  67576. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67577. import { Engine } from "babylonjs/Engines/engine";
  67578. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67579. /**
  67580. * Options to be set when merging outputs from the default pipeline.
  67581. */
  67582. export class DepthOfFieldMergePostProcessOptions {
  67583. /**
  67584. * The original image to merge on top of
  67585. */
  67586. originalFromInput: PostProcess;
  67587. /**
  67588. * Parameters to perform the merge of the depth of field effect
  67589. */
  67590. depthOfField?: {
  67591. circleOfConfusion: PostProcess;
  67592. blurSteps: Array<PostProcess>;
  67593. };
  67594. /**
  67595. * Parameters to perform the merge of bloom effect
  67596. */
  67597. bloom?: {
  67598. blurred: PostProcess;
  67599. weight: number;
  67600. };
  67601. }
  67602. /**
  67603. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67604. */
  67605. export class DepthOfFieldMergePostProcess extends PostProcess {
  67606. private blurSteps;
  67607. /**
  67608. * Creates a new instance of DepthOfFieldMergePostProcess
  67609. * @param name The name of the effect.
  67610. * @param originalFromInput Post process which's input will be used for the merge.
  67611. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67612. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67613. * @param options The required width/height ratio to downsize to before computing the render pass.
  67614. * @param camera The camera to apply the render pass to.
  67615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67616. * @param engine The engine which the post process will be applied. (default: current engine)
  67617. * @param reusable If the post process can be reused on the same frame. (default: false)
  67618. * @param textureType Type of textures used when performing the post process. (default: 0)
  67619. * @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)
  67620. */
  67621. 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);
  67622. /**
  67623. * Updates the effect with the current post process compile time values and recompiles the shader.
  67624. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67625. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67626. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67627. * @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
  67628. * @param onCompiled Called when the shader has been compiled.
  67629. * @param onError Called if there is an error when compiling a shader.
  67630. */
  67631. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67632. }
  67633. }
  67634. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67635. import { Nullable } from "babylonjs/types";
  67636. import { Camera } from "babylonjs/Cameras/camera";
  67637. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67638. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67639. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67640. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67641. import { Scene } from "babylonjs/scene";
  67642. /**
  67643. * Specifies the level of max blur that should be applied when using the depth of field effect
  67644. */
  67645. export enum DepthOfFieldEffectBlurLevel {
  67646. /**
  67647. * Subtle blur
  67648. */
  67649. Low = 0,
  67650. /**
  67651. * Medium blur
  67652. */
  67653. Medium = 1,
  67654. /**
  67655. * Large blur
  67656. */
  67657. High = 2
  67658. }
  67659. /**
  67660. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67661. */
  67662. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67663. private _circleOfConfusion;
  67664. /**
  67665. * @hidden Internal, blurs from high to low
  67666. */
  67667. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67668. private _depthOfFieldBlurY;
  67669. private _dofMerge;
  67670. /**
  67671. * @hidden Internal post processes in depth of field effect
  67672. */
  67673. _effects: Array<PostProcess>;
  67674. /**
  67675. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67676. */
  67677. set focalLength(value: number);
  67678. get focalLength(): number;
  67679. /**
  67680. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67681. */
  67682. set fStop(value: number);
  67683. get fStop(): number;
  67684. /**
  67685. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67686. */
  67687. set focusDistance(value: number);
  67688. get focusDistance(): number;
  67689. /**
  67690. * 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.
  67691. */
  67692. set lensSize(value: number);
  67693. get lensSize(): number;
  67694. /**
  67695. * Creates a new instance DepthOfFieldEffect
  67696. * @param scene The scene the effect belongs to.
  67697. * @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.
  67698. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67699. * @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)
  67700. */
  67701. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67702. /**
  67703. * Get the current class name of the current effet
  67704. * @returns "DepthOfFieldEffect"
  67705. */
  67706. getClassName(): string;
  67707. /**
  67708. * 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.
  67709. */
  67710. set depthTexture(value: RenderTargetTexture);
  67711. /**
  67712. * Disposes each of the internal effects for a given camera.
  67713. * @param camera The camera to dispose the effect on.
  67714. */
  67715. disposeEffects(camera: Camera): void;
  67716. /**
  67717. * @hidden Internal
  67718. */
  67719. _updateEffects(): void;
  67720. /**
  67721. * Internal
  67722. * @returns if all the contained post processes are ready.
  67723. * @hidden
  67724. */
  67725. _isReady(): boolean;
  67726. }
  67727. }
  67728. declare module "babylonjs/Shaders/displayPass.fragment" {
  67729. /** @hidden */
  67730. export var displayPassPixelShader: {
  67731. name: string;
  67732. shader: string;
  67733. };
  67734. }
  67735. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67736. import { Nullable } from "babylonjs/types";
  67737. import { Camera } from "babylonjs/Cameras/camera";
  67738. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67739. import { Engine } from "babylonjs/Engines/engine";
  67740. import "babylonjs/Shaders/displayPass.fragment";
  67741. /**
  67742. * DisplayPassPostProcess which produces an output the same as it's input
  67743. */
  67744. export class DisplayPassPostProcess extends PostProcess {
  67745. /**
  67746. * Creates the DisplayPassPostProcess
  67747. * @param name The name of the effect.
  67748. * @param options The required width/height ratio to downsize to before computing the render pass.
  67749. * @param camera The camera to apply the render pass to.
  67750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67751. * @param engine The engine which the post process will be applied. (default: current engine)
  67752. * @param reusable If the post process can be reused on the same frame. (default: false)
  67753. */
  67754. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67755. }
  67756. }
  67757. declare module "babylonjs/Shaders/filter.fragment" {
  67758. /** @hidden */
  67759. export var filterPixelShader: {
  67760. name: string;
  67761. shader: string;
  67762. };
  67763. }
  67764. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67765. import { Nullable } from "babylonjs/types";
  67766. import { Matrix } from "babylonjs/Maths/math.vector";
  67767. import { Camera } from "babylonjs/Cameras/camera";
  67768. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67769. import { Engine } from "babylonjs/Engines/engine";
  67770. import "babylonjs/Shaders/filter.fragment";
  67771. /**
  67772. * Applies a kernel filter to the image
  67773. */
  67774. export class FilterPostProcess extends PostProcess {
  67775. /** The matrix to be applied to the image */
  67776. kernelMatrix: Matrix;
  67777. /**
  67778. *
  67779. * @param name The name of the effect.
  67780. * @param kernelMatrix The matrix to be applied to the image
  67781. * @param options The required width/height ratio to downsize to before computing the render pass.
  67782. * @param camera The camera to apply the render pass to.
  67783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67784. * @param engine The engine which the post process will be applied. (default: current engine)
  67785. * @param reusable If the post process can be reused on the same frame. (default: false)
  67786. */
  67787. constructor(name: string,
  67788. /** The matrix to be applied to the image */
  67789. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67790. }
  67791. }
  67792. declare module "babylonjs/Shaders/fxaa.fragment" {
  67793. /** @hidden */
  67794. export var fxaaPixelShader: {
  67795. name: string;
  67796. shader: string;
  67797. };
  67798. }
  67799. declare module "babylonjs/Shaders/fxaa.vertex" {
  67800. /** @hidden */
  67801. export var fxaaVertexShader: {
  67802. name: string;
  67803. shader: string;
  67804. };
  67805. }
  67806. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67807. import { Nullable } from "babylonjs/types";
  67808. import { Camera } from "babylonjs/Cameras/camera";
  67809. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67810. import { Engine } from "babylonjs/Engines/engine";
  67811. import "babylonjs/Shaders/fxaa.fragment";
  67812. import "babylonjs/Shaders/fxaa.vertex";
  67813. /**
  67814. * Fxaa post process
  67815. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67816. */
  67817. export class FxaaPostProcess extends PostProcess {
  67818. /** @hidden */
  67819. texelWidth: number;
  67820. /** @hidden */
  67821. texelHeight: number;
  67822. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67823. private _getDefines;
  67824. }
  67825. }
  67826. declare module "babylonjs/Shaders/grain.fragment" {
  67827. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67828. /** @hidden */
  67829. export var grainPixelShader: {
  67830. name: string;
  67831. shader: string;
  67832. };
  67833. }
  67834. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67835. import { Nullable } from "babylonjs/types";
  67836. import { Camera } from "babylonjs/Cameras/camera";
  67837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67838. import { Engine } from "babylonjs/Engines/engine";
  67839. import "babylonjs/Shaders/grain.fragment";
  67840. /**
  67841. * The GrainPostProcess adds noise to the image at mid luminance levels
  67842. */
  67843. export class GrainPostProcess extends PostProcess {
  67844. /**
  67845. * The intensity of the grain added (default: 30)
  67846. */
  67847. intensity: number;
  67848. /**
  67849. * If the grain should be randomized on every frame
  67850. */
  67851. animated: boolean;
  67852. /**
  67853. * Creates a new instance of @see GrainPostProcess
  67854. * @param name The name of the effect.
  67855. * @param options The required width/height ratio to downsize to before computing the render pass.
  67856. * @param camera The camera to apply the render pass to.
  67857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67858. * @param engine The engine which the post process will be applied. (default: current engine)
  67859. * @param reusable If the post process can be reused on the same frame. (default: false)
  67860. * @param textureType Type of textures used when performing the post process. (default: 0)
  67861. * @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)
  67862. */
  67863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67864. }
  67865. }
  67866. declare module "babylonjs/Shaders/highlights.fragment" {
  67867. /** @hidden */
  67868. export var highlightsPixelShader: {
  67869. name: string;
  67870. shader: string;
  67871. };
  67872. }
  67873. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67874. import { Nullable } from "babylonjs/types";
  67875. import { Camera } from "babylonjs/Cameras/camera";
  67876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67877. import { Engine } from "babylonjs/Engines/engine";
  67878. import "babylonjs/Shaders/highlights.fragment";
  67879. /**
  67880. * Extracts highlights from the image
  67881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67882. */
  67883. export class HighlightsPostProcess extends PostProcess {
  67884. /**
  67885. * Extracts highlights from the image
  67886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67887. * @param name The name of the effect.
  67888. * @param options The required width/height ratio to downsize to before computing the render pass.
  67889. * @param camera The camera to apply the render pass to.
  67890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67891. * @param engine The engine which the post process will be applied. (default: current engine)
  67892. * @param reusable If the post process can be reused on the same frame. (default: false)
  67893. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67894. */
  67895. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67896. }
  67897. }
  67898. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67899. /** @hidden */
  67900. export var mrtFragmentDeclaration: {
  67901. name: string;
  67902. shader: string;
  67903. };
  67904. }
  67905. declare module "babylonjs/Shaders/geometry.fragment" {
  67906. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67907. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67908. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67909. /** @hidden */
  67910. export var geometryPixelShader: {
  67911. name: string;
  67912. shader: string;
  67913. };
  67914. }
  67915. declare module "babylonjs/Shaders/geometry.vertex" {
  67916. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67919. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67921. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67922. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67923. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67924. /** @hidden */
  67925. export var geometryVertexShader: {
  67926. name: string;
  67927. shader: string;
  67928. };
  67929. }
  67930. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67931. import { Matrix } from "babylonjs/Maths/math.vector";
  67932. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67933. import { Mesh } from "babylonjs/Meshes/mesh";
  67934. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67935. import { Effect } from "babylonjs/Materials/effect";
  67936. import { Scene } from "babylonjs/scene";
  67937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67938. import "babylonjs/Shaders/geometry.fragment";
  67939. import "babylonjs/Shaders/geometry.vertex";
  67940. /** @hidden */
  67941. interface ISavedTransformationMatrix {
  67942. world: Matrix;
  67943. viewProjection: Matrix;
  67944. }
  67945. /**
  67946. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67947. */
  67948. export class GeometryBufferRenderer {
  67949. /**
  67950. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67951. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67952. */
  67953. static readonly POSITION_TEXTURE_TYPE: number;
  67954. /**
  67955. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67956. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67957. */
  67958. static readonly VELOCITY_TEXTURE_TYPE: number;
  67959. /**
  67960. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67961. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67962. */
  67963. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67964. /**
  67965. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67966. * in order to compute objects velocities when enableVelocity is set to "true"
  67967. * @hidden
  67968. */
  67969. _previousTransformationMatrices: {
  67970. [index: number]: ISavedTransformationMatrix;
  67971. };
  67972. /**
  67973. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67974. * in order to compute objects velocities when enableVelocity is set to "true"
  67975. * @hidden
  67976. */
  67977. _previousBonesTransformationMatrices: {
  67978. [index: number]: Float32Array;
  67979. };
  67980. /**
  67981. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67982. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67983. */
  67984. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67985. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67986. renderTransparentMeshes: boolean;
  67987. private _scene;
  67988. private _multiRenderTarget;
  67989. private _ratio;
  67990. private _enablePosition;
  67991. private _enableVelocity;
  67992. private _enableReflectivity;
  67993. private _positionIndex;
  67994. private _velocityIndex;
  67995. private _reflectivityIndex;
  67996. protected _effect: Effect;
  67997. protected _cachedDefines: string;
  67998. /**
  67999. * Set the render list (meshes to be rendered) used in the G buffer.
  68000. */
  68001. set renderList(meshes: Mesh[]);
  68002. /**
  68003. * Gets wether or not G buffer are supported by the running hardware.
  68004. * This requires draw buffer supports
  68005. */
  68006. get isSupported(): boolean;
  68007. /**
  68008. * Returns the index of the given texture type in the G-Buffer textures array
  68009. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68010. * @returns the index of the given texture type in the G-Buffer textures array
  68011. */
  68012. getTextureIndex(textureType: number): number;
  68013. /**
  68014. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68015. */
  68016. get enablePosition(): boolean;
  68017. /**
  68018. * Sets whether or not objects positions are enabled for the G buffer.
  68019. */
  68020. set enablePosition(enable: boolean);
  68021. /**
  68022. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68023. */
  68024. get enableVelocity(): boolean;
  68025. /**
  68026. * Sets wether or not objects velocities are enabled for the G buffer.
  68027. */
  68028. set enableVelocity(enable: boolean);
  68029. /**
  68030. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68031. */
  68032. get enableReflectivity(): boolean;
  68033. /**
  68034. * Sets wether or not objects roughness are enabled for the G buffer.
  68035. */
  68036. set enableReflectivity(enable: boolean);
  68037. /**
  68038. * Gets the scene associated with the buffer.
  68039. */
  68040. get scene(): Scene;
  68041. /**
  68042. * Gets the ratio used by the buffer during its creation.
  68043. * How big is the buffer related to the main canvas.
  68044. */
  68045. get ratio(): number;
  68046. /** @hidden */
  68047. static _SceneComponentInitialization: (scene: Scene) => void;
  68048. /**
  68049. * Creates a new G Buffer for the scene
  68050. * @param scene The scene the buffer belongs to
  68051. * @param ratio How big is the buffer related to the main canvas.
  68052. */
  68053. constructor(scene: Scene, ratio?: number);
  68054. /**
  68055. * Checks wether everything is ready to render a submesh to the G buffer.
  68056. * @param subMesh the submesh to check readiness for
  68057. * @param useInstances is the mesh drawn using instance or not
  68058. * @returns true if ready otherwise false
  68059. */
  68060. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68061. /**
  68062. * Gets the current underlying G Buffer.
  68063. * @returns the buffer
  68064. */
  68065. getGBuffer(): MultiRenderTarget;
  68066. /**
  68067. * Gets the number of samples used to render the buffer (anti aliasing).
  68068. */
  68069. get samples(): number;
  68070. /**
  68071. * Sets the number of samples used to render the buffer (anti aliasing).
  68072. */
  68073. set samples(value: number);
  68074. /**
  68075. * Disposes the renderer and frees up associated resources.
  68076. */
  68077. dispose(): void;
  68078. protected _createRenderTargets(): void;
  68079. private _copyBonesTransformationMatrices;
  68080. }
  68081. }
  68082. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68083. import { Nullable } from "babylonjs/types";
  68084. import { Scene } from "babylonjs/scene";
  68085. import { ISceneComponent } from "babylonjs/sceneComponent";
  68086. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68087. module "babylonjs/scene" {
  68088. interface Scene {
  68089. /** @hidden (Backing field) */
  68090. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68091. /**
  68092. * Gets or Sets the current geometry buffer associated to the scene.
  68093. */
  68094. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68095. /**
  68096. * Enables a GeometryBufferRender and associates it with the scene
  68097. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68098. * @returns the GeometryBufferRenderer
  68099. */
  68100. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68101. /**
  68102. * Disables the GeometryBufferRender associated with the scene
  68103. */
  68104. disableGeometryBufferRenderer(): void;
  68105. }
  68106. }
  68107. /**
  68108. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68109. * in several rendering techniques.
  68110. */
  68111. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68112. /**
  68113. * The component name helpful to identify the component in the list of scene components.
  68114. */
  68115. readonly name: string;
  68116. /**
  68117. * The scene the component belongs to.
  68118. */
  68119. scene: Scene;
  68120. /**
  68121. * Creates a new instance of the component for the given scene
  68122. * @param scene Defines the scene to register the component in
  68123. */
  68124. constructor(scene: Scene);
  68125. /**
  68126. * Registers the component in a given scene
  68127. */
  68128. register(): void;
  68129. /**
  68130. * Rebuilds the elements related to this component in case of
  68131. * context lost for instance.
  68132. */
  68133. rebuild(): void;
  68134. /**
  68135. * Disposes the component and the associated ressources
  68136. */
  68137. dispose(): void;
  68138. private _gatherRenderTargets;
  68139. }
  68140. }
  68141. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68142. /** @hidden */
  68143. export var motionBlurPixelShader: {
  68144. name: string;
  68145. shader: string;
  68146. };
  68147. }
  68148. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68149. import { Nullable } from "babylonjs/types";
  68150. import { Camera } from "babylonjs/Cameras/camera";
  68151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68152. import { Scene } from "babylonjs/scene";
  68153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68154. import "babylonjs/Animations/animatable";
  68155. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68156. import "babylonjs/Shaders/motionBlur.fragment";
  68157. import { Engine } from "babylonjs/Engines/engine";
  68158. /**
  68159. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68160. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68161. * As an example, all you have to do is to create the post-process:
  68162. * var mb = new BABYLON.MotionBlurPostProcess(
  68163. * 'mb', // The name of the effect.
  68164. * scene, // The scene containing the objects to blur according to their velocity.
  68165. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68166. * camera // The camera to apply the render pass to.
  68167. * );
  68168. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68169. */
  68170. export class MotionBlurPostProcess extends PostProcess {
  68171. /**
  68172. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68173. */
  68174. motionStrength: number;
  68175. /**
  68176. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68177. */
  68178. get motionBlurSamples(): number;
  68179. /**
  68180. * Sets the number of iterations to be used for motion blur quality
  68181. */
  68182. set motionBlurSamples(samples: number);
  68183. private _motionBlurSamples;
  68184. private _geometryBufferRenderer;
  68185. /**
  68186. * Creates a new instance MotionBlurPostProcess
  68187. * @param name The name of the effect.
  68188. * @param scene The scene containing the objects to blur according to their velocity.
  68189. * @param options The required width/height ratio to downsize to before computing the render pass.
  68190. * @param camera The camera to apply the render pass to.
  68191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68192. * @param engine The engine which the post process will be applied. (default: current engine)
  68193. * @param reusable If the post process can be reused on the same frame. (default: false)
  68194. * @param textureType Type of textures used when performing the post process. (default: 0)
  68195. * @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)
  68196. */
  68197. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68198. /**
  68199. * Excludes the given skinned mesh from computing bones velocities.
  68200. * 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.
  68201. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68202. */
  68203. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68204. /**
  68205. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68206. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68207. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68208. */
  68209. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68210. /**
  68211. * Disposes the post process.
  68212. * @param camera The camera to dispose the post process on.
  68213. */
  68214. dispose(camera?: Camera): void;
  68215. }
  68216. }
  68217. declare module "babylonjs/Shaders/refraction.fragment" {
  68218. /** @hidden */
  68219. export var refractionPixelShader: {
  68220. name: string;
  68221. shader: string;
  68222. };
  68223. }
  68224. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68225. import { Color3 } from "babylonjs/Maths/math.color";
  68226. import { Camera } from "babylonjs/Cameras/camera";
  68227. import { Texture } from "babylonjs/Materials/Textures/texture";
  68228. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68229. import { Engine } from "babylonjs/Engines/engine";
  68230. import "babylonjs/Shaders/refraction.fragment";
  68231. /**
  68232. * Post process which applies a refractin texture
  68233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68234. */
  68235. export class RefractionPostProcess extends PostProcess {
  68236. /** the base color of the refraction (used to taint the rendering) */
  68237. color: Color3;
  68238. /** simulated refraction depth */
  68239. depth: number;
  68240. /** the coefficient of the base color (0 to remove base color tainting) */
  68241. colorLevel: number;
  68242. private _refTexture;
  68243. private _ownRefractionTexture;
  68244. /**
  68245. * Gets or sets the refraction texture
  68246. * Please note that you are responsible for disposing the texture if you set it manually
  68247. */
  68248. get refractionTexture(): Texture;
  68249. set refractionTexture(value: Texture);
  68250. /**
  68251. * Initializes the RefractionPostProcess
  68252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68253. * @param name The name of the effect.
  68254. * @param refractionTextureUrl Url of the refraction texture to use
  68255. * @param color the base color of the refraction (used to taint the rendering)
  68256. * @param depth simulated refraction depth
  68257. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68258. * @param camera The camera to apply the render pass to.
  68259. * @param options The required width/height ratio to downsize to before computing the render pass.
  68260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68261. * @param engine The engine which the post process will be applied. (default: current engine)
  68262. * @param reusable If the post process can be reused on the same frame. (default: false)
  68263. */
  68264. constructor(name: string, refractionTextureUrl: string,
  68265. /** the base color of the refraction (used to taint the rendering) */
  68266. color: Color3,
  68267. /** simulated refraction depth */
  68268. depth: number,
  68269. /** the coefficient of the base color (0 to remove base color tainting) */
  68270. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68271. /**
  68272. * Disposes of the post process
  68273. * @param camera Camera to dispose post process on
  68274. */
  68275. dispose(camera: Camera): void;
  68276. }
  68277. }
  68278. declare module "babylonjs/Shaders/sharpen.fragment" {
  68279. /** @hidden */
  68280. export var sharpenPixelShader: {
  68281. name: string;
  68282. shader: string;
  68283. };
  68284. }
  68285. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68286. import { Nullable } from "babylonjs/types";
  68287. import { Camera } from "babylonjs/Cameras/camera";
  68288. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68289. import "babylonjs/Shaders/sharpen.fragment";
  68290. import { Engine } from "babylonjs/Engines/engine";
  68291. /**
  68292. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68293. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68294. */
  68295. export class SharpenPostProcess extends PostProcess {
  68296. /**
  68297. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68298. */
  68299. colorAmount: number;
  68300. /**
  68301. * How much sharpness should be applied (default: 0.3)
  68302. */
  68303. edgeAmount: number;
  68304. /**
  68305. * Creates a new instance ConvolutionPostProcess
  68306. * @param name The name of the effect.
  68307. * @param options The required width/height ratio to downsize to before computing the render pass.
  68308. * @param camera The camera to apply the render pass to.
  68309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68310. * @param engine The engine which the post process will be applied. (default: current engine)
  68311. * @param reusable If the post process can be reused on the same frame. (default: false)
  68312. * @param textureType Type of textures used when performing the post process. (default: 0)
  68313. * @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)
  68314. */
  68315. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68316. }
  68317. }
  68318. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68319. import { Nullable } from "babylonjs/types";
  68320. import { Camera } from "babylonjs/Cameras/camera";
  68321. import { Engine } from "babylonjs/Engines/engine";
  68322. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68323. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68324. /**
  68325. * PostProcessRenderPipeline
  68326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68327. */
  68328. export class PostProcessRenderPipeline {
  68329. private engine;
  68330. private _renderEffects;
  68331. private _renderEffectsForIsolatedPass;
  68332. /**
  68333. * List of inspectable custom properties (used by the Inspector)
  68334. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68335. */
  68336. inspectableCustomProperties: IInspectable[];
  68337. /**
  68338. * @hidden
  68339. */
  68340. protected _cameras: Camera[];
  68341. /** @hidden */
  68342. _name: string;
  68343. /**
  68344. * Gets pipeline name
  68345. */
  68346. get name(): string;
  68347. /** Gets the list of attached cameras */
  68348. get cameras(): Camera[];
  68349. /**
  68350. * Initializes a PostProcessRenderPipeline
  68351. * @param engine engine to add the pipeline to
  68352. * @param name name of the pipeline
  68353. */
  68354. constructor(engine: Engine, name: string);
  68355. /**
  68356. * Gets the class name
  68357. * @returns "PostProcessRenderPipeline"
  68358. */
  68359. getClassName(): string;
  68360. /**
  68361. * If all the render effects in the pipeline are supported
  68362. */
  68363. get isSupported(): boolean;
  68364. /**
  68365. * Adds an effect to the pipeline
  68366. * @param renderEffect the effect to add
  68367. */
  68368. addEffect(renderEffect: PostProcessRenderEffect): void;
  68369. /** @hidden */
  68370. _rebuild(): void;
  68371. /** @hidden */
  68372. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68373. /** @hidden */
  68374. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68375. /** @hidden */
  68376. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68377. /** @hidden */
  68378. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68379. /** @hidden */
  68380. _attachCameras(cameras: Camera, unique: boolean): void;
  68381. /** @hidden */
  68382. _attachCameras(cameras: Camera[], unique: boolean): void;
  68383. /** @hidden */
  68384. _detachCameras(cameras: Camera): void;
  68385. /** @hidden */
  68386. _detachCameras(cameras: Nullable<Camera[]>): void;
  68387. /** @hidden */
  68388. _update(): void;
  68389. /** @hidden */
  68390. _reset(): void;
  68391. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68392. /**
  68393. * Disposes of the pipeline
  68394. */
  68395. dispose(): void;
  68396. }
  68397. }
  68398. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68399. import { Camera } from "babylonjs/Cameras/camera";
  68400. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68401. /**
  68402. * PostProcessRenderPipelineManager class
  68403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68404. */
  68405. export class PostProcessRenderPipelineManager {
  68406. private _renderPipelines;
  68407. /**
  68408. * Initializes a PostProcessRenderPipelineManager
  68409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68410. */
  68411. constructor();
  68412. /**
  68413. * Gets the list of supported render pipelines
  68414. */
  68415. get supportedPipelines(): PostProcessRenderPipeline[];
  68416. /**
  68417. * Adds a pipeline to the manager
  68418. * @param renderPipeline The pipeline to add
  68419. */
  68420. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68421. /**
  68422. * Attaches a camera to the pipeline
  68423. * @param renderPipelineName The name of the pipeline to attach to
  68424. * @param cameras the camera to attach
  68425. * @param unique if the camera can be attached multiple times to the pipeline
  68426. */
  68427. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68428. /**
  68429. * Detaches a camera from the pipeline
  68430. * @param renderPipelineName The name of the pipeline to detach from
  68431. * @param cameras the camera to detach
  68432. */
  68433. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68434. /**
  68435. * Enables an effect by name on a pipeline
  68436. * @param renderPipelineName the name of the pipeline to enable the effect in
  68437. * @param renderEffectName the name of the effect to enable
  68438. * @param cameras the cameras that the effect should be enabled on
  68439. */
  68440. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68441. /**
  68442. * Disables an effect by name on a pipeline
  68443. * @param renderPipelineName the name of the pipeline to disable the effect in
  68444. * @param renderEffectName the name of the effect to disable
  68445. * @param cameras the cameras that the effect should be disabled on
  68446. */
  68447. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68448. /**
  68449. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68450. */
  68451. update(): void;
  68452. /** @hidden */
  68453. _rebuild(): void;
  68454. /**
  68455. * Disposes of the manager and pipelines
  68456. */
  68457. dispose(): void;
  68458. }
  68459. }
  68460. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68461. import { ISceneComponent } from "babylonjs/sceneComponent";
  68462. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68463. import { Scene } from "babylonjs/scene";
  68464. module "babylonjs/scene" {
  68465. interface Scene {
  68466. /** @hidden (Backing field) */
  68467. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68468. /**
  68469. * Gets the postprocess render pipeline manager
  68470. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68471. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68472. */
  68473. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68474. }
  68475. }
  68476. /**
  68477. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68478. */
  68479. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68480. /**
  68481. * The component name helpfull to identify the component in the list of scene components.
  68482. */
  68483. readonly name: string;
  68484. /**
  68485. * The scene the component belongs to.
  68486. */
  68487. scene: Scene;
  68488. /**
  68489. * Creates a new instance of the component for the given scene
  68490. * @param scene Defines the scene to register the component in
  68491. */
  68492. constructor(scene: Scene);
  68493. /**
  68494. * Registers the component in a given scene
  68495. */
  68496. register(): void;
  68497. /**
  68498. * Rebuilds the elements related to this component in case of
  68499. * context lost for instance.
  68500. */
  68501. rebuild(): void;
  68502. /**
  68503. * Disposes the component and the associated ressources
  68504. */
  68505. dispose(): void;
  68506. private _gatherRenderTargets;
  68507. }
  68508. }
  68509. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68510. import { Nullable } from "babylonjs/types";
  68511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68512. import { Camera } from "babylonjs/Cameras/camera";
  68513. import { IDisposable } from "babylonjs/scene";
  68514. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68515. import { Scene } from "babylonjs/scene";
  68516. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68517. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68518. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68519. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68520. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68521. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68522. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68523. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68524. import { Animation } from "babylonjs/Animations/animation";
  68525. /**
  68526. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68527. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68528. */
  68529. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68530. private _scene;
  68531. private _camerasToBeAttached;
  68532. /**
  68533. * ID of the sharpen post process,
  68534. */
  68535. private readonly SharpenPostProcessId;
  68536. /**
  68537. * @ignore
  68538. * ID of the image processing post process;
  68539. */
  68540. readonly ImageProcessingPostProcessId: string;
  68541. /**
  68542. * @ignore
  68543. * ID of the Fast Approximate Anti-Aliasing post process;
  68544. */
  68545. readonly FxaaPostProcessId: string;
  68546. /**
  68547. * ID of the chromatic aberration post process,
  68548. */
  68549. private readonly ChromaticAberrationPostProcessId;
  68550. /**
  68551. * ID of the grain post process
  68552. */
  68553. private readonly GrainPostProcessId;
  68554. /**
  68555. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68556. */
  68557. sharpen: SharpenPostProcess;
  68558. private _sharpenEffect;
  68559. private bloom;
  68560. /**
  68561. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68562. */
  68563. depthOfField: DepthOfFieldEffect;
  68564. /**
  68565. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68566. */
  68567. fxaa: FxaaPostProcess;
  68568. /**
  68569. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68570. */
  68571. imageProcessing: ImageProcessingPostProcess;
  68572. /**
  68573. * Chromatic aberration post process which will shift rgb colors in the image
  68574. */
  68575. chromaticAberration: ChromaticAberrationPostProcess;
  68576. private _chromaticAberrationEffect;
  68577. /**
  68578. * Grain post process which add noise to the image
  68579. */
  68580. grain: GrainPostProcess;
  68581. private _grainEffect;
  68582. /**
  68583. * Glow post process which adds a glow to emissive areas of the image
  68584. */
  68585. private _glowLayer;
  68586. /**
  68587. * Animations which can be used to tweak settings over a period of time
  68588. */
  68589. animations: Animation[];
  68590. private _imageProcessingConfigurationObserver;
  68591. private _sharpenEnabled;
  68592. private _bloomEnabled;
  68593. private _depthOfFieldEnabled;
  68594. private _depthOfFieldBlurLevel;
  68595. private _fxaaEnabled;
  68596. private _imageProcessingEnabled;
  68597. private _defaultPipelineTextureType;
  68598. private _bloomScale;
  68599. private _chromaticAberrationEnabled;
  68600. private _grainEnabled;
  68601. private _buildAllowed;
  68602. /**
  68603. * Gets active scene
  68604. */
  68605. get scene(): Scene;
  68606. /**
  68607. * Enable or disable the sharpen process from the pipeline
  68608. */
  68609. set sharpenEnabled(enabled: boolean);
  68610. get sharpenEnabled(): boolean;
  68611. private _resizeObserver;
  68612. private _hardwareScaleLevel;
  68613. private _bloomKernel;
  68614. /**
  68615. * Specifies the size of the bloom blur kernel, relative to the final output size
  68616. */
  68617. get bloomKernel(): number;
  68618. set bloomKernel(value: number);
  68619. /**
  68620. * Specifies the weight of the bloom in the final rendering
  68621. */
  68622. private _bloomWeight;
  68623. /**
  68624. * Specifies the luma threshold for the area that will be blurred by the bloom
  68625. */
  68626. private _bloomThreshold;
  68627. private _hdr;
  68628. /**
  68629. * The strength of the bloom.
  68630. */
  68631. set bloomWeight(value: number);
  68632. get bloomWeight(): number;
  68633. /**
  68634. * The strength of the bloom.
  68635. */
  68636. set bloomThreshold(value: number);
  68637. get bloomThreshold(): number;
  68638. /**
  68639. * The scale of the bloom, lower value will provide better performance.
  68640. */
  68641. set bloomScale(value: number);
  68642. get bloomScale(): number;
  68643. /**
  68644. * Enable or disable the bloom from the pipeline
  68645. */
  68646. set bloomEnabled(enabled: boolean);
  68647. get bloomEnabled(): boolean;
  68648. private _rebuildBloom;
  68649. /**
  68650. * If the depth of field is enabled.
  68651. */
  68652. get depthOfFieldEnabled(): boolean;
  68653. set depthOfFieldEnabled(enabled: boolean);
  68654. /**
  68655. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68656. */
  68657. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68658. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68659. /**
  68660. * If the anti aliasing is enabled.
  68661. */
  68662. set fxaaEnabled(enabled: boolean);
  68663. get fxaaEnabled(): boolean;
  68664. private _samples;
  68665. /**
  68666. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68667. */
  68668. set samples(sampleCount: number);
  68669. get samples(): number;
  68670. /**
  68671. * If image processing is enabled.
  68672. */
  68673. set imageProcessingEnabled(enabled: boolean);
  68674. get imageProcessingEnabled(): boolean;
  68675. /**
  68676. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68677. */
  68678. set glowLayerEnabled(enabled: boolean);
  68679. get glowLayerEnabled(): boolean;
  68680. /**
  68681. * Gets the glow layer (or null if not defined)
  68682. */
  68683. get glowLayer(): Nullable<GlowLayer>;
  68684. /**
  68685. * Enable or disable the chromaticAberration process from the pipeline
  68686. */
  68687. set chromaticAberrationEnabled(enabled: boolean);
  68688. get chromaticAberrationEnabled(): boolean;
  68689. /**
  68690. * Enable or disable the grain process from the pipeline
  68691. */
  68692. set grainEnabled(enabled: boolean);
  68693. get grainEnabled(): boolean;
  68694. /**
  68695. * @constructor
  68696. * @param name - The rendering pipeline name (default: "")
  68697. * @param hdr - If high dynamic range textures should be used (default: true)
  68698. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68699. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68700. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68701. */
  68702. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68703. /**
  68704. * Get the class name
  68705. * @returns "DefaultRenderingPipeline"
  68706. */
  68707. getClassName(): string;
  68708. /**
  68709. * Force the compilation of the entire pipeline.
  68710. */
  68711. prepare(): void;
  68712. private _hasCleared;
  68713. private _prevPostProcess;
  68714. private _prevPrevPostProcess;
  68715. private _setAutoClearAndTextureSharing;
  68716. private _depthOfFieldSceneObserver;
  68717. private _buildPipeline;
  68718. private _disposePostProcesses;
  68719. /**
  68720. * Adds a camera to the pipeline
  68721. * @param camera the camera to be added
  68722. */
  68723. addCamera(camera: Camera): void;
  68724. /**
  68725. * Removes a camera from the pipeline
  68726. * @param camera the camera to remove
  68727. */
  68728. removeCamera(camera: Camera): void;
  68729. /**
  68730. * Dispose of the pipeline and stop all post processes
  68731. */
  68732. dispose(): void;
  68733. /**
  68734. * Serialize the rendering pipeline (Used when exporting)
  68735. * @returns the serialized object
  68736. */
  68737. serialize(): any;
  68738. /**
  68739. * Parse the serialized pipeline
  68740. * @param source Source pipeline.
  68741. * @param scene The scene to load the pipeline to.
  68742. * @param rootUrl The URL of the serialized pipeline.
  68743. * @returns An instantiated pipeline from the serialized object.
  68744. */
  68745. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68746. }
  68747. }
  68748. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68749. /** @hidden */
  68750. export var lensHighlightsPixelShader: {
  68751. name: string;
  68752. shader: string;
  68753. };
  68754. }
  68755. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68756. /** @hidden */
  68757. export var depthOfFieldPixelShader: {
  68758. name: string;
  68759. shader: string;
  68760. };
  68761. }
  68762. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68763. import { Camera } from "babylonjs/Cameras/camera";
  68764. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68765. import { Scene } from "babylonjs/scene";
  68766. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68767. import "babylonjs/Shaders/chromaticAberration.fragment";
  68768. import "babylonjs/Shaders/lensHighlights.fragment";
  68769. import "babylonjs/Shaders/depthOfField.fragment";
  68770. /**
  68771. * BABYLON.JS Chromatic Aberration GLSL Shader
  68772. * Author: Olivier Guyot
  68773. * Separates very slightly R, G and B colors on the edges of the screen
  68774. * Inspired by Francois Tarlier & Martins Upitis
  68775. */
  68776. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68777. /**
  68778. * @ignore
  68779. * The chromatic aberration PostProcess id in the pipeline
  68780. */
  68781. LensChromaticAberrationEffect: string;
  68782. /**
  68783. * @ignore
  68784. * The highlights enhancing PostProcess id in the pipeline
  68785. */
  68786. HighlightsEnhancingEffect: string;
  68787. /**
  68788. * @ignore
  68789. * The depth-of-field PostProcess id in the pipeline
  68790. */
  68791. LensDepthOfFieldEffect: string;
  68792. private _scene;
  68793. private _depthTexture;
  68794. private _grainTexture;
  68795. private _chromaticAberrationPostProcess;
  68796. private _highlightsPostProcess;
  68797. private _depthOfFieldPostProcess;
  68798. private _edgeBlur;
  68799. private _grainAmount;
  68800. private _chromaticAberration;
  68801. private _distortion;
  68802. private _highlightsGain;
  68803. private _highlightsThreshold;
  68804. private _dofDistance;
  68805. private _dofAperture;
  68806. private _dofDarken;
  68807. private _dofPentagon;
  68808. private _blurNoise;
  68809. /**
  68810. * @constructor
  68811. *
  68812. * Effect parameters are as follow:
  68813. * {
  68814. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68815. * edge_blur: number; // from 0 to x (1 for realism)
  68816. * distortion: number; // from 0 to x (1 for realism)
  68817. * grain_amount: number; // from 0 to 1
  68818. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68819. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68820. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68821. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68822. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68823. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68824. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68825. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68826. * }
  68827. * Note: if an effect parameter is unset, effect is disabled
  68828. *
  68829. * @param name The rendering pipeline name
  68830. * @param parameters - An object containing all parameters (see above)
  68831. * @param scene The scene linked to this pipeline
  68832. * @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)
  68833. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68834. */
  68835. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68836. /**
  68837. * Get the class name
  68838. * @returns "LensRenderingPipeline"
  68839. */
  68840. getClassName(): string;
  68841. /**
  68842. * Gets associated scene
  68843. */
  68844. get scene(): Scene;
  68845. /**
  68846. * Gets or sets the edge blur
  68847. */
  68848. get edgeBlur(): number;
  68849. set edgeBlur(value: number);
  68850. /**
  68851. * Gets or sets the grain amount
  68852. */
  68853. get grainAmount(): number;
  68854. set grainAmount(value: number);
  68855. /**
  68856. * Gets or sets the chromatic aberration amount
  68857. */
  68858. get chromaticAberration(): number;
  68859. set chromaticAberration(value: number);
  68860. /**
  68861. * Gets or sets the depth of field aperture
  68862. */
  68863. get dofAperture(): number;
  68864. set dofAperture(value: number);
  68865. /**
  68866. * Gets or sets the edge distortion
  68867. */
  68868. get edgeDistortion(): number;
  68869. set edgeDistortion(value: number);
  68870. /**
  68871. * Gets or sets the depth of field distortion
  68872. */
  68873. get dofDistortion(): number;
  68874. set dofDistortion(value: number);
  68875. /**
  68876. * Gets or sets the darken out of focus amount
  68877. */
  68878. get darkenOutOfFocus(): number;
  68879. set darkenOutOfFocus(value: number);
  68880. /**
  68881. * Gets or sets a boolean indicating if blur noise is enabled
  68882. */
  68883. get blurNoise(): boolean;
  68884. set blurNoise(value: boolean);
  68885. /**
  68886. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68887. */
  68888. get pentagonBokeh(): boolean;
  68889. set pentagonBokeh(value: boolean);
  68890. /**
  68891. * Gets or sets the highlight grain amount
  68892. */
  68893. get highlightsGain(): number;
  68894. set highlightsGain(value: number);
  68895. /**
  68896. * Gets or sets the highlight threshold
  68897. */
  68898. get highlightsThreshold(): number;
  68899. set highlightsThreshold(value: number);
  68900. /**
  68901. * Sets the amount of blur at the edges
  68902. * @param amount blur amount
  68903. */
  68904. setEdgeBlur(amount: number): void;
  68905. /**
  68906. * Sets edge blur to 0
  68907. */
  68908. disableEdgeBlur(): void;
  68909. /**
  68910. * Sets the amout of grain
  68911. * @param amount Amount of grain
  68912. */
  68913. setGrainAmount(amount: number): void;
  68914. /**
  68915. * Set grain amount to 0
  68916. */
  68917. disableGrain(): void;
  68918. /**
  68919. * Sets the chromatic aberration amount
  68920. * @param amount amount of chromatic aberration
  68921. */
  68922. setChromaticAberration(amount: number): void;
  68923. /**
  68924. * Sets chromatic aberration amount to 0
  68925. */
  68926. disableChromaticAberration(): void;
  68927. /**
  68928. * Sets the EdgeDistortion amount
  68929. * @param amount amount of EdgeDistortion
  68930. */
  68931. setEdgeDistortion(amount: number): void;
  68932. /**
  68933. * Sets edge distortion to 0
  68934. */
  68935. disableEdgeDistortion(): void;
  68936. /**
  68937. * Sets the FocusDistance amount
  68938. * @param amount amount of FocusDistance
  68939. */
  68940. setFocusDistance(amount: number): void;
  68941. /**
  68942. * Disables depth of field
  68943. */
  68944. disableDepthOfField(): void;
  68945. /**
  68946. * Sets the Aperture amount
  68947. * @param amount amount of Aperture
  68948. */
  68949. setAperture(amount: number): void;
  68950. /**
  68951. * Sets the DarkenOutOfFocus amount
  68952. * @param amount amount of DarkenOutOfFocus
  68953. */
  68954. setDarkenOutOfFocus(amount: number): void;
  68955. private _pentagonBokehIsEnabled;
  68956. /**
  68957. * Creates a pentagon bokeh effect
  68958. */
  68959. enablePentagonBokeh(): void;
  68960. /**
  68961. * Disables the pentagon bokeh effect
  68962. */
  68963. disablePentagonBokeh(): void;
  68964. /**
  68965. * Enables noise blur
  68966. */
  68967. enableNoiseBlur(): void;
  68968. /**
  68969. * Disables noise blur
  68970. */
  68971. disableNoiseBlur(): void;
  68972. /**
  68973. * Sets the HighlightsGain amount
  68974. * @param amount amount of HighlightsGain
  68975. */
  68976. setHighlightsGain(amount: number): void;
  68977. /**
  68978. * Sets the HighlightsThreshold amount
  68979. * @param amount amount of HighlightsThreshold
  68980. */
  68981. setHighlightsThreshold(amount: number): void;
  68982. /**
  68983. * Disables highlights
  68984. */
  68985. disableHighlights(): void;
  68986. /**
  68987. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68988. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68989. */
  68990. dispose(disableDepthRender?: boolean): void;
  68991. private _createChromaticAberrationPostProcess;
  68992. private _createHighlightsPostProcess;
  68993. private _createDepthOfFieldPostProcess;
  68994. private _createGrainTexture;
  68995. }
  68996. }
  68997. declare module "babylonjs/Shaders/ssao2.fragment" {
  68998. /** @hidden */
  68999. export var ssao2PixelShader: {
  69000. name: string;
  69001. shader: string;
  69002. };
  69003. }
  69004. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69005. /** @hidden */
  69006. export var ssaoCombinePixelShader: {
  69007. name: string;
  69008. shader: string;
  69009. };
  69010. }
  69011. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69012. import { Camera } from "babylonjs/Cameras/camera";
  69013. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69014. import { Scene } from "babylonjs/scene";
  69015. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69016. import "babylonjs/Shaders/ssao2.fragment";
  69017. import "babylonjs/Shaders/ssaoCombine.fragment";
  69018. /**
  69019. * Render pipeline to produce ssao effect
  69020. */
  69021. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69022. /**
  69023. * @ignore
  69024. * The PassPostProcess id in the pipeline that contains the original scene color
  69025. */
  69026. SSAOOriginalSceneColorEffect: string;
  69027. /**
  69028. * @ignore
  69029. * The SSAO PostProcess id in the pipeline
  69030. */
  69031. SSAORenderEffect: string;
  69032. /**
  69033. * @ignore
  69034. * The horizontal blur PostProcess id in the pipeline
  69035. */
  69036. SSAOBlurHRenderEffect: string;
  69037. /**
  69038. * @ignore
  69039. * The vertical blur PostProcess id in the pipeline
  69040. */
  69041. SSAOBlurVRenderEffect: string;
  69042. /**
  69043. * @ignore
  69044. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69045. */
  69046. SSAOCombineRenderEffect: string;
  69047. /**
  69048. * The output strength of the SSAO post-process. Default value is 1.0.
  69049. */
  69050. totalStrength: number;
  69051. /**
  69052. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69053. */
  69054. maxZ: number;
  69055. /**
  69056. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69057. */
  69058. minZAspect: number;
  69059. private _samples;
  69060. /**
  69061. * Number of samples used for the SSAO calculations. Default value is 8
  69062. */
  69063. set samples(n: number);
  69064. get samples(): number;
  69065. private _textureSamples;
  69066. /**
  69067. * Number of samples to use for antialiasing
  69068. */
  69069. set textureSamples(n: number);
  69070. get textureSamples(): number;
  69071. /**
  69072. * Ratio object used for SSAO ratio and blur ratio
  69073. */
  69074. private _ratio;
  69075. /**
  69076. * Dynamically generated sphere sampler.
  69077. */
  69078. private _sampleSphere;
  69079. /**
  69080. * Blur filter offsets
  69081. */
  69082. private _samplerOffsets;
  69083. private _expensiveBlur;
  69084. /**
  69085. * If bilateral blur should be used
  69086. */
  69087. set expensiveBlur(b: boolean);
  69088. get expensiveBlur(): boolean;
  69089. /**
  69090. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69091. */
  69092. radius: number;
  69093. /**
  69094. * The base color of the SSAO post-process
  69095. * The final result is "base + ssao" between [0, 1]
  69096. */
  69097. base: number;
  69098. /**
  69099. * Support test.
  69100. */
  69101. static get IsSupported(): boolean;
  69102. private _scene;
  69103. private _depthTexture;
  69104. private _normalTexture;
  69105. private _randomTexture;
  69106. private _originalColorPostProcess;
  69107. private _ssaoPostProcess;
  69108. private _blurHPostProcess;
  69109. private _blurVPostProcess;
  69110. private _ssaoCombinePostProcess;
  69111. /**
  69112. * Gets active scene
  69113. */
  69114. get scene(): Scene;
  69115. /**
  69116. * @constructor
  69117. * @param name The rendering pipeline name
  69118. * @param scene The scene linked to this pipeline
  69119. * @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 }
  69120. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69121. */
  69122. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69123. /**
  69124. * Get the class name
  69125. * @returns "SSAO2RenderingPipeline"
  69126. */
  69127. getClassName(): string;
  69128. /**
  69129. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69130. */
  69131. dispose(disableGeometryBufferRenderer?: boolean): void;
  69132. private _createBlurPostProcess;
  69133. /** @hidden */
  69134. _rebuild(): void;
  69135. private _bits;
  69136. private _radicalInverse_VdC;
  69137. private _hammersley;
  69138. private _hemisphereSample_uniform;
  69139. private _generateHemisphere;
  69140. private _createSSAOPostProcess;
  69141. private _createSSAOCombinePostProcess;
  69142. private _createRandomTexture;
  69143. /**
  69144. * Serialize the rendering pipeline (Used when exporting)
  69145. * @returns the serialized object
  69146. */
  69147. serialize(): any;
  69148. /**
  69149. * Parse the serialized pipeline
  69150. * @param source Source pipeline.
  69151. * @param scene The scene to load the pipeline to.
  69152. * @param rootUrl The URL of the serialized pipeline.
  69153. * @returns An instantiated pipeline from the serialized object.
  69154. */
  69155. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69156. }
  69157. }
  69158. declare module "babylonjs/Shaders/ssao.fragment" {
  69159. /** @hidden */
  69160. export var ssaoPixelShader: {
  69161. name: string;
  69162. shader: string;
  69163. };
  69164. }
  69165. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69166. import { Camera } from "babylonjs/Cameras/camera";
  69167. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69168. import { Scene } from "babylonjs/scene";
  69169. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69170. import "babylonjs/Shaders/ssao.fragment";
  69171. import "babylonjs/Shaders/ssaoCombine.fragment";
  69172. /**
  69173. * Render pipeline to produce ssao effect
  69174. */
  69175. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69176. /**
  69177. * @ignore
  69178. * The PassPostProcess id in the pipeline that contains the original scene color
  69179. */
  69180. SSAOOriginalSceneColorEffect: string;
  69181. /**
  69182. * @ignore
  69183. * The SSAO PostProcess id in the pipeline
  69184. */
  69185. SSAORenderEffect: string;
  69186. /**
  69187. * @ignore
  69188. * The horizontal blur PostProcess id in the pipeline
  69189. */
  69190. SSAOBlurHRenderEffect: string;
  69191. /**
  69192. * @ignore
  69193. * The vertical blur PostProcess id in the pipeline
  69194. */
  69195. SSAOBlurVRenderEffect: string;
  69196. /**
  69197. * @ignore
  69198. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69199. */
  69200. SSAOCombineRenderEffect: string;
  69201. /**
  69202. * The output strength of the SSAO post-process. Default value is 1.0.
  69203. */
  69204. totalStrength: number;
  69205. /**
  69206. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69207. */
  69208. radius: number;
  69209. /**
  69210. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69211. * Must not be equal to fallOff and superior to fallOff.
  69212. * Default value is 0.0075
  69213. */
  69214. area: number;
  69215. /**
  69216. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69217. * Must not be equal to area and inferior to area.
  69218. * Default value is 0.000001
  69219. */
  69220. fallOff: number;
  69221. /**
  69222. * The base color of the SSAO post-process
  69223. * The final result is "base + ssao" between [0, 1]
  69224. */
  69225. base: number;
  69226. private _scene;
  69227. private _depthTexture;
  69228. private _randomTexture;
  69229. private _originalColorPostProcess;
  69230. private _ssaoPostProcess;
  69231. private _blurHPostProcess;
  69232. private _blurVPostProcess;
  69233. private _ssaoCombinePostProcess;
  69234. private _firstUpdate;
  69235. /**
  69236. * Gets active scene
  69237. */
  69238. get scene(): Scene;
  69239. /**
  69240. * @constructor
  69241. * @param name - The rendering pipeline name
  69242. * @param scene - The scene linked to this pipeline
  69243. * @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 }
  69244. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69245. */
  69246. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69247. /**
  69248. * Get the class name
  69249. * @returns "SSAORenderingPipeline"
  69250. */
  69251. getClassName(): string;
  69252. /**
  69253. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69254. */
  69255. dispose(disableDepthRender?: boolean): void;
  69256. private _createBlurPostProcess;
  69257. /** @hidden */
  69258. _rebuild(): void;
  69259. private _createSSAOPostProcess;
  69260. private _createSSAOCombinePostProcess;
  69261. private _createRandomTexture;
  69262. }
  69263. }
  69264. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69265. /** @hidden */
  69266. export var screenSpaceReflectionPixelShader: {
  69267. name: string;
  69268. shader: string;
  69269. };
  69270. }
  69271. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69272. import { Nullable } from "babylonjs/types";
  69273. import { Camera } from "babylonjs/Cameras/camera";
  69274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69275. import { Scene } from "babylonjs/scene";
  69276. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69277. import { Engine } from "babylonjs/Engines/engine";
  69278. /**
  69279. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69280. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69281. */
  69282. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69283. /**
  69284. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69285. */
  69286. threshold: number;
  69287. /**
  69288. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69289. */
  69290. strength: number;
  69291. /**
  69292. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69293. */
  69294. reflectionSpecularFalloffExponent: number;
  69295. /**
  69296. * 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]
  69297. */
  69298. step: number;
  69299. /**
  69300. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69301. */
  69302. roughnessFactor: number;
  69303. private _geometryBufferRenderer;
  69304. private _enableSmoothReflections;
  69305. private _reflectionSamples;
  69306. private _smoothSteps;
  69307. /**
  69308. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69309. * @param name The name of the effect.
  69310. * @param scene The scene containing the objects to calculate reflections.
  69311. * @param options The required width/height ratio to downsize to before computing the render pass.
  69312. * @param camera The camera to apply the render pass to.
  69313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69314. * @param engine The engine which the post process will be applied. (default: current engine)
  69315. * @param reusable If the post process can be reused on the same frame. (default: false)
  69316. * @param textureType Type of textures used when performing the post process. (default: 0)
  69317. * @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)
  69318. */
  69319. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69320. /**
  69321. * Gets wether or not smoothing reflections is enabled.
  69322. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69323. */
  69324. get enableSmoothReflections(): boolean;
  69325. /**
  69326. * Sets wether or not smoothing reflections is enabled.
  69327. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69328. */
  69329. set enableSmoothReflections(enabled: boolean);
  69330. /**
  69331. * Gets the number of samples taken while computing reflections. More samples count is high,
  69332. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69333. */
  69334. get reflectionSamples(): number;
  69335. /**
  69336. * Sets the number of samples taken while computing reflections. More samples count is high,
  69337. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69338. */
  69339. set reflectionSamples(samples: number);
  69340. /**
  69341. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69342. * more the post-process will require GPU power and can generate a drop in FPS.
  69343. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69344. */
  69345. get smoothSteps(): number;
  69346. set smoothSteps(steps: number);
  69347. private _updateEffectDefines;
  69348. }
  69349. }
  69350. declare module "babylonjs/Shaders/standard.fragment" {
  69351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69352. /** @hidden */
  69353. export var standardPixelShader: {
  69354. name: string;
  69355. shader: string;
  69356. };
  69357. }
  69358. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69359. import { Nullable } from "babylonjs/types";
  69360. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69361. import { Camera } from "babylonjs/Cameras/camera";
  69362. import { Texture } from "babylonjs/Materials/Textures/texture";
  69363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69364. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69365. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69366. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69367. import { IDisposable } from "babylonjs/scene";
  69368. import { SpotLight } from "babylonjs/Lights/spotLight";
  69369. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69370. import { Scene } from "babylonjs/scene";
  69371. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69372. import { Animation } from "babylonjs/Animations/animation";
  69373. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69374. import "babylonjs/Shaders/standard.fragment";
  69375. /**
  69376. * Standard rendering pipeline
  69377. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69378. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69379. */
  69380. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69381. /**
  69382. * Public members
  69383. */
  69384. /**
  69385. * Post-process which contains the original scene color before the pipeline applies all the effects
  69386. */
  69387. originalPostProcess: Nullable<PostProcess>;
  69388. /**
  69389. * Post-process used to down scale an image x4
  69390. */
  69391. downSampleX4PostProcess: Nullable<PostProcess>;
  69392. /**
  69393. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69394. */
  69395. brightPassPostProcess: Nullable<PostProcess>;
  69396. /**
  69397. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69398. */
  69399. blurHPostProcesses: PostProcess[];
  69400. /**
  69401. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69402. */
  69403. blurVPostProcesses: PostProcess[];
  69404. /**
  69405. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69406. */
  69407. textureAdderPostProcess: Nullable<PostProcess>;
  69408. /**
  69409. * Post-process used to create volumetric lighting effect
  69410. */
  69411. volumetricLightPostProcess: Nullable<PostProcess>;
  69412. /**
  69413. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69414. */
  69415. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69416. /**
  69417. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69418. */
  69419. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69420. /**
  69421. * Post-process used to merge the volumetric light effect and the real scene color
  69422. */
  69423. volumetricLightMergePostProces: Nullable<PostProcess>;
  69424. /**
  69425. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69426. */
  69427. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69428. /**
  69429. * Base post-process used to calculate the average luminance of the final image for HDR
  69430. */
  69431. luminancePostProcess: Nullable<PostProcess>;
  69432. /**
  69433. * Post-processes used to create down sample post-processes in order to get
  69434. * the average luminance of the final image for HDR
  69435. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69436. */
  69437. luminanceDownSamplePostProcesses: PostProcess[];
  69438. /**
  69439. * Post-process used to create a HDR effect (light adaptation)
  69440. */
  69441. hdrPostProcess: Nullable<PostProcess>;
  69442. /**
  69443. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69444. */
  69445. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69446. /**
  69447. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69448. */
  69449. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69450. /**
  69451. * Post-process used to merge the final HDR post-process and the real scene color
  69452. */
  69453. hdrFinalPostProcess: Nullable<PostProcess>;
  69454. /**
  69455. * Post-process used to create a lens flare effect
  69456. */
  69457. lensFlarePostProcess: Nullable<PostProcess>;
  69458. /**
  69459. * Post-process that merges the result of the lens flare post-process and the real scene color
  69460. */
  69461. lensFlareComposePostProcess: Nullable<PostProcess>;
  69462. /**
  69463. * Post-process used to create a motion blur effect
  69464. */
  69465. motionBlurPostProcess: Nullable<PostProcess>;
  69466. /**
  69467. * Post-process used to create a depth of field effect
  69468. */
  69469. depthOfFieldPostProcess: Nullable<PostProcess>;
  69470. /**
  69471. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69472. */
  69473. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69474. /**
  69475. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69476. */
  69477. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69478. /**
  69479. * Represents the brightness threshold in order to configure the illuminated surfaces
  69480. */
  69481. brightThreshold: number;
  69482. /**
  69483. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69484. */
  69485. blurWidth: number;
  69486. /**
  69487. * Sets if the blur for highlighted surfaces must be only horizontal
  69488. */
  69489. horizontalBlur: boolean;
  69490. /**
  69491. * Gets the overall exposure used by the pipeline
  69492. */
  69493. get exposure(): number;
  69494. /**
  69495. * Sets the overall exposure used by the pipeline
  69496. */
  69497. set exposure(value: number);
  69498. /**
  69499. * Texture used typically to simulate "dirty" on camera lens
  69500. */
  69501. lensTexture: Nullable<Texture>;
  69502. /**
  69503. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69504. */
  69505. volumetricLightCoefficient: number;
  69506. /**
  69507. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69508. */
  69509. volumetricLightPower: number;
  69510. /**
  69511. * Used the set the blur intensity to smooth the volumetric lights
  69512. */
  69513. volumetricLightBlurScale: number;
  69514. /**
  69515. * Light (spot or directional) used to generate the volumetric lights rays
  69516. * The source light must have a shadow generate so the pipeline can get its
  69517. * depth map
  69518. */
  69519. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69520. /**
  69521. * For eye adaptation, represents the minimum luminance the eye can see
  69522. */
  69523. hdrMinimumLuminance: number;
  69524. /**
  69525. * For eye adaptation, represents the decrease luminance speed
  69526. */
  69527. hdrDecreaseRate: number;
  69528. /**
  69529. * For eye adaptation, represents the increase luminance speed
  69530. */
  69531. hdrIncreaseRate: number;
  69532. /**
  69533. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69534. */
  69535. get hdrAutoExposure(): boolean;
  69536. /**
  69537. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69538. */
  69539. set hdrAutoExposure(value: boolean);
  69540. /**
  69541. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69542. */
  69543. lensColorTexture: Nullable<Texture>;
  69544. /**
  69545. * The overall strengh for the lens flare effect
  69546. */
  69547. lensFlareStrength: number;
  69548. /**
  69549. * Dispersion coefficient for lens flare ghosts
  69550. */
  69551. lensFlareGhostDispersal: number;
  69552. /**
  69553. * Main lens flare halo width
  69554. */
  69555. lensFlareHaloWidth: number;
  69556. /**
  69557. * Based on the lens distortion effect, defines how much the lens flare result
  69558. * is distorted
  69559. */
  69560. lensFlareDistortionStrength: number;
  69561. /**
  69562. * Configures the blur intensity used for for lens flare (halo)
  69563. */
  69564. lensFlareBlurWidth: number;
  69565. /**
  69566. * Lens star texture must be used to simulate rays on the flares and is available
  69567. * in the documentation
  69568. */
  69569. lensStarTexture: Nullable<Texture>;
  69570. /**
  69571. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69572. * flare effect by taking account of the dirt texture
  69573. */
  69574. lensFlareDirtTexture: Nullable<Texture>;
  69575. /**
  69576. * Represents the focal length for the depth of field effect
  69577. */
  69578. depthOfFieldDistance: number;
  69579. /**
  69580. * Represents the blur intensity for the blurred part of the depth of field effect
  69581. */
  69582. depthOfFieldBlurWidth: number;
  69583. /**
  69584. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69585. */
  69586. get motionStrength(): number;
  69587. /**
  69588. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69589. */
  69590. set motionStrength(strength: number);
  69591. /**
  69592. * Gets wether or not the motion blur post-process is object based or screen based.
  69593. */
  69594. get objectBasedMotionBlur(): boolean;
  69595. /**
  69596. * Sets wether or not the motion blur post-process should be object based or screen based
  69597. */
  69598. set objectBasedMotionBlur(value: boolean);
  69599. /**
  69600. * List of animations for the pipeline (IAnimatable implementation)
  69601. */
  69602. animations: Animation[];
  69603. /**
  69604. * Private members
  69605. */
  69606. private _scene;
  69607. private _currentDepthOfFieldSource;
  69608. private _basePostProcess;
  69609. private _fixedExposure;
  69610. private _currentExposure;
  69611. private _hdrAutoExposure;
  69612. private _hdrCurrentLuminance;
  69613. private _motionStrength;
  69614. private _isObjectBasedMotionBlur;
  69615. private _floatTextureType;
  69616. private _camerasToBeAttached;
  69617. private _ratio;
  69618. private _bloomEnabled;
  69619. private _depthOfFieldEnabled;
  69620. private _vlsEnabled;
  69621. private _lensFlareEnabled;
  69622. private _hdrEnabled;
  69623. private _motionBlurEnabled;
  69624. private _fxaaEnabled;
  69625. private _screenSpaceReflectionsEnabled;
  69626. private _motionBlurSamples;
  69627. private _volumetricLightStepsCount;
  69628. private _samples;
  69629. /**
  69630. * @ignore
  69631. * Specifies if the bloom pipeline is enabled
  69632. */
  69633. get BloomEnabled(): boolean;
  69634. set BloomEnabled(enabled: boolean);
  69635. /**
  69636. * @ignore
  69637. * Specifies if the depth of field pipeline is enabed
  69638. */
  69639. get DepthOfFieldEnabled(): boolean;
  69640. set DepthOfFieldEnabled(enabled: boolean);
  69641. /**
  69642. * @ignore
  69643. * Specifies if the lens flare pipeline is enabed
  69644. */
  69645. get LensFlareEnabled(): boolean;
  69646. set LensFlareEnabled(enabled: boolean);
  69647. /**
  69648. * @ignore
  69649. * Specifies if the HDR pipeline is enabled
  69650. */
  69651. get HDREnabled(): boolean;
  69652. set HDREnabled(enabled: boolean);
  69653. /**
  69654. * @ignore
  69655. * Specifies if the volumetric lights scattering effect is enabled
  69656. */
  69657. get VLSEnabled(): boolean;
  69658. set VLSEnabled(enabled: boolean);
  69659. /**
  69660. * @ignore
  69661. * Specifies if the motion blur effect is enabled
  69662. */
  69663. get MotionBlurEnabled(): boolean;
  69664. set MotionBlurEnabled(enabled: boolean);
  69665. /**
  69666. * Specifies if anti-aliasing is enabled
  69667. */
  69668. get fxaaEnabled(): boolean;
  69669. set fxaaEnabled(enabled: boolean);
  69670. /**
  69671. * Specifies if screen space reflections are enabled.
  69672. */
  69673. get screenSpaceReflectionsEnabled(): boolean;
  69674. set screenSpaceReflectionsEnabled(enabled: boolean);
  69675. /**
  69676. * Specifies the number of steps used to calculate the volumetric lights
  69677. * Typically in interval [50, 200]
  69678. */
  69679. get volumetricLightStepsCount(): number;
  69680. set volumetricLightStepsCount(count: number);
  69681. /**
  69682. * Specifies the number of samples used for the motion blur effect
  69683. * Typically in interval [16, 64]
  69684. */
  69685. get motionBlurSamples(): number;
  69686. set motionBlurSamples(samples: number);
  69687. /**
  69688. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69689. */
  69690. get samples(): number;
  69691. set samples(sampleCount: number);
  69692. /**
  69693. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69694. * @constructor
  69695. * @param name The rendering pipeline name
  69696. * @param scene The scene linked to this pipeline
  69697. * @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)
  69698. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69699. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69700. */
  69701. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69702. private _buildPipeline;
  69703. private _createDownSampleX4PostProcess;
  69704. private _createBrightPassPostProcess;
  69705. private _createBlurPostProcesses;
  69706. private _createTextureAdderPostProcess;
  69707. private _createVolumetricLightPostProcess;
  69708. private _createLuminancePostProcesses;
  69709. private _createHdrPostProcess;
  69710. private _createLensFlarePostProcess;
  69711. private _createDepthOfFieldPostProcess;
  69712. private _createMotionBlurPostProcess;
  69713. private _getDepthTexture;
  69714. private _disposePostProcesses;
  69715. /**
  69716. * Dispose of the pipeline and stop all post processes
  69717. */
  69718. dispose(): void;
  69719. /**
  69720. * Serialize the rendering pipeline (Used when exporting)
  69721. * @returns the serialized object
  69722. */
  69723. serialize(): any;
  69724. /**
  69725. * Parse the serialized pipeline
  69726. * @param source Source pipeline.
  69727. * @param scene The scene to load the pipeline to.
  69728. * @param rootUrl The URL of the serialized pipeline.
  69729. * @returns An instantiated pipeline from the serialized object.
  69730. */
  69731. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69732. /**
  69733. * Luminance steps
  69734. */
  69735. static LuminanceSteps: number;
  69736. }
  69737. }
  69738. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69739. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69740. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69741. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69742. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69743. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69744. }
  69745. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69746. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69747. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69749. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69750. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69751. }
  69752. declare module "babylonjs/Shaders/tonemap.fragment" {
  69753. /** @hidden */
  69754. export var tonemapPixelShader: {
  69755. name: string;
  69756. shader: string;
  69757. };
  69758. }
  69759. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69760. import { Camera } from "babylonjs/Cameras/camera";
  69761. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69762. import "babylonjs/Shaders/tonemap.fragment";
  69763. import { Engine } from "babylonjs/Engines/engine";
  69764. /** Defines operator used for tonemapping */
  69765. export enum TonemappingOperator {
  69766. /** Hable */
  69767. Hable = 0,
  69768. /** Reinhard */
  69769. Reinhard = 1,
  69770. /** HejiDawson */
  69771. HejiDawson = 2,
  69772. /** Photographic */
  69773. Photographic = 3
  69774. }
  69775. /**
  69776. * Defines a post process to apply tone mapping
  69777. */
  69778. export class TonemapPostProcess extends PostProcess {
  69779. private _operator;
  69780. /** Defines the required exposure adjustement */
  69781. exposureAdjustment: number;
  69782. /**
  69783. * Creates a new TonemapPostProcess
  69784. * @param name defines the name of the postprocess
  69785. * @param _operator defines the operator to use
  69786. * @param exposureAdjustment defines the required exposure adjustement
  69787. * @param camera defines the camera to use (can be null)
  69788. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69789. * @param engine defines the hosting engine (can be ignore if camera is set)
  69790. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69791. */
  69792. constructor(name: string, _operator: TonemappingOperator,
  69793. /** Defines the required exposure adjustement */
  69794. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69795. }
  69796. }
  69797. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69798. /** @hidden */
  69799. export var volumetricLightScatteringPixelShader: {
  69800. name: string;
  69801. shader: string;
  69802. };
  69803. }
  69804. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69805. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69806. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69807. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69808. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69809. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69810. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69811. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69812. /** @hidden */
  69813. export var volumetricLightScatteringPassVertexShader: {
  69814. name: string;
  69815. shader: string;
  69816. };
  69817. }
  69818. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69819. /** @hidden */
  69820. export var volumetricLightScatteringPassPixelShader: {
  69821. name: string;
  69822. shader: string;
  69823. };
  69824. }
  69825. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69826. import { Vector3 } from "babylonjs/Maths/math.vector";
  69827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69828. import { Mesh } from "babylonjs/Meshes/mesh";
  69829. import { Camera } from "babylonjs/Cameras/camera";
  69830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69831. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69832. import { Scene } from "babylonjs/scene";
  69833. import "babylonjs/Meshes/Builders/planeBuilder";
  69834. import "babylonjs/Shaders/depth.vertex";
  69835. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69836. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69837. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69838. import { Engine } from "babylonjs/Engines/engine";
  69839. /**
  69840. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69841. */
  69842. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69843. private _volumetricLightScatteringPass;
  69844. private _volumetricLightScatteringRTT;
  69845. private _viewPort;
  69846. private _screenCoordinates;
  69847. private _cachedDefines;
  69848. /**
  69849. * If not undefined, the mesh position is computed from the attached node position
  69850. */
  69851. attachedNode: {
  69852. position: Vector3;
  69853. };
  69854. /**
  69855. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69856. */
  69857. customMeshPosition: Vector3;
  69858. /**
  69859. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69860. */
  69861. useCustomMeshPosition: boolean;
  69862. /**
  69863. * If the post-process should inverse the light scattering direction
  69864. */
  69865. invert: boolean;
  69866. /**
  69867. * The internal mesh used by the post-process
  69868. */
  69869. mesh: Mesh;
  69870. /**
  69871. * @hidden
  69872. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69873. */
  69874. get useDiffuseColor(): boolean;
  69875. set useDiffuseColor(useDiffuseColor: boolean);
  69876. /**
  69877. * Array containing the excluded meshes not rendered in the internal pass
  69878. */
  69879. excludedMeshes: AbstractMesh[];
  69880. /**
  69881. * Controls the overall intensity of the post-process
  69882. */
  69883. exposure: number;
  69884. /**
  69885. * Dissipates each sample's contribution in range [0, 1]
  69886. */
  69887. decay: number;
  69888. /**
  69889. * Controls the overall intensity of each sample
  69890. */
  69891. weight: number;
  69892. /**
  69893. * Controls the density of each sample
  69894. */
  69895. density: number;
  69896. /**
  69897. * @constructor
  69898. * @param name The post-process name
  69899. * @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)
  69900. * @param camera The camera that the post-process will be attached to
  69901. * @param mesh The mesh used to create the light scattering
  69902. * @param samples The post-process quality, default 100
  69903. * @param samplingModeThe post-process filtering mode
  69904. * @param engine The babylon engine
  69905. * @param reusable If the post-process is reusable
  69906. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69907. */
  69908. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69909. /**
  69910. * Returns the string "VolumetricLightScatteringPostProcess"
  69911. * @returns "VolumetricLightScatteringPostProcess"
  69912. */
  69913. getClassName(): string;
  69914. private _isReady;
  69915. /**
  69916. * Sets the new light position for light scattering effect
  69917. * @param position The new custom light position
  69918. */
  69919. setCustomMeshPosition(position: Vector3): void;
  69920. /**
  69921. * Returns the light position for light scattering effect
  69922. * @return Vector3 The custom light position
  69923. */
  69924. getCustomMeshPosition(): Vector3;
  69925. /**
  69926. * Disposes the internal assets and detaches the post-process from the camera
  69927. */
  69928. dispose(camera: Camera): void;
  69929. /**
  69930. * Returns the render target texture used by the post-process
  69931. * @return the render target texture used by the post-process
  69932. */
  69933. getPass(): RenderTargetTexture;
  69934. private _meshExcluded;
  69935. private _createPass;
  69936. private _updateMeshScreenCoordinates;
  69937. /**
  69938. * Creates a default mesh for the Volumeric Light Scattering post-process
  69939. * @param name The mesh name
  69940. * @param scene The scene where to create the mesh
  69941. * @return the default mesh
  69942. */
  69943. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69944. }
  69945. }
  69946. declare module "babylonjs/PostProcesses/index" {
  69947. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69948. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69949. export * from "babylonjs/PostProcesses/bloomEffect";
  69950. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69951. export * from "babylonjs/PostProcesses/blurPostProcess";
  69952. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69953. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69954. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69955. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69956. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69957. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69958. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69959. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69960. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69961. export * from "babylonjs/PostProcesses/filterPostProcess";
  69962. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69963. export * from "babylonjs/PostProcesses/grainPostProcess";
  69964. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69965. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69966. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69967. export * from "babylonjs/PostProcesses/passPostProcess";
  69968. export * from "babylonjs/PostProcesses/postProcess";
  69969. export * from "babylonjs/PostProcesses/postProcessManager";
  69970. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69971. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69972. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69973. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69974. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69975. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69976. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69977. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69978. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69979. }
  69980. declare module "babylonjs/Probes/index" {
  69981. export * from "babylonjs/Probes/reflectionProbe";
  69982. }
  69983. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69984. import { Scene } from "babylonjs/scene";
  69985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69986. import { SmartArray } from "babylonjs/Misc/smartArray";
  69987. import { ISceneComponent } from "babylonjs/sceneComponent";
  69988. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69989. import "babylonjs/Meshes/Builders/boxBuilder";
  69990. import "babylonjs/Shaders/color.fragment";
  69991. import "babylonjs/Shaders/color.vertex";
  69992. import { Color3 } from "babylonjs/Maths/math.color";
  69993. module "babylonjs/scene" {
  69994. interface Scene {
  69995. /** @hidden (Backing field) */
  69996. _boundingBoxRenderer: BoundingBoxRenderer;
  69997. /** @hidden (Backing field) */
  69998. _forceShowBoundingBoxes: boolean;
  69999. /**
  70000. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70001. */
  70002. forceShowBoundingBoxes: boolean;
  70003. /**
  70004. * Gets the bounding box renderer associated with the scene
  70005. * @returns a BoundingBoxRenderer
  70006. */
  70007. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70008. }
  70009. }
  70010. module "babylonjs/Meshes/abstractMesh" {
  70011. interface AbstractMesh {
  70012. /** @hidden (Backing field) */
  70013. _showBoundingBox: boolean;
  70014. /**
  70015. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70016. */
  70017. showBoundingBox: boolean;
  70018. }
  70019. }
  70020. /**
  70021. * Component responsible of rendering the bounding box of the meshes in a scene.
  70022. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70023. */
  70024. export class BoundingBoxRenderer implements ISceneComponent {
  70025. /**
  70026. * The component name helpfull to identify the component in the list of scene components.
  70027. */
  70028. readonly name: string;
  70029. /**
  70030. * The scene the component belongs to.
  70031. */
  70032. scene: Scene;
  70033. /**
  70034. * Color of the bounding box lines placed in front of an object
  70035. */
  70036. frontColor: Color3;
  70037. /**
  70038. * Color of the bounding box lines placed behind an object
  70039. */
  70040. backColor: Color3;
  70041. /**
  70042. * Defines if the renderer should show the back lines or not
  70043. */
  70044. showBackLines: boolean;
  70045. /**
  70046. * @hidden
  70047. */
  70048. renderList: SmartArray<BoundingBox>;
  70049. private _colorShader;
  70050. private _vertexBuffers;
  70051. private _indexBuffer;
  70052. private _fillIndexBuffer;
  70053. private _fillIndexData;
  70054. /**
  70055. * Instantiates a new bounding box renderer in a scene.
  70056. * @param scene the scene the renderer renders in
  70057. */
  70058. constructor(scene: Scene);
  70059. /**
  70060. * Registers the component in a given scene
  70061. */
  70062. register(): void;
  70063. private _evaluateSubMesh;
  70064. private _activeMesh;
  70065. private _prepareRessources;
  70066. private _createIndexBuffer;
  70067. /**
  70068. * Rebuilds the elements related to this component in case of
  70069. * context lost for instance.
  70070. */
  70071. rebuild(): void;
  70072. /**
  70073. * @hidden
  70074. */
  70075. reset(): void;
  70076. /**
  70077. * Render the bounding boxes of a specific rendering group
  70078. * @param renderingGroupId defines the rendering group to render
  70079. */
  70080. render(renderingGroupId: number): void;
  70081. /**
  70082. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70083. * @param mesh Define the mesh to render the occlusion bounding box for
  70084. */
  70085. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70086. /**
  70087. * Dispose and release the resources attached to this renderer.
  70088. */
  70089. dispose(): void;
  70090. }
  70091. }
  70092. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70093. import { Nullable } from "babylonjs/types";
  70094. import { Scene } from "babylonjs/scene";
  70095. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70096. import { Camera } from "babylonjs/Cameras/camera";
  70097. import { ISceneComponent } from "babylonjs/sceneComponent";
  70098. module "babylonjs/scene" {
  70099. interface Scene {
  70100. /** @hidden (Backing field) */
  70101. _depthRenderer: {
  70102. [id: string]: DepthRenderer;
  70103. };
  70104. /**
  70105. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70106. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70107. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70108. * @returns the created depth renderer
  70109. */
  70110. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70111. /**
  70112. * Disables a depth renderer for a given camera
  70113. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70114. */
  70115. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70116. }
  70117. }
  70118. /**
  70119. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70120. * in several rendering techniques.
  70121. */
  70122. export class DepthRendererSceneComponent implements ISceneComponent {
  70123. /**
  70124. * The component name helpfull to identify the component in the list of scene components.
  70125. */
  70126. readonly name: string;
  70127. /**
  70128. * The scene the component belongs to.
  70129. */
  70130. scene: Scene;
  70131. /**
  70132. * Creates a new instance of the component for the given scene
  70133. * @param scene Defines the scene to register the component in
  70134. */
  70135. constructor(scene: Scene);
  70136. /**
  70137. * Registers the component in a given scene
  70138. */
  70139. register(): void;
  70140. /**
  70141. * Rebuilds the elements related to this component in case of
  70142. * context lost for instance.
  70143. */
  70144. rebuild(): void;
  70145. /**
  70146. * Disposes the component and the associated ressources
  70147. */
  70148. dispose(): void;
  70149. private _gatherRenderTargets;
  70150. private _gatherActiveCameraRenderTargets;
  70151. }
  70152. }
  70153. declare module "babylonjs/Shaders/outline.fragment" {
  70154. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70155. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70156. /** @hidden */
  70157. export var outlinePixelShader: {
  70158. name: string;
  70159. shader: string;
  70160. };
  70161. }
  70162. declare module "babylonjs/Shaders/outline.vertex" {
  70163. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70164. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70165. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70166. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70167. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70168. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70169. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70170. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70171. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70172. /** @hidden */
  70173. export var outlineVertexShader: {
  70174. name: string;
  70175. shader: string;
  70176. };
  70177. }
  70178. declare module "babylonjs/Rendering/outlineRenderer" {
  70179. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70180. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70181. import { Scene } from "babylonjs/scene";
  70182. import { ISceneComponent } from "babylonjs/sceneComponent";
  70183. import "babylonjs/Shaders/outline.fragment";
  70184. import "babylonjs/Shaders/outline.vertex";
  70185. module "babylonjs/scene" {
  70186. interface Scene {
  70187. /** @hidden */
  70188. _outlineRenderer: OutlineRenderer;
  70189. /**
  70190. * Gets the outline renderer associated with the scene
  70191. * @returns a OutlineRenderer
  70192. */
  70193. getOutlineRenderer(): OutlineRenderer;
  70194. }
  70195. }
  70196. module "babylonjs/Meshes/abstractMesh" {
  70197. interface AbstractMesh {
  70198. /** @hidden (Backing field) */
  70199. _renderOutline: boolean;
  70200. /**
  70201. * Gets or sets a boolean indicating if the outline must be rendered as well
  70202. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70203. */
  70204. renderOutline: boolean;
  70205. /** @hidden (Backing field) */
  70206. _renderOverlay: boolean;
  70207. /**
  70208. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70209. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70210. */
  70211. renderOverlay: boolean;
  70212. }
  70213. }
  70214. /**
  70215. * This class is responsible to draw bothe outline/overlay of meshes.
  70216. * It should not be used directly but through the available method on mesh.
  70217. */
  70218. export class OutlineRenderer implements ISceneComponent {
  70219. /**
  70220. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70221. */
  70222. private static _StencilReference;
  70223. /**
  70224. * The name of the component. Each component must have a unique name.
  70225. */
  70226. name: string;
  70227. /**
  70228. * The scene the component belongs to.
  70229. */
  70230. scene: Scene;
  70231. /**
  70232. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70233. */
  70234. zOffset: number;
  70235. private _engine;
  70236. private _effect;
  70237. private _cachedDefines;
  70238. private _savedDepthWrite;
  70239. /**
  70240. * Instantiates a new outline renderer. (There could be only one per scene).
  70241. * @param scene Defines the scene it belongs to
  70242. */
  70243. constructor(scene: Scene);
  70244. /**
  70245. * Register the component to one instance of a scene.
  70246. */
  70247. register(): void;
  70248. /**
  70249. * Rebuilds the elements related to this component in case of
  70250. * context lost for instance.
  70251. */
  70252. rebuild(): void;
  70253. /**
  70254. * Disposes the component and the associated ressources.
  70255. */
  70256. dispose(): void;
  70257. /**
  70258. * Renders the outline in the canvas.
  70259. * @param subMesh Defines the sumesh to render
  70260. * @param batch Defines the batch of meshes in case of instances
  70261. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70262. */
  70263. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70264. /**
  70265. * Returns whether or not the outline renderer is ready for a given submesh.
  70266. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70267. * @param subMesh Defines the submesh to check readyness for
  70268. * @param useInstances Defines wheter wee are trying to render instances or not
  70269. * @returns true if ready otherwise false
  70270. */
  70271. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70272. private _beforeRenderingMesh;
  70273. private _afterRenderingMesh;
  70274. }
  70275. }
  70276. declare module "babylonjs/Rendering/index" {
  70277. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70278. export * from "babylonjs/Rendering/depthRenderer";
  70279. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70280. export * from "babylonjs/Rendering/edgesRenderer";
  70281. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70282. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70283. export * from "babylonjs/Rendering/outlineRenderer";
  70284. export * from "babylonjs/Rendering/renderingGroup";
  70285. export * from "babylonjs/Rendering/renderingManager";
  70286. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70287. }
  70288. declare module "babylonjs/Sprites/ISprites" {
  70289. /**
  70290. * Defines the basic options interface of a Sprite Frame Source Size.
  70291. */
  70292. export interface ISpriteJSONSpriteSourceSize {
  70293. /**
  70294. * number of the original width of the Frame
  70295. */
  70296. w: number;
  70297. /**
  70298. * number of the original height of the Frame
  70299. */
  70300. h: number;
  70301. }
  70302. /**
  70303. * Defines the basic options interface of a Sprite Frame Data.
  70304. */
  70305. export interface ISpriteJSONSpriteFrameData {
  70306. /**
  70307. * number of the x offset of the Frame
  70308. */
  70309. x: number;
  70310. /**
  70311. * number of the y offset of the Frame
  70312. */
  70313. y: number;
  70314. /**
  70315. * number of the width of the Frame
  70316. */
  70317. w: number;
  70318. /**
  70319. * number of the height of the Frame
  70320. */
  70321. h: number;
  70322. }
  70323. /**
  70324. * Defines the basic options interface of a JSON Sprite.
  70325. */
  70326. export interface ISpriteJSONSprite {
  70327. /**
  70328. * string name of the Frame
  70329. */
  70330. filename: string;
  70331. /**
  70332. * ISpriteJSONSpriteFrame basic object of the frame data
  70333. */
  70334. frame: ISpriteJSONSpriteFrameData;
  70335. /**
  70336. * boolean to flag is the frame was rotated.
  70337. */
  70338. rotated: boolean;
  70339. /**
  70340. * boolean to flag is the frame was trimmed.
  70341. */
  70342. trimmed: boolean;
  70343. /**
  70344. * ISpriteJSONSpriteFrame basic object of the source data
  70345. */
  70346. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70347. /**
  70348. * ISpriteJSONSpriteFrame basic object of the source data
  70349. */
  70350. sourceSize: ISpriteJSONSpriteSourceSize;
  70351. }
  70352. /**
  70353. * Defines the basic options interface of a JSON atlas.
  70354. */
  70355. export interface ISpriteJSONAtlas {
  70356. /**
  70357. * Array of objects that contain the frame data.
  70358. */
  70359. frames: Array<ISpriteJSONSprite>;
  70360. /**
  70361. * object basic object containing the sprite meta data.
  70362. */
  70363. meta?: object;
  70364. }
  70365. }
  70366. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70367. /** @hidden */
  70368. export var spriteMapPixelShader: {
  70369. name: string;
  70370. shader: string;
  70371. };
  70372. }
  70373. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70374. /** @hidden */
  70375. export var spriteMapVertexShader: {
  70376. name: string;
  70377. shader: string;
  70378. };
  70379. }
  70380. declare module "babylonjs/Sprites/spriteMap" {
  70381. import { IDisposable, Scene } from "babylonjs/scene";
  70382. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70383. import { Texture } from "babylonjs/Materials/Textures/texture";
  70384. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70385. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70386. import "babylonjs/Meshes/Builders/planeBuilder";
  70387. import "babylonjs/Shaders/spriteMap.fragment";
  70388. import "babylonjs/Shaders/spriteMap.vertex";
  70389. /**
  70390. * Defines the basic options interface of a SpriteMap
  70391. */
  70392. export interface ISpriteMapOptions {
  70393. /**
  70394. * Vector2 of the number of cells in the grid.
  70395. */
  70396. stageSize?: Vector2;
  70397. /**
  70398. * Vector2 of the size of the output plane in World Units.
  70399. */
  70400. outputSize?: Vector2;
  70401. /**
  70402. * Vector3 of the position of the output plane in World Units.
  70403. */
  70404. outputPosition?: Vector3;
  70405. /**
  70406. * Vector3 of the rotation of the output plane.
  70407. */
  70408. outputRotation?: Vector3;
  70409. /**
  70410. * number of layers that the system will reserve in resources.
  70411. */
  70412. layerCount?: number;
  70413. /**
  70414. * number of max animation frames a single cell will reserve in resources.
  70415. */
  70416. maxAnimationFrames?: number;
  70417. /**
  70418. * number cell index of the base tile when the system compiles.
  70419. */
  70420. baseTile?: number;
  70421. /**
  70422. * boolean flip the sprite after its been repositioned by the framing data.
  70423. */
  70424. flipU?: boolean;
  70425. /**
  70426. * Vector3 scalar of the global RGB values of the SpriteMap.
  70427. */
  70428. colorMultiply?: Vector3;
  70429. }
  70430. /**
  70431. * Defines the IDisposable interface in order to be cleanable from resources.
  70432. */
  70433. export interface ISpriteMap extends IDisposable {
  70434. /**
  70435. * String name of the SpriteMap.
  70436. */
  70437. name: string;
  70438. /**
  70439. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70440. */
  70441. atlasJSON: ISpriteJSONAtlas;
  70442. /**
  70443. * Texture of the SpriteMap.
  70444. */
  70445. spriteSheet: Texture;
  70446. /**
  70447. * The parameters to initialize the SpriteMap with.
  70448. */
  70449. options: ISpriteMapOptions;
  70450. }
  70451. /**
  70452. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70453. */
  70454. export class SpriteMap implements ISpriteMap {
  70455. /** The Name of the spriteMap */
  70456. name: string;
  70457. /** The JSON file with the frame and meta data */
  70458. atlasJSON: ISpriteJSONAtlas;
  70459. /** The systems Sprite Sheet Texture */
  70460. spriteSheet: Texture;
  70461. /** Arguments passed with the Constructor */
  70462. options: ISpriteMapOptions;
  70463. /** Public Sprite Storage array, parsed from atlasJSON */
  70464. sprites: Array<ISpriteJSONSprite>;
  70465. /** Returns the Number of Sprites in the System */
  70466. get spriteCount(): number;
  70467. /** Returns the Position of Output Plane*/
  70468. get position(): Vector3;
  70469. /** Returns the Position of Output Plane*/
  70470. set position(v: Vector3);
  70471. /** Returns the Rotation of Output Plane*/
  70472. get rotation(): Vector3;
  70473. /** Returns the Rotation of Output Plane*/
  70474. set rotation(v: Vector3);
  70475. /** Sets the AnimationMap*/
  70476. get animationMap(): RawTexture;
  70477. /** Sets the AnimationMap*/
  70478. set animationMap(v: RawTexture);
  70479. /** Scene that the SpriteMap was created in */
  70480. private _scene;
  70481. /** Texture Buffer of Float32 that holds tile frame data*/
  70482. private _frameMap;
  70483. /** Texture Buffers of Float32 that holds tileMap data*/
  70484. private _tileMaps;
  70485. /** Texture Buffer of Float32 that holds Animation Data*/
  70486. private _animationMap;
  70487. /** Custom ShaderMaterial Central to the System*/
  70488. private _material;
  70489. /** Custom ShaderMaterial Central to the System*/
  70490. private _output;
  70491. /** Systems Time Ticker*/
  70492. private _time;
  70493. /**
  70494. * Creates a new SpriteMap
  70495. * @param name defines the SpriteMaps Name
  70496. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70497. * @param spriteSheet is the Texture that the Sprites are on.
  70498. * @param options a basic deployment configuration
  70499. * @param scene The Scene that the map is deployed on
  70500. */
  70501. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70502. /**
  70503. * Returns tileID location
  70504. * @returns Vector2 the cell position ID
  70505. */
  70506. getTileID(): Vector2;
  70507. /**
  70508. * Gets the UV location of the mouse over the SpriteMap.
  70509. * @returns Vector2 the UV position of the mouse interaction
  70510. */
  70511. getMousePosition(): Vector2;
  70512. /**
  70513. * Creates the "frame" texture Buffer
  70514. * -------------------------------------
  70515. * Structure of frames
  70516. * "filename": "Falling-Water-2.png",
  70517. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70518. * "rotated": true,
  70519. * "trimmed": true,
  70520. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70521. * "sourceSize": {"w":32,"h":32}
  70522. * @returns RawTexture of the frameMap
  70523. */
  70524. private _createFrameBuffer;
  70525. /**
  70526. * Creates the tileMap texture Buffer
  70527. * @param buffer normally and array of numbers, or a false to generate from scratch
  70528. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70529. * @returns RawTexture of the tileMap
  70530. */
  70531. private _createTileBuffer;
  70532. /**
  70533. * Modifies the data of the tileMaps
  70534. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70535. * @param pos is the iVector2 Coordinates of the Tile
  70536. * @param tile The SpriteIndex of the new Tile
  70537. */
  70538. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70539. /**
  70540. * Creates the animationMap texture Buffer
  70541. * @param buffer normally and array of numbers, or a false to generate from scratch
  70542. * @returns RawTexture of the animationMap
  70543. */
  70544. private _createTileAnimationBuffer;
  70545. /**
  70546. * Modifies the data of the animationMap
  70547. * @param cellID is the Index of the Sprite
  70548. * @param _frame is the target Animation frame
  70549. * @param toCell is the Target Index of the next frame of the animation
  70550. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70551. * @param speed is a global scalar of the time variable on the map.
  70552. */
  70553. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70554. /**
  70555. * Exports the .tilemaps file
  70556. */
  70557. saveTileMaps(): void;
  70558. /**
  70559. * Imports the .tilemaps file
  70560. * @param url of the .tilemaps file
  70561. */
  70562. loadTileMaps(url: string): void;
  70563. /**
  70564. * Release associated resources
  70565. */
  70566. dispose(): void;
  70567. }
  70568. }
  70569. declare module "babylonjs/Sprites/spritePackedManager" {
  70570. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70571. import { Scene } from "babylonjs/scene";
  70572. /**
  70573. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70574. * @see http://doc.babylonjs.com/babylon101/sprites
  70575. */
  70576. export class SpritePackedManager extends SpriteManager {
  70577. /** defines the packed manager's name */
  70578. name: string;
  70579. /**
  70580. * Creates a new sprite manager from a packed sprite sheet
  70581. * @param name defines the manager's name
  70582. * @param imgUrl defines the sprite sheet url
  70583. * @param capacity defines the maximum allowed number of sprites
  70584. * @param scene defines the hosting scene
  70585. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70586. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70587. * @param samplingMode defines the smapling mode to use with spritesheet
  70588. * @param fromPacked set to true; do not alter
  70589. */
  70590. constructor(
  70591. /** defines the packed manager's name */
  70592. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70593. }
  70594. }
  70595. declare module "babylonjs/Sprites/index" {
  70596. export * from "babylonjs/Sprites/sprite";
  70597. export * from "babylonjs/Sprites/ISprites";
  70598. export * from "babylonjs/Sprites/spriteManager";
  70599. export * from "babylonjs/Sprites/spriteMap";
  70600. export * from "babylonjs/Sprites/spritePackedManager";
  70601. export * from "babylonjs/Sprites/spriteSceneComponent";
  70602. }
  70603. declare module "babylonjs/States/index" {
  70604. export * from "babylonjs/States/alphaCullingState";
  70605. export * from "babylonjs/States/depthCullingState";
  70606. export * from "babylonjs/States/stencilState";
  70607. }
  70608. declare module "babylonjs/Misc/assetsManager" {
  70609. import { Scene } from "babylonjs/scene";
  70610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70611. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70612. import { Skeleton } from "babylonjs/Bones/skeleton";
  70613. import { Observable } from "babylonjs/Misc/observable";
  70614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70615. import { Texture } from "babylonjs/Materials/Textures/texture";
  70616. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70617. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70618. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70619. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70620. /**
  70621. * Defines the list of states available for a task inside a AssetsManager
  70622. */
  70623. export enum AssetTaskState {
  70624. /**
  70625. * Initialization
  70626. */
  70627. INIT = 0,
  70628. /**
  70629. * Running
  70630. */
  70631. RUNNING = 1,
  70632. /**
  70633. * Done
  70634. */
  70635. DONE = 2,
  70636. /**
  70637. * Error
  70638. */
  70639. ERROR = 3
  70640. }
  70641. /**
  70642. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70643. */
  70644. export abstract class AbstractAssetTask {
  70645. /**
  70646. * Task name
  70647. */ name: string;
  70648. /**
  70649. * Callback called when the task is successful
  70650. */
  70651. onSuccess: (task: any) => void;
  70652. /**
  70653. * Callback called when the task is not successful
  70654. */
  70655. onError: (task: any, message?: string, exception?: any) => void;
  70656. /**
  70657. * Creates a new AssetsManager
  70658. * @param name defines the name of the task
  70659. */
  70660. constructor(
  70661. /**
  70662. * Task name
  70663. */ name: string);
  70664. private _isCompleted;
  70665. private _taskState;
  70666. private _errorObject;
  70667. /**
  70668. * Get if the task is completed
  70669. */
  70670. get isCompleted(): boolean;
  70671. /**
  70672. * Gets the current state of the task
  70673. */
  70674. get taskState(): AssetTaskState;
  70675. /**
  70676. * Gets the current error object (if task is in error)
  70677. */
  70678. get errorObject(): {
  70679. message?: string;
  70680. exception?: any;
  70681. };
  70682. /**
  70683. * Internal only
  70684. * @hidden
  70685. */
  70686. _setErrorObject(message?: string, exception?: any): void;
  70687. /**
  70688. * Execute the current task
  70689. * @param scene defines the scene where you want your assets to be loaded
  70690. * @param onSuccess is a callback called when the task is successfully executed
  70691. * @param onError is a callback called if an error occurs
  70692. */
  70693. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70694. /**
  70695. * Execute the current task
  70696. * @param scene defines the scene where you want your assets to be loaded
  70697. * @param onSuccess is a callback called when the task is successfully executed
  70698. * @param onError is a callback called if an error occurs
  70699. */
  70700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70701. /**
  70702. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70703. * This can be used with failed tasks that have the reason for failure fixed.
  70704. */
  70705. reset(): void;
  70706. private onErrorCallback;
  70707. private onDoneCallback;
  70708. }
  70709. /**
  70710. * Define the interface used by progress events raised during assets loading
  70711. */
  70712. export interface IAssetsProgressEvent {
  70713. /**
  70714. * Defines the number of remaining tasks to process
  70715. */
  70716. remainingCount: number;
  70717. /**
  70718. * Defines the total number of tasks
  70719. */
  70720. totalCount: number;
  70721. /**
  70722. * Defines the task that was just processed
  70723. */
  70724. task: AbstractAssetTask;
  70725. }
  70726. /**
  70727. * Class used to share progress information about assets loading
  70728. */
  70729. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70730. /**
  70731. * Defines the number of remaining tasks to process
  70732. */
  70733. remainingCount: number;
  70734. /**
  70735. * Defines the total number of tasks
  70736. */
  70737. totalCount: number;
  70738. /**
  70739. * Defines the task that was just processed
  70740. */
  70741. task: AbstractAssetTask;
  70742. /**
  70743. * Creates a AssetsProgressEvent
  70744. * @param remainingCount defines the number of remaining tasks to process
  70745. * @param totalCount defines the total number of tasks
  70746. * @param task defines the task that was just processed
  70747. */
  70748. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70749. }
  70750. /**
  70751. * Define a task used by AssetsManager to load meshes
  70752. */
  70753. export class MeshAssetTask extends AbstractAssetTask {
  70754. /**
  70755. * Defines the name of the task
  70756. */
  70757. name: string;
  70758. /**
  70759. * Defines the list of mesh's names you want to load
  70760. */
  70761. meshesNames: any;
  70762. /**
  70763. * Defines the root url to use as a base to load your meshes and associated resources
  70764. */
  70765. rootUrl: string;
  70766. /**
  70767. * Defines the filename of the scene to load from
  70768. */
  70769. sceneFilename: string;
  70770. /**
  70771. * Gets the list of loaded meshes
  70772. */
  70773. loadedMeshes: Array<AbstractMesh>;
  70774. /**
  70775. * Gets the list of loaded particle systems
  70776. */
  70777. loadedParticleSystems: Array<IParticleSystem>;
  70778. /**
  70779. * Gets the list of loaded skeletons
  70780. */
  70781. loadedSkeletons: Array<Skeleton>;
  70782. /**
  70783. * Gets the list of loaded animation groups
  70784. */
  70785. loadedAnimationGroups: Array<AnimationGroup>;
  70786. /**
  70787. * Callback called when the task is successful
  70788. */
  70789. onSuccess: (task: MeshAssetTask) => void;
  70790. /**
  70791. * Callback called when the task is successful
  70792. */
  70793. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70794. /**
  70795. * Creates a new MeshAssetTask
  70796. * @param name defines the name of the task
  70797. * @param meshesNames defines the list of mesh's names you want to load
  70798. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70799. * @param sceneFilename defines the filename of the scene to load from
  70800. */
  70801. constructor(
  70802. /**
  70803. * Defines the name of the task
  70804. */
  70805. name: string,
  70806. /**
  70807. * Defines the list of mesh's names you want to load
  70808. */
  70809. meshesNames: any,
  70810. /**
  70811. * Defines the root url to use as a base to load your meshes and associated resources
  70812. */
  70813. rootUrl: string,
  70814. /**
  70815. * Defines the filename of the scene to load from
  70816. */
  70817. sceneFilename: string);
  70818. /**
  70819. * Execute the current task
  70820. * @param scene defines the scene where you want your assets to be loaded
  70821. * @param onSuccess is a callback called when the task is successfully executed
  70822. * @param onError is a callback called if an error occurs
  70823. */
  70824. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70825. }
  70826. /**
  70827. * Define a task used by AssetsManager to load text content
  70828. */
  70829. export class TextFileAssetTask extends AbstractAssetTask {
  70830. /**
  70831. * Defines the name of the task
  70832. */
  70833. name: string;
  70834. /**
  70835. * Defines the location of the file to load
  70836. */
  70837. url: string;
  70838. /**
  70839. * Gets the loaded text string
  70840. */
  70841. text: string;
  70842. /**
  70843. * Callback called when the task is successful
  70844. */
  70845. onSuccess: (task: TextFileAssetTask) => void;
  70846. /**
  70847. * Callback called when the task is successful
  70848. */
  70849. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70850. /**
  70851. * Creates a new TextFileAssetTask object
  70852. * @param name defines the name of the task
  70853. * @param url defines the location of the file to load
  70854. */
  70855. constructor(
  70856. /**
  70857. * Defines the name of the task
  70858. */
  70859. name: string,
  70860. /**
  70861. * Defines the location of the file to load
  70862. */
  70863. url: string);
  70864. /**
  70865. * Execute the current task
  70866. * @param scene defines the scene where you want your assets to be loaded
  70867. * @param onSuccess is a callback called when the task is successfully executed
  70868. * @param onError is a callback called if an error occurs
  70869. */
  70870. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70871. }
  70872. /**
  70873. * Define a task used by AssetsManager to load binary data
  70874. */
  70875. export class BinaryFileAssetTask extends AbstractAssetTask {
  70876. /**
  70877. * Defines the name of the task
  70878. */
  70879. name: string;
  70880. /**
  70881. * Defines the location of the file to load
  70882. */
  70883. url: string;
  70884. /**
  70885. * Gets the lodaded data (as an array buffer)
  70886. */
  70887. data: ArrayBuffer;
  70888. /**
  70889. * Callback called when the task is successful
  70890. */
  70891. onSuccess: (task: BinaryFileAssetTask) => void;
  70892. /**
  70893. * Callback called when the task is successful
  70894. */
  70895. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70896. /**
  70897. * Creates a new BinaryFileAssetTask object
  70898. * @param name defines the name of the new task
  70899. * @param url defines the location of the file to load
  70900. */
  70901. constructor(
  70902. /**
  70903. * Defines the name of the task
  70904. */
  70905. name: string,
  70906. /**
  70907. * Defines the location of the file to load
  70908. */
  70909. url: string);
  70910. /**
  70911. * Execute the current task
  70912. * @param scene defines the scene where you want your assets to be loaded
  70913. * @param onSuccess is a callback called when the task is successfully executed
  70914. * @param onError is a callback called if an error occurs
  70915. */
  70916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70917. }
  70918. /**
  70919. * Define a task used by AssetsManager to load images
  70920. */
  70921. export class ImageAssetTask extends AbstractAssetTask {
  70922. /**
  70923. * Defines the name of the task
  70924. */
  70925. name: string;
  70926. /**
  70927. * Defines the location of the image to load
  70928. */
  70929. url: string;
  70930. /**
  70931. * Gets the loaded images
  70932. */
  70933. image: HTMLImageElement;
  70934. /**
  70935. * Callback called when the task is successful
  70936. */
  70937. onSuccess: (task: ImageAssetTask) => void;
  70938. /**
  70939. * Callback called when the task is successful
  70940. */
  70941. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70942. /**
  70943. * Creates a new ImageAssetTask
  70944. * @param name defines the name of the task
  70945. * @param url defines the location of the image to load
  70946. */
  70947. constructor(
  70948. /**
  70949. * Defines the name of the task
  70950. */
  70951. name: string,
  70952. /**
  70953. * Defines the location of the image to load
  70954. */
  70955. url: string);
  70956. /**
  70957. * Execute the current task
  70958. * @param scene defines the scene where you want your assets to be loaded
  70959. * @param onSuccess is a callback called when the task is successfully executed
  70960. * @param onError is a callback called if an error occurs
  70961. */
  70962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70963. }
  70964. /**
  70965. * Defines the interface used by texture loading tasks
  70966. */
  70967. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70968. /**
  70969. * Gets the loaded texture
  70970. */
  70971. texture: TEX;
  70972. }
  70973. /**
  70974. * Define a task used by AssetsManager to load 2D textures
  70975. */
  70976. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70977. /**
  70978. * Defines the name of the task
  70979. */
  70980. name: string;
  70981. /**
  70982. * Defines the location of the file to load
  70983. */
  70984. url: string;
  70985. /**
  70986. * Defines if mipmap should not be generated (default is false)
  70987. */
  70988. noMipmap?: boolean | undefined;
  70989. /**
  70990. * Defines if texture must be inverted on Y axis (default is false)
  70991. */
  70992. invertY?: boolean | undefined;
  70993. /**
  70994. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70995. */
  70996. samplingMode: number;
  70997. /**
  70998. * Gets the loaded texture
  70999. */
  71000. texture: Texture;
  71001. /**
  71002. * Callback called when the task is successful
  71003. */
  71004. onSuccess: (task: TextureAssetTask) => void;
  71005. /**
  71006. * Callback called when the task is successful
  71007. */
  71008. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71009. /**
  71010. * Creates a new TextureAssetTask object
  71011. * @param name defines the name of the task
  71012. * @param url defines the location of the file to load
  71013. * @param noMipmap defines if mipmap should not be generated (default is false)
  71014. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71015. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71016. */
  71017. constructor(
  71018. /**
  71019. * Defines the name of the task
  71020. */
  71021. name: string,
  71022. /**
  71023. * Defines the location of the file to load
  71024. */
  71025. url: string,
  71026. /**
  71027. * Defines if mipmap should not be generated (default is false)
  71028. */
  71029. noMipmap?: boolean | undefined,
  71030. /**
  71031. * Defines if texture must be inverted on Y axis (default is false)
  71032. */
  71033. invertY?: boolean | undefined,
  71034. /**
  71035. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71036. */
  71037. samplingMode?: number);
  71038. /**
  71039. * Execute the current task
  71040. * @param scene defines the scene where you want your assets to be loaded
  71041. * @param onSuccess is a callback called when the task is successfully executed
  71042. * @param onError is a callback called if an error occurs
  71043. */
  71044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71045. }
  71046. /**
  71047. * Define a task used by AssetsManager to load cube textures
  71048. */
  71049. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71050. /**
  71051. * Defines the name of the task
  71052. */
  71053. name: string;
  71054. /**
  71055. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71056. */
  71057. url: string;
  71058. /**
  71059. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71060. */
  71061. extensions?: string[] | undefined;
  71062. /**
  71063. * Defines if mipmaps should not be generated (default is false)
  71064. */
  71065. noMipmap?: boolean | undefined;
  71066. /**
  71067. * Defines the explicit list of files (undefined by default)
  71068. */
  71069. files?: string[] | undefined;
  71070. /**
  71071. * Gets the loaded texture
  71072. */
  71073. texture: CubeTexture;
  71074. /**
  71075. * Callback called when the task is successful
  71076. */
  71077. onSuccess: (task: CubeTextureAssetTask) => void;
  71078. /**
  71079. * Callback called when the task is successful
  71080. */
  71081. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71082. /**
  71083. * Creates a new CubeTextureAssetTask
  71084. * @param name defines the name of the task
  71085. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71086. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71087. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71088. * @param files defines the explicit list of files (undefined by default)
  71089. */
  71090. constructor(
  71091. /**
  71092. * Defines the name of the task
  71093. */
  71094. name: string,
  71095. /**
  71096. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71097. */
  71098. url: string,
  71099. /**
  71100. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71101. */
  71102. extensions?: string[] | undefined,
  71103. /**
  71104. * Defines if mipmaps should not be generated (default is false)
  71105. */
  71106. noMipmap?: boolean | undefined,
  71107. /**
  71108. * Defines the explicit list of files (undefined by default)
  71109. */
  71110. files?: string[] | undefined);
  71111. /**
  71112. * Execute the current task
  71113. * @param scene defines the scene where you want your assets to be loaded
  71114. * @param onSuccess is a callback called when the task is successfully executed
  71115. * @param onError is a callback called if an error occurs
  71116. */
  71117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71118. }
  71119. /**
  71120. * Define a task used by AssetsManager to load HDR cube textures
  71121. */
  71122. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71123. /**
  71124. * Defines the name of the task
  71125. */
  71126. name: string;
  71127. /**
  71128. * Defines the location of the file to load
  71129. */
  71130. url: string;
  71131. /**
  71132. * Defines the desired size (the more it increases the longer the generation will be)
  71133. */
  71134. size: number;
  71135. /**
  71136. * Defines if mipmaps should not be generated (default is false)
  71137. */
  71138. noMipmap: boolean;
  71139. /**
  71140. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71141. */
  71142. generateHarmonics: boolean;
  71143. /**
  71144. * 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)
  71145. */
  71146. gammaSpace: boolean;
  71147. /**
  71148. * Internal Use Only
  71149. */
  71150. reserved: boolean;
  71151. /**
  71152. * Gets the loaded texture
  71153. */
  71154. texture: HDRCubeTexture;
  71155. /**
  71156. * Callback called when the task is successful
  71157. */
  71158. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71159. /**
  71160. * Callback called when the task is successful
  71161. */
  71162. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71163. /**
  71164. * Creates a new HDRCubeTextureAssetTask object
  71165. * @param name defines the name of the task
  71166. * @param url defines the location of the file to load
  71167. * @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.
  71168. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71169. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71170. * @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)
  71171. * @param reserved Internal use only
  71172. */
  71173. constructor(
  71174. /**
  71175. * Defines the name of the task
  71176. */
  71177. name: string,
  71178. /**
  71179. * Defines the location of the file to load
  71180. */
  71181. url: string,
  71182. /**
  71183. * Defines the desired size (the more it increases the longer the generation will be)
  71184. */
  71185. size: number,
  71186. /**
  71187. * Defines if mipmaps should not be generated (default is false)
  71188. */
  71189. noMipmap?: boolean,
  71190. /**
  71191. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71192. */
  71193. generateHarmonics?: boolean,
  71194. /**
  71195. * 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)
  71196. */
  71197. gammaSpace?: boolean,
  71198. /**
  71199. * Internal Use Only
  71200. */
  71201. reserved?: boolean);
  71202. /**
  71203. * Execute the current task
  71204. * @param scene defines the scene where you want your assets to be loaded
  71205. * @param onSuccess is a callback called when the task is successfully executed
  71206. * @param onError is a callback called if an error occurs
  71207. */
  71208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71209. }
  71210. /**
  71211. * Define a task used by AssetsManager to load Equirectangular cube textures
  71212. */
  71213. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71214. /**
  71215. * Defines the name of the task
  71216. */
  71217. name: string;
  71218. /**
  71219. * Defines the location of the file to load
  71220. */
  71221. url: string;
  71222. /**
  71223. * Defines the desired size (the more it increases the longer the generation will be)
  71224. */
  71225. size: number;
  71226. /**
  71227. * Defines if mipmaps should not be generated (default is false)
  71228. */
  71229. noMipmap: boolean;
  71230. /**
  71231. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71232. * but the standard material would require them in Gamma space) (default is true)
  71233. */
  71234. gammaSpace: boolean;
  71235. /**
  71236. * Gets the loaded texture
  71237. */
  71238. texture: EquiRectangularCubeTexture;
  71239. /**
  71240. * Callback called when the task is successful
  71241. */
  71242. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71243. /**
  71244. * Callback called when the task is successful
  71245. */
  71246. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71247. /**
  71248. * Creates a new EquiRectangularCubeTextureAssetTask object
  71249. * @param name defines the name of the task
  71250. * @param url defines the location of the file to load
  71251. * @param size defines the desired size (the more it increases the longer the generation will be)
  71252. * If the size is omitted this implies you are using a preprocessed cubemap.
  71253. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71254. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71255. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71256. * (default is true)
  71257. */
  71258. constructor(
  71259. /**
  71260. * Defines the name of the task
  71261. */
  71262. name: string,
  71263. /**
  71264. * Defines the location of the file to load
  71265. */
  71266. url: string,
  71267. /**
  71268. * Defines the desired size (the more it increases the longer the generation will be)
  71269. */
  71270. size: number,
  71271. /**
  71272. * Defines if mipmaps should not be generated (default is false)
  71273. */
  71274. noMipmap?: boolean,
  71275. /**
  71276. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71277. * but the standard material would require them in Gamma space) (default is true)
  71278. */
  71279. gammaSpace?: boolean);
  71280. /**
  71281. * Execute the current task
  71282. * @param scene defines the scene where you want your assets to be loaded
  71283. * @param onSuccess is a callback called when the task is successfully executed
  71284. * @param onError is a callback called if an error occurs
  71285. */
  71286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71287. }
  71288. /**
  71289. * This class can be used to easily import assets into a scene
  71290. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71291. */
  71292. export class AssetsManager {
  71293. private _scene;
  71294. private _isLoading;
  71295. protected _tasks: AbstractAssetTask[];
  71296. protected _waitingTasksCount: number;
  71297. protected _totalTasksCount: number;
  71298. /**
  71299. * Callback called when all tasks are processed
  71300. */
  71301. onFinish: (tasks: AbstractAssetTask[]) => void;
  71302. /**
  71303. * Callback called when a task is successful
  71304. */
  71305. onTaskSuccess: (task: AbstractAssetTask) => void;
  71306. /**
  71307. * Callback called when a task had an error
  71308. */
  71309. onTaskError: (task: AbstractAssetTask) => void;
  71310. /**
  71311. * Callback called when a task is done (whatever the result is)
  71312. */
  71313. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71314. /**
  71315. * Observable called when all tasks are processed
  71316. */
  71317. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71318. /**
  71319. * Observable called when a task had an error
  71320. */
  71321. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71322. /**
  71323. * Observable called when all tasks were executed
  71324. */
  71325. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71326. /**
  71327. * Observable called when a task is done (whatever the result is)
  71328. */
  71329. onProgressObservable: Observable<IAssetsProgressEvent>;
  71330. /**
  71331. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71332. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71333. */
  71334. useDefaultLoadingScreen: boolean;
  71335. /**
  71336. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71337. * when all assets have been downloaded.
  71338. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71339. */
  71340. autoHideLoadingUI: boolean;
  71341. /**
  71342. * Creates a new AssetsManager
  71343. * @param scene defines the scene to work on
  71344. */
  71345. constructor(scene: Scene);
  71346. /**
  71347. * Add a MeshAssetTask to the list of active tasks
  71348. * @param taskName defines the name of the new task
  71349. * @param meshesNames defines the name of meshes to load
  71350. * @param rootUrl defines the root url to use to locate files
  71351. * @param sceneFilename defines the filename of the scene file
  71352. * @returns a new MeshAssetTask object
  71353. */
  71354. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71355. /**
  71356. * Add a TextFileAssetTask to the list of active tasks
  71357. * @param taskName defines the name of the new task
  71358. * @param url defines the url of the file to load
  71359. * @returns a new TextFileAssetTask object
  71360. */
  71361. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71362. /**
  71363. * Add a BinaryFileAssetTask to the list of active tasks
  71364. * @param taskName defines the name of the new task
  71365. * @param url defines the url of the file to load
  71366. * @returns a new BinaryFileAssetTask object
  71367. */
  71368. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71369. /**
  71370. * Add a ImageAssetTask to the list of active tasks
  71371. * @param taskName defines the name of the new task
  71372. * @param url defines the url of the file to load
  71373. * @returns a new ImageAssetTask object
  71374. */
  71375. addImageTask(taskName: string, url: string): ImageAssetTask;
  71376. /**
  71377. * Add a TextureAssetTask to the list of active tasks
  71378. * @param taskName defines the name of the new task
  71379. * @param url defines the url of the file to load
  71380. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71381. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71382. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71383. * @returns a new TextureAssetTask object
  71384. */
  71385. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71386. /**
  71387. * Add a CubeTextureAssetTask to the list of active tasks
  71388. * @param taskName defines the name of the new task
  71389. * @param url defines the url of the file to load
  71390. * @param extensions defines the extension to use to load the cube map (can be null)
  71391. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71392. * @param files defines the list of files to load (can be null)
  71393. * @returns a new CubeTextureAssetTask object
  71394. */
  71395. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71396. /**
  71397. *
  71398. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71399. * @param taskName defines the name of the new task
  71400. * @param url defines the url of the file to load
  71401. * @param size defines the size you want for the cubemap (can be null)
  71402. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71403. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71404. * @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)
  71405. * @param reserved Internal use only
  71406. * @returns a new HDRCubeTextureAssetTask object
  71407. */
  71408. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71409. /**
  71410. *
  71411. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71412. * @param taskName defines the name of the new task
  71413. * @param url defines the url of the file to load
  71414. * @param size defines the size you want for the cubemap (can be null)
  71415. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71416. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71417. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71418. * @returns a new EquiRectangularCubeTextureAssetTask object
  71419. */
  71420. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71421. /**
  71422. * Remove a task from the assets manager.
  71423. * @param task the task to remove
  71424. */
  71425. removeTask(task: AbstractAssetTask): void;
  71426. private _decreaseWaitingTasksCount;
  71427. private _runTask;
  71428. /**
  71429. * Reset the AssetsManager and remove all tasks
  71430. * @return the current instance of the AssetsManager
  71431. */
  71432. reset(): AssetsManager;
  71433. /**
  71434. * Start the loading process
  71435. * @return the current instance of the AssetsManager
  71436. */
  71437. load(): AssetsManager;
  71438. /**
  71439. * Start the loading process as an async operation
  71440. * @return a promise returning the list of failed tasks
  71441. */
  71442. loadAsync(): Promise<void>;
  71443. }
  71444. }
  71445. declare module "babylonjs/Misc/deferred" {
  71446. /**
  71447. * Wrapper class for promise with external resolve and reject.
  71448. */
  71449. export class Deferred<T> {
  71450. /**
  71451. * The promise associated with this deferred object.
  71452. */
  71453. readonly promise: Promise<T>;
  71454. private _resolve;
  71455. private _reject;
  71456. /**
  71457. * The resolve method of the promise associated with this deferred object.
  71458. */
  71459. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71460. /**
  71461. * The reject method of the promise associated with this deferred object.
  71462. */
  71463. get reject(): (reason?: any) => void;
  71464. /**
  71465. * Constructor for this deferred object.
  71466. */
  71467. constructor();
  71468. }
  71469. }
  71470. declare module "babylonjs/Misc/meshExploder" {
  71471. import { Mesh } from "babylonjs/Meshes/mesh";
  71472. /**
  71473. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71474. */
  71475. export class MeshExploder {
  71476. private _centerMesh;
  71477. private _meshes;
  71478. private _meshesOrigins;
  71479. private _toCenterVectors;
  71480. private _scaledDirection;
  71481. private _newPosition;
  71482. private _centerPosition;
  71483. /**
  71484. * Explodes meshes from a center mesh.
  71485. * @param meshes The meshes to explode.
  71486. * @param centerMesh The mesh to be center of explosion.
  71487. */
  71488. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71489. private _setCenterMesh;
  71490. /**
  71491. * Get class name
  71492. * @returns "MeshExploder"
  71493. */
  71494. getClassName(): string;
  71495. /**
  71496. * "Exploded meshes"
  71497. * @returns Array of meshes with the centerMesh at index 0.
  71498. */
  71499. getMeshes(): Array<Mesh>;
  71500. /**
  71501. * Explodes meshes giving a specific direction
  71502. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71503. */
  71504. explode(direction?: number): void;
  71505. }
  71506. }
  71507. declare module "babylonjs/Misc/filesInput" {
  71508. import { Engine } from "babylonjs/Engines/engine";
  71509. import { Scene } from "babylonjs/scene";
  71510. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71511. /**
  71512. * Class used to help managing file picking and drag'n'drop
  71513. */
  71514. export class FilesInput {
  71515. /**
  71516. * List of files ready to be loaded
  71517. */
  71518. static get FilesToLoad(): {
  71519. [key: string]: File;
  71520. };
  71521. /**
  71522. * Callback called when a file is processed
  71523. */
  71524. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71525. private _engine;
  71526. private _currentScene;
  71527. private _sceneLoadedCallback;
  71528. private _progressCallback;
  71529. private _additionalRenderLoopLogicCallback;
  71530. private _textureLoadingCallback;
  71531. private _startingProcessingFilesCallback;
  71532. private _onReloadCallback;
  71533. private _errorCallback;
  71534. private _elementToMonitor;
  71535. private _sceneFileToLoad;
  71536. private _filesToLoad;
  71537. /**
  71538. * Creates a new FilesInput
  71539. * @param engine defines the rendering engine
  71540. * @param scene defines the hosting scene
  71541. * @param sceneLoadedCallback callback called when scene is loaded
  71542. * @param progressCallback callback called to track progress
  71543. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71544. * @param textureLoadingCallback callback called when a texture is loading
  71545. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71546. * @param onReloadCallback callback called when a reload is requested
  71547. * @param errorCallback callback call if an error occurs
  71548. */
  71549. 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);
  71550. private _dragEnterHandler;
  71551. private _dragOverHandler;
  71552. private _dropHandler;
  71553. /**
  71554. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71555. * @param elementToMonitor defines the DOM element to track
  71556. */
  71557. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71558. /**
  71559. * Release all associated resources
  71560. */
  71561. dispose(): void;
  71562. private renderFunction;
  71563. private drag;
  71564. private drop;
  71565. private _traverseFolder;
  71566. private _processFiles;
  71567. /**
  71568. * Load files from a drop event
  71569. * @param event defines the drop event to use as source
  71570. */
  71571. loadFiles(event: any): void;
  71572. private _processReload;
  71573. /**
  71574. * Reload the current scene from the loaded files
  71575. */
  71576. reload(): void;
  71577. }
  71578. }
  71579. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71580. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71581. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71582. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71583. }
  71584. declare module "babylonjs/Misc/sceneOptimizer" {
  71585. import { Scene, IDisposable } from "babylonjs/scene";
  71586. import { Observable } from "babylonjs/Misc/observable";
  71587. /**
  71588. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71590. */
  71591. export class SceneOptimization {
  71592. /**
  71593. * Defines the priority of this optimization (0 by default which means first in the list)
  71594. */
  71595. priority: number;
  71596. /**
  71597. * Gets a string describing the action executed by the current optimization
  71598. * @returns description string
  71599. */
  71600. getDescription(): string;
  71601. /**
  71602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71603. * @param scene defines the current scene where to apply this optimization
  71604. * @param optimizer defines the current optimizer
  71605. * @returns true if everything that can be done was applied
  71606. */
  71607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71608. /**
  71609. * Creates the SceneOptimization object
  71610. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71611. * @param desc defines the description associated with the optimization
  71612. */
  71613. constructor(
  71614. /**
  71615. * Defines the priority of this optimization (0 by default which means first in the list)
  71616. */
  71617. priority?: number);
  71618. }
  71619. /**
  71620. * Defines an optimization used to reduce the size of render target textures
  71621. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71622. */
  71623. export class TextureOptimization extends SceneOptimization {
  71624. /**
  71625. * Defines the priority of this optimization (0 by default which means first in the list)
  71626. */
  71627. priority: number;
  71628. /**
  71629. * 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
  71630. */
  71631. maximumSize: number;
  71632. /**
  71633. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71634. */
  71635. step: number;
  71636. /**
  71637. * Gets a string describing the action executed by the current optimization
  71638. * @returns description string
  71639. */
  71640. getDescription(): string;
  71641. /**
  71642. * Creates the TextureOptimization object
  71643. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71644. * @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
  71645. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71646. */
  71647. constructor(
  71648. /**
  71649. * Defines the priority of this optimization (0 by default which means first in the list)
  71650. */
  71651. priority?: number,
  71652. /**
  71653. * 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. */
  71655. maximumSize?: number,
  71656. /**
  71657. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71658. */
  71659. step?: number);
  71660. /**
  71661. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71662. * @param scene defines the current scene where to apply this optimization
  71663. * @param optimizer defines the current optimizer
  71664. * @returns true if everything that can be done was applied
  71665. */
  71666. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71667. }
  71668. /**
  71669. * Defines an optimization used to increase or decrease the rendering resolution
  71670. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71671. */
  71672. export class HardwareScalingOptimization extends SceneOptimization {
  71673. /**
  71674. * Defines the priority of this optimization (0 by default which means first in the list)
  71675. */
  71676. priority: number;
  71677. /**
  71678. * Defines the maximum scale to use (2 by default)
  71679. */
  71680. maximumScale: number;
  71681. /**
  71682. * Defines the step to use between two passes (0.5 by default)
  71683. */
  71684. step: number;
  71685. private _currentScale;
  71686. private _directionOffset;
  71687. /**
  71688. * Gets a string describing the action executed by the current optimization
  71689. * @return description string
  71690. */
  71691. getDescription(): string;
  71692. /**
  71693. * Creates the HardwareScalingOptimization object
  71694. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71695. * @param maximumScale defines the maximum scale to use (2 by default)
  71696. * @param step defines the step to use between two passes (0.5 by default)
  71697. */
  71698. constructor(
  71699. /**
  71700. * Defines the priority of this optimization (0 by default which means first in the list)
  71701. */
  71702. priority?: number,
  71703. /**
  71704. * Defines the maximum scale to use (2 by default)
  71705. */
  71706. maximumScale?: number,
  71707. /**
  71708. * Defines the step to use between two passes (0.5 by default)
  71709. */
  71710. step?: number);
  71711. /**
  71712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71713. * @param scene defines the current scene where to apply this optimization
  71714. * @param optimizer defines the current optimizer
  71715. * @returns true if everything that can be done was applied
  71716. */
  71717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71718. }
  71719. /**
  71720. * Defines an optimization used to remove shadows
  71721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71722. */
  71723. export class ShadowsOptimization extends SceneOptimization {
  71724. /**
  71725. * Gets a string describing the action executed by the current optimization
  71726. * @return description string
  71727. */
  71728. getDescription(): string;
  71729. /**
  71730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71731. * @param scene defines the current scene where to apply this optimization
  71732. * @param optimizer defines the current optimizer
  71733. * @returns true if everything that can be done was applied
  71734. */
  71735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71736. }
  71737. /**
  71738. * Defines an optimization used to turn post-processes off
  71739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71740. */
  71741. export class PostProcessesOptimization extends SceneOptimization {
  71742. /**
  71743. * Gets a string describing the action executed by the current optimization
  71744. * @return description string
  71745. */
  71746. getDescription(): string;
  71747. /**
  71748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71749. * @param scene defines the current scene where to apply this optimization
  71750. * @param optimizer defines the current optimizer
  71751. * @returns true if everything that can be done was applied
  71752. */
  71753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71754. }
  71755. /**
  71756. * Defines an optimization used to turn lens flares off
  71757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71758. */
  71759. export class LensFlaresOptimization extends SceneOptimization {
  71760. /**
  71761. * Gets a string describing the action executed by the current optimization
  71762. * @return description string
  71763. */
  71764. getDescription(): string;
  71765. /**
  71766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71767. * @param scene defines the current scene where to apply this optimization
  71768. * @param optimizer defines the current optimizer
  71769. * @returns true if everything that can be done was applied
  71770. */
  71771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71772. }
  71773. /**
  71774. * Defines an optimization based on user defined callback.
  71775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71776. */
  71777. export class CustomOptimization extends SceneOptimization {
  71778. /**
  71779. * Callback called to apply the custom optimization.
  71780. */
  71781. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71782. /**
  71783. * Callback called to get custom description
  71784. */
  71785. onGetDescription: () => string;
  71786. /**
  71787. * Gets a string describing the action executed by the current optimization
  71788. * @returns description string
  71789. */
  71790. getDescription(): string;
  71791. /**
  71792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71793. * @param scene defines the current scene where to apply this optimization
  71794. * @param optimizer defines the current optimizer
  71795. * @returns true if everything that can be done was applied
  71796. */
  71797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71798. }
  71799. /**
  71800. * Defines an optimization used to turn particles off
  71801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71802. */
  71803. export class ParticlesOptimization extends SceneOptimization {
  71804. /**
  71805. * Gets a string describing the action executed by the current optimization
  71806. * @return description string
  71807. */
  71808. getDescription(): string;
  71809. /**
  71810. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71811. * @param scene defines the current scene where to apply this optimization
  71812. * @param optimizer defines the current optimizer
  71813. * @returns true if everything that can be done was applied
  71814. */
  71815. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71816. }
  71817. /**
  71818. * Defines an optimization used to turn render targets off
  71819. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71820. */
  71821. export class RenderTargetsOptimization extends SceneOptimization {
  71822. /**
  71823. * Gets a string describing the action executed by the current optimization
  71824. * @return description string
  71825. */
  71826. getDescription(): string;
  71827. /**
  71828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71829. * @param scene defines the current scene where to apply this optimization
  71830. * @param optimizer defines the current optimizer
  71831. * @returns true if everything that can be done was applied
  71832. */
  71833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71834. }
  71835. /**
  71836. * Defines an optimization used to merge meshes with compatible materials
  71837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71838. */
  71839. export class MergeMeshesOptimization extends SceneOptimization {
  71840. private static _UpdateSelectionTree;
  71841. /**
  71842. * Gets or sets a boolean which defines if optimization octree has to be updated
  71843. */
  71844. static get UpdateSelectionTree(): boolean;
  71845. /**
  71846. * Gets or sets a boolean which defines if optimization octree has to be updated
  71847. */
  71848. static set UpdateSelectionTree(value: boolean);
  71849. /**
  71850. * Gets a string describing the action executed by the current optimization
  71851. * @return description string
  71852. */
  71853. getDescription(): string;
  71854. private _canBeMerged;
  71855. /**
  71856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71857. * @param scene defines the current scene where to apply this optimization
  71858. * @param optimizer defines the current optimizer
  71859. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71860. * @returns true if everything that can be done was applied
  71861. */
  71862. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71863. }
  71864. /**
  71865. * Defines a list of options used by SceneOptimizer
  71866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71867. */
  71868. export class SceneOptimizerOptions {
  71869. /**
  71870. * Defines the target frame rate to reach (60 by default)
  71871. */
  71872. targetFrameRate: number;
  71873. /**
  71874. * Defines the interval between two checkes (2000ms by default)
  71875. */
  71876. trackerDuration: number;
  71877. /**
  71878. * Gets the list of optimizations to apply
  71879. */
  71880. optimizations: SceneOptimization[];
  71881. /**
  71882. * Creates a new list of options used by SceneOptimizer
  71883. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71884. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71885. */
  71886. constructor(
  71887. /**
  71888. * Defines the target frame rate to reach (60 by default)
  71889. */
  71890. targetFrameRate?: number,
  71891. /**
  71892. * Defines the interval between two checkes (2000ms by default)
  71893. */
  71894. trackerDuration?: number);
  71895. /**
  71896. * Add a new optimization
  71897. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71898. * @returns the current SceneOptimizerOptions
  71899. */
  71900. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71901. /**
  71902. * Add a new custom optimization
  71903. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71904. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71905. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71906. * @returns the current SceneOptimizerOptions
  71907. */
  71908. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71909. /**
  71910. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71911. * @param targetFrameRate defines the target frame rate (60 by default)
  71912. * @returns a SceneOptimizerOptions object
  71913. */
  71914. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71915. /**
  71916. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71917. * @param targetFrameRate defines the target frame rate (60 by default)
  71918. * @returns a SceneOptimizerOptions object
  71919. */
  71920. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71921. /**
  71922. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71923. * @param targetFrameRate defines the target frame rate (60 by default)
  71924. * @returns a SceneOptimizerOptions object
  71925. */
  71926. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71927. }
  71928. /**
  71929. * Class used to run optimizations in order to reach a target frame rate
  71930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71931. */
  71932. export class SceneOptimizer implements IDisposable {
  71933. private _isRunning;
  71934. private _options;
  71935. private _scene;
  71936. private _currentPriorityLevel;
  71937. private _targetFrameRate;
  71938. private _trackerDuration;
  71939. private _currentFrameRate;
  71940. private _sceneDisposeObserver;
  71941. private _improvementMode;
  71942. /**
  71943. * Defines an observable called when the optimizer reaches the target frame rate
  71944. */
  71945. onSuccessObservable: Observable<SceneOptimizer>;
  71946. /**
  71947. * Defines an observable called when the optimizer enables an optimization
  71948. */
  71949. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71950. /**
  71951. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71952. */
  71953. onFailureObservable: Observable<SceneOptimizer>;
  71954. /**
  71955. * Gets a boolean indicating if the optimizer is in improvement mode
  71956. */
  71957. get isInImprovementMode(): boolean;
  71958. /**
  71959. * Gets the current priority level (0 at start)
  71960. */
  71961. get currentPriorityLevel(): number;
  71962. /**
  71963. * Gets the current frame rate checked by the SceneOptimizer
  71964. */
  71965. get currentFrameRate(): number;
  71966. /**
  71967. * Gets or sets the current target frame rate (60 by default)
  71968. */
  71969. get targetFrameRate(): number;
  71970. /**
  71971. * Gets or sets the current target frame rate (60 by default)
  71972. */
  71973. set targetFrameRate(value: number);
  71974. /**
  71975. * Gets or sets the current interval between two checks (every 2000ms by default)
  71976. */
  71977. get trackerDuration(): number;
  71978. /**
  71979. * Gets or sets the current interval between two checks (every 2000ms by default)
  71980. */
  71981. set trackerDuration(value: number);
  71982. /**
  71983. * Gets the list of active optimizations
  71984. */
  71985. get optimizations(): SceneOptimization[];
  71986. /**
  71987. * Creates a new SceneOptimizer
  71988. * @param scene defines the scene to work on
  71989. * @param options defines the options to use with the SceneOptimizer
  71990. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71991. * @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)
  71992. */
  71993. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71994. /**
  71995. * Stops the current optimizer
  71996. */
  71997. stop(): void;
  71998. /**
  71999. * Reset the optimizer to initial step (current priority level = 0)
  72000. */
  72001. reset(): void;
  72002. /**
  72003. * Start the optimizer. By default it will try to reach a specific framerate
  72004. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72005. */
  72006. start(): void;
  72007. private _checkCurrentState;
  72008. /**
  72009. * Release all resources
  72010. */
  72011. dispose(): void;
  72012. /**
  72013. * Helper function to create a SceneOptimizer with one single line of code
  72014. * @param scene defines the scene to work on
  72015. * @param options defines the options to use with the SceneOptimizer
  72016. * @param onSuccess defines a callback to call on success
  72017. * @param onFailure defines a callback to call on failure
  72018. * @returns the new SceneOptimizer object
  72019. */
  72020. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72021. }
  72022. }
  72023. declare module "babylonjs/Misc/sceneSerializer" {
  72024. import { Scene } from "babylonjs/scene";
  72025. /**
  72026. * Class used to serialize a scene into a string
  72027. */
  72028. export class SceneSerializer {
  72029. /**
  72030. * Clear cache used by a previous serialization
  72031. */
  72032. static ClearCache(): void;
  72033. /**
  72034. * Serialize a scene into a JSON compatible object
  72035. * @param scene defines the scene to serialize
  72036. * @returns a JSON compatible object
  72037. */
  72038. static Serialize(scene: Scene): any;
  72039. /**
  72040. * Serialize a mesh into a JSON compatible object
  72041. * @param toSerialize defines the mesh to serialize
  72042. * @param withParents defines if parents must be serialized as well
  72043. * @param withChildren defines if children must be serialized as well
  72044. * @returns a JSON compatible object
  72045. */
  72046. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72047. }
  72048. }
  72049. declare module "babylonjs/Misc/textureTools" {
  72050. import { Texture } from "babylonjs/Materials/Textures/texture";
  72051. /**
  72052. * Class used to host texture specific utilities
  72053. */
  72054. export class TextureTools {
  72055. /**
  72056. * Uses the GPU to create a copy texture rescaled at a given size
  72057. * @param texture Texture to copy from
  72058. * @param width defines the desired width
  72059. * @param height defines the desired height
  72060. * @param useBilinearMode defines if bilinear mode has to be used
  72061. * @return the generated texture
  72062. */
  72063. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72064. }
  72065. }
  72066. declare module "babylonjs/Misc/videoRecorder" {
  72067. import { Nullable } from "babylonjs/types";
  72068. import { Engine } from "babylonjs/Engines/engine";
  72069. /**
  72070. * This represents the different options available for the video capture.
  72071. */
  72072. export interface VideoRecorderOptions {
  72073. /** Defines the mime type of the video. */
  72074. mimeType: string;
  72075. /** Defines the FPS the video should be recorded at. */
  72076. fps: number;
  72077. /** Defines the chunk size for the recording data. */
  72078. recordChunckSize: number;
  72079. /** The audio tracks to attach to the recording. */
  72080. audioTracks?: MediaStreamTrack[];
  72081. }
  72082. /**
  72083. * This can help with recording videos from BabylonJS.
  72084. * This is based on the available WebRTC functionalities of the browser.
  72085. *
  72086. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72087. */
  72088. export class VideoRecorder {
  72089. private static readonly _defaultOptions;
  72090. /**
  72091. * Returns whether or not the VideoRecorder is available in your browser.
  72092. * @param engine Defines the Babylon Engine.
  72093. * @returns true if supported otherwise false.
  72094. */
  72095. static IsSupported(engine: Engine): boolean;
  72096. private readonly _options;
  72097. private _canvas;
  72098. private _mediaRecorder;
  72099. private _recordedChunks;
  72100. private _fileName;
  72101. private _resolve;
  72102. private _reject;
  72103. /**
  72104. * True when a recording is already in progress.
  72105. */
  72106. get isRecording(): boolean;
  72107. /**
  72108. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72109. * @param engine Defines the BabylonJS Engine you wish to record.
  72110. * @param options Defines options that can be used to customize the capture.
  72111. */
  72112. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72113. /**
  72114. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72115. */
  72116. stopRecording(): void;
  72117. /**
  72118. * Starts recording the canvas for a max duration specified in parameters.
  72119. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72120. * If null no automatic download will start and you can rely on the promise to get the data back.
  72121. * @param maxDuration Defines the maximum recording time in seconds.
  72122. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72123. * @return A promise callback at the end of the recording with the video data in Blob.
  72124. */
  72125. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72126. /**
  72127. * Releases internal resources used during the recording.
  72128. */
  72129. dispose(): void;
  72130. private _handleDataAvailable;
  72131. private _handleError;
  72132. private _handleStop;
  72133. }
  72134. }
  72135. declare module "babylonjs/Misc/screenshotTools" {
  72136. import { Camera } from "babylonjs/Cameras/camera";
  72137. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72138. import { Engine } from "babylonjs/Engines/engine";
  72139. /**
  72140. * Class containing a set of static utilities functions for screenshots
  72141. */
  72142. export class ScreenshotTools {
  72143. /**
  72144. * Captures a screenshot of the current rendering
  72145. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72146. * @param engine defines the rendering engine
  72147. * @param camera defines the source camera
  72148. * @param size This parameter can be set to a single number or to an object with the
  72149. * following (optional) properties: precision, width, height. If a single number is passed,
  72150. * it will be used for both width and height. If an object is passed, the screenshot size
  72151. * will be derived from the parameters. The precision property is a multiplier allowing
  72152. * rendering at a higher or lower resolution
  72153. * @param successCallback defines the callback receives a single parameter which contains the
  72154. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72155. * src parameter of an <img> to display it
  72156. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72157. * Check your browser for supported MIME types
  72158. */
  72159. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72160. /**
  72161. * Captures a screenshot of the current rendering
  72162. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72163. * @param engine defines the rendering engine
  72164. * @param camera defines the source camera
  72165. * @param size This parameter can be set to a single number or to an object with the
  72166. * following (optional) properties: precision, width, height. If a single number is passed,
  72167. * it will be used for both width and height. If an object is passed, the screenshot size
  72168. * will be derived from the parameters. The precision property is a multiplier allowing
  72169. * rendering at a higher or lower resolution
  72170. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72171. * Check your browser for supported MIME types
  72172. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72173. * to the src parameter of an <img> to display it
  72174. */
  72175. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72176. /**
  72177. * Generates an image screenshot from the specified camera.
  72178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72179. * @param engine The engine to use for rendering
  72180. * @param camera The camera to use for rendering
  72181. * @param size This parameter can be set to a single number or to an object with the
  72182. * following (optional) properties: precision, width, height. If a single number is passed,
  72183. * it will be used for both width and height. If an object is passed, the screenshot size
  72184. * will be derived from the parameters. The precision property is a multiplier allowing
  72185. * rendering at a higher or lower resolution
  72186. * @param successCallback The callback receives a single parameter which contains the
  72187. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72188. * src parameter of an <img> to display it
  72189. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72190. * Check your browser for supported MIME types
  72191. * @param samples Texture samples (default: 1)
  72192. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72193. * @param fileName A name for for the downloaded file.
  72194. */
  72195. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72196. /**
  72197. * Generates an image screenshot from the specified camera.
  72198. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72199. * @param engine The engine to use for rendering
  72200. * @param camera The camera to use for rendering
  72201. * @param size This parameter can be set to a single number or to an object with the
  72202. * following (optional) properties: precision, width, height. If a single number is passed,
  72203. * it will be used for both width and height. If an object is passed, the screenshot size
  72204. * will be derived from the parameters. The precision property is a multiplier allowing
  72205. * rendering at a higher or lower resolution
  72206. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72207. * Check your browser for supported MIME types
  72208. * @param samples Texture samples (default: 1)
  72209. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72210. * @param fileName A name for for the downloaded file.
  72211. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72212. * to the src parameter of an <img> to display it
  72213. */
  72214. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72215. /**
  72216. * Gets height and width for screenshot size
  72217. * @private
  72218. */
  72219. private static _getScreenshotSize;
  72220. }
  72221. }
  72222. declare module "babylonjs/Misc/dataReader" {
  72223. /**
  72224. * Interface for a data buffer
  72225. */
  72226. export interface IDataBuffer {
  72227. /**
  72228. * Reads bytes from the data buffer.
  72229. * @param byteOffset The byte offset to read
  72230. * @param byteLength The byte length to read
  72231. * @returns A promise that resolves when the bytes are read
  72232. */
  72233. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72234. /**
  72235. * The byte length of the buffer.
  72236. */
  72237. readonly byteLength: number;
  72238. }
  72239. /**
  72240. * Utility class for reading from a data buffer
  72241. */
  72242. export class DataReader {
  72243. /**
  72244. * The data buffer associated with this data reader.
  72245. */
  72246. readonly buffer: IDataBuffer;
  72247. /**
  72248. * The current byte offset from the beginning of the data buffer.
  72249. */
  72250. byteOffset: number;
  72251. private _dataView;
  72252. private _dataByteOffset;
  72253. /**
  72254. * Constructor
  72255. * @param buffer The buffer to read
  72256. */
  72257. constructor(buffer: IDataBuffer);
  72258. /**
  72259. * Loads the given byte length.
  72260. * @param byteLength The byte length to load
  72261. * @returns A promise that resolves when the load is complete
  72262. */
  72263. loadAsync(byteLength: number): Promise<void>;
  72264. /**
  72265. * Read a unsigned 32-bit integer from the currently loaded data range.
  72266. * @returns The 32-bit integer read
  72267. */
  72268. readUint32(): number;
  72269. /**
  72270. * Read a byte array from the currently loaded data range.
  72271. * @param byteLength The byte length to read
  72272. * @returns The byte array read
  72273. */
  72274. readUint8Array(byteLength: number): Uint8Array;
  72275. /**
  72276. * Read a string from the currently loaded data range.
  72277. * @param byteLength The byte length to read
  72278. * @returns The string read
  72279. */
  72280. readString(byteLength: number): string;
  72281. /**
  72282. * Skips the given byte length the currently loaded data range.
  72283. * @param byteLength The byte length to skip
  72284. */
  72285. skipBytes(byteLength: number): void;
  72286. }
  72287. }
  72288. declare module "babylonjs/Misc/index" {
  72289. export * from "babylonjs/Misc/andOrNotEvaluator";
  72290. export * from "babylonjs/Misc/assetsManager";
  72291. export * from "babylonjs/Misc/basis";
  72292. export * from "babylonjs/Misc/dds";
  72293. export * from "babylonjs/Misc/decorators";
  72294. export * from "babylonjs/Misc/deferred";
  72295. export * from "babylonjs/Misc/environmentTextureTools";
  72296. export * from "babylonjs/Misc/meshExploder";
  72297. export * from "babylonjs/Misc/filesInput";
  72298. export * from "babylonjs/Misc/HighDynamicRange/index";
  72299. export * from "babylonjs/Misc/khronosTextureContainer";
  72300. export * from "babylonjs/Misc/observable";
  72301. export * from "babylonjs/Misc/performanceMonitor";
  72302. export * from "babylonjs/Misc/promise";
  72303. export * from "babylonjs/Misc/sceneOptimizer";
  72304. export * from "babylonjs/Misc/sceneSerializer";
  72305. export * from "babylonjs/Misc/smartArray";
  72306. export * from "babylonjs/Misc/stringDictionary";
  72307. export * from "babylonjs/Misc/tags";
  72308. export * from "babylonjs/Misc/textureTools";
  72309. export * from "babylonjs/Misc/tga";
  72310. export * from "babylonjs/Misc/tools";
  72311. export * from "babylonjs/Misc/videoRecorder";
  72312. export * from "babylonjs/Misc/virtualJoystick";
  72313. export * from "babylonjs/Misc/workerPool";
  72314. export * from "babylonjs/Misc/logger";
  72315. export * from "babylonjs/Misc/typeStore";
  72316. export * from "babylonjs/Misc/filesInputStore";
  72317. export * from "babylonjs/Misc/deepCopier";
  72318. export * from "babylonjs/Misc/pivotTools";
  72319. export * from "babylonjs/Misc/precisionDate";
  72320. export * from "babylonjs/Misc/screenshotTools";
  72321. export * from "babylonjs/Misc/typeStore";
  72322. export * from "babylonjs/Misc/webRequest";
  72323. export * from "babylonjs/Misc/iInspectable";
  72324. export * from "babylonjs/Misc/brdfTextureTools";
  72325. export * from "babylonjs/Misc/rgbdTextureTools";
  72326. export * from "babylonjs/Misc/gradients";
  72327. export * from "babylonjs/Misc/perfCounter";
  72328. export * from "babylonjs/Misc/fileRequest";
  72329. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72330. export * from "babylonjs/Misc/retryStrategy";
  72331. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72332. export * from "babylonjs/Misc/canvasGenerator";
  72333. export * from "babylonjs/Misc/fileTools";
  72334. export * from "babylonjs/Misc/stringTools";
  72335. export * from "babylonjs/Misc/dataReader";
  72336. export * from "babylonjs/Misc/minMaxReducer";
  72337. export * from "babylonjs/Misc/depthReducer";
  72338. }
  72339. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72340. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72341. import { Observable } from "babylonjs/Misc/observable";
  72342. import { Matrix } from "babylonjs/Maths/math.vector";
  72343. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72344. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72345. /**
  72346. * Options used for hit testing
  72347. */
  72348. export interface IWebXRHitTestOptions {
  72349. /**
  72350. * Only test when user interacted with the scene. Default - hit test every frame
  72351. */
  72352. testOnPointerDownOnly?: boolean;
  72353. /**
  72354. * The node to use to transform the local results to world coordinates
  72355. */
  72356. worldParentNode?: TransformNode;
  72357. }
  72358. /**
  72359. * Interface defining the babylon result of raycasting/hit-test
  72360. */
  72361. export interface IWebXRHitResult {
  72362. /**
  72363. * The native hit test result
  72364. */
  72365. xrHitResult: XRHitResult;
  72366. /**
  72367. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72368. */
  72369. transformationMatrix: Matrix;
  72370. }
  72371. /**
  72372. * The currently-working hit-test module.
  72373. * Hit test (or raycasting) is used to interact with the real world.
  72374. * For further information read here - https://github.com/immersive-web/hit-test
  72375. */
  72376. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72377. /**
  72378. * options to use when constructing this feature
  72379. */
  72380. readonly options: IWebXRHitTestOptions;
  72381. /**
  72382. * The module's name
  72383. */
  72384. static readonly Name: string;
  72385. /**
  72386. * The (Babylon) version of this module.
  72387. * This is an integer representing the implementation version.
  72388. * This number does not correspond to the webxr specs version
  72389. */
  72390. static readonly Version: number;
  72391. /**
  72392. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72393. * @param event the (select) event to use to select with
  72394. * @param referenceSpace the reference space to use for this hit test
  72395. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72396. */
  72397. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72398. /**
  72399. * execute a hit test with an XR Ray
  72400. *
  72401. * @param xrSession a native xrSession that will execute this hit test
  72402. * @param xrRay the ray (position and direction) to use for raycasting
  72403. * @param referenceSpace native XR reference space to use for the hit-test
  72404. * @param filter filter function that will filter the results
  72405. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72406. */
  72407. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72408. /**
  72409. * Triggered when new babylon (transformed) hit test results are available
  72410. */
  72411. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72412. private _onSelectEnabled;
  72413. /**
  72414. * Creates a new instance of the (legacy version) hit test feature
  72415. * @param _xrSessionManager an instance of WebXRSessionManager
  72416. * @param options options to use when constructing this feature
  72417. */
  72418. constructor(_xrSessionManager: WebXRSessionManager,
  72419. /**
  72420. * options to use when constructing this feature
  72421. */
  72422. options?: IWebXRHitTestOptions);
  72423. /**
  72424. * Populated with the last native XR Hit Results
  72425. */
  72426. lastNativeXRHitResults: XRHitResult[];
  72427. /**
  72428. * attach this feature
  72429. * Will usually be called by the features manager
  72430. *
  72431. * @returns true if successful.
  72432. */
  72433. attach(): boolean;
  72434. /**
  72435. * detach this feature.
  72436. * Will usually be called by the features manager
  72437. *
  72438. * @returns true if successful.
  72439. */
  72440. detach(): boolean;
  72441. private _onHitTestResults;
  72442. private _origin;
  72443. private _direction;
  72444. private _mat;
  72445. protected _onXRFrame(frame: XRFrame): void;
  72446. private _onSelect;
  72447. /**
  72448. * Dispose this feature and all of the resources attached
  72449. */
  72450. dispose(): void;
  72451. }
  72452. }
  72453. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72455. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72456. import { Observable } from "babylonjs/Misc/observable";
  72457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72458. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72459. /**
  72460. * Options used in the plane detector module
  72461. */
  72462. export interface IWebXRPlaneDetectorOptions {
  72463. /**
  72464. * The node to use to transform the local results to world coordinates
  72465. */
  72466. worldParentNode?: TransformNode;
  72467. }
  72468. /**
  72469. * A babylon interface for a webxr plane.
  72470. * A Plane is actually a polygon, built from N points in space
  72471. *
  72472. * Supported in chrome 79, not supported in canary 81 ATM
  72473. */
  72474. export interface IWebXRPlane {
  72475. /**
  72476. * a babylon-assigned ID for this polygon
  72477. */
  72478. id: number;
  72479. /**
  72480. * the native xr-plane object
  72481. */
  72482. xrPlane: XRPlane;
  72483. /**
  72484. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72485. */
  72486. polygonDefinition: Array<Vector3>;
  72487. /**
  72488. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72489. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72490. */
  72491. transformationMatrix: Matrix;
  72492. }
  72493. /**
  72494. * The plane detector is used to detect planes in the real world when in AR
  72495. * For more information see https://github.com/immersive-web/real-world-geometry/
  72496. */
  72497. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72498. private _options;
  72499. /**
  72500. * The module's name
  72501. */
  72502. static readonly Name: string;
  72503. /**
  72504. * The (Babylon) version of this module.
  72505. * This is an integer representing the implementation version.
  72506. * This number does not correspond to the webxr specs version
  72507. */
  72508. static readonly Version: number;
  72509. /**
  72510. * Observers registered here will be executed when a new plane was added to the session
  72511. */
  72512. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72513. /**
  72514. * Observers registered here will be executed when a plane is no longer detected in the session
  72515. */
  72516. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72517. /**
  72518. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72519. * This can execute N times every frame
  72520. */
  72521. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72522. private _enabled;
  72523. private _detectedPlanes;
  72524. private _lastFrameDetected;
  72525. /**
  72526. * construct a new Plane Detector
  72527. * @param _xrSessionManager an instance of xr Session manager
  72528. * @param _options configuration to use when constructing this feature
  72529. */
  72530. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72531. private _init;
  72532. protected _onXRFrame(frame: XRFrame): void;
  72533. /**
  72534. * Dispose this feature and all of the resources attached
  72535. */
  72536. dispose(): void;
  72537. private _updatePlaneWithXRPlane;
  72538. /**
  72539. * avoiding using Array.find for global support.
  72540. * @param xrPlane the plane to find in the array
  72541. */
  72542. private findIndexInPlaneArray;
  72543. }
  72544. }
  72545. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72546. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72547. import { Observable } from "babylonjs/Misc/observable";
  72548. import { Matrix } from "babylonjs/Maths/math.vector";
  72549. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72550. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72551. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72552. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72553. /**
  72554. * Configuration options of the anchor system
  72555. */
  72556. export interface IWebXRAnchorSystemOptions {
  72557. /**
  72558. * a node that will be used to convert local to world coordinates
  72559. */
  72560. worldParentNode?: TransformNode;
  72561. /**
  72562. * should the anchor system use plane detection.
  72563. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72564. */
  72565. usePlaneDetection?: boolean;
  72566. /**
  72567. * Should a new anchor be added every time a select event is triggered
  72568. */
  72569. addAnchorOnSelect?: boolean;
  72570. }
  72571. /**
  72572. * A babylon container for an XR Anchor
  72573. */
  72574. export interface IWebXRAnchor {
  72575. /**
  72576. * A babylon-assigned ID for this anchor
  72577. */
  72578. id: number;
  72579. /**
  72580. * The native anchor object
  72581. */
  72582. xrAnchor: XRAnchor;
  72583. /**
  72584. * Transformation matrix to apply to an object attached to this anchor
  72585. */
  72586. transformationMatrix: Matrix;
  72587. }
  72588. /**
  72589. * An implementation of the anchor system of WebXR.
  72590. * Note that the current documented implementation is not available in any browser. Future implementations
  72591. * will use the frame to create an anchor and not the session or a detected plane
  72592. * For further information see https://github.com/immersive-web/anchors/
  72593. */
  72594. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72595. private _options;
  72596. /**
  72597. * The module's name
  72598. */
  72599. static readonly Name: string;
  72600. /**
  72601. * The (Babylon) version of this module.
  72602. * This is an integer representing the implementation version.
  72603. * This number does not correspond to the webxr specs version
  72604. */
  72605. static readonly Version: number;
  72606. /**
  72607. * Observers registered here will be executed when a new anchor was added to the session
  72608. */
  72609. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72610. /**
  72611. * Observers registered here will be executed when an existing anchor updates
  72612. * This can execute N times every frame
  72613. */
  72614. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72615. /**
  72616. * Observers registered here will be executed when an anchor was removed from the session
  72617. */
  72618. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72619. private _planeDetector;
  72620. private _hitTestModule;
  72621. private _enabled;
  72622. private _trackedAnchors;
  72623. private _lastFrameDetected;
  72624. /**
  72625. * constructs a new anchor system
  72626. * @param _xrSessionManager an instance of WebXRSessionManager
  72627. * @param _options configuration object for this feature
  72628. */
  72629. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72630. /**
  72631. * set the plane detector to use in order to create anchors from frames
  72632. * @param planeDetector the plane-detector module to use
  72633. * @param enable enable plane-anchors. default is true
  72634. */
  72635. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72636. /**
  72637. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72638. * @param hitTestModule the hit-test module to use.
  72639. */
  72640. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72641. /**
  72642. * attach this feature
  72643. * Will usually be called by the features manager
  72644. *
  72645. * @returns true if successful.
  72646. */
  72647. attach(): boolean;
  72648. /**
  72649. * detach this feature.
  72650. * Will usually be called by the features manager
  72651. *
  72652. * @returns true if successful.
  72653. */
  72654. detach(): boolean;
  72655. /**
  72656. * Dispose this feature and all of the resources attached
  72657. */
  72658. dispose(): void;
  72659. protected _onXRFrame(frame: XRFrame): void;
  72660. private _onSelect;
  72661. /**
  72662. * Add anchor at a specific XR point.
  72663. *
  72664. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72665. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72666. * @returns a promise the fulfills when the anchor was created
  72667. */
  72668. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72669. private _updateAnchorWithXRFrame;
  72670. /**
  72671. * avoiding using Array.find for global support.
  72672. * @param xrAnchor the plane to find in the array
  72673. */
  72674. private _findIndexInAnchorArray;
  72675. }
  72676. }
  72677. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72678. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72680. import { Observable } from "babylonjs/Misc/observable";
  72681. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72682. /**
  72683. * Options interface for the background remover plugin
  72684. */
  72685. export interface IWebXRBackgroundRemoverOptions {
  72686. /**
  72687. * don't disable the environment helper
  72688. */
  72689. ignoreEnvironmentHelper?: boolean;
  72690. /**
  72691. * flags to configure the removal of the environment helper.
  72692. * If not set, the entire background will be removed. If set, flags should be set as well.
  72693. */
  72694. environmentHelperRemovalFlags?: {
  72695. /**
  72696. * Should the skybox be removed (default false)
  72697. */
  72698. skyBox?: boolean;
  72699. /**
  72700. * Should the ground be removed (default false)
  72701. */
  72702. ground?: boolean;
  72703. };
  72704. /**
  72705. * Further background meshes to disable when entering AR
  72706. */
  72707. backgroundMeshes?: AbstractMesh[];
  72708. }
  72709. /**
  72710. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72711. */
  72712. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72713. /**
  72714. * read-only options to be used in this module
  72715. */
  72716. readonly options: IWebXRBackgroundRemoverOptions;
  72717. /**
  72718. * The module's name
  72719. */
  72720. static readonly Name: string;
  72721. /**
  72722. * The (Babylon) version of this module.
  72723. * This is an integer representing the implementation version.
  72724. * This number does not correspond to the webxr specs version
  72725. */
  72726. static readonly Version: number;
  72727. /**
  72728. * registered observers will be triggered when the background state changes
  72729. */
  72730. onBackgroundStateChangedObservable: Observable<boolean>;
  72731. /**
  72732. * constructs a new background remover module
  72733. * @param _xrSessionManager the session manager for this module
  72734. * @param options read-only options to be used in this module
  72735. */
  72736. constructor(_xrSessionManager: WebXRSessionManager,
  72737. /**
  72738. * read-only options to be used in this module
  72739. */
  72740. options?: IWebXRBackgroundRemoverOptions);
  72741. /**
  72742. * attach this feature
  72743. * Will usually be called by the features manager
  72744. *
  72745. * @returns true if successful.
  72746. */
  72747. attach(): boolean;
  72748. /**
  72749. * detach this feature.
  72750. * Will usually be called by the features manager
  72751. *
  72752. * @returns true if successful.
  72753. */
  72754. detach(): boolean;
  72755. private _setBackgroundState;
  72756. /**
  72757. * Dispose this feature and all of the resources attached
  72758. */
  72759. dispose(): void;
  72760. protected _onXRFrame(_xrFrame: XRFrame): void;
  72761. }
  72762. }
  72763. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72764. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72765. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72766. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72767. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72768. /**
  72769. * Options for the controller physics feature
  72770. */
  72771. export class IWebXRControllerPhysicsOptions {
  72772. /**
  72773. * the xr input to use with this pointer selection
  72774. */
  72775. xrInput: WebXRInput;
  72776. /**
  72777. * The physics properties of the future impostors
  72778. */
  72779. physicsProperties?: {
  72780. /**
  72781. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72782. * Note that this requires a physics engine that supports mesh impostors!
  72783. */
  72784. useControllerMesh?: boolean;
  72785. /**
  72786. * The type of impostor to create. Default is sphere
  72787. */
  72788. impostorType?: number;
  72789. /**
  72790. * the size of the impostor. Defaults to 10cm
  72791. */
  72792. impostorSize?: number | {
  72793. width: number;
  72794. height: number;
  72795. depth: number;
  72796. };
  72797. /**
  72798. * Friction definitions
  72799. */
  72800. friction?: number;
  72801. /**
  72802. * Restitution
  72803. */
  72804. restitution?: number;
  72805. };
  72806. }
  72807. /**
  72808. * Add physics impostor to your webxr controllers,
  72809. * including naive calculation of their linear and angular velocity
  72810. */
  72811. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72812. private readonly _options;
  72813. /**
  72814. * The module's name
  72815. */
  72816. static readonly Name: string;
  72817. /**
  72818. * The (Babylon) version of this module.
  72819. * This is an integer representing the implementation version.
  72820. * This number does not correspond to the webxr specs version
  72821. */
  72822. static readonly Version: number;
  72823. private _lastTimestamp;
  72824. private _delta;
  72825. private _controllers;
  72826. private _tmpVector;
  72827. private _tmpQuaternion;
  72828. /**
  72829. * Construct a new Controller Physics Feature
  72830. * @param _xrSessionManager the corresponding xr session manager
  72831. * @param _options options to create this feature with
  72832. */
  72833. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72834. /**
  72835. * Update the physics properties provided in the constructor
  72836. * @param newProperties the new properties object
  72837. */
  72838. setPhysicsProperties(newProperties: {
  72839. impostorType?: number;
  72840. impostorSize?: number | {
  72841. width: number;
  72842. height: number;
  72843. depth: number;
  72844. };
  72845. friction?: number;
  72846. restitution?: number;
  72847. }): void;
  72848. /**
  72849. * attach this feature
  72850. * Will usually be called by the features manager
  72851. *
  72852. * @returns true if successful.
  72853. */
  72854. attach(): boolean;
  72855. /**
  72856. * detach this feature.
  72857. * Will usually be called by the features manager
  72858. *
  72859. * @returns true if successful.
  72860. */
  72861. detach(): boolean;
  72862. /**
  72863. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72864. * @param xrController the controller to add
  72865. */
  72866. addController(xrController: WebXRInputSource): void;
  72867. private _debugMode;
  72868. /**
  72869. * @hidden
  72870. * enable debugging - will show console outputs and the impostor mesh
  72871. */
  72872. _enablePhysicsDebug(): void;
  72873. private _attachController;
  72874. private _detachController;
  72875. protected _onXRFrame(_xrFrame: any): void;
  72876. }
  72877. }
  72878. declare module "babylonjs/XR/features/index" {
  72879. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72880. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72881. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72882. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72883. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72884. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72885. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72886. }
  72887. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72888. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72890. import { Scene } from "babylonjs/scene";
  72891. /**
  72892. * The motion controller class for all microsoft mixed reality controllers
  72893. */
  72894. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72895. /**
  72896. * The base url used to load the left and right controller models
  72897. */
  72898. static MODEL_BASE_URL: string;
  72899. /**
  72900. * The name of the left controller model file
  72901. */
  72902. static MODEL_LEFT_FILENAME: string;
  72903. /**
  72904. * The name of the right controller model file
  72905. */
  72906. static MODEL_RIGHT_FILENAME: string;
  72907. profileId: string;
  72908. protected readonly _mapping: {
  72909. defaultButton: {
  72910. "valueNodeName": string;
  72911. "unpressedNodeName": string;
  72912. "pressedNodeName": string;
  72913. };
  72914. defaultAxis: {
  72915. "valueNodeName": string;
  72916. "minNodeName": string;
  72917. "maxNodeName": string;
  72918. };
  72919. buttons: {
  72920. "xr-standard-trigger": {
  72921. "rootNodeName": string;
  72922. "componentProperty": string;
  72923. "states": string[];
  72924. };
  72925. "xr-standard-squeeze": {
  72926. "rootNodeName": string;
  72927. "componentProperty": string;
  72928. "states": string[];
  72929. };
  72930. "xr-standard-touchpad": {
  72931. "rootNodeName": string;
  72932. "labelAnchorNodeName": string;
  72933. "touchPointNodeName": string;
  72934. };
  72935. "xr-standard-thumbstick": {
  72936. "rootNodeName": string;
  72937. "componentProperty": string;
  72938. "states": string[];
  72939. };
  72940. };
  72941. axes: {
  72942. "xr-standard-touchpad": {
  72943. "x-axis": {
  72944. "rootNodeName": string;
  72945. };
  72946. "y-axis": {
  72947. "rootNodeName": string;
  72948. };
  72949. };
  72950. "xr-standard-thumbstick": {
  72951. "x-axis": {
  72952. "rootNodeName": string;
  72953. };
  72954. "y-axis": {
  72955. "rootNodeName": string;
  72956. };
  72957. };
  72958. };
  72959. };
  72960. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72961. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72962. protected _getFilenameAndPath(): {
  72963. filename: string;
  72964. path: string;
  72965. };
  72966. protected _updateModel(): void;
  72967. protected _getModelLoadingConstraints(): boolean;
  72968. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72969. }
  72970. }
  72971. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  72972. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72974. import { Scene } from "babylonjs/scene";
  72975. /**
  72976. * The motion controller class for oculus touch (quest, rift).
  72977. * This class supports legacy mapping as well the standard xr mapping
  72978. */
  72979. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72980. private _forceLegacyControllers;
  72981. /**
  72982. * The base url used to load the left and right controller models
  72983. */
  72984. static MODEL_BASE_URL: string;
  72985. /**
  72986. * The name of the left controller model file
  72987. */
  72988. static MODEL_LEFT_FILENAME: string;
  72989. /**
  72990. * The name of the right controller model file
  72991. */
  72992. static MODEL_RIGHT_FILENAME: string;
  72993. /**
  72994. * Base Url for the Quest controller model.
  72995. */
  72996. static QUEST_MODEL_BASE_URL: string;
  72997. profileId: string;
  72998. private _modelRootNode;
  72999. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73000. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73001. protected _getFilenameAndPath(): {
  73002. filename: string;
  73003. path: string;
  73004. };
  73005. /**
  73006. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73007. * between the touch and touch 2.
  73008. */
  73009. private _isQuest;
  73010. protected _updateModel(): void;
  73011. protected _getModelLoadingConstraints(): boolean;
  73012. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73013. }
  73014. }
  73015. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73016. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73017. import { Scene } from "babylonjs/scene";
  73018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73019. /**
  73020. * The motion controller class for the standard HTC-Vive controllers
  73021. */
  73022. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73023. /**
  73024. * The base url used to load the left and right controller models
  73025. */
  73026. static MODEL_BASE_URL: string;
  73027. /**
  73028. * File name for the controller model.
  73029. */
  73030. static MODEL_FILENAME: string;
  73031. profileId: string;
  73032. private _modelRootNode;
  73033. /**
  73034. * Create a new Vive motion controller object
  73035. * @param scene the scene to use to create this controller
  73036. * @param gamepadObject the corresponding gamepad object
  73037. * @param handness the handness of the controller
  73038. */
  73039. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73040. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73041. protected _getFilenameAndPath(): {
  73042. filename: string;
  73043. path: string;
  73044. };
  73045. protected _updateModel(): void;
  73046. protected _getModelLoadingConstraints(): boolean;
  73047. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73048. }
  73049. }
  73050. declare module "babylonjs/XR/motionController/index" {
  73051. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73052. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73053. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73054. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73055. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73056. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73057. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73058. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73059. }
  73060. declare module "babylonjs/XR/index" {
  73061. export * from "babylonjs/XR/webXRCamera";
  73062. export * from "babylonjs/XR/webXREnterExitUI";
  73063. export * from "babylonjs/XR/webXRExperienceHelper";
  73064. export * from "babylonjs/XR/webXRInput";
  73065. export * from "babylonjs/XR/webXRInputSource";
  73066. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73067. export * from "babylonjs/XR/webXRTypes";
  73068. export * from "babylonjs/XR/webXRSessionManager";
  73069. export * from "babylonjs/XR/webXRDefaultExperience";
  73070. export * from "babylonjs/XR/webXRFeaturesManager";
  73071. export * from "babylonjs/XR/features/index";
  73072. export * from "babylonjs/XR/motionController/index";
  73073. }
  73074. declare module "babylonjs/index" {
  73075. export * from "babylonjs/abstractScene";
  73076. export * from "babylonjs/Actions/index";
  73077. export * from "babylonjs/Animations/index";
  73078. export * from "babylonjs/assetContainer";
  73079. export * from "babylonjs/Audio/index";
  73080. export * from "babylonjs/Behaviors/index";
  73081. export * from "babylonjs/Bones/index";
  73082. export * from "babylonjs/Cameras/index";
  73083. export * from "babylonjs/Collisions/index";
  73084. export * from "babylonjs/Culling/index";
  73085. export * from "babylonjs/Debug/index";
  73086. export * from "babylonjs/Engines/index";
  73087. export * from "babylonjs/Events/index";
  73088. export * from "babylonjs/Gamepads/index";
  73089. export * from "babylonjs/Gizmos/index";
  73090. export * from "babylonjs/Helpers/index";
  73091. export * from "babylonjs/Instrumentation/index";
  73092. export * from "babylonjs/Layers/index";
  73093. export * from "babylonjs/LensFlares/index";
  73094. export * from "babylonjs/Lights/index";
  73095. export * from "babylonjs/Loading/index";
  73096. export * from "babylonjs/Materials/index";
  73097. export * from "babylonjs/Maths/index";
  73098. export * from "babylonjs/Meshes/index";
  73099. export * from "babylonjs/Morph/index";
  73100. export * from "babylonjs/Navigation/index";
  73101. export * from "babylonjs/node";
  73102. export * from "babylonjs/Offline/index";
  73103. export * from "babylonjs/Particles/index";
  73104. export * from "babylonjs/Physics/index";
  73105. export * from "babylonjs/PostProcesses/index";
  73106. export * from "babylonjs/Probes/index";
  73107. export * from "babylonjs/Rendering/index";
  73108. export * from "babylonjs/scene";
  73109. export * from "babylonjs/sceneComponent";
  73110. export * from "babylonjs/Sprites/index";
  73111. export * from "babylonjs/States/index";
  73112. export * from "babylonjs/Misc/index";
  73113. export * from "babylonjs/XR/index";
  73114. export * from "babylonjs/types";
  73115. }
  73116. declare module "babylonjs/Animations/pathCursor" {
  73117. import { Vector3 } from "babylonjs/Maths/math.vector";
  73118. import { Path2 } from "babylonjs/Maths/math.path";
  73119. /**
  73120. * A cursor which tracks a point on a path
  73121. */
  73122. export class PathCursor {
  73123. private path;
  73124. /**
  73125. * Stores path cursor callbacks for when an onchange event is triggered
  73126. */
  73127. private _onchange;
  73128. /**
  73129. * The value of the path cursor
  73130. */
  73131. value: number;
  73132. /**
  73133. * The animation array of the path cursor
  73134. */
  73135. animations: Animation[];
  73136. /**
  73137. * Initializes the path cursor
  73138. * @param path The path to track
  73139. */
  73140. constructor(path: Path2);
  73141. /**
  73142. * Gets the cursor point on the path
  73143. * @returns A point on the path cursor at the cursor location
  73144. */
  73145. getPoint(): Vector3;
  73146. /**
  73147. * Moves the cursor ahead by the step amount
  73148. * @param step The amount to move the cursor forward
  73149. * @returns This path cursor
  73150. */
  73151. moveAhead(step?: number): PathCursor;
  73152. /**
  73153. * Moves the cursor behind by the step amount
  73154. * @param step The amount to move the cursor back
  73155. * @returns This path cursor
  73156. */
  73157. moveBack(step?: number): PathCursor;
  73158. /**
  73159. * Moves the cursor by the step amount
  73160. * If the step amount is greater than one, an exception is thrown
  73161. * @param step The amount to move the cursor
  73162. * @returns This path cursor
  73163. */
  73164. move(step: number): PathCursor;
  73165. /**
  73166. * Ensures that the value is limited between zero and one
  73167. * @returns This path cursor
  73168. */
  73169. private ensureLimits;
  73170. /**
  73171. * Runs onchange callbacks on change (used by the animation engine)
  73172. * @returns This path cursor
  73173. */
  73174. private raiseOnChange;
  73175. /**
  73176. * Executes a function on change
  73177. * @param f A path cursor onchange callback
  73178. * @returns This path cursor
  73179. */
  73180. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73181. }
  73182. }
  73183. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73184. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73185. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73186. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73187. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73188. }
  73189. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73190. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73191. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73192. }
  73193. declare module "babylonjs/Engines/Processors/index" {
  73194. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73195. export * from "babylonjs/Engines/Processors/Expressions/index";
  73196. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73197. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73198. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73199. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73200. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73201. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73202. }
  73203. declare module "babylonjs/Legacy/legacy" {
  73204. import * as Babylon from "babylonjs/index";
  73205. export * from "babylonjs/index";
  73206. }
  73207. declare module "babylonjs/Shaders/blur.fragment" {
  73208. /** @hidden */
  73209. export var blurPixelShader: {
  73210. name: string;
  73211. shader: string;
  73212. };
  73213. }
  73214. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73215. /** @hidden */
  73216. export var pointCloudVertexDeclaration: {
  73217. name: string;
  73218. shader: string;
  73219. };
  73220. }
  73221. declare module "babylonjs" {
  73222. export * from "babylonjs/Legacy/legacy";
  73223. }
  73224. declare module BABYLON {
  73225. /** Alias type for value that can be null */
  73226. export type Nullable<T> = T | null;
  73227. /**
  73228. * Alias type for number that are floats
  73229. * @ignorenaming
  73230. */
  73231. export type float = number;
  73232. /**
  73233. * Alias type for number that are doubles.
  73234. * @ignorenaming
  73235. */
  73236. export type double = number;
  73237. /**
  73238. * Alias type for number that are integer
  73239. * @ignorenaming
  73240. */
  73241. export type int = number;
  73242. /** Alias type for number array or Float32Array */
  73243. export type FloatArray = number[] | Float32Array;
  73244. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73245. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73246. /**
  73247. * Alias for types that can be used by a Buffer or VertexBuffer.
  73248. */
  73249. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73250. /**
  73251. * Alias type for primitive types
  73252. * @ignorenaming
  73253. */
  73254. type Primitive = undefined | null | boolean | string | number | Function;
  73255. /**
  73256. * Type modifier to make all the properties of an object Readonly
  73257. */
  73258. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73259. /**
  73260. * Type modifier to make all the properties of an object Readonly recursively
  73261. */
  73262. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73263. /**
  73264. * Type modifier to make object properties readonly.
  73265. */
  73266. export type DeepImmutableObject<T> = {
  73267. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73268. };
  73269. /** @hidden */
  73270. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73271. }
  73272. }
  73273. declare module BABYLON {
  73274. /**
  73275. * A class serves as a medium between the observable and its observers
  73276. */
  73277. export class EventState {
  73278. /**
  73279. * Create a new EventState
  73280. * @param mask defines the mask associated with this state
  73281. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73282. * @param target defines the original target of the state
  73283. * @param currentTarget defines the current target of the state
  73284. */
  73285. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73286. /**
  73287. * Initialize the current event state
  73288. * @param mask defines the mask associated with this state
  73289. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73290. * @param target defines the original target of the state
  73291. * @param currentTarget defines the current target of the state
  73292. * @returns the current event state
  73293. */
  73294. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73295. /**
  73296. * An Observer can set this property to true to prevent subsequent observers of being notified
  73297. */
  73298. skipNextObservers: boolean;
  73299. /**
  73300. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73301. */
  73302. mask: number;
  73303. /**
  73304. * The object that originally notified the event
  73305. */
  73306. target?: any;
  73307. /**
  73308. * The current object in the bubbling phase
  73309. */
  73310. currentTarget?: any;
  73311. /**
  73312. * This will be populated with the return value of the last function that was executed.
  73313. * If it is the first function in the callback chain it will be the event data.
  73314. */
  73315. lastReturnValue?: any;
  73316. }
  73317. /**
  73318. * Represent an Observer registered to a given Observable object.
  73319. */
  73320. export class Observer<T> {
  73321. /**
  73322. * Defines the callback to call when the observer is notified
  73323. */
  73324. callback: (eventData: T, eventState: EventState) => void;
  73325. /**
  73326. * Defines the mask of the observer (used to filter notifications)
  73327. */
  73328. mask: number;
  73329. /**
  73330. * Defines the current scope used to restore the JS context
  73331. */
  73332. scope: any;
  73333. /** @hidden */
  73334. _willBeUnregistered: boolean;
  73335. /**
  73336. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73337. */
  73338. unregisterOnNextCall: boolean;
  73339. /**
  73340. * Creates a new observer
  73341. * @param callback defines the callback to call when the observer is notified
  73342. * @param mask defines the mask of the observer (used to filter notifications)
  73343. * @param scope defines the current scope used to restore the JS context
  73344. */
  73345. constructor(
  73346. /**
  73347. * Defines the callback to call when the observer is notified
  73348. */
  73349. callback: (eventData: T, eventState: EventState) => void,
  73350. /**
  73351. * Defines the mask of the observer (used to filter notifications)
  73352. */
  73353. mask: number,
  73354. /**
  73355. * Defines the current scope used to restore the JS context
  73356. */
  73357. scope?: any);
  73358. }
  73359. /**
  73360. * Represent a list of observers registered to multiple Observables object.
  73361. */
  73362. export class MultiObserver<T> {
  73363. private _observers;
  73364. private _observables;
  73365. /**
  73366. * Release associated resources
  73367. */
  73368. dispose(): void;
  73369. /**
  73370. * Raise a callback when one of the observable will notify
  73371. * @param observables defines a list of observables to watch
  73372. * @param callback defines the callback to call on notification
  73373. * @param mask defines the mask used to filter notifications
  73374. * @param scope defines the current scope used to restore the JS context
  73375. * @returns the new MultiObserver
  73376. */
  73377. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73378. }
  73379. /**
  73380. * The Observable class is a simple implementation of the Observable pattern.
  73381. *
  73382. * 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.
  73383. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73384. * 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).
  73385. * 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.
  73386. */
  73387. export class Observable<T> {
  73388. private _observers;
  73389. private _eventState;
  73390. private _onObserverAdded;
  73391. /**
  73392. * Gets the list of observers
  73393. */
  73394. get observers(): Array<Observer<T>>;
  73395. /**
  73396. * Creates a new observable
  73397. * @param onObserverAdded defines a callback to call when a new observer is added
  73398. */
  73399. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73400. /**
  73401. * Create a new Observer with the specified callback
  73402. * @param callback the callback that will be executed for that Observer
  73403. * @param mask the mask used to filter observers
  73404. * @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.
  73405. * @param scope optional scope for the callback to be called from
  73406. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73407. * @returns the new observer created for the callback
  73408. */
  73409. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73410. /**
  73411. * Create a new Observer with the specified callback and unregisters after the next notification
  73412. * @param callback the callback that will be executed for that Observer
  73413. * @returns the new observer created for the callback
  73414. */
  73415. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73416. /**
  73417. * Remove an Observer from the Observable object
  73418. * @param observer the instance of the Observer to remove
  73419. * @returns false if it doesn't belong to this Observable
  73420. */
  73421. remove(observer: Nullable<Observer<T>>): boolean;
  73422. /**
  73423. * Remove a callback from the Observable object
  73424. * @param callback the callback to remove
  73425. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73426. * @returns false if it doesn't belong to this Observable
  73427. */
  73428. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73429. private _deferUnregister;
  73430. private _remove;
  73431. /**
  73432. * Moves the observable to the top of the observer list making it get called first when notified
  73433. * @param observer the observer to move
  73434. */
  73435. makeObserverTopPriority(observer: Observer<T>): void;
  73436. /**
  73437. * Moves the observable to the bottom of the observer list making it get called last when notified
  73438. * @param observer the observer to move
  73439. */
  73440. makeObserverBottomPriority(observer: Observer<T>): void;
  73441. /**
  73442. * Notify all Observers by calling their respective callback with the given data
  73443. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73444. * @param eventData defines the data to send to all observers
  73445. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73446. * @param target defines the original target of the state
  73447. * @param currentTarget defines the current target of the state
  73448. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73449. */
  73450. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73451. /**
  73452. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73453. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73454. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73455. * and it is crucial that all callbacks will be executed.
  73456. * The order of the callbacks is kept, callbacks are not executed parallel.
  73457. *
  73458. * @param eventData The data to be sent to each callback
  73459. * @param mask is used to filter observers defaults to -1
  73460. * @param target defines the callback target (see EventState)
  73461. * @param currentTarget defines he current object in the bubbling phase
  73462. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73463. */
  73464. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73465. /**
  73466. * Notify a specific observer
  73467. * @param observer defines the observer to notify
  73468. * @param eventData defines the data to be sent to each callback
  73469. * @param mask is used to filter observers defaults to -1
  73470. */
  73471. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73472. /**
  73473. * Gets a boolean indicating if the observable has at least one observer
  73474. * @returns true is the Observable has at least one Observer registered
  73475. */
  73476. hasObservers(): boolean;
  73477. /**
  73478. * Clear the list of observers
  73479. */
  73480. clear(): void;
  73481. /**
  73482. * Clone the current observable
  73483. * @returns a new observable
  73484. */
  73485. clone(): Observable<T>;
  73486. /**
  73487. * Does this observable handles observer registered with a given mask
  73488. * @param mask defines the mask to be tested
  73489. * @return whether or not one observer registered with the given mask is handeled
  73490. **/
  73491. hasSpecificMask(mask?: number): boolean;
  73492. }
  73493. }
  73494. declare module BABYLON {
  73495. /**
  73496. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73497. * Babylon.js
  73498. */
  73499. export class DomManagement {
  73500. /**
  73501. * Checks if the window object exists
  73502. * @returns true if the window object exists
  73503. */
  73504. static IsWindowObjectExist(): boolean;
  73505. /**
  73506. * Checks if the navigator object exists
  73507. * @returns true if the navigator object exists
  73508. */
  73509. static IsNavigatorAvailable(): boolean;
  73510. /**
  73511. * Extracts text content from a DOM element hierarchy
  73512. * @param element defines the root element
  73513. * @returns a string
  73514. */
  73515. static GetDOMTextContent(element: HTMLElement): string;
  73516. }
  73517. }
  73518. declare module BABYLON {
  73519. /**
  73520. * Logger used througouht the application to allow configuration of
  73521. * the log level required for the messages.
  73522. */
  73523. export class Logger {
  73524. /**
  73525. * No log
  73526. */
  73527. static readonly NoneLogLevel: number;
  73528. /**
  73529. * Only message logs
  73530. */
  73531. static readonly MessageLogLevel: number;
  73532. /**
  73533. * Only warning logs
  73534. */
  73535. static readonly WarningLogLevel: number;
  73536. /**
  73537. * Only error logs
  73538. */
  73539. static readonly ErrorLogLevel: number;
  73540. /**
  73541. * All logs
  73542. */
  73543. static readonly AllLogLevel: number;
  73544. private static _LogCache;
  73545. /**
  73546. * Gets a value indicating the number of loading errors
  73547. * @ignorenaming
  73548. */
  73549. static errorsCount: number;
  73550. /**
  73551. * Callback called when a new log is added
  73552. */
  73553. static OnNewCacheEntry: (entry: string) => void;
  73554. private static _AddLogEntry;
  73555. private static _FormatMessage;
  73556. private static _LogDisabled;
  73557. private static _LogEnabled;
  73558. private static _WarnDisabled;
  73559. private static _WarnEnabled;
  73560. private static _ErrorDisabled;
  73561. private static _ErrorEnabled;
  73562. /**
  73563. * Log a message to the console
  73564. */
  73565. static Log: (message: string) => void;
  73566. /**
  73567. * Write a warning message to the console
  73568. */
  73569. static Warn: (message: string) => void;
  73570. /**
  73571. * Write an error message to the console
  73572. */
  73573. static Error: (message: string) => void;
  73574. /**
  73575. * Gets current log cache (list of logs)
  73576. */
  73577. static get LogCache(): string;
  73578. /**
  73579. * Clears the log cache
  73580. */
  73581. static ClearLogCache(): void;
  73582. /**
  73583. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73584. */
  73585. static set LogLevels(level: number);
  73586. }
  73587. }
  73588. declare module BABYLON {
  73589. /** @hidden */
  73590. export class _TypeStore {
  73591. /** @hidden */
  73592. static RegisteredTypes: {
  73593. [key: string]: Object;
  73594. };
  73595. /** @hidden */
  73596. static GetClass(fqdn: string): any;
  73597. }
  73598. }
  73599. declare module BABYLON {
  73600. /**
  73601. * Helper to manipulate strings
  73602. */
  73603. export class StringTools {
  73604. /**
  73605. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73606. * @param str Source string
  73607. * @param suffix Suffix to search for in the source string
  73608. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73609. */
  73610. static EndsWith(str: string, suffix: string): boolean;
  73611. /**
  73612. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73613. * @param str Source string
  73614. * @param suffix Suffix to search for in the source string
  73615. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73616. */
  73617. static StartsWith(str: string, suffix: string): boolean;
  73618. /**
  73619. * Decodes a buffer into a string
  73620. * @param buffer The buffer to decode
  73621. * @returns The decoded string
  73622. */
  73623. static Decode(buffer: Uint8Array | Uint16Array): string;
  73624. /**
  73625. * Encode a buffer to a base64 string
  73626. * @param buffer defines the buffer to encode
  73627. * @returns the encoded string
  73628. */
  73629. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73630. }
  73631. }
  73632. declare module BABYLON {
  73633. /**
  73634. * Class containing a set of static utilities functions for deep copy.
  73635. */
  73636. export class DeepCopier {
  73637. /**
  73638. * Tries to copy an object by duplicating every property
  73639. * @param source defines the source object
  73640. * @param destination defines the target object
  73641. * @param doNotCopyList defines a list of properties to avoid
  73642. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73643. */
  73644. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73645. }
  73646. }
  73647. declare module BABYLON {
  73648. /**
  73649. * Class containing a set of static utilities functions for precision date
  73650. */
  73651. export class PrecisionDate {
  73652. /**
  73653. * Gets either window.performance.now() if supported or Date.now() else
  73654. */
  73655. static get Now(): number;
  73656. }
  73657. }
  73658. declare module BABYLON {
  73659. /** @hidden */
  73660. export class _DevTools {
  73661. static WarnImport(name: string): string;
  73662. }
  73663. }
  73664. declare module BABYLON {
  73665. /**
  73666. * Interface used to define the mechanism to get data from the network
  73667. */
  73668. export interface IWebRequest {
  73669. /**
  73670. * Returns client's response url
  73671. */
  73672. responseURL: string;
  73673. /**
  73674. * Returns client's status
  73675. */
  73676. status: number;
  73677. /**
  73678. * Returns client's status as a text
  73679. */
  73680. statusText: string;
  73681. }
  73682. }
  73683. declare module BABYLON {
  73684. /**
  73685. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73686. */
  73687. export class WebRequest implements IWebRequest {
  73688. private _xhr;
  73689. /**
  73690. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73691. * i.e. when loading files, where the server/service expects an Authorization header
  73692. */
  73693. static CustomRequestHeaders: {
  73694. [key: string]: string;
  73695. };
  73696. /**
  73697. * Add callback functions in this array to update all the requests before they get sent to the network
  73698. */
  73699. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73700. private _injectCustomRequestHeaders;
  73701. /**
  73702. * Gets or sets a function to be called when loading progress changes
  73703. */
  73704. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73705. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73706. /**
  73707. * Returns client's state
  73708. */
  73709. get readyState(): number;
  73710. /**
  73711. * Returns client's status
  73712. */
  73713. get status(): number;
  73714. /**
  73715. * Returns client's status as a text
  73716. */
  73717. get statusText(): string;
  73718. /**
  73719. * Returns client's response
  73720. */
  73721. get response(): any;
  73722. /**
  73723. * Returns client's response url
  73724. */
  73725. get responseURL(): string;
  73726. /**
  73727. * Returns client's response as text
  73728. */
  73729. get responseText(): string;
  73730. /**
  73731. * Gets or sets the expected response type
  73732. */
  73733. get responseType(): XMLHttpRequestResponseType;
  73734. set responseType(value: XMLHttpRequestResponseType);
  73735. /** @hidden */
  73736. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73737. /** @hidden */
  73738. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73739. /**
  73740. * Cancels any network activity
  73741. */
  73742. abort(): void;
  73743. /**
  73744. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73745. * @param body defines an optional request body
  73746. */
  73747. send(body?: Document | BodyInit | null): void;
  73748. /**
  73749. * Sets the request method, request URL
  73750. * @param method defines the method to use (GET, POST, etc..)
  73751. * @param url defines the url to connect with
  73752. */
  73753. open(method: string, url: string): void;
  73754. /**
  73755. * Sets the value of a request header.
  73756. * @param name The name of the header whose value is to be set
  73757. * @param value The value to set as the body of the header
  73758. */
  73759. setRequestHeader(name: string, value: string): void;
  73760. /**
  73761. * Get the string containing the text of a particular header's value.
  73762. * @param name The name of the header
  73763. * @returns The string containing the text of the given header name
  73764. */
  73765. getResponseHeader(name: string): Nullable<string>;
  73766. }
  73767. }
  73768. declare module BABYLON {
  73769. /**
  73770. * File request interface
  73771. */
  73772. export interface IFileRequest {
  73773. /**
  73774. * Raised when the request is complete (success or error).
  73775. */
  73776. onCompleteObservable: Observable<IFileRequest>;
  73777. /**
  73778. * Aborts the request for a file.
  73779. */
  73780. abort: () => void;
  73781. }
  73782. }
  73783. declare module BABYLON {
  73784. /**
  73785. * Define options used to create a render target texture
  73786. */
  73787. export class RenderTargetCreationOptions {
  73788. /**
  73789. * Specifies is mipmaps must be generated
  73790. */
  73791. generateMipMaps?: boolean;
  73792. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73793. generateDepthBuffer?: boolean;
  73794. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73795. generateStencilBuffer?: boolean;
  73796. /** Defines texture type (int by default) */
  73797. type?: number;
  73798. /** Defines sampling mode (trilinear by default) */
  73799. samplingMode?: number;
  73800. /** Defines format (RGBA by default) */
  73801. format?: number;
  73802. }
  73803. }
  73804. declare module BABYLON {
  73805. /** Defines the cross module used constants to avoid circular dependncies */
  73806. export class Constants {
  73807. /** Defines that alpha blending is disabled */
  73808. static readonly ALPHA_DISABLE: number;
  73809. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73810. static readonly ALPHA_ADD: number;
  73811. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73812. static readonly ALPHA_COMBINE: number;
  73813. /** Defines that alpha blending is DEST - SRC * DEST */
  73814. static readonly ALPHA_SUBTRACT: number;
  73815. /** Defines that alpha blending is SRC * DEST */
  73816. static readonly ALPHA_MULTIPLY: number;
  73817. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73818. static readonly ALPHA_MAXIMIZED: number;
  73819. /** Defines that alpha blending is SRC + DEST */
  73820. static readonly ALPHA_ONEONE: number;
  73821. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73822. static readonly ALPHA_PREMULTIPLIED: number;
  73823. /**
  73824. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73825. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73826. */
  73827. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73828. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73829. static readonly ALPHA_INTERPOLATE: number;
  73830. /**
  73831. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73832. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73833. */
  73834. static readonly ALPHA_SCREENMODE: number;
  73835. /**
  73836. * Defines that alpha blending is SRC + DST
  73837. * Alpha will be set to SRC ALPHA + DST ALPHA
  73838. */
  73839. static readonly ALPHA_ONEONE_ONEONE: number;
  73840. /**
  73841. * Defines that alpha blending is SRC * DST ALPHA + DST
  73842. * Alpha will be set to 0
  73843. */
  73844. static readonly ALPHA_ALPHATOCOLOR: number;
  73845. /**
  73846. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73847. */
  73848. static readonly ALPHA_REVERSEONEMINUS: number;
  73849. /**
  73850. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73851. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73852. */
  73853. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73854. /**
  73855. * Defines that alpha blending is SRC + DST
  73856. * Alpha will be set to SRC ALPHA
  73857. */
  73858. static readonly ALPHA_ONEONE_ONEZERO: number;
  73859. /**
  73860. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73861. * Alpha will be set to DST ALPHA
  73862. */
  73863. static readonly ALPHA_EXCLUSION: number;
  73864. /** Defines that alpha blending equation a SUM */
  73865. static readonly ALPHA_EQUATION_ADD: number;
  73866. /** Defines that alpha blending equation a SUBSTRACTION */
  73867. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73868. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73869. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73870. /** Defines that alpha blending equation a MAX operation */
  73871. static readonly ALPHA_EQUATION_MAX: number;
  73872. /** Defines that alpha blending equation a MIN operation */
  73873. static readonly ALPHA_EQUATION_MIN: number;
  73874. /**
  73875. * Defines that alpha blending equation a DARKEN operation:
  73876. * It takes the min of the src and sums the alpha channels.
  73877. */
  73878. static readonly ALPHA_EQUATION_DARKEN: number;
  73879. /** Defines that the ressource is not delayed*/
  73880. static readonly DELAYLOADSTATE_NONE: number;
  73881. /** Defines that the ressource was successfully delay loaded */
  73882. static readonly DELAYLOADSTATE_LOADED: number;
  73883. /** Defines that the ressource is currently delay loading */
  73884. static readonly DELAYLOADSTATE_LOADING: number;
  73885. /** Defines that the ressource is delayed and has not started loading */
  73886. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73887. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73888. static readonly NEVER: number;
  73889. /** 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 */
  73890. static readonly ALWAYS: number;
  73891. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73892. static readonly LESS: number;
  73893. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73894. static readonly EQUAL: number;
  73895. /** 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 */
  73896. static readonly LEQUAL: number;
  73897. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73898. static readonly GREATER: number;
  73899. /** 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 */
  73900. static readonly GEQUAL: number;
  73901. /** 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 */
  73902. static readonly NOTEQUAL: number;
  73903. /** Passed to stencilOperation to specify that stencil value must be kept */
  73904. static readonly KEEP: number;
  73905. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73906. static readonly REPLACE: number;
  73907. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73908. static readonly INCR: number;
  73909. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73910. static readonly DECR: number;
  73911. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73912. static readonly INVERT: number;
  73913. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73914. static readonly INCR_WRAP: number;
  73915. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73916. static readonly DECR_WRAP: number;
  73917. /** Texture is not repeating outside of 0..1 UVs */
  73918. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73919. /** Texture is repeating outside of 0..1 UVs */
  73920. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73921. /** Texture is repeating and mirrored */
  73922. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73923. /** ALPHA */
  73924. static readonly TEXTUREFORMAT_ALPHA: number;
  73925. /** LUMINANCE */
  73926. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73927. /** LUMINANCE_ALPHA */
  73928. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73929. /** RGB */
  73930. static readonly TEXTUREFORMAT_RGB: number;
  73931. /** RGBA */
  73932. static readonly TEXTUREFORMAT_RGBA: number;
  73933. /** RED */
  73934. static readonly TEXTUREFORMAT_RED: number;
  73935. /** RED (2nd reference) */
  73936. static readonly TEXTUREFORMAT_R: number;
  73937. /** RG */
  73938. static readonly TEXTUREFORMAT_RG: number;
  73939. /** RED_INTEGER */
  73940. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73941. /** RED_INTEGER (2nd reference) */
  73942. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73943. /** RG_INTEGER */
  73944. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73945. /** RGB_INTEGER */
  73946. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73947. /** RGBA_INTEGER */
  73948. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73949. /** UNSIGNED_BYTE */
  73950. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73951. /** UNSIGNED_BYTE (2nd reference) */
  73952. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73953. /** FLOAT */
  73954. static readonly TEXTURETYPE_FLOAT: number;
  73955. /** HALF_FLOAT */
  73956. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73957. /** BYTE */
  73958. static readonly TEXTURETYPE_BYTE: number;
  73959. /** SHORT */
  73960. static readonly TEXTURETYPE_SHORT: number;
  73961. /** UNSIGNED_SHORT */
  73962. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73963. /** INT */
  73964. static readonly TEXTURETYPE_INT: number;
  73965. /** UNSIGNED_INT */
  73966. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73967. /** UNSIGNED_SHORT_4_4_4_4 */
  73968. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73969. /** UNSIGNED_SHORT_5_5_5_1 */
  73970. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73971. /** UNSIGNED_SHORT_5_6_5 */
  73972. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73973. /** UNSIGNED_INT_2_10_10_10_REV */
  73974. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73975. /** UNSIGNED_INT_24_8 */
  73976. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73977. /** UNSIGNED_INT_10F_11F_11F_REV */
  73978. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73979. /** UNSIGNED_INT_5_9_9_9_REV */
  73980. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73981. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73982. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73983. /** nearest is mag = nearest and min = nearest and no mip */
  73984. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73985. /** mag = nearest and min = nearest and mip = none */
  73986. static readonly TEXTURE_NEAREST_NEAREST: number;
  73987. /** Bilinear is mag = linear and min = linear and no mip */
  73988. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73989. /** mag = linear and min = linear and mip = none */
  73990. static readonly TEXTURE_LINEAR_LINEAR: number;
  73991. /** Trilinear is mag = linear and min = linear and mip = linear */
  73992. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73993. /** Trilinear is mag = linear and min = linear and mip = linear */
  73994. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73995. /** mag = nearest and min = nearest and mip = nearest */
  73996. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73997. /** mag = nearest and min = linear and mip = nearest */
  73998. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  73999. /** mag = nearest and min = linear and mip = linear */
  74000. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74001. /** mag = nearest and min = linear and mip = none */
  74002. static readonly TEXTURE_NEAREST_LINEAR: number;
  74003. /** nearest is mag = nearest and min = nearest and mip = linear */
  74004. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74005. /** mag = linear and min = nearest and mip = nearest */
  74006. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74007. /** mag = linear and min = nearest and mip = linear */
  74008. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74009. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74010. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74011. /** mag = linear and min = nearest and mip = none */
  74012. static readonly TEXTURE_LINEAR_NEAREST: number;
  74013. /** Explicit coordinates mode */
  74014. static readonly TEXTURE_EXPLICIT_MODE: number;
  74015. /** Spherical coordinates mode */
  74016. static readonly TEXTURE_SPHERICAL_MODE: number;
  74017. /** Planar coordinates mode */
  74018. static readonly TEXTURE_PLANAR_MODE: number;
  74019. /** Cubic coordinates mode */
  74020. static readonly TEXTURE_CUBIC_MODE: number;
  74021. /** Projection coordinates mode */
  74022. static readonly TEXTURE_PROJECTION_MODE: number;
  74023. /** Skybox coordinates mode */
  74024. static readonly TEXTURE_SKYBOX_MODE: number;
  74025. /** Inverse Cubic coordinates mode */
  74026. static readonly TEXTURE_INVCUBIC_MODE: number;
  74027. /** Equirectangular coordinates mode */
  74028. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74029. /** Equirectangular Fixed coordinates mode */
  74030. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74031. /** Equirectangular Fixed Mirrored coordinates mode */
  74032. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74033. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74034. static readonly SCALEMODE_FLOOR: number;
  74035. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74036. static readonly SCALEMODE_NEAREST: number;
  74037. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74038. static readonly SCALEMODE_CEILING: number;
  74039. /**
  74040. * The dirty texture flag value
  74041. */
  74042. static readonly MATERIAL_TextureDirtyFlag: number;
  74043. /**
  74044. * The dirty light flag value
  74045. */
  74046. static readonly MATERIAL_LightDirtyFlag: number;
  74047. /**
  74048. * The dirty fresnel flag value
  74049. */
  74050. static readonly MATERIAL_FresnelDirtyFlag: number;
  74051. /**
  74052. * The dirty attribute flag value
  74053. */
  74054. static readonly MATERIAL_AttributesDirtyFlag: number;
  74055. /**
  74056. * The dirty misc flag value
  74057. */
  74058. static readonly MATERIAL_MiscDirtyFlag: number;
  74059. /**
  74060. * The all dirty flag value
  74061. */
  74062. static readonly MATERIAL_AllDirtyFlag: number;
  74063. /**
  74064. * Returns the triangle fill mode
  74065. */
  74066. static readonly MATERIAL_TriangleFillMode: number;
  74067. /**
  74068. * Returns the wireframe mode
  74069. */
  74070. static readonly MATERIAL_WireFrameFillMode: number;
  74071. /**
  74072. * Returns the point fill mode
  74073. */
  74074. static readonly MATERIAL_PointFillMode: number;
  74075. /**
  74076. * Returns the point list draw mode
  74077. */
  74078. static readonly MATERIAL_PointListDrawMode: number;
  74079. /**
  74080. * Returns the line list draw mode
  74081. */
  74082. static readonly MATERIAL_LineListDrawMode: number;
  74083. /**
  74084. * Returns the line loop draw mode
  74085. */
  74086. static readonly MATERIAL_LineLoopDrawMode: number;
  74087. /**
  74088. * Returns the line strip draw mode
  74089. */
  74090. static readonly MATERIAL_LineStripDrawMode: number;
  74091. /**
  74092. * Returns the triangle strip draw mode
  74093. */
  74094. static readonly MATERIAL_TriangleStripDrawMode: number;
  74095. /**
  74096. * Returns the triangle fan draw mode
  74097. */
  74098. static readonly MATERIAL_TriangleFanDrawMode: number;
  74099. /**
  74100. * Stores the clock-wise side orientation
  74101. */
  74102. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74103. /**
  74104. * Stores the counter clock-wise side orientation
  74105. */
  74106. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74107. /**
  74108. * Nothing
  74109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74110. */
  74111. static readonly ACTION_NothingTrigger: number;
  74112. /**
  74113. * On pick
  74114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74115. */
  74116. static readonly ACTION_OnPickTrigger: number;
  74117. /**
  74118. * On left pick
  74119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74120. */
  74121. static readonly ACTION_OnLeftPickTrigger: number;
  74122. /**
  74123. * On right pick
  74124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74125. */
  74126. static readonly ACTION_OnRightPickTrigger: number;
  74127. /**
  74128. * On center pick
  74129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74130. */
  74131. static readonly ACTION_OnCenterPickTrigger: number;
  74132. /**
  74133. * On pick down
  74134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74135. */
  74136. static readonly ACTION_OnPickDownTrigger: number;
  74137. /**
  74138. * On double pick
  74139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74140. */
  74141. static readonly ACTION_OnDoublePickTrigger: number;
  74142. /**
  74143. * On pick up
  74144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74145. */
  74146. static readonly ACTION_OnPickUpTrigger: number;
  74147. /**
  74148. * On pick out.
  74149. * This trigger will only be raised if you also declared a OnPickDown
  74150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74151. */
  74152. static readonly ACTION_OnPickOutTrigger: number;
  74153. /**
  74154. * On long press
  74155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74156. */
  74157. static readonly ACTION_OnLongPressTrigger: number;
  74158. /**
  74159. * On pointer over
  74160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74161. */
  74162. static readonly ACTION_OnPointerOverTrigger: number;
  74163. /**
  74164. * On pointer out
  74165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74166. */
  74167. static readonly ACTION_OnPointerOutTrigger: number;
  74168. /**
  74169. * On every frame
  74170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74171. */
  74172. static readonly ACTION_OnEveryFrameTrigger: number;
  74173. /**
  74174. * On intersection enter
  74175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74176. */
  74177. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74178. /**
  74179. * On intersection exit
  74180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74181. */
  74182. static readonly ACTION_OnIntersectionExitTrigger: number;
  74183. /**
  74184. * On key down
  74185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74186. */
  74187. static readonly ACTION_OnKeyDownTrigger: number;
  74188. /**
  74189. * On key up
  74190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74191. */
  74192. static readonly ACTION_OnKeyUpTrigger: number;
  74193. /**
  74194. * Billboard mode will only apply to Y axis
  74195. */
  74196. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74197. /**
  74198. * Billboard mode will apply to all axes
  74199. */
  74200. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74201. /**
  74202. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74203. */
  74204. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74205. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74206. * Test order :
  74207. * Is the bounding sphere outside the frustum ?
  74208. * If not, are the bounding box vertices outside the frustum ?
  74209. * It not, then the cullable object is in the frustum.
  74210. */
  74211. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74212. /** Culling strategy : Bounding Sphere Only.
  74213. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74214. * It's also less accurate than the standard because some not visible objects can still be selected.
  74215. * Test : is the bounding sphere outside the frustum ?
  74216. * If not, then the cullable object is in the frustum.
  74217. */
  74218. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74219. /** Culling strategy : Optimistic Inclusion.
  74220. * This in an inclusion test first, then the standard exclusion test.
  74221. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74222. * 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.
  74223. * Anyway, it's as accurate as the standard strategy.
  74224. * Test :
  74225. * Is the cullable object bounding sphere center in the frustum ?
  74226. * If not, apply the default culling strategy.
  74227. */
  74228. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74229. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74230. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74231. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74232. * 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.
  74233. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74234. * Test :
  74235. * Is the cullable object bounding sphere center in the frustum ?
  74236. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74237. */
  74238. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74239. /**
  74240. * No logging while loading
  74241. */
  74242. static readonly SCENELOADER_NO_LOGGING: number;
  74243. /**
  74244. * Minimal logging while loading
  74245. */
  74246. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74247. /**
  74248. * Summary logging while loading
  74249. */
  74250. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74251. /**
  74252. * Detailled logging while loading
  74253. */
  74254. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74255. }
  74256. }
  74257. declare module BABYLON {
  74258. /**
  74259. * This represents the required contract to create a new type of texture loader.
  74260. */
  74261. export interface IInternalTextureLoader {
  74262. /**
  74263. * Defines wether the loader supports cascade loading the different faces.
  74264. */
  74265. supportCascades: boolean;
  74266. /**
  74267. * This returns if the loader support the current file information.
  74268. * @param extension defines the file extension of the file being loaded
  74269. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74270. * @param fallback defines the fallback internal texture if any
  74271. * @param isBase64 defines whether the texture is encoded as a base64
  74272. * @param isBuffer defines whether the texture data are stored as a buffer
  74273. * @returns true if the loader can load the specified file
  74274. */
  74275. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  74276. /**
  74277. * Transform the url before loading if required.
  74278. * @param rootUrl the url of the texture
  74279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74280. * @returns the transformed texture
  74281. */
  74282. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  74283. /**
  74284. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  74285. * @param rootUrl the url of the texture
  74286. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74287. * @returns the fallback texture
  74288. */
  74289. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  74290. /**
  74291. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  74292. * @param data contains the texture data
  74293. * @param texture defines the BabylonJS internal texture
  74294. * @param createPolynomials will be true if polynomials have been requested
  74295. * @param onLoad defines the callback to trigger once the texture is ready
  74296. * @param onError defines the callback to trigger in case of error
  74297. */
  74298. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74299. /**
  74300. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  74301. * @param data contains the texture data
  74302. * @param texture defines the BabylonJS internal texture
  74303. * @param callback defines the method to call once ready to upload
  74304. */
  74305. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74306. }
  74307. }
  74308. declare module BABYLON {
  74309. /**
  74310. * Class used to store and describe the pipeline context associated with an effect
  74311. */
  74312. export interface IPipelineContext {
  74313. /**
  74314. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74315. */
  74316. isAsync: boolean;
  74317. /**
  74318. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74319. */
  74320. isReady: boolean;
  74321. /** @hidden */
  74322. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74323. }
  74324. }
  74325. declare module BABYLON {
  74326. /**
  74327. * Class used to store gfx data (like WebGLBuffer)
  74328. */
  74329. export class DataBuffer {
  74330. /**
  74331. * Gets or sets the number of objects referencing this buffer
  74332. */
  74333. references: number;
  74334. /** Gets or sets the size of the underlying buffer */
  74335. capacity: number;
  74336. /**
  74337. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74338. */
  74339. is32Bits: boolean;
  74340. /**
  74341. * Gets the underlying buffer
  74342. */
  74343. get underlyingResource(): any;
  74344. }
  74345. }
  74346. declare module BABYLON {
  74347. /** @hidden */
  74348. export interface IShaderProcessor {
  74349. attributeProcessor?: (attribute: string) => string;
  74350. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74351. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74352. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74353. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74354. lineProcessor?: (line: string, isFragment: boolean) => string;
  74355. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74356. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74357. }
  74358. }
  74359. declare module BABYLON {
  74360. /** @hidden */
  74361. export interface ProcessingOptions {
  74362. defines: string[];
  74363. indexParameters: any;
  74364. isFragment: boolean;
  74365. shouldUseHighPrecisionShader: boolean;
  74366. supportsUniformBuffers: boolean;
  74367. shadersRepository: string;
  74368. includesShadersStore: {
  74369. [key: string]: string;
  74370. };
  74371. processor?: IShaderProcessor;
  74372. version: string;
  74373. platformName: string;
  74374. lookForClosingBracketForUniformBuffer?: boolean;
  74375. }
  74376. }
  74377. declare module BABYLON {
  74378. /** @hidden */
  74379. export class ShaderCodeNode {
  74380. line: string;
  74381. children: ShaderCodeNode[];
  74382. additionalDefineKey?: string;
  74383. additionalDefineValue?: string;
  74384. isValid(preprocessors: {
  74385. [key: string]: string;
  74386. }): boolean;
  74387. process(preprocessors: {
  74388. [key: string]: string;
  74389. }, options: ProcessingOptions): string;
  74390. }
  74391. }
  74392. declare module BABYLON {
  74393. /** @hidden */
  74394. export class ShaderCodeCursor {
  74395. private _lines;
  74396. lineIndex: number;
  74397. get currentLine(): string;
  74398. get canRead(): boolean;
  74399. set lines(value: string[]);
  74400. }
  74401. }
  74402. declare module BABYLON {
  74403. /** @hidden */
  74404. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74405. process(preprocessors: {
  74406. [key: string]: string;
  74407. }, options: ProcessingOptions): string;
  74408. }
  74409. }
  74410. declare module BABYLON {
  74411. /** @hidden */
  74412. export class ShaderDefineExpression {
  74413. isTrue(preprocessors: {
  74414. [key: string]: string;
  74415. }): boolean;
  74416. }
  74417. }
  74418. declare module BABYLON {
  74419. /** @hidden */
  74420. export class ShaderCodeTestNode extends ShaderCodeNode {
  74421. testExpression: ShaderDefineExpression;
  74422. isValid(preprocessors: {
  74423. [key: string]: string;
  74424. }): boolean;
  74425. }
  74426. }
  74427. declare module BABYLON {
  74428. /** @hidden */
  74429. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74430. define: string;
  74431. not: boolean;
  74432. constructor(define: string, not?: boolean);
  74433. isTrue(preprocessors: {
  74434. [key: string]: string;
  74435. }): boolean;
  74436. }
  74437. }
  74438. declare module BABYLON {
  74439. /** @hidden */
  74440. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74441. leftOperand: ShaderDefineExpression;
  74442. rightOperand: ShaderDefineExpression;
  74443. isTrue(preprocessors: {
  74444. [key: string]: string;
  74445. }): boolean;
  74446. }
  74447. }
  74448. declare module BABYLON {
  74449. /** @hidden */
  74450. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74451. leftOperand: ShaderDefineExpression;
  74452. rightOperand: ShaderDefineExpression;
  74453. isTrue(preprocessors: {
  74454. [key: string]: string;
  74455. }): boolean;
  74456. }
  74457. }
  74458. declare module BABYLON {
  74459. /** @hidden */
  74460. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74461. define: string;
  74462. operand: string;
  74463. testValue: string;
  74464. constructor(define: string, operand: string, testValue: string);
  74465. isTrue(preprocessors: {
  74466. [key: string]: string;
  74467. }): boolean;
  74468. }
  74469. }
  74470. declare module BABYLON {
  74471. /**
  74472. * Class used to enable access to offline support
  74473. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74474. */
  74475. export interface IOfflineProvider {
  74476. /**
  74477. * Gets a boolean indicating if scene must be saved in the database
  74478. */
  74479. enableSceneOffline: boolean;
  74480. /**
  74481. * Gets a boolean indicating if textures must be saved in the database
  74482. */
  74483. enableTexturesOffline: boolean;
  74484. /**
  74485. * Open the offline support and make it available
  74486. * @param successCallback defines the callback to call on success
  74487. * @param errorCallback defines the callback to call on error
  74488. */
  74489. open(successCallback: () => void, errorCallback: () => void): void;
  74490. /**
  74491. * Loads an image from the offline support
  74492. * @param url defines the url to load from
  74493. * @param image defines the target DOM image
  74494. */
  74495. loadImage(url: string, image: HTMLImageElement): void;
  74496. /**
  74497. * Loads a file from offline support
  74498. * @param url defines the URL to load from
  74499. * @param sceneLoaded defines a callback to call on success
  74500. * @param progressCallBack defines a callback to call when progress changed
  74501. * @param errorCallback defines a callback to call on error
  74502. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74503. */
  74504. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74505. }
  74506. }
  74507. declare module BABYLON {
  74508. /**
  74509. * Class used to help managing file picking and drag'n'drop
  74510. * File Storage
  74511. */
  74512. export class FilesInputStore {
  74513. /**
  74514. * List of files ready to be loaded
  74515. */
  74516. static FilesToLoad: {
  74517. [key: string]: File;
  74518. };
  74519. }
  74520. }
  74521. declare module BABYLON {
  74522. /**
  74523. * Class used to define a retry strategy when error happens while loading assets
  74524. */
  74525. export class RetryStrategy {
  74526. /**
  74527. * Function used to defines an exponential back off strategy
  74528. * @param maxRetries defines the maximum number of retries (3 by default)
  74529. * @param baseInterval defines the interval between retries
  74530. * @returns the strategy function to use
  74531. */
  74532. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74533. }
  74534. }
  74535. declare module BABYLON {
  74536. /**
  74537. * @ignore
  74538. * Application error to support additional information when loading a file
  74539. */
  74540. export abstract class BaseError extends Error {
  74541. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74542. }
  74543. }
  74544. declare module BABYLON {
  74545. /** @ignore */
  74546. export class LoadFileError extends BaseError {
  74547. request?: WebRequest;
  74548. file?: File;
  74549. /**
  74550. * Creates a new LoadFileError
  74551. * @param message defines the message of the error
  74552. * @param request defines the optional web request
  74553. * @param file defines the optional file
  74554. */
  74555. constructor(message: string, object?: WebRequest | File);
  74556. }
  74557. /** @ignore */
  74558. export class RequestFileError extends BaseError {
  74559. request: WebRequest;
  74560. /**
  74561. * Creates a new LoadFileError
  74562. * @param message defines the message of the error
  74563. * @param request defines the optional web request
  74564. */
  74565. constructor(message: string, request: WebRequest);
  74566. }
  74567. /** @ignore */
  74568. export class ReadFileError extends BaseError {
  74569. file: File;
  74570. /**
  74571. * Creates a new ReadFileError
  74572. * @param message defines the message of the error
  74573. * @param file defines the optional file
  74574. */
  74575. constructor(message: string, file: File);
  74576. }
  74577. /**
  74578. * @hidden
  74579. */
  74580. export class FileTools {
  74581. /**
  74582. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74583. */
  74584. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74585. /**
  74586. * Gets or sets the base URL to use to load assets
  74587. */
  74588. static BaseUrl: string;
  74589. /**
  74590. * Default behaviour for cors in the application.
  74591. * It can be a string if the expected behavior is identical in the entire app.
  74592. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74593. */
  74594. static CorsBehavior: string | ((url: string | string[]) => string);
  74595. /**
  74596. * Gets or sets a function used to pre-process url before using them to load assets
  74597. */
  74598. static PreprocessUrl: (url: string) => string;
  74599. /**
  74600. * Removes unwanted characters from an url
  74601. * @param url defines the url to clean
  74602. * @returns the cleaned url
  74603. */
  74604. private static _CleanUrl;
  74605. /**
  74606. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74607. * @param url define the url we are trying
  74608. * @param element define the dom element where to configure the cors policy
  74609. */
  74610. static SetCorsBehavior(url: string | string[], element: {
  74611. crossOrigin: string | null;
  74612. }): void;
  74613. /**
  74614. * Loads an image as an HTMLImageElement.
  74615. * @param input url string, ArrayBuffer, or Blob to load
  74616. * @param onLoad callback called when the image successfully loads
  74617. * @param onError callback called when the image fails to load
  74618. * @param offlineProvider offline provider for caching
  74619. * @param mimeType optional mime type
  74620. * @returns the HTMLImageElement of the loaded image
  74621. */
  74622. 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>;
  74623. /**
  74624. * Reads a file from a File object
  74625. * @param file defines the file to load
  74626. * @param onSuccess defines the callback to call when data is loaded
  74627. * @param onProgress defines the callback to call during loading process
  74628. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74629. * @param onError defines the callback to call when an error occurs
  74630. * @returns a file request object
  74631. */
  74632. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74633. /**
  74634. * Loads a file from a url
  74635. * @param url url to load
  74636. * @param onSuccess callback called when the file successfully loads
  74637. * @param onProgress callback called while file is loading (if the server supports this mode)
  74638. * @param offlineProvider defines the offline provider for caching
  74639. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74640. * @param onError callback called when the file fails to load
  74641. * @returns a file request object
  74642. */
  74643. 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;
  74644. /**
  74645. * Loads a file
  74646. * @param url url to load
  74647. * @param onSuccess callback called when the file successfully loads
  74648. * @param onProgress callback called while file is loading (if the server supports this mode)
  74649. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74650. * @param onError callback called when the file fails to load
  74651. * @param onOpened callback called when the web request is opened
  74652. * @returns a file request object
  74653. */
  74654. 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;
  74655. /**
  74656. * Checks if the loaded document was accessed via `file:`-Protocol.
  74657. * @returns boolean
  74658. */
  74659. static IsFileURL(): boolean;
  74660. }
  74661. }
  74662. declare module BABYLON {
  74663. /** @hidden */
  74664. export class ShaderProcessor {
  74665. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74666. private static _ProcessPrecision;
  74667. private static _ExtractOperation;
  74668. private static _BuildSubExpression;
  74669. private static _BuildExpression;
  74670. private static _MoveCursorWithinIf;
  74671. private static _MoveCursor;
  74672. private static _EvaluatePreProcessors;
  74673. private static _PreparePreProcessors;
  74674. private static _ProcessShaderConversion;
  74675. private static _ProcessIncludes;
  74676. /**
  74677. * Loads a file from a url
  74678. * @param url url to load
  74679. * @param onSuccess callback called when the file successfully loads
  74680. * @param onProgress callback called while file is loading (if the server supports this mode)
  74681. * @param offlineProvider defines the offline provider for caching
  74682. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74683. * @param onError callback called when the file fails to load
  74684. * @returns a file request object
  74685. * @hidden
  74686. */
  74687. 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;
  74688. }
  74689. }
  74690. declare module BABYLON {
  74691. /**
  74692. * @hidden
  74693. */
  74694. export interface IColor4Like {
  74695. r: float;
  74696. g: float;
  74697. b: float;
  74698. a: float;
  74699. }
  74700. /**
  74701. * @hidden
  74702. */
  74703. export interface IColor3Like {
  74704. r: float;
  74705. g: float;
  74706. b: float;
  74707. }
  74708. /**
  74709. * @hidden
  74710. */
  74711. export interface IVector4Like {
  74712. x: float;
  74713. y: float;
  74714. z: float;
  74715. w: float;
  74716. }
  74717. /**
  74718. * @hidden
  74719. */
  74720. export interface IVector3Like {
  74721. x: float;
  74722. y: float;
  74723. z: float;
  74724. }
  74725. /**
  74726. * @hidden
  74727. */
  74728. export interface IVector2Like {
  74729. x: float;
  74730. y: float;
  74731. }
  74732. /**
  74733. * @hidden
  74734. */
  74735. export interface IMatrixLike {
  74736. toArray(): DeepImmutable<Float32Array>;
  74737. updateFlag: int;
  74738. }
  74739. /**
  74740. * @hidden
  74741. */
  74742. export interface IViewportLike {
  74743. x: float;
  74744. y: float;
  74745. width: float;
  74746. height: float;
  74747. }
  74748. /**
  74749. * @hidden
  74750. */
  74751. export interface IPlaneLike {
  74752. normal: IVector3Like;
  74753. d: float;
  74754. normalize(): void;
  74755. }
  74756. }
  74757. declare module BABYLON {
  74758. /**
  74759. * Interface used to define common properties for effect fallbacks
  74760. */
  74761. export interface IEffectFallbacks {
  74762. /**
  74763. * Removes the defines that should be removed when falling back.
  74764. * @param currentDefines defines the current define statements for the shader.
  74765. * @param effect defines the current effect we try to compile
  74766. * @returns The resulting defines with defines of the current rank removed.
  74767. */
  74768. reduce(currentDefines: string, effect: Effect): string;
  74769. /**
  74770. * Removes the fallback from the bound mesh.
  74771. */
  74772. unBindMesh(): void;
  74773. /**
  74774. * Checks to see if more fallbacks are still availible.
  74775. */
  74776. hasMoreFallbacks: boolean;
  74777. }
  74778. }
  74779. declare module BABYLON {
  74780. /**
  74781. * Class used to evalaute queries containing `and` and `or` operators
  74782. */
  74783. export class AndOrNotEvaluator {
  74784. /**
  74785. * Evaluate a query
  74786. * @param query defines the query to evaluate
  74787. * @param evaluateCallback defines the callback used to filter result
  74788. * @returns true if the query matches
  74789. */
  74790. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74791. private static _HandleParenthesisContent;
  74792. private static _SimplifyNegation;
  74793. }
  74794. }
  74795. declare module BABYLON {
  74796. /**
  74797. * Class used to store custom tags
  74798. */
  74799. export class Tags {
  74800. /**
  74801. * Adds support for tags on the given object
  74802. * @param obj defines the object to use
  74803. */
  74804. static EnableFor(obj: any): void;
  74805. /**
  74806. * Removes tags support
  74807. * @param obj defines the object to use
  74808. */
  74809. static DisableFor(obj: any): void;
  74810. /**
  74811. * Gets a boolean indicating if the given object has tags
  74812. * @param obj defines the object to use
  74813. * @returns a boolean
  74814. */
  74815. static HasTags(obj: any): boolean;
  74816. /**
  74817. * Gets the tags available on a given object
  74818. * @param obj defines the object to use
  74819. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74820. * @returns the tags
  74821. */
  74822. static GetTags(obj: any, asString?: boolean): any;
  74823. /**
  74824. * Adds tags to an object
  74825. * @param obj defines the object to use
  74826. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74827. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74828. */
  74829. static AddTagsTo(obj: any, tagsString: string): void;
  74830. /**
  74831. * @hidden
  74832. */
  74833. static _AddTagTo(obj: any, tag: string): void;
  74834. /**
  74835. * Removes specific tags from a specific object
  74836. * @param obj defines the object to use
  74837. * @param tagsString defines the tags to remove
  74838. */
  74839. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74840. /**
  74841. * @hidden
  74842. */
  74843. static _RemoveTagFrom(obj: any, tag: string): void;
  74844. /**
  74845. * Defines if tags hosted on an object match a given query
  74846. * @param obj defines the object to use
  74847. * @param tagsQuery defines the tag query
  74848. * @returns a boolean
  74849. */
  74850. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74851. }
  74852. }
  74853. declare module BABYLON {
  74854. /**
  74855. * Scalar computation library
  74856. */
  74857. export class Scalar {
  74858. /**
  74859. * Two pi constants convenient for computation.
  74860. */
  74861. static TwoPi: number;
  74862. /**
  74863. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74864. * @param a number
  74865. * @param b number
  74866. * @param epsilon (default = 1.401298E-45)
  74867. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74868. */
  74869. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74870. /**
  74871. * Returns a string : the upper case translation of the number i to hexadecimal.
  74872. * @param i number
  74873. * @returns the upper case translation of the number i to hexadecimal.
  74874. */
  74875. static ToHex(i: number): string;
  74876. /**
  74877. * Returns -1 if value is negative and +1 is value is positive.
  74878. * @param value the value
  74879. * @returns the value itself if it's equal to zero.
  74880. */
  74881. static Sign(value: number): number;
  74882. /**
  74883. * Returns the value itself if it's between min and max.
  74884. * Returns min if the value is lower than min.
  74885. * Returns max if the value is greater than max.
  74886. * @param value the value to clmap
  74887. * @param min the min value to clamp to (default: 0)
  74888. * @param max the max value to clamp to (default: 1)
  74889. * @returns the clamped value
  74890. */
  74891. static Clamp(value: number, min?: number, max?: number): number;
  74892. /**
  74893. * the log2 of value.
  74894. * @param value the value to compute log2 of
  74895. * @returns the log2 of value.
  74896. */
  74897. static Log2(value: number): number;
  74898. /**
  74899. * Loops the value, so that it is never larger than length and never smaller than 0.
  74900. *
  74901. * This is similar to the modulo operator but it works with floating point numbers.
  74902. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74903. * With t = 5 and length = 2.5, the result would be 0.0.
  74904. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74905. * @param value the value
  74906. * @param length the length
  74907. * @returns the looped value
  74908. */
  74909. static Repeat(value: number, length: number): number;
  74910. /**
  74911. * Normalize the value between 0.0 and 1.0 using min and max values
  74912. * @param value value to normalize
  74913. * @param min max to normalize between
  74914. * @param max min to normalize between
  74915. * @returns the normalized value
  74916. */
  74917. static Normalize(value: number, min: number, max: number): number;
  74918. /**
  74919. * Denormalize the value from 0.0 and 1.0 using min and max values
  74920. * @param normalized value to denormalize
  74921. * @param min max to denormalize between
  74922. * @param max min to denormalize between
  74923. * @returns the denormalized value
  74924. */
  74925. static Denormalize(normalized: number, min: number, max: number): number;
  74926. /**
  74927. * Calculates the shortest difference between two given angles given in degrees.
  74928. * @param current current angle in degrees
  74929. * @param target target angle in degrees
  74930. * @returns the delta
  74931. */
  74932. static DeltaAngle(current: number, target: number): number;
  74933. /**
  74934. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74935. * @param tx value
  74936. * @param length length
  74937. * @returns The returned value will move back and forth between 0 and length
  74938. */
  74939. static PingPong(tx: number, length: number): number;
  74940. /**
  74941. * Interpolates between min and max with smoothing at the limits.
  74942. *
  74943. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74944. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74945. * @param from from
  74946. * @param to to
  74947. * @param tx value
  74948. * @returns the smooth stepped value
  74949. */
  74950. static SmoothStep(from: number, to: number, tx: number): number;
  74951. /**
  74952. * Moves a value current towards target.
  74953. *
  74954. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74955. * Negative values of maxDelta pushes the value away from target.
  74956. * @param current current value
  74957. * @param target target value
  74958. * @param maxDelta max distance to move
  74959. * @returns resulting value
  74960. */
  74961. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74962. /**
  74963. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74964. *
  74965. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74966. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74967. * @param current current value
  74968. * @param target target value
  74969. * @param maxDelta max distance to move
  74970. * @returns resulting angle
  74971. */
  74972. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74973. /**
  74974. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74975. * @param start start value
  74976. * @param end target value
  74977. * @param amount amount to lerp between
  74978. * @returns the lerped value
  74979. */
  74980. static Lerp(start: number, end: number, amount: number): number;
  74981. /**
  74982. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74983. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74984. * @param start start value
  74985. * @param end target value
  74986. * @param amount amount to lerp between
  74987. * @returns the lerped value
  74988. */
  74989. static LerpAngle(start: number, end: number, amount: number): number;
  74990. /**
  74991. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74992. * @param a start value
  74993. * @param b target value
  74994. * @param value value between a and b
  74995. * @returns the inverseLerp value
  74996. */
  74997. static InverseLerp(a: number, b: number, value: number): number;
  74998. /**
  74999. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75000. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75001. * @param value1 spline value
  75002. * @param tangent1 spline value
  75003. * @param value2 spline value
  75004. * @param tangent2 spline value
  75005. * @param amount input value
  75006. * @returns hermite result
  75007. */
  75008. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75009. /**
  75010. * Returns a random float number between and min and max values
  75011. * @param min min value of random
  75012. * @param max max value of random
  75013. * @returns random value
  75014. */
  75015. static RandomRange(min: number, max: number): number;
  75016. /**
  75017. * This function returns percentage of a number in a given range.
  75018. *
  75019. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75020. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75021. * @param number to convert to percentage
  75022. * @param min min range
  75023. * @param max max range
  75024. * @returns the percentage
  75025. */
  75026. static RangeToPercent(number: number, min: number, max: number): number;
  75027. /**
  75028. * This function returns number that corresponds to the percentage in a given range.
  75029. *
  75030. * PercentToRange(0.34,0,100) will return 34.
  75031. * @param percent to convert to number
  75032. * @param min min range
  75033. * @param max max range
  75034. * @returns the number
  75035. */
  75036. static PercentToRange(percent: number, min: number, max: number): number;
  75037. /**
  75038. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75039. * @param angle The angle to normalize in radian.
  75040. * @return The converted angle.
  75041. */
  75042. static NormalizeRadians(angle: number): number;
  75043. }
  75044. }
  75045. declare module BABYLON {
  75046. /**
  75047. * Constant used to convert a value to gamma space
  75048. * @ignorenaming
  75049. */
  75050. export const ToGammaSpace: number;
  75051. /**
  75052. * Constant used to convert a value to linear space
  75053. * @ignorenaming
  75054. */
  75055. export const ToLinearSpace = 2.2;
  75056. /**
  75057. * Constant used to define the minimal number value in Babylon.js
  75058. * @ignorenaming
  75059. */
  75060. let Epsilon: number;
  75061. }
  75062. declare module BABYLON {
  75063. /**
  75064. * Class used to represent a viewport on screen
  75065. */
  75066. export class Viewport {
  75067. /** viewport left coordinate */
  75068. x: number;
  75069. /** viewport top coordinate */
  75070. y: number;
  75071. /**viewport width */
  75072. width: number;
  75073. /** viewport height */
  75074. height: number;
  75075. /**
  75076. * Creates a Viewport object located at (x, y) and sized (width, height)
  75077. * @param x defines viewport left coordinate
  75078. * @param y defines viewport top coordinate
  75079. * @param width defines the viewport width
  75080. * @param height defines the viewport height
  75081. */
  75082. constructor(
  75083. /** viewport left coordinate */
  75084. x: number,
  75085. /** viewport top coordinate */
  75086. y: number,
  75087. /**viewport width */
  75088. width: number,
  75089. /** viewport height */
  75090. height: number);
  75091. /**
  75092. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75093. * @param renderWidth defines the rendering width
  75094. * @param renderHeight defines the rendering height
  75095. * @returns a new Viewport
  75096. */
  75097. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75098. /**
  75099. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75100. * @param renderWidth defines the rendering width
  75101. * @param renderHeight defines the rendering height
  75102. * @param ref defines the target viewport
  75103. * @returns the current viewport
  75104. */
  75105. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75106. /**
  75107. * Returns a new Viewport copied from the current one
  75108. * @returns a new Viewport
  75109. */
  75110. clone(): Viewport;
  75111. }
  75112. }
  75113. declare module BABYLON {
  75114. /**
  75115. * Class containing a set of static utilities functions for arrays.
  75116. */
  75117. export class ArrayTools {
  75118. /**
  75119. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75120. * @param size the number of element to construct and put in the array
  75121. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75122. * @returns a new array filled with new objects
  75123. */
  75124. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75125. }
  75126. }
  75127. declare module BABYLON {
  75128. /**
  75129. * Class representing a vector containing 2 coordinates
  75130. */
  75131. export class Vector2 {
  75132. /** defines the first coordinate */
  75133. x: number;
  75134. /** defines the second coordinate */
  75135. y: number;
  75136. /**
  75137. * Creates a new Vector2 from the given x and y coordinates
  75138. * @param x defines the first coordinate
  75139. * @param y defines the second coordinate
  75140. */
  75141. constructor(
  75142. /** defines the first coordinate */
  75143. x?: number,
  75144. /** defines the second coordinate */
  75145. y?: number);
  75146. /**
  75147. * Gets a string with the Vector2 coordinates
  75148. * @returns a string with the Vector2 coordinates
  75149. */
  75150. toString(): string;
  75151. /**
  75152. * Gets class name
  75153. * @returns the string "Vector2"
  75154. */
  75155. getClassName(): string;
  75156. /**
  75157. * Gets current vector hash code
  75158. * @returns the Vector2 hash code as a number
  75159. */
  75160. getHashCode(): number;
  75161. /**
  75162. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75163. * @param array defines the source array
  75164. * @param index defines the offset in source array
  75165. * @returns the current Vector2
  75166. */
  75167. toArray(array: FloatArray, index?: number): Vector2;
  75168. /**
  75169. * Copy the current vector to an array
  75170. * @returns a new array with 2 elements: the Vector2 coordinates.
  75171. */
  75172. asArray(): number[];
  75173. /**
  75174. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75175. * @param source defines the source Vector2
  75176. * @returns the current updated Vector2
  75177. */
  75178. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75179. /**
  75180. * Sets the Vector2 coordinates with the given floats
  75181. * @param x defines the first coordinate
  75182. * @param y defines the second coordinate
  75183. * @returns the current updated Vector2
  75184. */
  75185. copyFromFloats(x: number, y: number): Vector2;
  75186. /**
  75187. * Sets the Vector2 coordinates with the given floats
  75188. * @param x defines the first coordinate
  75189. * @param y defines the second coordinate
  75190. * @returns the current updated Vector2
  75191. */
  75192. set(x: number, y: number): Vector2;
  75193. /**
  75194. * Add another vector with the current one
  75195. * @param otherVector defines the other vector
  75196. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75197. */
  75198. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75199. /**
  75200. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75201. * @param otherVector defines the other vector
  75202. * @param result defines the target vector
  75203. * @returns the unmodified current Vector2
  75204. */
  75205. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75206. /**
  75207. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75208. * @param otherVector defines the other vector
  75209. * @returns the current updated Vector2
  75210. */
  75211. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75212. /**
  75213. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75214. * @param otherVector defines the other vector
  75215. * @returns a new Vector2
  75216. */
  75217. addVector3(otherVector: Vector3): Vector2;
  75218. /**
  75219. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75220. * @param otherVector defines the other vector
  75221. * @returns a new Vector2
  75222. */
  75223. subtract(otherVector: Vector2): Vector2;
  75224. /**
  75225. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75226. * @param otherVector defines the other vector
  75227. * @param result defines the target vector
  75228. * @returns the unmodified current Vector2
  75229. */
  75230. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75231. /**
  75232. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75233. * @param otherVector defines the other vector
  75234. * @returns the current updated Vector2
  75235. */
  75236. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75237. /**
  75238. * Multiplies in place the current Vector2 coordinates by the given ones
  75239. * @param otherVector defines the other vector
  75240. * @returns the current updated Vector2
  75241. */
  75242. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75243. /**
  75244. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75245. * @param otherVector defines the other vector
  75246. * @returns a new Vector2
  75247. */
  75248. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75249. /**
  75250. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75251. * @param otherVector defines the other vector
  75252. * @param result defines the target vector
  75253. * @returns the unmodified current Vector2
  75254. */
  75255. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75256. /**
  75257. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75258. * @param x defines the first coordinate
  75259. * @param y defines the second coordinate
  75260. * @returns a new Vector2
  75261. */
  75262. multiplyByFloats(x: number, y: number): Vector2;
  75263. /**
  75264. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75265. * @param otherVector defines the other vector
  75266. * @returns a new Vector2
  75267. */
  75268. divide(otherVector: Vector2): Vector2;
  75269. /**
  75270. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75271. * @param otherVector defines the other vector
  75272. * @param result defines the target vector
  75273. * @returns the unmodified current Vector2
  75274. */
  75275. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75276. /**
  75277. * Divides the current Vector2 coordinates by the given ones
  75278. * @param otherVector defines the other vector
  75279. * @returns the current updated Vector2
  75280. */
  75281. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75282. /**
  75283. * Gets a new Vector2 with current Vector2 negated coordinates
  75284. * @returns a new Vector2
  75285. */
  75286. negate(): Vector2;
  75287. /**
  75288. * Negate this vector in place
  75289. * @returns this
  75290. */
  75291. negateInPlace(): Vector2;
  75292. /**
  75293. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75294. * @param result defines the Vector3 object where to store the result
  75295. * @returns the current Vector2
  75296. */
  75297. negateToRef(result: Vector2): Vector2;
  75298. /**
  75299. * Multiply the Vector2 coordinates by scale
  75300. * @param scale defines the scaling factor
  75301. * @returns the current updated Vector2
  75302. */
  75303. scaleInPlace(scale: number): Vector2;
  75304. /**
  75305. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75306. * @param scale defines the scaling factor
  75307. * @returns a new Vector2
  75308. */
  75309. scale(scale: number): Vector2;
  75310. /**
  75311. * Scale the current Vector2 values by a factor to a given Vector2
  75312. * @param scale defines the scale factor
  75313. * @param result defines the Vector2 object where to store the result
  75314. * @returns the unmodified current Vector2
  75315. */
  75316. scaleToRef(scale: number, result: Vector2): Vector2;
  75317. /**
  75318. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75319. * @param scale defines the scale factor
  75320. * @param result defines the Vector2 object where to store the result
  75321. * @returns the unmodified current Vector2
  75322. */
  75323. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75324. /**
  75325. * Gets a boolean if two vectors are equals
  75326. * @param otherVector defines the other vector
  75327. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75328. */
  75329. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75330. /**
  75331. * Gets a boolean if two vectors are equals (using an epsilon value)
  75332. * @param otherVector defines the other vector
  75333. * @param epsilon defines the minimal distance to consider equality
  75334. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75335. */
  75336. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75337. /**
  75338. * Gets a new Vector2 from current Vector2 floored values
  75339. * @returns a new Vector2
  75340. */
  75341. floor(): Vector2;
  75342. /**
  75343. * Gets a new Vector2 from current Vector2 floored values
  75344. * @returns a new Vector2
  75345. */
  75346. fract(): Vector2;
  75347. /**
  75348. * Gets the length of the vector
  75349. * @returns the vector length (float)
  75350. */
  75351. length(): number;
  75352. /**
  75353. * Gets the vector squared length
  75354. * @returns the vector squared length (float)
  75355. */
  75356. lengthSquared(): number;
  75357. /**
  75358. * Normalize the vector
  75359. * @returns the current updated Vector2
  75360. */
  75361. normalize(): Vector2;
  75362. /**
  75363. * Gets a new Vector2 copied from the Vector2
  75364. * @returns a new Vector2
  75365. */
  75366. clone(): Vector2;
  75367. /**
  75368. * Gets a new Vector2(0, 0)
  75369. * @returns a new Vector2
  75370. */
  75371. static Zero(): Vector2;
  75372. /**
  75373. * Gets a new Vector2(1, 1)
  75374. * @returns a new Vector2
  75375. */
  75376. static One(): Vector2;
  75377. /**
  75378. * Gets a new Vector2 set from the given index element of the given array
  75379. * @param array defines the data source
  75380. * @param offset defines the offset in the data source
  75381. * @returns a new Vector2
  75382. */
  75383. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75384. /**
  75385. * Sets "result" from the given index element of the given array
  75386. * @param array defines the data source
  75387. * @param offset defines the offset in the data source
  75388. * @param result defines the target vector
  75389. */
  75390. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75391. /**
  75392. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75393. * @param value1 defines 1st point of control
  75394. * @param value2 defines 2nd point of control
  75395. * @param value3 defines 3rd point of control
  75396. * @param value4 defines 4th point of control
  75397. * @param amount defines the interpolation factor
  75398. * @returns a new Vector2
  75399. */
  75400. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75401. /**
  75402. * 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".
  75403. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75404. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75405. * @param value defines the value to clamp
  75406. * @param min defines the lower limit
  75407. * @param max defines the upper limit
  75408. * @returns a new Vector2
  75409. */
  75410. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75411. /**
  75412. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75413. * @param value1 defines the 1st control point
  75414. * @param tangent1 defines the outgoing tangent
  75415. * @param value2 defines the 2nd control point
  75416. * @param tangent2 defines the incoming tangent
  75417. * @param amount defines the interpolation factor
  75418. * @returns a new Vector2
  75419. */
  75420. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75421. /**
  75422. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75423. * @param start defines the start vector
  75424. * @param end defines the end vector
  75425. * @param amount defines the interpolation factor
  75426. * @returns a new Vector2
  75427. */
  75428. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75429. /**
  75430. * Gets the dot product of the vector "left" and the vector "right"
  75431. * @param left defines first vector
  75432. * @param right defines second vector
  75433. * @returns the dot product (float)
  75434. */
  75435. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75436. /**
  75437. * Returns a new Vector2 equal to the normalized given vector
  75438. * @param vector defines the vector to normalize
  75439. * @returns a new Vector2
  75440. */
  75441. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75442. /**
  75443. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75444. * @param left defines 1st vector
  75445. * @param right defines 2nd vector
  75446. * @returns a new Vector2
  75447. */
  75448. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75449. /**
  75450. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75451. * @param left defines 1st vector
  75452. * @param right defines 2nd vector
  75453. * @returns a new Vector2
  75454. */
  75455. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75456. /**
  75457. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75458. * @param vector defines the vector to transform
  75459. * @param transformation defines the matrix to apply
  75460. * @returns a new Vector2
  75461. */
  75462. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75463. /**
  75464. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75465. * @param vector defines the vector to transform
  75466. * @param transformation defines the matrix to apply
  75467. * @param result defines the target vector
  75468. */
  75469. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75470. /**
  75471. * Determines if a given vector is included in a triangle
  75472. * @param p defines the vector to test
  75473. * @param p0 defines 1st triangle point
  75474. * @param p1 defines 2nd triangle point
  75475. * @param p2 defines 3rd triangle point
  75476. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75477. */
  75478. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75479. /**
  75480. * Gets the distance between the vectors "value1" and "value2"
  75481. * @param value1 defines first vector
  75482. * @param value2 defines second vector
  75483. * @returns the distance between vectors
  75484. */
  75485. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75486. /**
  75487. * Returns the squared distance between the vectors "value1" and "value2"
  75488. * @param value1 defines first vector
  75489. * @param value2 defines second vector
  75490. * @returns the squared distance between vectors
  75491. */
  75492. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75493. /**
  75494. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75495. * @param value1 defines first vector
  75496. * @param value2 defines second vector
  75497. * @returns a new Vector2
  75498. */
  75499. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75500. /**
  75501. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75502. * @param p defines the middle point
  75503. * @param segA defines one point of the segment
  75504. * @param segB defines the other point of the segment
  75505. * @returns the shortest distance
  75506. */
  75507. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75508. }
  75509. /**
  75510. * Class used to store (x,y,z) vector representation
  75511. * A Vector3 is the main object used in 3D geometry
  75512. * It can represent etiher the coordinates of a point the space, either a direction
  75513. * Reminder: js uses a left handed forward facing system
  75514. */
  75515. export class Vector3 {
  75516. /**
  75517. * Defines the first coordinates (on X axis)
  75518. */
  75519. x: number;
  75520. /**
  75521. * Defines the second coordinates (on Y axis)
  75522. */
  75523. y: number;
  75524. /**
  75525. * Defines the third coordinates (on Z axis)
  75526. */
  75527. z: number;
  75528. private static _UpReadOnly;
  75529. private static _ZeroReadOnly;
  75530. /**
  75531. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75532. * @param x defines the first coordinates (on X axis)
  75533. * @param y defines the second coordinates (on Y axis)
  75534. * @param z defines the third coordinates (on Z axis)
  75535. */
  75536. constructor(
  75537. /**
  75538. * Defines the first coordinates (on X axis)
  75539. */
  75540. x?: number,
  75541. /**
  75542. * Defines the second coordinates (on Y axis)
  75543. */
  75544. y?: number,
  75545. /**
  75546. * Defines the third coordinates (on Z axis)
  75547. */
  75548. z?: number);
  75549. /**
  75550. * Creates a string representation of the Vector3
  75551. * @returns a string with the Vector3 coordinates.
  75552. */
  75553. toString(): string;
  75554. /**
  75555. * Gets the class name
  75556. * @returns the string "Vector3"
  75557. */
  75558. getClassName(): string;
  75559. /**
  75560. * Creates the Vector3 hash code
  75561. * @returns a number which tends to be unique between Vector3 instances
  75562. */
  75563. getHashCode(): number;
  75564. /**
  75565. * Creates an array containing three elements : the coordinates of the Vector3
  75566. * @returns a new array of numbers
  75567. */
  75568. asArray(): number[];
  75569. /**
  75570. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75571. * @param array defines the destination array
  75572. * @param index defines the offset in the destination array
  75573. * @returns the current Vector3
  75574. */
  75575. toArray(array: FloatArray, index?: number): Vector3;
  75576. /**
  75577. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75578. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75579. */
  75580. toQuaternion(): Quaternion;
  75581. /**
  75582. * Adds the given vector to the current Vector3
  75583. * @param otherVector defines the second operand
  75584. * @returns the current updated Vector3
  75585. */
  75586. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75587. /**
  75588. * Adds the given coordinates to the current Vector3
  75589. * @param x defines the x coordinate of the operand
  75590. * @param y defines the y coordinate of the operand
  75591. * @param z defines the z coordinate of the operand
  75592. * @returns the current updated Vector3
  75593. */
  75594. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75595. /**
  75596. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75597. * @param otherVector defines the second operand
  75598. * @returns the resulting Vector3
  75599. */
  75600. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75601. /**
  75602. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75603. * @param otherVector defines the second operand
  75604. * @param result defines the Vector3 object where to store the result
  75605. * @returns the current Vector3
  75606. */
  75607. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75608. /**
  75609. * Subtract the given vector from the current Vector3
  75610. * @param otherVector defines the second operand
  75611. * @returns the current updated Vector3
  75612. */
  75613. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75614. /**
  75615. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75616. * @param otherVector defines the second operand
  75617. * @returns the resulting Vector3
  75618. */
  75619. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75620. /**
  75621. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75622. * @param otherVector defines the second operand
  75623. * @param result defines the Vector3 object where to store the result
  75624. * @returns the current Vector3
  75625. */
  75626. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75627. /**
  75628. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75629. * @param x defines the x coordinate of the operand
  75630. * @param y defines the y coordinate of the operand
  75631. * @param z defines the z coordinate of the operand
  75632. * @returns the resulting Vector3
  75633. */
  75634. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75635. /**
  75636. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75637. * @param x defines the x coordinate of the operand
  75638. * @param y defines the y coordinate of the operand
  75639. * @param z defines the z coordinate of the operand
  75640. * @param result defines the Vector3 object where to store the result
  75641. * @returns the current Vector3
  75642. */
  75643. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75644. /**
  75645. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75646. * @returns a new Vector3
  75647. */
  75648. negate(): Vector3;
  75649. /**
  75650. * Negate this vector in place
  75651. * @returns this
  75652. */
  75653. negateInPlace(): Vector3;
  75654. /**
  75655. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75656. * @param result defines the Vector3 object where to store the result
  75657. * @returns the current Vector3
  75658. */
  75659. negateToRef(result: Vector3): Vector3;
  75660. /**
  75661. * Multiplies the Vector3 coordinates by the float "scale"
  75662. * @param scale defines the multiplier factor
  75663. * @returns the current updated Vector3
  75664. */
  75665. scaleInPlace(scale: number): Vector3;
  75666. /**
  75667. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75668. * @param scale defines the multiplier factor
  75669. * @returns a new Vector3
  75670. */
  75671. scale(scale: number): Vector3;
  75672. /**
  75673. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75674. * @param scale defines the multiplier factor
  75675. * @param result defines the Vector3 object where to store the result
  75676. * @returns the current Vector3
  75677. */
  75678. scaleToRef(scale: number, result: Vector3): Vector3;
  75679. /**
  75680. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75681. * @param scale defines the scale factor
  75682. * @param result defines the Vector3 object where to store the result
  75683. * @returns the unmodified current Vector3
  75684. */
  75685. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75686. /**
  75687. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75688. * @param otherVector defines the second operand
  75689. * @returns true if both vectors are equals
  75690. */
  75691. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75692. /**
  75693. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75694. * @param otherVector defines the second operand
  75695. * @param epsilon defines the minimal distance to define values as equals
  75696. * @returns true if both vectors are distant less than epsilon
  75697. */
  75698. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75699. /**
  75700. * Returns true if the current Vector3 coordinates equals the given floats
  75701. * @param x defines the x coordinate of the operand
  75702. * @param y defines the y coordinate of the operand
  75703. * @param z defines the z coordinate of the operand
  75704. * @returns true if both vectors are equals
  75705. */
  75706. equalsToFloats(x: number, y: number, z: number): boolean;
  75707. /**
  75708. * Multiplies the current Vector3 coordinates by the given ones
  75709. * @param otherVector defines the second operand
  75710. * @returns the current updated Vector3
  75711. */
  75712. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75713. /**
  75714. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75715. * @param otherVector defines the second operand
  75716. * @returns the new Vector3
  75717. */
  75718. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75719. /**
  75720. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75721. * @param otherVector defines the second operand
  75722. * @param result defines the Vector3 object where to store the result
  75723. * @returns the current Vector3
  75724. */
  75725. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75726. /**
  75727. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75728. * @param x defines the x coordinate of the operand
  75729. * @param y defines the y coordinate of the operand
  75730. * @param z defines the z coordinate of the operand
  75731. * @returns the new Vector3
  75732. */
  75733. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75734. /**
  75735. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75736. * @param otherVector defines the second operand
  75737. * @returns the new Vector3
  75738. */
  75739. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75740. /**
  75741. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75742. * @param otherVector defines the second operand
  75743. * @param result defines the Vector3 object where to store the result
  75744. * @returns the current Vector3
  75745. */
  75746. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75747. /**
  75748. * Divides the current Vector3 coordinates by the given ones.
  75749. * @param otherVector defines the second operand
  75750. * @returns the current updated Vector3
  75751. */
  75752. divideInPlace(otherVector: Vector3): Vector3;
  75753. /**
  75754. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75755. * @param other defines the second operand
  75756. * @returns the current updated Vector3
  75757. */
  75758. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75759. /**
  75760. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75761. * @param other defines the second operand
  75762. * @returns the current updated Vector3
  75763. */
  75764. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75765. /**
  75766. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75767. * @param x defines the x coordinate of the operand
  75768. * @param y defines the y coordinate of the operand
  75769. * @param z defines the z coordinate of the operand
  75770. * @returns the current updated Vector3
  75771. */
  75772. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75773. /**
  75774. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75775. * @param x defines the x coordinate of the operand
  75776. * @param y defines the y coordinate of the operand
  75777. * @param z defines the z coordinate of the operand
  75778. * @returns the current updated Vector3
  75779. */
  75780. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75781. /**
  75782. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75783. * Check if is non uniform within a certain amount of decimal places to account for this
  75784. * @param epsilon the amount the values can differ
  75785. * @returns if the the vector is non uniform to a certain number of decimal places
  75786. */
  75787. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75788. /**
  75789. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75790. */
  75791. get isNonUniform(): boolean;
  75792. /**
  75793. * Gets a new Vector3 from current Vector3 floored values
  75794. * @returns a new Vector3
  75795. */
  75796. floor(): Vector3;
  75797. /**
  75798. * Gets a new Vector3 from current Vector3 floored values
  75799. * @returns a new Vector3
  75800. */
  75801. fract(): Vector3;
  75802. /**
  75803. * Gets the length of the Vector3
  75804. * @returns the length of the Vector3
  75805. */
  75806. length(): number;
  75807. /**
  75808. * Gets the squared length of the Vector3
  75809. * @returns squared length of the Vector3
  75810. */
  75811. lengthSquared(): number;
  75812. /**
  75813. * Normalize the current Vector3.
  75814. * Please note that this is an in place operation.
  75815. * @returns the current updated Vector3
  75816. */
  75817. normalize(): Vector3;
  75818. /**
  75819. * Reorders the x y z properties of the vector in place
  75820. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75821. * @returns the current updated vector
  75822. */
  75823. reorderInPlace(order: string): this;
  75824. /**
  75825. * Rotates the vector around 0,0,0 by a quaternion
  75826. * @param quaternion the rotation quaternion
  75827. * @param result vector to store the result
  75828. * @returns the resulting vector
  75829. */
  75830. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75831. /**
  75832. * Rotates a vector around a given point
  75833. * @param quaternion the rotation quaternion
  75834. * @param point the point to rotate around
  75835. * @param result vector to store the result
  75836. * @returns the resulting vector
  75837. */
  75838. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75839. /**
  75840. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75841. * The cross product is then orthogonal to both current and "other"
  75842. * @param other defines the right operand
  75843. * @returns the cross product
  75844. */
  75845. cross(other: Vector3): Vector3;
  75846. /**
  75847. * Normalize the current Vector3 with the given input length.
  75848. * Please note that this is an in place operation.
  75849. * @param len the length of the vector
  75850. * @returns the current updated Vector3
  75851. */
  75852. normalizeFromLength(len: number): Vector3;
  75853. /**
  75854. * Normalize the current Vector3 to a new vector
  75855. * @returns the new Vector3
  75856. */
  75857. normalizeToNew(): Vector3;
  75858. /**
  75859. * Normalize the current Vector3 to the reference
  75860. * @param reference define the Vector3 to update
  75861. * @returns the updated Vector3
  75862. */
  75863. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75864. /**
  75865. * Creates a new Vector3 copied from the current Vector3
  75866. * @returns the new Vector3
  75867. */
  75868. clone(): Vector3;
  75869. /**
  75870. * Copies the given vector coordinates to the current Vector3 ones
  75871. * @param source defines the source Vector3
  75872. * @returns the current updated Vector3
  75873. */
  75874. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75875. /**
  75876. * Copies the given floats to the current Vector3 coordinates
  75877. * @param x defines the x coordinate of the operand
  75878. * @param y defines the y coordinate of the operand
  75879. * @param z defines the z coordinate of the operand
  75880. * @returns the current updated Vector3
  75881. */
  75882. copyFromFloats(x: number, y: number, z: number): Vector3;
  75883. /**
  75884. * Copies the given floats to the current Vector3 coordinates
  75885. * @param x defines the x coordinate of the operand
  75886. * @param y defines the y coordinate of the operand
  75887. * @param z defines the z coordinate of the operand
  75888. * @returns the current updated Vector3
  75889. */
  75890. set(x: number, y: number, z: number): Vector3;
  75891. /**
  75892. * Copies the given float to the current Vector3 coordinates
  75893. * @param v defines the x, y and z coordinates of the operand
  75894. * @returns the current updated Vector3
  75895. */
  75896. setAll(v: number): Vector3;
  75897. /**
  75898. * Get the clip factor between two vectors
  75899. * @param vector0 defines the first operand
  75900. * @param vector1 defines the second operand
  75901. * @param axis defines the axis to use
  75902. * @param size defines the size along the axis
  75903. * @returns the clip factor
  75904. */
  75905. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75906. /**
  75907. * Get angle between two vectors
  75908. * @param vector0 angle between vector0 and vector1
  75909. * @param vector1 angle between vector0 and vector1
  75910. * @param normal direction of the normal
  75911. * @return the angle between vector0 and vector1
  75912. */
  75913. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75914. /**
  75915. * Returns a new Vector3 set from the index "offset" of the given array
  75916. * @param array defines the source array
  75917. * @param offset defines the offset in the source array
  75918. * @returns the new Vector3
  75919. */
  75920. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75921. /**
  75922. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75923. * @param array defines the source array
  75924. * @param offset defines the offset in the source array
  75925. * @returns the new Vector3
  75926. * @deprecated Please use FromArray instead.
  75927. */
  75928. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75929. /**
  75930. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75931. * @param array defines the source array
  75932. * @param offset defines the offset in the source array
  75933. * @param result defines the Vector3 where to store the result
  75934. */
  75935. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75936. /**
  75937. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75938. * @param array defines the source array
  75939. * @param offset defines the offset in the source array
  75940. * @param result defines the Vector3 where to store the result
  75941. * @deprecated Please use FromArrayToRef instead.
  75942. */
  75943. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75944. /**
  75945. * Sets the given vector "result" with the given floats.
  75946. * @param x defines the x coordinate of the source
  75947. * @param y defines the y coordinate of the source
  75948. * @param z defines the z coordinate of the source
  75949. * @param result defines the Vector3 where to store the result
  75950. */
  75951. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75952. /**
  75953. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75954. * @returns a new empty Vector3
  75955. */
  75956. static Zero(): Vector3;
  75957. /**
  75958. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75959. * @returns a new unit Vector3
  75960. */
  75961. static One(): Vector3;
  75962. /**
  75963. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75964. * @returns a new up Vector3
  75965. */
  75966. static Up(): Vector3;
  75967. /**
  75968. * Gets a up Vector3 that must not be updated
  75969. */
  75970. static get UpReadOnly(): DeepImmutable<Vector3>;
  75971. /**
  75972. * Gets a zero Vector3 that must not be updated
  75973. */
  75974. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75975. /**
  75976. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75977. * @returns a new down Vector3
  75978. */
  75979. static Down(): Vector3;
  75980. /**
  75981. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75982. * @returns a new forward Vector3
  75983. */
  75984. static Forward(): Vector3;
  75985. /**
  75986. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75987. * @returns a new forward Vector3
  75988. */
  75989. static Backward(): Vector3;
  75990. /**
  75991. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75992. * @returns a new right Vector3
  75993. */
  75994. static Right(): Vector3;
  75995. /**
  75996. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75997. * @returns a new left Vector3
  75998. */
  75999. static Left(): Vector3;
  76000. /**
  76001. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76002. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76003. * @param vector defines the Vector3 to transform
  76004. * @param transformation defines the transformation matrix
  76005. * @returns the transformed Vector3
  76006. */
  76007. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76008. /**
  76009. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76010. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76011. * @param vector defines the Vector3 to transform
  76012. * @param transformation defines the transformation matrix
  76013. * @param result defines the Vector3 where to store the result
  76014. */
  76015. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76016. /**
  76017. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76018. * This method computes tranformed coordinates only, not transformed direction vectors
  76019. * @param x define the x coordinate of the source vector
  76020. * @param y define the y coordinate of the source vector
  76021. * @param z define the z coordinate of the source vector
  76022. * @param transformation defines the transformation matrix
  76023. * @param result defines the Vector3 where to store the result
  76024. */
  76025. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76026. /**
  76027. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76028. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76029. * @param vector defines the Vector3 to transform
  76030. * @param transformation defines the transformation matrix
  76031. * @returns the new Vector3
  76032. */
  76033. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76034. /**
  76035. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76036. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76037. * @param vector defines the Vector3 to transform
  76038. * @param transformation defines the transformation matrix
  76039. * @param result defines the Vector3 where to store the result
  76040. */
  76041. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76042. /**
  76043. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76044. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76045. * @param x define the x coordinate of the source vector
  76046. * @param y define the y coordinate of the source vector
  76047. * @param z define the z coordinate of the source vector
  76048. * @param transformation defines the transformation matrix
  76049. * @param result defines the Vector3 where to store the result
  76050. */
  76051. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76052. /**
  76053. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76054. * @param value1 defines the first control point
  76055. * @param value2 defines the second control point
  76056. * @param value3 defines the third control point
  76057. * @param value4 defines the fourth control point
  76058. * @param amount defines the amount on the spline to use
  76059. * @returns the new Vector3
  76060. */
  76061. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76062. /**
  76063. * 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"
  76064. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76065. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76066. * @param value defines the current value
  76067. * @param min defines the lower range value
  76068. * @param max defines the upper range value
  76069. * @returns the new Vector3
  76070. */
  76071. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76072. /**
  76073. * 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"
  76074. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76075. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76076. * @param value defines the current value
  76077. * @param min defines the lower range value
  76078. * @param max defines the upper range value
  76079. * @param result defines the Vector3 where to store the result
  76080. */
  76081. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76082. /**
  76083. * Checks if a given vector is inside a specific range
  76084. * @param v defines the vector to test
  76085. * @param min defines the minimum range
  76086. * @param max defines the maximum range
  76087. */
  76088. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76089. /**
  76090. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76091. * @param value1 defines the first control point
  76092. * @param tangent1 defines the first tangent vector
  76093. * @param value2 defines the second control point
  76094. * @param tangent2 defines the second tangent vector
  76095. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76096. * @returns the new Vector3
  76097. */
  76098. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76099. /**
  76100. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76101. * @param start defines the start value
  76102. * @param end defines the end value
  76103. * @param amount max defines amount between both (between 0 and 1)
  76104. * @returns the new Vector3
  76105. */
  76106. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76107. /**
  76108. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76109. * @param start defines the start value
  76110. * @param end defines the end value
  76111. * @param amount max defines amount between both (between 0 and 1)
  76112. * @param result defines the Vector3 where to store the result
  76113. */
  76114. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76115. /**
  76116. * Returns the dot product (float) between the vectors "left" and "right"
  76117. * @param left defines the left operand
  76118. * @param right defines the right operand
  76119. * @returns the dot product
  76120. */
  76121. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76122. /**
  76123. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76124. * The cross product is then orthogonal to both "left" and "right"
  76125. * @param left defines the left operand
  76126. * @param right defines the right operand
  76127. * @returns the cross product
  76128. */
  76129. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76130. /**
  76131. * Sets the given vector "result" with the cross product of "left" and "right"
  76132. * The cross product is then orthogonal to both "left" and "right"
  76133. * @param left defines the left operand
  76134. * @param right defines the right operand
  76135. * @param result defines the Vector3 where to store the result
  76136. */
  76137. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76138. /**
  76139. * Returns a new Vector3 as the normalization of the given vector
  76140. * @param vector defines the Vector3 to normalize
  76141. * @returns the new Vector3
  76142. */
  76143. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76144. /**
  76145. * Sets the given vector "result" with the normalization of the given first vector
  76146. * @param vector defines the Vector3 to normalize
  76147. * @param result defines the Vector3 where to store the result
  76148. */
  76149. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76150. /**
  76151. * Project a Vector3 onto screen space
  76152. * @param vector defines the Vector3 to project
  76153. * @param world defines the world matrix to use
  76154. * @param transform defines the transform (view x projection) matrix to use
  76155. * @param viewport defines the screen viewport to use
  76156. * @returns the new Vector3
  76157. */
  76158. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76159. /** @hidden */
  76160. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76161. /**
  76162. * Unproject from screen space to object space
  76163. * @param source defines the screen space Vector3 to use
  76164. * @param viewportWidth defines the current width of the viewport
  76165. * @param viewportHeight defines the current height of the viewport
  76166. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76167. * @param transform defines the transform (view x projection) matrix to use
  76168. * @returns the new Vector3
  76169. */
  76170. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76171. /**
  76172. * Unproject from screen space to object space
  76173. * @param source defines the screen space Vector3 to use
  76174. * @param viewportWidth defines the current width of the viewport
  76175. * @param viewportHeight defines the current height of the viewport
  76176. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76177. * @param view defines the view matrix to use
  76178. * @param projection defines the projection matrix to use
  76179. * @returns the new Vector3
  76180. */
  76181. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76182. /**
  76183. * Unproject from screen space to object space
  76184. * @param source defines the screen space Vector3 to use
  76185. * @param viewportWidth defines the current width of the viewport
  76186. * @param viewportHeight defines the current height of the viewport
  76187. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76188. * @param view defines the view matrix to use
  76189. * @param projection defines the projection matrix to use
  76190. * @param result defines the Vector3 where to store the result
  76191. */
  76192. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76193. /**
  76194. * Unproject from screen space to object space
  76195. * @param sourceX defines the screen space x coordinate to use
  76196. * @param sourceY defines the screen space y coordinate to use
  76197. * @param sourceZ defines the screen space z coordinate to use
  76198. * @param viewportWidth defines the current width of the viewport
  76199. * @param viewportHeight defines the current height of the viewport
  76200. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76201. * @param view defines the view matrix to use
  76202. * @param projection defines the projection matrix to use
  76203. * @param result defines the Vector3 where to store the result
  76204. */
  76205. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76206. /**
  76207. * Gets the minimal coordinate values between two Vector3
  76208. * @param left defines the first operand
  76209. * @param right defines the second operand
  76210. * @returns the new Vector3
  76211. */
  76212. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76213. /**
  76214. * Gets the maximal coordinate values between two Vector3
  76215. * @param left defines the first operand
  76216. * @param right defines the second operand
  76217. * @returns the new Vector3
  76218. */
  76219. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76220. /**
  76221. * Returns the distance between the vectors "value1" and "value2"
  76222. * @param value1 defines the first operand
  76223. * @param value2 defines the second operand
  76224. * @returns the distance
  76225. */
  76226. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76227. /**
  76228. * Returns the squared distance between the vectors "value1" and "value2"
  76229. * @param value1 defines the first operand
  76230. * @param value2 defines the second operand
  76231. * @returns the squared distance
  76232. */
  76233. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76234. /**
  76235. * Returns a new Vector3 located at the center between "value1" and "value2"
  76236. * @param value1 defines the first operand
  76237. * @param value2 defines the second operand
  76238. * @returns the new Vector3
  76239. */
  76240. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76241. /**
  76242. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76243. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76244. * to something in order to rotate it from its local system to the given target system
  76245. * Note: axis1, axis2 and axis3 are normalized during this operation
  76246. * @param axis1 defines the first axis
  76247. * @param axis2 defines the second axis
  76248. * @param axis3 defines the third axis
  76249. * @returns a new Vector3
  76250. */
  76251. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76252. /**
  76253. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76254. * @param axis1 defines the first axis
  76255. * @param axis2 defines the second axis
  76256. * @param axis3 defines the third axis
  76257. * @param ref defines the Vector3 where to store the result
  76258. */
  76259. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76260. }
  76261. /**
  76262. * Vector4 class created for EulerAngle class conversion to Quaternion
  76263. */
  76264. export class Vector4 {
  76265. /** x value of the vector */
  76266. x: number;
  76267. /** y value of the vector */
  76268. y: number;
  76269. /** z value of the vector */
  76270. z: number;
  76271. /** w value of the vector */
  76272. w: number;
  76273. /**
  76274. * Creates a Vector4 object from the given floats.
  76275. * @param x x value of the vector
  76276. * @param y y value of the vector
  76277. * @param z z value of the vector
  76278. * @param w w value of the vector
  76279. */
  76280. constructor(
  76281. /** x value of the vector */
  76282. x: number,
  76283. /** y value of the vector */
  76284. y: number,
  76285. /** z value of the vector */
  76286. z: number,
  76287. /** w value of the vector */
  76288. w: number);
  76289. /**
  76290. * Returns the string with the Vector4 coordinates.
  76291. * @returns a string containing all the vector values
  76292. */
  76293. toString(): string;
  76294. /**
  76295. * Returns the string "Vector4".
  76296. * @returns "Vector4"
  76297. */
  76298. getClassName(): string;
  76299. /**
  76300. * Returns the Vector4 hash code.
  76301. * @returns a unique hash code
  76302. */
  76303. getHashCode(): number;
  76304. /**
  76305. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76306. * @returns the resulting array
  76307. */
  76308. asArray(): number[];
  76309. /**
  76310. * Populates the given array from the given index with the Vector4 coordinates.
  76311. * @param array array to populate
  76312. * @param index index of the array to start at (default: 0)
  76313. * @returns the Vector4.
  76314. */
  76315. toArray(array: FloatArray, index?: number): Vector4;
  76316. /**
  76317. * Adds the given vector to the current Vector4.
  76318. * @param otherVector the vector to add
  76319. * @returns the updated Vector4.
  76320. */
  76321. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76322. /**
  76323. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76324. * @param otherVector the vector to add
  76325. * @returns the resulting vector
  76326. */
  76327. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76328. /**
  76329. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76330. * @param otherVector the vector to add
  76331. * @param result the vector to store the result
  76332. * @returns the current Vector4.
  76333. */
  76334. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76335. /**
  76336. * Subtract in place the given vector from the current Vector4.
  76337. * @param otherVector the vector to subtract
  76338. * @returns the updated Vector4.
  76339. */
  76340. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76341. /**
  76342. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76343. * @param otherVector the vector to add
  76344. * @returns the new vector with the result
  76345. */
  76346. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76347. /**
  76348. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76349. * @param otherVector the vector to subtract
  76350. * @param result the vector to store the result
  76351. * @returns the current Vector4.
  76352. */
  76353. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76354. /**
  76355. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76356. */
  76357. /**
  76358. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76359. * @param x value to subtract
  76360. * @param y value to subtract
  76361. * @param z value to subtract
  76362. * @param w value to subtract
  76363. * @returns new vector containing the result
  76364. */
  76365. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76366. /**
  76367. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76368. * @param x value to subtract
  76369. * @param y value to subtract
  76370. * @param z value to subtract
  76371. * @param w value to subtract
  76372. * @param result the vector to store the result in
  76373. * @returns the current Vector4.
  76374. */
  76375. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76376. /**
  76377. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76378. * @returns a new vector with the negated values
  76379. */
  76380. negate(): Vector4;
  76381. /**
  76382. * Negate this vector in place
  76383. * @returns this
  76384. */
  76385. negateInPlace(): Vector4;
  76386. /**
  76387. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76388. * @param result defines the Vector3 object where to store the result
  76389. * @returns the current Vector4
  76390. */
  76391. negateToRef(result: Vector4): Vector4;
  76392. /**
  76393. * Multiplies the current Vector4 coordinates by scale (float).
  76394. * @param scale the number to scale with
  76395. * @returns the updated Vector4.
  76396. */
  76397. scaleInPlace(scale: number): Vector4;
  76398. /**
  76399. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76400. * @param scale the number to scale with
  76401. * @returns a new vector with the result
  76402. */
  76403. scale(scale: number): Vector4;
  76404. /**
  76405. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76406. * @param scale the number to scale with
  76407. * @param result a vector to store the result in
  76408. * @returns the current Vector4.
  76409. */
  76410. scaleToRef(scale: number, result: Vector4): Vector4;
  76411. /**
  76412. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76413. * @param scale defines the scale factor
  76414. * @param result defines the Vector4 object where to store the result
  76415. * @returns the unmodified current Vector4
  76416. */
  76417. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76418. /**
  76419. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76420. * @param otherVector the vector to compare against
  76421. * @returns true if they are equal
  76422. */
  76423. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76424. /**
  76425. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76426. * @param otherVector vector to compare against
  76427. * @param epsilon (Default: very small number)
  76428. * @returns true if they are equal
  76429. */
  76430. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76431. /**
  76432. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76433. * @param x x value to compare against
  76434. * @param y y value to compare against
  76435. * @param z z value to compare against
  76436. * @param w w value to compare against
  76437. * @returns true if equal
  76438. */
  76439. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76440. /**
  76441. * Multiplies in place the current Vector4 by the given one.
  76442. * @param otherVector vector to multiple with
  76443. * @returns the updated Vector4.
  76444. */
  76445. multiplyInPlace(otherVector: Vector4): Vector4;
  76446. /**
  76447. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76448. * @param otherVector vector to multiple with
  76449. * @returns resulting new vector
  76450. */
  76451. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76452. /**
  76453. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76454. * @param otherVector vector to multiple with
  76455. * @param result vector to store the result
  76456. * @returns the current Vector4.
  76457. */
  76458. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76459. /**
  76460. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76461. * @param x x value multiply with
  76462. * @param y y value multiply with
  76463. * @param z z value multiply with
  76464. * @param w w value multiply with
  76465. * @returns resulting new vector
  76466. */
  76467. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76468. /**
  76469. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76470. * @param otherVector vector to devide with
  76471. * @returns resulting new vector
  76472. */
  76473. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76474. /**
  76475. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76476. * @param otherVector vector to devide with
  76477. * @param result vector to store the result
  76478. * @returns the current Vector4.
  76479. */
  76480. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76481. /**
  76482. * Divides the current Vector3 coordinates by the given ones.
  76483. * @param otherVector vector to devide with
  76484. * @returns the updated Vector3.
  76485. */
  76486. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76487. /**
  76488. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76489. * @param other defines the second operand
  76490. * @returns the current updated Vector4
  76491. */
  76492. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76493. /**
  76494. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76495. * @param other defines the second operand
  76496. * @returns the current updated Vector4
  76497. */
  76498. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76499. /**
  76500. * Gets a new Vector4 from current Vector4 floored values
  76501. * @returns a new Vector4
  76502. */
  76503. floor(): Vector4;
  76504. /**
  76505. * Gets a new Vector4 from current Vector3 floored values
  76506. * @returns a new Vector4
  76507. */
  76508. fract(): Vector4;
  76509. /**
  76510. * Returns the Vector4 length (float).
  76511. * @returns the length
  76512. */
  76513. length(): number;
  76514. /**
  76515. * Returns the Vector4 squared length (float).
  76516. * @returns the length squared
  76517. */
  76518. lengthSquared(): number;
  76519. /**
  76520. * Normalizes in place the Vector4.
  76521. * @returns the updated Vector4.
  76522. */
  76523. normalize(): Vector4;
  76524. /**
  76525. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76526. * @returns this converted to a new vector3
  76527. */
  76528. toVector3(): Vector3;
  76529. /**
  76530. * Returns a new Vector4 copied from the current one.
  76531. * @returns the new cloned vector
  76532. */
  76533. clone(): Vector4;
  76534. /**
  76535. * Updates the current Vector4 with the given one coordinates.
  76536. * @param source the source vector to copy from
  76537. * @returns the updated Vector4.
  76538. */
  76539. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76540. /**
  76541. * Updates the current Vector4 coordinates with the given floats.
  76542. * @param x float to copy from
  76543. * @param y float to copy from
  76544. * @param z float to copy from
  76545. * @param w float to copy from
  76546. * @returns the updated Vector4.
  76547. */
  76548. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76549. /**
  76550. * Updates the current Vector4 coordinates with the given floats.
  76551. * @param x float to set from
  76552. * @param y float to set from
  76553. * @param z float to set from
  76554. * @param w float to set from
  76555. * @returns the updated Vector4.
  76556. */
  76557. set(x: number, y: number, z: number, w: number): Vector4;
  76558. /**
  76559. * Copies the given float to the current Vector3 coordinates
  76560. * @param v defines the x, y, z and w coordinates of the operand
  76561. * @returns the current updated Vector3
  76562. */
  76563. setAll(v: number): Vector4;
  76564. /**
  76565. * Returns a new Vector4 set from the starting index of the given array.
  76566. * @param array the array to pull values from
  76567. * @param offset the offset into the array to start at
  76568. * @returns the new vector
  76569. */
  76570. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76571. /**
  76572. * Updates the given vector "result" from the starting index of the given array.
  76573. * @param array the array to pull values from
  76574. * @param offset the offset into the array to start at
  76575. * @param result the vector to store the result in
  76576. */
  76577. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76578. /**
  76579. * Updates the given vector "result" from the starting index of the given Float32Array.
  76580. * @param array the array to pull values from
  76581. * @param offset the offset into the array to start at
  76582. * @param result the vector to store the result in
  76583. */
  76584. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76585. /**
  76586. * Updates the given vector "result" coordinates from the given floats.
  76587. * @param x float to set from
  76588. * @param y float to set from
  76589. * @param z float to set from
  76590. * @param w float to set from
  76591. * @param result the vector to the floats in
  76592. */
  76593. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76594. /**
  76595. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76596. * @returns the new vector
  76597. */
  76598. static Zero(): Vector4;
  76599. /**
  76600. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76601. * @returns the new vector
  76602. */
  76603. static One(): Vector4;
  76604. /**
  76605. * Returns a new normalized Vector4 from the given one.
  76606. * @param vector the vector to normalize
  76607. * @returns the vector
  76608. */
  76609. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76610. /**
  76611. * Updates the given vector "result" from the normalization of the given one.
  76612. * @param vector the vector to normalize
  76613. * @param result the vector to store the result in
  76614. */
  76615. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76616. /**
  76617. * Returns a vector with the minimum values from the left and right vectors
  76618. * @param left left vector to minimize
  76619. * @param right right vector to minimize
  76620. * @returns a new vector with the minimum of the left and right vector values
  76621. */
  76622. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76623. /**
  76624. * Returns a vector with the maximum values from the left and right vectors
  76625. * @param left left vector to maximize
  76626. * @param right right vector to maximize
  76627. * @returns a new vector with the maximum of the left and right vector values
  76628. */
  76629. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76630. /**
  76631. * Returns the distance (float) between the vectors "value1" and "value2".
  76632. * @param value1 value to calulate the distance between
  76633. * @param value2 value to calulate the distance between
  76634. * @return the distance between the two vectors
  76635. */
  76636. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76637. /**
  76638. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76639. * @param value1 value to calulate the distance between
  76640. * @param value2 value to calulate the distance between
  76641. * @return the distance between the two vectors squared
  76642. */
  76643. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76644. /**
  76645. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76646. * @param value1 value to calulate the center between
  76647. * @param value2 value to calulate the center between
  76648. * @return the center between the two vectors
  76649. */
  76650. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76651. /**
  76652. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76653. * This methods computes transformed normalized direction vectors only.
  76654. * @param vector the vector to transform
  76655. * @param transformation the transformation matrix to apply
  76656. * @returns the new vector
  76657. */
  76658. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76659. /**
  76660. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76661. * This methods computes transformed normalized direction vectors only.
  76662. * @param vector the vector to transform
  76663. * @param transformation the transformation matrix to apply
  76664. * @param result the vector to store the result in
  76665. */
  76666. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76667. /**
  76668. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76669. * This methods computes transformed normalized direction vectors only.
  76670. * @param x value to transform
  76671. * @param y value to transform
  76672. * @param z value to transform
  76673. * @param w value to transform
  76674. * @param transformation the transformation matrix to apply
  76675. * @param result the vector to store the results in
  76676. */
  76677. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76678. /**
  76679. * Creates a new Vector4 from a Vector3
  76680. * @param source defines the source data
  76681. * @param w defines the 4th component (default is 0)
  76682. * @returns a new Vector4
  76683. */
  76684. static FromVector3(source: Vector3, w?: number): Vector4;
  76685. }
  76686. /**
  76687. * Class used to store quaternion data
  76688. * @see https://en.wikipedia.org/wiki/Quaternion
  76689. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76690. */
  76691. export class Quaternion {
  76692. /** defines the first component (0 by default) */
  76693. x: number;
  76694. /** defines the second component (0 by default) */
  76695. y: number;
  76696. /** defines the third component (0 by default) */
  76697. z: number;
  76698. /** defines the fourth component (1.0 by default) */
  76699. w: number;
  76700. /**
  76701. * Creates a new Quaternion from the given floats
  76702. * @param x defines the first component (0 by default)
  76703. * @param y defines the second component (0 by default)
  76704. * @param z defines the third component (0 by default)
  76705. * @param w defines the fourth component (1.0 by default)
  76706. */
  76707. constructor(
  76708. /** defines the first component (0 by default) */
  76709. x?: number,
  76710. /** defines the second component (0 by default) */
  76711. y?: number,
  76712. /** defines the third component (0 by default) */
  76713. z?: number,
  76714. /** defines the fourth component (1.0 by default) */
  76715. w?: number);
  76716. /**
  76717. * Gets a string representation for the current quaternion
  76718. * @returns a string with the Quaternion coordinates
  76719. */
  76720. toString(): string;
  76721. /**
  76722. * Gets the class name of the quaternion
  76723. * @returns the string "Quaternion"
  76724. */
  76725. getClassName(): string;
  76726. /**
  76727. * Gets a hash code for this quaternion
  76728. * @returns the quaternion hash code
  76729. */
  76730. getHashCode(): number;
  76731. /**
  76732. * Copy the quaternion to an array
  76733. * @returns a new array populated with 4 elements from the quaternion coordinates
  76734. */
  76735. asArray(): number[];
  76736. /**
  76737. * Check if two quaternions are equals
  76738. * @param otherQuaternion defines the second operand
  76739. * @return true if the current quaternion and the given one coordinates are strictly equals
  76740. */
  76741. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76742. /**
  76743. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76744. * @param otherQuaternion defines the other quaternion
  76745. * @param epsilon defines the minimal distance to consider equality
  76746. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76747. */
  76748. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76749. /**
  76750. * Clone the current quaternion
  76751. * @returns a new quaternion copied from the current one
  76752. */
  76753. clone(): Quaternion;
  76754. /**
  76755. * Copy a quaternion to the current one
  76756. * @param other defines the other quaternion
  76757. * @returns the updated current quaternion
  76758. */
  76759. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76760. /**
  76761. * Updates the current quaternion with the given float coordinates
  76762. * @param x defines the x coordinate
  76763. * @param y defines the y coordinate
  76764. * @param z defines the z coordinate
  76765. * @param w defines the w coordinate
  76766. * @returns the updated current quaternion
  76767. */
  76768. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76769. /**
  76770. * Updates the current quaternion from the given float coordinates
  76771. * @param x defines the x coordinate
  76772. * @param y defines the y coordinate
  76773. * @param z defines the z coordinate
  76774. * @param w defines the w coordinate
  76775. * @returns the updated current quaternion
  76776. */
  76777. set(x: number, y: number, z: number, w: number): Quaternion;
  76778. /**
  76779. * Adds two quaternions
  76780. * @param other defines the second operand
  76781. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76782. */
  76783. add(other: DeepImmutable<Quaternion>): Quaternion;
  76784. /**
  76785. * Add a quaternion to the current one
  76786. * @param other defines the quaternion to add
  76787. * @returns the current quaternion
  76788. */
  76789. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76790. /**
  76791. * Subtract two quaternions
  76792. * @param other defines the second operand
  76793. * @returns a new quaternion as the subtraction result of the given one from the current one
  76794. */
  76795. subtract(other: Quaternion): Quaternion;
  76796. /**
  76797. * Multiplies the current quaternion by a scale factor
  76798. * @param value defines the scale factor
  76799. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76800. */
  76801. scale(value: number): Quaternion;
  76802. /**
  76803. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76804. * @param scale defines the scale factor
  76805. * @param result defines the Quaternion object where to store the result
  76806. * @returns the unmodified current quaternion
  76807. */
  76808. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76809. /**
  76810. * Multiplies in place the current quaternion by a scale factor
  76811. * @param value defines the scale factor
  76812. * @returns the current modified quaternion
  76813. */
  76814. scaleInPlace(value: number): Quaternion;
  76815. /**
  76816. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76817. * @param scale defines the scale factor
  76818. * @param result defines the Quaternion object where to store the result
  76819. * @returns the unmodified current quaternion
  76820. */
  76821. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76822. /**
  76823. * Multiplies two quaternions
  76824. * @param q1 defines the second operand
  76825. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76826. */
  76827. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76828. /**
  76829. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76830. * @param q1 defines the second operand
  76831. * @param result defines the target quaternion
  76832. * @returns the current quaternion
  76833. */
  76834. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76835. /**
  76836. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76837. * @param q1 defines the second operand
  76838. * @returns the currentupdated quaternion
  76839. */
  76840. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76841. /**
  76842. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76843. * @param ref defines the target quaternion
  76844. * @returns the current quaternion
  76845. */
  76846. conjugateToRef(ref: Quaternion): Quaternion;
  76847. /**
  76848. * Conjugates in place (1-q) the current quaternion
  76849. * @returns the current updated quaternion
  76850. */
  76851. conjugateInPlace(): Quaternion;
  76852. /**
  76853. * Conjugates in place (1-q) the current quaternion
  76854. * @returns a new quaternion
  76855. */
  76856. conjugate(): Quaternion;
  76857. /**
  76858. * Gets length of current quaternion
  76859. * @returns the quaternion length (float)
  76860. */
  76861. length(): number;
  76862. /**
  76863. * Normalize in place the current quaternion
  76864. * @returns the current updated quaternion
  76865. */
  76866. normalize(): Quaternion;
  76867. /**
  76868. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76869. * @param order is a reserved parameter and is ignore for now
  76870. * @returns a new Vector3 containing the Euler angles
  76871. */
  76872. toEulerAngles(order?: string): Vector3;
  76873. /**
  76874. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76875. * @param result defines the vector which will be filled with the Euler angles
  76876. * @param order is a reserved parameter and is ignore for now
  76877. * @returns the current unchanged quaternion
  76878. */
  76879. toEulerAnglesToRef(result: Vector3): Quaternion;
  76880. /**
  76881. * Updates the given rotation matrix with the current quaternion values
  76882. * @param result defines the target matrix
  76883. * @returns the current unchanged quaternion
  76884. */
  76885. toRotationMatrix(result: Matrix): Quaternion;
  76886. /**
  76887. * Updates the current quaternion from the given rotation matrix values
  76888. * @param matrix defines the source matrix
  76889. * @returns the current updated quaternion
  76890. */
  76891. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76892. /**
  76893. * Creates a new quaternion from a rotation matrix
  76894. * @param matrix defines the source matrix
  76895. * @returns a new quaternion created from the given rotation matrix values
  76896. */
  76897. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76898. /**
  76899. * Updates the given quaternion with the given rotation matrix values
  76900. * @param matrix defines the source matrix
  76901. * @param result defines the target quaternion
  76902. */
  76903. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76904. /**
  76905. * Returns the dot product (float) between the quaternions "left" and "right"
  76906. * @param left defines the left operand
  76907. * @param right defines the right operand
  76908. * @returns the dot product
  76909. */
  76910. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76911. /**
  76912. * Checks if the two quaternions are close to each other
  76913. * @param quat0 defines the first quaternion to check
  76914. * @param quat1 defines the second quaternion to check
  76915. * @returns true if the two quaternions are close to each other
  76916. */
  76917. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76918. /**
  76919. * Creates an empty quaternion
  76920. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76921. */
  76922. static Zero(): Quaternion;
  76923. /**
  76924. * Inverse a given quaternion
  76925. * @param q defines the source quaternion
  76926. * @returns a new quaternion as the inverted current quaternion
  76927. */
  76928. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76929. /**
  76930. * Inverse a given quaternion
  76931. * @param q defines the source quaternion
  76932. * @param result the quaternion the result will be stored in
  76933. * @returns the result quaternion
  76934. */
  76935. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76936. /**
  76937. * Creates an identity quaternion
  76938. * @returns the identity quaternion
  76939. */
  76940. static Identity(): Quaternion;
  76941. /**
  76942. * Gets a boolean indicating if the given quaternion is identity
  76943. * @param quaternion defines the quaternion to check
  76944. * @returns true if the quaternion is identity
  76945. */
  76946. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76947. /**
  76948. * Creates a quaternion from a rotation around an axis
  76949. * @param axis defines the axis to use
  76950. * @param angle defines the angle to use
  76951. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76952. */
  76953. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76954. /**
  76955. * Creates a rotation around an axis and stores it into the given quaternion
  76956. * @param axis defines the axis to use
  76957. * @param angle defines the angle to use
  76958. * @param result defines the target quaternion
  76959. * @returns the target quaternion
  76960. */
  76961. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76962. /**
  76963. * Creates a new quaternion from data stored into an array
  76964. * @param array defines the data source
  76965. * @param offset defines the offset in the source array where the data starts
  76966. * @returns a new quaternion
  76967. */
  76968. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76969. /**
  76970. * Create a quaternion from Euler rotation angles
  76971. * @param x Pitch
  76972. * @param y Yaw
  76973. * @param z Roll
  76974. * @returns the new Quaternion
  76975. */
  76976. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76977. /**
  76978. * Updates a quaternion from Euler rotation angles
  76979. * @param x Pitch
  76980. * @param y Yaw
  76981. * @param z Roll
  76982. * @param result the quaternion to store the result
  76983. * @returns the updated quaternion
  76984. */
  76985. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76986. /**
  76987. * Create a quaternion from Euler rotation vector
  76988. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76989. * @returns the new Quaternion
  76990. */
  76991. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76992. /**
  76993. * Updates a quaternion from Euler rotation vector
  76994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76995. * @param result the quaternion to store the result
  76996. * @returns the updated quaternion
  76997. */
  76998. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76999. /**
  77000. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77001. * @param yaw defines the rotation around Y axis
  77002. * @param pitch defines the rotation around X axis
  77003. * @param roll defines the rotation around Z axis
  77004. * @returns the new quaternion
  77005. */
  77006. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77007. /**
  77008. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77009. * @param yaw defines the rotation around Y axis
  77010. * @param pitch defines the rotation around X axis
  77011. * @param roll defines the rotation around Z axis
  77012. * @param result defines the target quaternion
  77013. */
  77014. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77015. /**
  77016. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77017. * @param alpha defines the rotation around first axis
  77018. * @param beta defines the rotation around second axis
  77019. * @param gamma defines the rotation around third axis
  77020. * @returns the new quaternion
  77021. */
  77022. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77023. /**
  77024. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77025. * @param alpha defines the rotation around first axis
  77026. * @param beta defines the rotation around second axis
  77027. * @param gamma defines the rotation around third axis
  77028. * @param result defines the target quaternion
  77029. */
  77030. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77031. /**
  77032. * 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)
  77033. * @param axis1 defines the first axis
  77034. * @param axis2 defines the second axis
  77035. * @param axis3 defines the third axis
  77036. * @returns the new quaternion
  77037. */
  77038. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77039. /**
  77040. * 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
  77041. * @param axis1 defines the first axis
  77042. * @param axis2 defines the second axis
  77043. * @param axis3 defines the third axis
  77044. * @param ref defines the target quaternion
  77045. */
  77046. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77047. /**
  77048. * Interpolates between two quaternions
  77049. * @param left defines first quaternion
  77050. * @param right defines second quaternion
  77051. * @param amount defines the gradient to use
  77052. * @returns the new interpolated quaternion
  77053. */
  77054. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77055. /**
  77056. * Interpolates between two quaternions and stores it into a target quaternion
  77057. * @param left defines first quaternion
  77058. * @param right defines second quaternion
  77059. * @param amount defines the gradient to use
  77060. * @param result defines the target quaternion
  77061. */
  77062. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77063. /**
  77064. * Interpolate between two quaternions using Hermite interpolation
  77065. * @param value1 defines first quaternion
  77066. * @param tangent1 defines the incoming tangent
  77067. * @param value2 defines second quaternion
  77068. * @param tangent2 defines the outgoing tangent
  77069. * @param amount defines the target quaternion
  77070. * @returns the new interpolated quaternion
  77071. */
  77072. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77073. }
  77074. /**
  77075. * Class used to store matrix data (4x4)
  77076. */
  77077. export class Matrix {
  77078. private static _updateFlagSeed;
  77079. private static _identityReadOnly;
  77080. private _isIdentity;
  77081. private _isIdentityDirty;
  77082. private _isIdentity3x2;
  77083. private _isIdentity3x2Dirty;
  77084. /**
  77085. * Gets the update flag of the matrix which is an unique number for the matrix.
  77086. * It will be incremented every time the matrix data change.
  77087. * You can use it to speed the comparison between two versions of the same matrix.
  77088. */
  77089. updateFlag: number;
  77090. private readonly _m;
  77091. /**
  77092. * Gets the internal data of the matrix
  77093. */
  77094. get m(): DeepImmutable<Float32Array>;
  77095. /** @hidden */
  77096. _markAsUpdated(): void;
  77097. /** @hidden */
  77098. private _updateIdentityStatus;
  77099. /**
  77100. * Creates an empty matrix (filled with zeros)
  77101. */
  77102. constructor();
  77103. /**
  77104. * Check if the current matrix is identity
  77105. * @returns true is the matrix is the identity matrix
  77106. */
  77107. isIdentity(): boolean;
  77108. /**
  77109. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77110. * @returns true is the matrix is the identity matrix
  77111. */
  77112. isIdentityAs3x2(): boolean;
  77113. /**
  77114. * Gets the determinant of the matrix
  77115. * @returns the matrix determinant
  77116. */
  77117. determinant(): number;
  77118. /**
  77119. * Returns the matrix as a Float32Array
  77120. * @returns the matrix underlying array
  77121. */
  77122. toArray(): DeepImmutable<Float32Array>;
  77123. /**
  77124. * Returns the matrix as a Float32Array
  77125. * @returns the matrix underlying array.
  77126. */
  77127. asArray(): DeepImmutable<Float32Array>;
  77128. /**
  77129. * Inverts the current matrix in place
  77130. * @returns the current inverted matrix
  77131. */
  77132. invert(): Matrix;
  77133. /**
  77134. * Sets all the matrix elements to zero
  77135. * @returns the current matrix
  77136. */
  77137. reset(): Matrix;
  77138. /**
  77139. * Adds the current matrix with a second one
  77140. * @param other defines the matrix to add
  77141. * @returns a new matrix as the addition of the current matrix and the given one
  77142. */
  77143. add(other: DeepImmutable<Matrix>): Matrix;
  77144. /**
  77145. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77146. * @param other defines the matrix to add
  77147. * @param result defines the target matrix
  77148. * @returns the current matrix
  77149. */
  77150. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77151. /**
  77152. * Adds in place the given matrix to the current matrix
  77153. * @param other defines the second operand
  77154. * @returns the current updated matrix
  77155. */
  77156. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77157. /**
  77158. * Sets the given matrix to the current inverted Matrix
  77159. * @param other defines the target matrix
  77160. * @returns the unmodified current matrix
  77161. */
  77162. invertToRef(other: Matrix): Matrix;
  77163. /**
  77164. * add a value at the specified position in the current Matrix
  77165. * @param index the index of the value within the matrix. between 0 and 15.
  77166. * @param value the value to be added
  77167. * @returns the current updated matrix
  77168. */
  77169. addAtIndex(index: number, value: number): Matrix;
  77170. /**
  77171. * mutiply the specified position in the current Matrix by a value
  77172. * @param index the index of the value within the matrix. between 0 and 15.
  77173. * @param value the value to be added
  77174. * @returns the current updated matrix
  77175. */
  77176. multiplyAtIndex(index: number, value: number): Matrix;
  77177. /**
  77178. * Inserts the translation vector (using 3 floats) in the current matrix
  77179. * @param x defines the 1st component of the translation
  77180. * @param y defines the 2nd component of the translation
  77181. * @param z defines the 3rd component of the translation
  77182. * @returns the current updated matrix
  77183. */
  77184. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77185. /**
  77186. * Adds the translation vector (using 3 floats) in the current matrix
  77187. * @param x defines the 1st component of the translation
  77188. * @param y defines the 2nd component of the translation
  77189. * @param z defines the 3rd component of the translation
  77190. * @returns the current updated matrix
  77191. */
  77192. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77193. /**
  77194. * Inserts the translation vector in the current matrix
  77195. * @param vector3 defines the translation to insert
  77196. * @returns the current updated matrix
  77197. */
  77198. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77199. /**
  77200. * Gets the translation value of the current matrix
  77201. * @returns a new Vector3 as the extracted translation from the matrix
  77202. */
  77203. getTranslation(): Vector3;
  77204. /**
  77205. * Fill a Vector3 with the extracted translation from the matrix
  77206. * @param result defines the Vector3 where to store the translation
  77207. * @returns the current matrix
  77208. */
  77209. getTranslationToRef(result: Vector3): Matrix;
  77210. /**
  77211. * Remove rotation and scaling part from the matrix
  77212. * @returns the updated matrix
  77213. */
  77214. removeRotationAndScaling(): Matrix;
  77215. /**
  77216. * Multiply two matrices
  77217. * @param other defines the second operand
  77218. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77219. */
  77220. multiply(other: DeepImmutable<Matrix>): Matrix;
  77221. /**
  77222. * Copy the current matrix from the given one
  77223. * @param other defines the source matrix
  77224. * @returns the current updated matrix
  77225. */
  77226. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77227. /**
  77228. * Populates the given array from the starting index with the current matrix values
  77229. * @param array defines the target array
  77230. * @param offset defines the offset in the target array where to start storing values
  77231. * @returns the current matrix
  77232. */
  77233. copyToArray(array: Float32Array, offset?: number): Matrix;
  77234. /**
  77235. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77236. * @param other defines the second operand
  77237. * @param result defines the matrix where to store the multiplication
  77238. * @returns the current matrix
  77239. */
  77240. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77241. /**
  77242. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77243. * @param other defines the second operand
  77244. * @param result defines the array where to store the multiplication
  77245. * @param offset defines the offset in the target array where to start storing values
  77246. * @returns the current matrix
  77247. */
  77248. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77249. /**
  77250. * Check equality between this matrix and a second one
  77251. * @param value defines the second matrix to compare
  77252. * @returns true is the current matrix and the given one values are strictly equal
  77253. */
  77254. equals(value: DeepImmutable<Matrix>): boolean;
  77255. /**
  77256. * Clone the current matrix
  77257. * @returns a new matrix from the current matrix
  77258. */
  77259. clone(): Matrix;
  77260. /**
  77261. * Returns the name of the current matrix class
  77262. * @returns the string "Matrix"
  77263. */
  77264. getClassName(): string;
  77265. /**
  77266. * Gets the hash code of the current matrix
  77267. * @returns the hash code
  77268. */
  77269. getHashCode(): number;
  77270. /**
  77271. * Decomposes the current Matrix into a translation, rotation and scaling components
  77272. * @param scale defines the scale vector3 given as a reference to update
  77273. * @param rotation defines the rotation quaternion given as a reference to update
  77274. * @param translation defines the translation vector3 given as a reference to update
  77275. * @returns true if operation was successful
  77276. */
  77277. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77278. /**
  77279. * Gets specific row of the matrix
  77280. * @param index defines the number of the row to get
  77281. * @returns the index-th row of the current matrix as a new Vector4
  77282. */
  77283. getRow(index: number): Nullable<Vector4>;
  77284. /**
  77285. * Sets the index-th row of the current matrix to the vector4 values
  77286. * @param index defines the number of the row to set
  77287. * @param row defines the target vector4
  77288. * @returns the updated current matrix
  77289. */
  77290. setRow(index: number, row: Vector4): Matrix;
  77291. /**
  77292. * Compute the transpose of the matrix
  77293. * @returns the new transposed matrix
  77294. */
  77295. transpose(): Matrix;
  77296. /**
  77297. * Compute the transpose of the matrix and store it in a given matrix
  77298. * @param result defines the target matrix
  77299. * @returns the current matrix
  77300. */
  77301. transposeToRef(result: Matrix): Matrix;
  77302. /**
  77303. * Sets the index-th row of the current matrix with the given 4 x float values
  77304. * @param index defines the row index
  77305. * @param x defines the x component to set
  77306. * @param y defines the y component to set
  77307. * @param z defines the z component to set
  77308. * @param w defines the w component to set
  77309. * @returns the updated current matrix
  77310. */
  77311. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77312. /**
  77313. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77314. * @param scale defines the scale factor
  77315. * @returns a new matrix
  77316. */
  77317. scale(scale: number): Matrix;
  77318. /**
  77319. * Scale the current matrix values by a factor to a given result matrix
  77320. * @param scale defines the scale factor
  77321. * @param result defines the matrix to store the result
  77322. * @returns the current matrix
  77323. */
  77324. scaleToRef(scale: number, result: Matrix): Matrix;
  77325. /**
  77326. * Scale the current matrix values by a factor and add the result to a given matrix
  77327. * @param scale defines the scale factor
  77328. * @param result defines the Matrix to store the result
  77329. * @returns the current matrix
  77330. */
  77331. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77332. /**
  77333. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77334. * @param ref matrix to store the result
  77335. */
  77336. toNormalMatrix(ref: Matrix): void;
  77337. /**
  77338. * Gets only rotation part of the current matrix
  77339. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77340. */
  77341. getRotationMatrix(): Matrix;
  77342. /**
  77343. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77344. * @param result defines the target matrix to store data to
  77345. * @returns the current matrix
  77346. */
  77347. getRotationMatrixToRef(result: Matrix): Matrix;
  77348. /**
  77349. * Toggles model matrix from being right handed to left handed in place and vice versa
  77350. */
  77351. toggleModelMatrixHandInPlace(): void;
  77352. /**
  77353. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77354. */
  77355. toggleProjectionMatrixHandInPlace(): void;
  77356. /**
  77357. * Creates a matrix from an array
  77358. * @param array defines the source array
  77359. * @param offset defines an offset in the source array
  77360. * @returns a new Matrix set from the starting index of the given array
  77361. */
  77362. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77363. /**
  77364. * Copy the content of an array into a given matrix
  77365. * @param array defines the source array
  77366. * @param offset defines an offset in the source array
  77367. * @param result defines the target matrix
  77368. */
  77369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77370. /**
  77371. * Stores an array into a matrix after having multiplied each component by a given factor
  77372. * @param array defines the source array
  77373. * @param offset defines the offset in the source array
  77374. * @param scale defines the scaling factor
  77375. * @param result defines the target matrix
  77376. */
  77377. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77378. /**
  77379. * Gets an identity matrix that must not be updated
  77380. */
  77381. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77382. /**
  77383. * Stores a list of values (16) inside a given matrix
  77384. * @param initialM11 defines 1st value of 1st row
  77385. * @param initialM12 defines 2nd value of 1st row
  77386. * @param initialM13 defines 3rd value of 1st row
  77387. * @param initialM14 defines 4th value of 1st row
  77388. * @param initialM21 defines 1st value of 2nd row
  77389. * @param initialM22 defines 2nd value of 2nd row
  77390. * @param initialM23 defines 3rd value of 2nd row
  77391. * @param initialM24 defines 4th value of 2nd row
  77392. * @param initialM31 defines 1st value of 3rd row
  77393. * @param initialM32 defines 2nd value of 3rd row
  77394. * @param initialM33 defines 3rd value of 3rd row
  77395. * @param initialM34 defines 4th value of 3rd row
  77396. * @param initialM41 defines 1st value of 4th row
  77397. * @param initialM42 defines 2nd value of 4th row
  77398. * @param initialM43 defines 3rd value of 4th row
  77399. * @param initialM44 defines 4th value of 4th row
  77400. * @param result defines the target matrix
  77401. */
  77402. 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;
  77403. /**
  77404. * Creates new matrix from a list of values (16)
  77405. * @param initialM11 defines 1st value of 1st row
  77406. * @param initialM12 defines 2nd value of 1st row
  77407. * @param initialM13 defines 3rd value of 1st row
  77408. * @param initialM14 defines 4th value of 1st row
  77409. * @param initialM21 defines 1st value of 2nd row
  77410. * @param initialM22 defines 2nd value of 2nd row
  77411. * @param initialM23 defines 3rd value of 2nd row
  77412. * @param initialM24 defines 4th value of 2nd row
  77413. * @param initialM31 defines 1st value of 3rd row
  77414. * @param initialM32 defines 2nd value of 3rd row
  77415. * @param initialM33 defines 3rd value of 3rd row
  77416. * @param initialM34 defines 4th value of 3rd row
  77417. * @param initialM41 defines 1st value of 4th row
  77418. * @param initialM42 defines 2nd value of 4th row
  77419. * @param initialM43 defines 3rd value of 4th row
  77420. * @param initialM44 defines 4th value of 4th row
  77421. * @returns the new matrix
  77422. */
  77423. 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;
  77424. /**
  77425. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77426. * @param scale defines the scale vector3
  77427. * @param rotation defines the rotation quaternion
  77428. * @param translation defines the translation vector3
  77429. * @returns a new matrix
  77430. */
  77431. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77432. /**
  77433. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77434. * @param scale defines the scale vector3
  77435. * @param rotation defines the rotation quaternion
  77436. * @param translation defines the translation vector3
  77437. * @param result defines the target matrix
  77438. */
  77439. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77440. /**
  77441. * Creates a new identity matrix
  77442. * @returns a new identity matrix
  77443. */
  77444. static Identity(): Matrix;
  77445. /**
  77446. * Creates a new identity matrix and stores the result in a given matrix
  77447. * @param result defines the target matrix
  77448. */
  77449. static IdentityToRef(result: Matrix): void;
  77450. /**
  77451. * Creates a new zero matrix
  77452. * @returns a new zero matrix
  77453. */
  77454. static Zero(): Matrix;
  77455. /**
  77456. * Creates a new rotation matrix for "angle" radians around the X axis
  77457. * @param angle defines the angle (in radians) to use
  77458. * @return the new matrix
  77459. */
  77460. static RotationX(angle: number): Matrix;
  77461. /**
  77462. * Creates a new matrix as the invert of a given matrix
  77463. * @param source defines the source matrix
  77464. * @returns the new matrix
  77465. */
  77466. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77467. /**
  77468. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77469. * @param angle defines the angle (in radians) to use
  77470. * @param result defines the target matrix
  77471. */
  77472. static RotationXToRef(angle: number, result: Matrix): void;
  77473. /**
  77474. * Creates a new rotation matrix for "angle" radians around the Y axis
  77475. * @param angle defines the angle (in radians) to use
  77476. * @return the new matrix
  77477. */
  77478. static RotationY(angle: number): Matrix;
  77479. /**
  77480. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77481. * @param angle defines the angle (in radians) to use
  77482. * @param result defines the target matrix
  77483. */
  77484. static RotationYToRef(angle: number, result: Matrix): void;
  77485. /**
  77486. * Creates a new rotation matrix for "angle" radians around the Z axis
  77487. * @param angle defines the angle (in radians) to use
  77488. * @return the new matrix
  77489. */
  77490. static RotationZ(angle: number): Matrix;
  77491. /**
  77492. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77493. * @param angle defines the angle (in radians) to use
  77494. * @param result defines the target matrix
  77495. */
  77496. static RotationZToRef(angle: number, result: Matrix): void;
  77497. /**
  77498. * Creates a new rotation matrix for "angle" radians around the given axis
  77499. * @param axis defines the axis to use
  77500. * @param angle defines the angle (in radians) to use
  77501. * @return the new matrix
  77502. */
  77503. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77504. /**
  77505. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77506. * @param axis defines the axis to use
  77507. * @param angle defines the angle (in radians) to use
  77508. * @param result defines the target matrix
  77509. */
  77510. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77511. /**
  77512. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77513. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77514. * @param from defines the vector to align
  77515. * @param to defines the vector to align to
  77516. * @param result defines the target matrix
  77517. */
  77518. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77519. /**
  77520. * Creates a rotation matrix
  77521. * @param yaw defines the yaw angle in radians (Y axis)
  77522. * @param pitch defines the pitch angle in radians (X axis)
  77523. * @param roll defines the roll angle in radians (X axis)
  77524. * @returns the new rotation matrix
  77525. */
  77526. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77527. /**
  77528. * Creates a rotation matrix and stores it in a given matrix
  77529. * @param yaw defines the yaw angle in radians (Y axis)
  77530. * @param pitch defines the pitch angle in radians (X axis)
  77531. * @param roll defines the roll angle in radians (X axis)
  77532. * @param result defines the target matrix
  77533. */
  77534. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77535. /**
  77536. * Creates a scaling matrix
  77537. * @param x defines the scale factor on X axis
  77538. * @param y defines the scale factor on Y axis
  77539. * @param z defines the scale factor on Z axis
  77540. * @returns the new matrix
  77541. */
  77542. static Scaling(x: number, y: number, z: number): Matrix;
  77543. /**
  77544. * Creates a scaling matrix and stores it in a given matrix
  77545. * @param x defines the scale factor on X axis
  77546. * @param y defines the scale factor on Y axis
  77547. * @param z defines the scale factor on Z axis
  77548. * @param result defines the target matrix
  77549. */
  77550. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77551. /**
  77552. * Creates a translation matrix
  77553. * @param x defines the translation on X axis
  77554. * @param y defines the translation on Y axis
  77555. * @param z defines the translationon Z axis
  77556. * @returns the new matrix
  77557. */
  77558. static Translation(x: number, y: number, z: number): Matrix;
  77559. /**
  77560. * Creates a translation matrix and stores it in a given matrix
  77561. * @param x defines the translation on X axis
  77562. * @param y defines the translation on Y axis
  77563. * @param z defines the translationon Z axis
  77564. * @param result defines the target matrix
  77565. */
  77566. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77567. /**
  77568. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77569. * @param startValue defines the start value
  77570. * @param endValue defines the end value
  77571. * @param gradient defines the gradient factor
  77572. * @returns the new matrix
  77573. */
  77574. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77575. /**
  77576. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77577. * @param startValue defines the start value
  77578. * @param endValue defines the end value
  77579. * @param gradient defines the gradient factor
  77580. * @param result defines the Matrix object where to store data
  77581. */
  77582. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77583. /**
  77584. * Builds a new matrix whose values are computed by:
  77585. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77586. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77587. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77588. * @param startValue defines the first matrix
  77589. * @param endValue defines the second matrix
  77590. * @param gradient defines the gradient between the two matrices
  77591. * @returns the new matrix
  77592. */
  77593. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77594. /**
  77595. * Update a matrix to values which are computed by:
  77596. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77597. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77598. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77599. * @param startValue defines the first matrix
  77600. * @param endValue defines the second matrix
  77601. * @param gradient defines the gradient between the two matrices
  77602. * @param result defines the target matrix
  77603. */
  77604. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77605. /**
  77606. * 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"
  77607. * This function works in left handed mode
  77608. * @param eye defines the final position of the entity
  77609. * @param target defines where the entity should look at
  77610. * @param up defines the up vector for the entity
  77611. * @returns the new matrix
  77612. */
  77613. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77614. /**
  77615. * 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".
  77616. * This function works in left handed mode
  77617. * @param eye defines the final position of the entity
  77618. * @param target defines where the entity should look at
  77619. * @param up defines the up vector for the entity
  77620. * @param result defines the target matrix
  77621. */
  77622. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77623. /**
  77624. * 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"
  77625. * This function works in right handed mode
  77626. * @param eye defines the final position of the entity
  77627. * @param target defines where the entity should look at
  77628. * @param up defines the up vector for the entity
  77629. * @returns the new matrix
  77630. */
  77631. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77632. /**
  77633. * 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".
  77634. * This function works in right handed mode
  77635. * @param eye defines the final position of the entity
  77636. * @param target defines where the entity should look at
  77637. * @param up defines the up vector for the entity
  77638. * @param result defines the target matrix
  77639. */
  77640. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77641. /**
  77642. * Create a left-handed orthographic projection matrix
  77643. * @param width defines the viewport width
  77644. * @param height defines the viewport height
  77645. * @param znear defines the near clip plane
  77646. * @param zfar defines the far clip plane
  77647. * @returns a new matrix as a left-handed orthographic projection matrix
  77648. */
  77649. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77650. /**
  77651. * Store a left-handed orthographic projection to a given matrix
  77652. * @param width defines the viewport width
  77653. * @param height defines the viewport height
  77654. * @param znear defines the near clip plane
  77655. * @param zfar defines the far clip plane
  77656. * @param result defines the target matrix
  77657. */
  77658. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77659. /**
  77660. * Create a left-handed orthographic projection matrix
  77661. * @param left defines the viewport left coordinate
  77662. * @param right defines the viewport right coordinate
  77663. * @param bottom defines the viewport bottom coordinate
  77664. * @param top defines the viewport top coordinate
  77665. * @param znear defines the near clip plane
  77666. * @param zfar defines the far clip plane
  77667. * @returns a new matrix as a left-handed orthographic projection matrix
  77668. */
  77669. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77670. /**
  77671. * Stores a left-handed orthographic projection into a given matrix
  77672. * @param left defines the viewport left coordinate
  77673. * @param right defines the viewport right coordinate
  77674. * @param bottom defines the viewport bottom coordinate
  77675. * @param top defines the viewport top coordinate
  77676. * @param znear defines the near clip plane
  77677. * @param zfar defines the far clip plane
  77678. * @param result defines the target matrix
  77679. */
  77680. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77681. /**
  77682. * Creates a right-handed orthographic projection matrix
  77683. * @param left defines the viewport left coordinate
  77684. * @param right defines the viewport right coordinate
  77685. * @param bottom defines the viewport bottom coordinate
  77686. * @param top defines the viewport top coordinate
  77687. * @param znear defines the near clip plane
  77688. * @param zfar defines the far clip plane
  77689. * @returns a new matrix as a right-handed orthographic projection matrix
  77690. */
  77691. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77692. /**
  77693. * Stores a right-handed orthographic projection into a given matrix
  77694. * @param left defines the viewport left coordinate
  77695. * @param right defines the viewport right coordinate
  77696. * @param bottom defines the viewport bottom coordinate
  77697. * @param top defines the viewport top coordinate
  77698. * @param znear defines the near clip plane
  77699. * @param zfar defines the far clip plane
  77700. * @param result defines the target matrix
  77701. */
  77702. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77703. /**
  77704. * Creates a left-handed perspective projection matrix
  77705. * @param width defines the viewport width
  77706. * @param height defines the viewport height
  77707. * @param znear defines the near clip plane
  77708. * @param zfar defines the far clip plane
  77709. * @returns a new matrix as a left-handed perspective projection matrix
  77710. */
  77711. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77712. /**
  77713. * Creates a left-handed perspective projection matrix
  77714. * @param fov defines the horizontal field of view
  77715. * @param aspect defines the aspect ratio
  77716. * @param znear defines the near clip plane
  77717. * @param zfar defines the far clip plane
  77718. * @returns a new matrix as a left-handed perspective projection matrix
  77719. */
  77720. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77721. /**
  77722. * Stores a left-handed perspective projection into a given matrix
  77723. * @param fov defines the horizontal field of view
  77724. * @param aspect defines the aspect ratio
  77725. * @param znear defines the near clip plane
  77726. * @param zfar defines the far clip plane
  77727. * @param result defines the target matrix
  77728. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77729. */
  77730. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77731. /**
  77732. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77733. * @param fov defines the horizontal field of view
  77734. * @param aspect defines the aspect ratio
  77735. * @param znear defines the near clip plane
  77736. * @param zfar not used as infinity is used as far clip
  77737. * @param result defines the target matrix
  77738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77739. */
  77740. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77741. /**
  77742. * Creates a right-handed perspective projection matrix
  77743. * @param fov defines the horizontal field of view
  77744. * @param aspect defines the aspect ratio
  77745. * @param znear defines the near clip plane
  77746. * @param zfar defines the far clip plane
  77747. * @returns a new matrix as a right-handed perspective projection matrix
  77748. */
  77749. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77750. /**
  77751. * Stores a right-handed perspective projection into a given 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. * @param result defines the target matrix
  77757. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77758. */
  77759. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77760. /**
  77761. * Stores a right-handed perspective projection into a given matrix
  77762. * @param fov defines the horizontal field of view
  77763. * @param aspect defines the aspect ratio
  77764. * @param znear defines the near clip plane
  77765. * @param zfar not used as infinity is used as far clip
  77766. * @param result defines the target matrix
  77767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77768. */
  77769. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77770. /**
  77771. * Stores a perspective projection for WebVR info a given matrix
  77772. * @param fov defines the field of view
  77773. * @param znear defines the near clip plane
  77774. * @param zfar defines the far clip plane
  77775. * @param result defines the target matrix
  77776. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77777. */
  77778. static PerspectiveFovWebVRToRef(fov: {
  77779. upDegrees: number;
  77780. downDegrees: number;
  77781. leftDegrees: number;
  77782. rightDegrees: number;
  77783. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77784. /**
  77785. * Computes a complete transformation matrix
  77786. * @param viewport defines the viewport to use
  77787. * @param world defines the world matrix
  77788. * @param view defines the view matrix
  77789. * @param projection defines the projection matrix
  77790. * @param zmin defines the near clip plane
  77791. * @param zmax defines the far clip plane
  77792. * @returns the transformation matrix
  77793. */
  77794. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77795. /**
  77796. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77797. * @param matrix defines the matrix to use
  77798. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77799. */
  77800. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77801. /**
  77802. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77803. * @param matrix defines the matrix to use
  77804. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77805. */
  77806. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77807. /**
  77808. * Compute the transpose of a given matrix
  77809. * @param matrix defines the matrix to transpose
  77810. * @returns the new matrix
  77811. */
  77812. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77813. /**
  77814. * Compute the transpose of a matrix and store it in a target matrix
  77815. * @param matrix defines the matrix to transpose
  77816. * @param result defines the target matrix
  77817. */
  77818. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77819. /**
  77820. * Computes a reflection matrix from a plane
  77821. * @param plane defines the reflection plane
  77822. * @returns a new matrix
  77823. */
  77824. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77825. /**
  77826. * Computes a reflection matrix from a plane
  77827. * @param plane defines the reflection plane
  77828. * @param result defines the target matrix
  77829. */
  77830. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77831. /**
  77832. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77833. * @param xaxis defines the value of the 1st axis
  77834. * @param yaxis defines the value of the 2nd axis
  77835. * @param zaxis defines the value of the 3rd axis
  77836. * @param result defines the target matrix
  77837. */
  77838. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77839. /**
  77840. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77841. * @param quat defines the quaternion to use
  77842. * @param result defines the target matrix
  77843. */
  77844. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77845. }
  77846. /**
  77847. * @hidden
  77848. */
  77849. export class TmpVectors {
  77850. static Vector2: Vector2[];
  77851. static Vector3: Vector3[];
  77852. static Vector4: Vector4[];
  77853. static Quaternion: Quaternion[];
  77854. static Matrix: Matrix[];
  77855. }
  77856. }
  77857. declare module BABYLON {
  77858. /**
  77859. * Defines potential orientation for back face culling
  77860. */
  77861. export enum Orientation {
  77862. /**
  77863. * Clockwise
  77864. */
  77865. CW = 0,
  77866. /** Counter clockwise */
  77867. CCW = 1
  77868. }
  77869. /** Class used to represent a Bezier curve */
  77870. export class BezierCurve {
  77871. /**
  77872. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77873. * @param t defines the time
  77874. * @param x1 defines the left coordinate on X axis
  77875. * @param y1 defines the left coordinate on Y axis
  77876. * @param x2 defines the right coordinate on X axis
  77877. * @param y2 defines the right coordinate on Y axis
  77878. * @returns the interpolated value
  77879. */
  77880. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77881. }
  77882. /**
  77883. * Defines angle representation
  77884. */
  77885. export class Angle {
  77886. private _radians;
  77887. /**
  77888. * Creates an Angle object of "radians" radians (float).
  77889. * @param radians the angle in radians
  77890. */
  77891. constructor(radians: number);
  77892. /**
  77893. * Get value in degrees
  77894. * @returns the Angle value in degrees (float)
  77895. */
  77896. degrees(): number;
  77897. /**
  77898. * Get value in radians
  77899. * @returns the Angle value in radians (float)
  77900. */
  77901. radians(): number;
  77902. /**
  77903. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77904. * @param a defines first vector
  77905. * @param b defines second vector
  77906. * @returns a new Angle
  77907. */
  77908. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77909. /**
  77910. * Gets a new Angle object from the given float in radians
  77911. * @param radians defines the angle value in radians
  77912. * @returns a new Angle
  77913. */
  77914. static FromRadians(radians: number): Angle;
  77915. /**
  77916. * Gets a new Angle object from the given float in degrees
  77917. * @param degrees defines the angle value in degrees
  77918. * @returns a new Angle
  77919. */
  77920. static FromDegrees(degrees: number): Angle;
  77921. }
  77922. /**
  77923. * This represents an arc in a 2d space.
  77924. */
  77925. export class Arc2 {
  77926. /** Defines the start point of the arc */
  77927. startPoint: Vector2;
  77928. /** Defines the mid point of the arc */
  77929. midPoint: Vector2;
  77930. /** Defines the end point of the arc */
  77931. endPoint: Vector2;
  77932. /**
  77933. * Defines the center point of the arc.
  77934. */
  77935. centerPoint: Vector2;
  77936. /**
  77937. * Defines the radius of the arc.
  77938. */
  77939. radius: number;
  77940. /**
  77941. * Defines the angle of the arc (from mid point to end point).
  77942. */
  77943. angle: Angle;
  77944. /**
  77945. * Defines the start angle of the arc (from start point to middle point).
  77946. */
  77947. startAngle: Angle;
  77948. /**
  77949. * Defines the orientation of the arc (clock wise/counter clock wise).
  77950. */
  77951. orientation: Orientation;
  77952. /**
  77953. * Creates an Arc object from the three given points : start, middle and end.
  77954. * @param startPoint Defines the start point of the arc
  77955. * @param midPoint Defines the midlle point of the arc
  77956. * @param endPoint Defines the end point of the arc
  77957. */
  77958. constructor(
  77959. /** Defines the start point of the arc */
  77960. startPoint: Vector2,
  77961. /** Defines the mid point of the arc */
  77962. midPoint: Vector2,
  77963. /** Defines the end point of the arc */
  77964. endPoint: Vector2);
  77965. }
  77966. /**
  77967. * Represents a 2D path made up of multiple 2D points
  77968. */
  77969. export class Path2 {
  77970. private _points;
  77971. private _length;
  77972. /**
  77973. * If the path start and end point are the same
  77974. */
  77975. closed: boolean;
  77976. /**
  77977. * Creates a Path2 object from the starting 2D coordinates x and y.
  77978. * @param x the starting points x value
  77979. * @param y the starting points y value
  77980. */
  77981. constructor(x: number, y: number);
  77982. /**
  77983. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77984. * @param x the added points x value
  77985. * @param y the added points y value
  77986. * @returns the updated Path2.
  77987. */
  77988. addLineTo(x: number, y: number): Path2;
  77989. /**
  77990. * 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.
  77991. * @param midX middle point x value
  77992. * @param midY middle point y value
  77993. * @param endX end point x value
  77994. * @param endY end point y value
  77995. * @param numberOfSegments (default: 36)
  77996. * @returns the updated Path2.
  77997. */
  77998. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77999. /**
  78000. * Closes the Path2.
  78001. * @returns the Path2.
  78002. */
  78003. close(): Path2;
  78004. /**
  78005. * Gets the sum of the distance between each sequential point in the path
  78006. * @returns the Path2 total length (float).
  78007. */
  78008. length(): number;
  78009. /**
  78010. * Gets the points which construct the path
  78011. * @returns the Path2 internal array of points.
  78012. */
  78013. getPoints(): Vector2[];
  78014. /**
  78015. * Retreives the point at the distance aways from the starting point
  78016. * @param normalizedLengthPosition the length along the path to retreive the point from
  78017. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78018. */
  78019. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78020. /**
  78021. * Creates a new path starting from an x and y position
  78022. * @param x starting x value
  78023. * @param y starting y value
  78024. * @returns a new Path2 starting at the coordinates (x, y).
  78025. */
  78026. static StartingAt(x: number, y: number): Path2;
  78027. }
  78028. /**
  78029. * Represents a 3D path made up of multiple 3D points
  78030. */
  78031. export class Path3D {
  78032. /**
  78033. * an array of Vector3, the curve axis of the Path3D
  78034. */
  78035. path: Vector3[];
  78036. private _curve;
  78037. private _distances;
  78038. private _tangents;
  78039. private _normals;
  78040. private _binormals;
  78041. private _raw;
  78042. private _alignTangentsWithPath;
  78043. private readonly _pointAtData;
  78044. /**
  78045. * new Path3D(path, normal, raw)
  78046. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78047. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78048. * @param path an array of Vector3, the curve axis of the Path3D
  78049. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78050. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78051. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78052. */
  78053. constructor(
  78054. /**
  78055. * an array of Vector3, the curve axis of the Path3D
  78056. */
  78057. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78058. /**
  78059. * Returns the Path3D array of successive Vector3 designing its curve.
  78060. * @returns the Path3D array of successive Vector3 designing its curve.
  78061. */
  78062. getCurve(): Vector3[];
  78063. /**
  78064. * Returns the Path3D array of successive Vector3 designing its curve.
  78065. * @returns the Path3D array of successive Vector3 designing its curve.
  78066. */
  78067. getPoints(): Vector3[];
  78068. /**
  78069. * @returns the computed length (float) of the path.
  78070. */
  78071. length(): number;
  78072. /**
  78073. * Returns an array populated with tangent vectors on each Path3D curve point.
  78074. * @returns an array populated with tangent vectors on each Path3D curve point.
  78075. */
  78076. getTangents(): Vector3[];
  78077. /**
  78078. * Returns an array populated with normal vectors on each Path3D curve point.
  78079. * @returns an array populated with normal vectors on each Path3D curve point.
  78080. */
  78081. getNormals(): Vector3[];
  78082. /**
  78083. * Returns an array populated with binormal vectors on each Path3D curve point.
  78084. * @returns an array populated with binormal vectors on each Path3D curve point.
  78085. */
  78086. getBinormals(): Vector3[];
  78087. /**
  78088. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78089. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78090. */
  78091. getDistances(): number[];
  78092. /**
  78093. * Returns an interpolated point along this path
  78094. * @param position the position of the point along this path, from 0.0 to 1.0
  78095. * @returns a new Vector3 as the point
  78096. */
  78097. getPointAt(position: number): Vector3;
  78098. /**
  78099. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78100. * @param position the position of the point along this path, from 0.0 to 1.0
  78101. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78102. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78103. */
  78104. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78105. /**
  78106. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78107. * @param position the position of the point along this path, from 0.0 to 1.0
  78108. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78109. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78110. */
  78111. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78112. /**
  78113. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78114. * @param position the position of the point along this path, from 0.0 to 1.0
  78115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78116. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78117. */
  78118. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78119. /**
  78120. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78121. * @param position the position of the point along this path, from 0.0 to 1.0
  78122. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78123. */
  78124. getDistanceAt(position: number): number;
  78125. /**
  78126. * Returns the array index of the previous point of an interpolated point along this path
  78127. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78128. * @returns the array index
  78129. */
  78130. getPreviousPointIndexAt(position: number): number;
  78131. /**
  78132. * 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)
  78133. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78134. * @returns the sub position
  78135. */
  78136. getSubPositionAt(position: number): number;
  78137. /**
  78138. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78139. * @param target the vector of which to get the closest position to
  78140. * @returns the position of the closest virtual point on this path to the target vector
  78141. */
  78142. getClosestPositionTo(target: Vector3): number;
  78143. /**
  78144. * Returns a sub path (slice) of this path
  78145. * @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
  78146. * @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
  78147. * @returns a sub path (slice) of this path
  78148. */
  78149. slice(start?: number, end?: number): Path3D;
  78150. /**
  78151. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78152. * @param path path which all values are copied into the curves points
  78153. * @param firstNormal which should be projected onto the curve
  78154. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78155. * @returns the same object updated.
  78156. */
  78157. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78158. private _compute;
  78159. private _getFirstNonNullVector;
  78160. private _getLastNonNullVector;
  78161. private _normalVector;
  78162. /**
  78163. * Updates the point at data for an interpolated point along this curve
  78164. * @param position the position of the point along this curve, from 0.0 to 1.0
  78165. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78166. * @returns the (updated) point at data
  78167. */
  78168. private _updatePointAtData;
  78169. /**
  78170. * Updates the point at data from the specified parameters
  78171. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78172. * @param point the interpolated point
  78173. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78174. */
  78175. private _setPointAtData;
  78176. /**
  78177. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78178. */
  78179. private _updateInterpolationMatrix;
  78180. }
  78181. /**
  78182. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78183. * A Curve3 is designed from a series of successive Vector3.
  78184. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78185. */
  78186. export class Curve3 {
  78187. private _points;
  78188. private _length;
  78189. /**
  78190. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78191. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78192. * @param v1 (Vector3) the control point
  78193. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78194. * @param nbPoints (integer) the wanted number of points in the curve
  78195. * @returns the created Curve3
  78196. */
  78197. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78198. /**
  78199. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78200. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78201. * @param v1 (Vector3) the first control point
  78202. * @param v2 (Vector3) the second control point
  78203. * @param v3 (Vector3) the end point of the Cubic Bezier
  78204. * @param nbPoints (integer) the wanted number of points in the curve
  78205. * @returns the created Curve3
  78206. */
  78207. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78208. /**
  78209. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78210. * @param p1 (Vector3) the origin point of the Hermite Spline
  78211. * @param t1 (Vector3) the tangent vector at the origin point
  78212. * @param p2 (Vector3) the end point of the Hermite Spline
  78213. * @param t2 (Vector3) the tangent vector at the end point
  78214. * @param nbPoints (integer) the wanted number of points in the curve
  78215. * @returns the created Curve3
  78216. */
  78217. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78218. /**
  78219. * Returns a Curve3 object along a CatmullRom Spline curve :
  78220. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78221. * @param nbPoints (integer) the wanted number of points between each curve control points
  78222. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78223. * @returns the created Curve3
  78224. */
  78225. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78226. /**
  78227. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78228. * A Curve3 is designed from a series of successive Vector3.
  78229. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78230. * @param points points which make up the curve
  78231. */
  78232. constructor(points: Vector3[]);
  78233. /**
  78234. * @returns the Curve3 stored array of successive Vector3
  78235. */
  78236. getPoints(): Vector3[];
  78237. /**
  78238. * @returns the computed length (float) of the curve.
  78239. */
  78240. length(): number;
  78241. /**
  78242. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78243. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78244. * curveA and curveB keep unchanged.
  78245. * @param curve the curve to continue from this curve
  78246. * @returns the newly constructed curve
  78247. */
  78248. continue(curve: DeepImmutable<Curve3>): Curve3;
  78249. private _computeLength;
  78250. }
  78251. }
  78252. declare module BABYLON {
  78253. /**
  78254. * This represents the main contract an easing function should follow.
  78255. * Easing functions are used throughout the animation system.
  78256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78257. */
  78258. export interface IEasingFunction {
  78259. /**
  78260. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78261. * of the easing function.
  78262. * The link below provides some of the most common examples of easing functions.
  78263. * @see https://easings.net/
  78264. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78265. * @returns the corresponding value on the curve defined by the easing function
  78266. */
  78267. ease(gradient: number): number;
  78268. }
  78269. /**
  78270. * Base class used for every default easing function.
  78271. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78272. */
  78273. export class EasingFunction implements IEasingFunction {
  78274. /**
  78275. * Interpolation follows the mathematical formula associated with the easing function.
  78276. */
  78277. static readonly EASINGMODE_EASEIN: number;
  78278. /**
  78279. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78280. */
  78281. static readonly EASINGMODE_EASEOUT: number;
  78282. /**
  78283. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78284. */
  78285. static readonly EASINGMODE_EASEINOUT: number;
  78286. private _easingMode;
  78287. /**
  78288. * Sets the easing mode of the current function.
  78289. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78290. */
  78291. setEasingMode(easingMode: number): void;
  78292. /**
  78293. * Gets the current easing mode.
  78294. * @returns the easing mode
  78295. */
  78296. getEasingMode(): number;
  78297. /**
  78298. * @hidden
  78299. */
  78300. easeInCore(gradient: number): number;
  78301. /**
  78302. * Given an input gradient between 0 and 1, this returns the corresponding value
  78303. * of the easing function.
  78304. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78305. * @returns the corresponding value on the curve defined by the easing function
  78306. */
  78307. ease(gradient: number): number;
  78308. }
  78309. /**
  78310. * Easing function with a circle shape (see link below).
  78311. * @see https://easings.net/#easeInCirc
  78312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78313. */
  78314. export class CircleEase extends EasingFunction implements IEasingFunction {
  78315. /** @hidden */
  78316. easeInCore(gradient: number): number;
  78317. }
  78318. /**
  78319. * Easing function with a ease back shape (see link below).
  78320. * @see https://easings.net/#easeInBack
  78321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78322. */
  78323. export class BackEase extends EasingFunction implements IEasingFunction {
  78324. /** Defines the amplitude of the function */
  78325. amplitude: number;
  78326. /**
  78327. * Instantiates a back ease easing
  78328. * @see https://easings.net/#easeInBack
  78329. * @param amplitude Defines the amplitude of the function
  78330. */
  78331. constructor(
  78332. /** Defines the amplitude of the function */
  78333. amplitude?: number);
  78334. /** @hidden */
  78335. easeInCore(gradient: number): number;
  78336. }
  78337. /**
  78338. * Easing function with a bouncing shape (see link below).
  78339. * @see https://easings.net/#easeInBounce
  78340. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78341. */
  78342. export class BounceEase extends EasingFunction implements IEasingFunction {
  78343. /** Defines the number of bounces */
  78344. bounces: number;
  78345. /** Defines the amplitude of the bounce */
  78346. bounciness: number;
  78347. /**
  78348. * Instantiates a bounce easing
  78349. * @see https://easings.net/#easeInBounce
  78350. * @param bounces Defines the number of bounces
  78351. * @param bounciness Defines the amplitude of the bounce
  78352. */
  78353. constructor(
  78354. /** Defines the number of bounces */
  78355. bounces?: number,
  78356. /** Defines the amplitude of the bounce */
  78357. bounciness?: number);
  78358. /** @hidden */
  78359. easeInCore(gradient: number): number;
  78360. }
  78361. /**
  78362. * Easing function with a power of 3 shape (see link below).
  78363. * @see https://easings.net/#easeInCubic
  78364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78365. */
  78366. export class CubicEase extends EasingFunction implements IEasingFunction {
  78367. /** @hidden */
  78368. easeInCore(gradient: number): number;
  78369. }
  78370. /**
  78371. * Easing function with an elastic shape (see link below).
  78372. * @see https://easings.net/#easeInElastic
  78373. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78374. */
  78375. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78376. /** Defines the number of oscillations*/
  78377. oscillations: number;
  78378. /** Defines the amplitude of the oscillations*/
  78379. springiness: number;
  78380. /**
  78381. * Instantiates an elastic easing function
  78382. * @see https://easings.net/#easeInElastic
  78383. * @param oscillations Defines the number of oscillations
  78384. * @param springiness Defines the amplitude of the oscillations
  78385. */
  78386. constructor(
  78387. /** Defines the number of oscillations*/
  78388. oscillations?: number,
  78389. /** Defines the amplitude of the oscillations*/
  78390. springiness?: number);
  78391. /** @hidden */
  78392. easeInCore(gradient: number): number;
  78393. }
  78394. /**
  78395. * Easing function with an exponential shape (see link below).
  78396. * @see https://easings.net/#easeInExpo
  78397. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78398. */
  78399. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78400. /** Defines the exponent of the function */
  78401. exponent: number;
  78402. /**
  78403. * Instantiates an exponential easing function
  78404. * @see https://easings.net/#easeInExpo
  78405. * @param exponent Defines the exponent of the function
  78406. */
  78407. constructor(
  78408. /** Defines the exponent of the function */
  78409. exponent?: number);
  78410. /** @hidden */
  78411. easeInCore(gradient: number): number;
  78412. }
  78413. /**
  78414. * Easing function with a power shape (see link below).
  78415. * @see https://easings.net/#easeInQuad
  78416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78417. */
  78418. export class PowerEase extends EasingFunction implements IEasingFunction {
  78419. /** Defines the power of the function */
  78420. power: number;
  78421. /**
  78422. * Instantiates an power base easing function
  78423. * @see https://easings.net/#easeInQuad
  78424. * @param power Defines the power of the function
  78425. */
  78426. constructor(
  78427. /** Defines the power of the function */
  78428. power?: number);
  78429. /** @hidden */
  78430. easeInCore(gradient: number): number;
  78431. }
  78432. /**
  78433. * Easing function with a power of 2 shape (see link below).
  78434. * @see https://easings.net/#easeInQuad
  78435. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78436. */
  78437. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78438. /** @hidden */
  78439. easeInCore(gradient: number): number;
  78440. }
  78441. /**
  78442. * Easing function with a power of 4 shape (see link below).
  78443. * @see https://easings.net/#easeInQuart
  78444. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78445. */
  78446. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78447. /** @hidden */
  78448. easeInCore(gradient: number): number;
  78449. }
  78450. /**
  78451. * Easing function with a power of 5 shape (see link below).
  78452. * @see https://easings.net/#easeInQuint
  78453. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78454. */
  78455. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78456. /** @hidden */
  78457. easeInCore(gradient: number): number;
  78458. }
  78459. /**
  78460. * Easing function with a sin shape (see link below).
  78461. * @see https://easings.net/#easeInSine
  78462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78463. */
  78464. export class SineEase extends EasingFunction implements IEasingFunction {
  78465. /** @hidden */
  78466. easeInCore(gradient: number): number;
  78467. }
  78468. /**
  78469. * Easing function with a bezier shape (see link below).
  78470. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78472. */
  78473. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78474. /** Defines the x component of the start tangent in the bezier curve */
  78475. x1: number;
  78476. /** Defines the y component of the start tangent in the bezier curve */
  78477. y1: number;
  78478. /** Defines the x component of the end tangent in the bezier curve */
  78479. x2: number;
  78480. /** Defines the y component of the end tangent in the bezier curve */
  78481. y2: number;
  78482. /**
  78483. * Instantiates a bezier function
  78484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78485. * @param x1 Defines the x component of the start tangent in the bezier curve
  78486. * @param y1 Defines the y component of the start tangent in the bezier curve
  78487. * @param x2 Defines the x component of the end tangent in the bezier curve
  78488. * @param y2 Defines the y component of the end tangent in the bezier curve
  78489. */
  78490. constructor(
  78491. /** Defines the x component of the start tangent in the bezier curve */
  78492. x1?: number,
  78493. /** Defines the y component of the start tangent in the bezier curve */
  78494. y1?: number,
  78495. /** Defines the x component of the end tangent in the bezier curve */
  78496. x2?: number,
  78497. /** Defines the y component of the end tangent in the bezier curve */
  78498. y2?: number);
  78499. /** @hidden */
  78500. easeInCore(gradient: number): number;
  78501. }
  78502. }
  78503. declare module BABYLON {
  78504. /**
  78505. * Class used to hold a RBG color
  78506. */
  78507. export class Color3 {
  78508. /**
  78509. * Defines the red component (between 0 and 1, default is 0)
  78510. */
  78511. r: number;
  78512. /**
  78513. * Defines the green component (between 0 and 1, default is 0)
  78514. */
  78515. g: number;
  78516. /**
  78517. * Defines the blue component (between 0 and 1, default is 0)
  78518. */
  78519. b: number;
  78520. /**
  78521. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78522. * @param r defines the red component (between 0 and 1, default is 0)
  78523. * @param g defines the green component (between 0 and 1, default is 0)
  78524. * @param b defines the blue component (between 0 and 1, default is 0)
  78525. */
  78526. constructor(
  78527. /**
  78528. * Defines the red component (between 0 and 1, default is 0)
  78529. */
  78530. r?: number,
  78531. /**
  78532. * Defines the green component (between 0 and 1, default is 0)
  78533. */
  78534. g?: number,
  78535. /**
  78536. * Defines the blue component (between 0 and 1, default is 0)
  78537. */
  78538. b?: number);
  78539. /**
  78540. * Creates a string with the Color3 current values
  78541. * @returns the string representation of the Color3 object
  78542. */
  78543. toString(): string;
  78544. /**
  78545. * Returns the string "Color3"
  78546. * @returns "Color3"
  78547. */
  78548. getClassName(): string;
  78549. /**
  78550. * Compute the Color3 hash code
  78551. * @returns an unique number that can be used to hash Color3 objects
  78552. */
  78553. getHashCode(): number;
  78554. /**
  78555. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78556. * @param array defines the array where to store the r,g,b components
  78557. * @param index defines an optional index in the target array to define where to start storing values
  78558. * @returns the current Color3 object
  78559. */
  78560. toArray(array: FloatArray, index?: number): Color3;
  78561. /**
  78562. * Returns a new Color4 object from the current Color3 and the given alpha
  78563. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78564. * @returns a new Color4 object
  78565. */
  78566. toColor4(alpha?: number): Color4;
  78567. /**
  78568. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78569. * @returns the new array
  78570. */
  78571. asArray(): number[];
  78572. /**
  78573. * Returns the luminance value
  78574. * @returns a float value
  78575. */
  78576. toLuminance(): number;
  78577. /**
  78578. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78579. * @param otherColor defines the second operand
  78580. * @returns the new Color3 object
  78581. */
  78582. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78583. /**
  78584. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78585. * @param otherColor defines the second operand
  78586. * @param result defines the Color3 object where to store the result
  78587. * @returns the current Color3
  78588. */
  78589. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78590. /**
  78591. * Determines equality between Color3 objects
  78592. * @param otherColor defines the second operand
  78593. * @returns true if the rgb values are equal to the given ones
  78594. */
  78595. equals(otherColor: DeepImmutable<Color3>): boolean;
  78596. /**
  78597. * Determines equality between the current Color3 object and a set of r,b,g values
  78598. * @param r defines the red component to check
  78599. * @param g defines the green component to check
  78600. * @param b defines the blue component to check
  78601. * @returns true if the rgb values are equal to the given ones
  78602. */
  78603. equalsFloats(r: number, g: number, b: number): boolean;
  78604. /**
  78605. * Multiplies in place each rgb value by scale
  78606. * @param scale defines the scaling factor
  78607. * @returns the updated Color3
  78608. */
  78609. scale(scale: number): Color3;
  78610. /**
  78611. * Multiplies the rgb values by scale and stores the result into "result"
  78612. * @param scale defines the scaling factor
  78613. * @param result defines the Color3 object where to store the result
  78614. * @returns the unmodified current Color3
  78615. */
  78616. scaleToRef(scale: number, result: Color3): Color3;
  78617. /**
  78618. * Scale the current Color3 values by a factor and add the result to a given Color3
  78619. * @param scale defines the scale factor
  78620. * @param result defines color to store the result into
  78621. * @returns the unmodified current Color3
  78622. */
  78623. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78624. /**
  78625. * Clamps the rgb values by the min and max values and stores the result into "result"
  78626. * @param min defines minimum clamping value (default is 0)
  78627. * @param max defines maximum clamping value (default is 1)
  78628. * @param result defines color to store the result into
  78629. * @returns the original Color3
  78630. */
  78631. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78632. /**
  78633. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78634. * @param otherColor defines the second operand
  78635. * @returns the new Color3
  78636. */
  78637. add(otherColor: DeepImmutable<Color3>): Color3;
  78638. /**
  78639. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78640. * @param otherColor defines the second operand
  78641. * @param result defines Color3 object to store the result into
  78642. * @returns the unmodified current Color3
  78643. */
  78644. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78645. /**
  78646. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78647. * @param otherColor defines the second operand
  78648. * @returns the new Color3
  78649. */
  78650. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78651. /**
  78652. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78653. * @param otherColor defines the second operand
  78654. * @param result defines Color3 object to store the result into
  78655. * @returns the unmodified current Color3
  78656. */
  78657. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78658. /**
  78659. * Copy the current object
  78660. * @returns a new Color3 copied the current one
  78661. */
  78662. clone(): Color3;
  78663. /**
  78664. * Copies the rgb values from the source in the current Color3
  78665. * @param source defines the source Color3 object
  78666. * @returns the updated Color3 object
  78667. */
  78668. copyFrom(source: DeepImmutable<Color3>): Color3;
  78669. /**
  78670. * Updates the Color3 rgb values from the given floats
  78671. * @param r defines the red component to read from
  78672. * @param g defines the green component to read from
  78673. * @param b defines the blue component to read from
  78674. * @returns the current Color3 object
  78675. */
  78676. copyFromFloats(r: number, g: number, b: number): Color3;
  78677. /**
  78678. * Updates the Color3 rgb values from the given floats
  78679. * @param r defines the red component to read from
  78680. * @param g defines the green component to read from
  78681. * @param b defines the blue component to read from
  78682. * @returns the current Color3 object
  78683. */
  78684. set(r: number, g: number, b: number): Color3;
  78685. /**
  78686. * Compute the Color3 hexadecimal code as a string
  78687. * @returns a string containing the hexadecimal representation of the Color3 object
  78688. */
  78689. toHexString(): string;
  78690. /**
  78691. * Computes a new Color3 converted from the current one to linear space
  78692. * @returns a new Color3 object
  78693. */
  78694. toLinearSpace(): Color3;
  78695. /**
  78696. * Converts current color in rgb space to HSV values
  78697. * @returns a new color3 representing the HSV values
  78698. */
  78699. toHSV(): Color3;
  78700. /**
  78701. * Converts current color in rgb space to HSV values
  78702. * @param result defines the Color3 where to store the HSV values
  78703. */
  78704. toHSVToRef(result: Color3): void;
  78705. /**
  78706. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78707. * @param convertedColor defines the Color3 object where to store the linear space version
  78708. * @returns the unmodified Color3
  78709. */
  78710. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78711. /**
  78712. * Computes a new Color3 converted from the current one to gamma space
  78713. * @returns a new Color3 object
  78714. */
  78715. toGammaSpace(): Color3;
  78716. /**
  78717. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78718. * @param convertedColor defines the Color3 object where to store the gamma space version
  78719. * @returns the unmodified Color3
  78720. */
  78721. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78722. private static _BlackReadOnly;
  78723. /**
  78724. * Convert Hue, saturation and value to a Color3 (RGB)
  78725. * @param hue defines the hue
  78726. * @param saturation defines the saturation
  78727. * @param value defines the value
  78728. * @param result defines the Color3 where to store the RGB values
  78729. */
  78730. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78731. /**
  78732. * Creates a new Color3 from the string containing valid hexadecimal values
  78733. * @param hex defines a string containing valid hexadecimal values
  78734. * @returns a new Color3 object
  78735. */
  78736. static FromHexString(hex: string): Color3;
  78737. /**
  78738. * Creates a new Color3 from the starting index of the given array
  78739. * @param array defines the source array
  78740. * @param offset defines an offset in the source array
  78741. * @returns a new Color3 object
  78742. */
  78743. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78744. /**
  78745. * Creates a new Color3 from integer values (< 256)
  78746. * @param r defines the red component to read from (value between 0 and 255)
  78747. * @param g defines the green component to read from (value between 0 and 255)
  78748. * @param b defines the blue component to read from (value between 0 and 255)
  78749. * @returns a new Color3 object
  78750. */
  78751. static FromInts(r: number, g: number, b: number): Color3;
  78752. /**
  78753. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78754. * @param start defines the start Color3 value
  78755. * @param end defines the end Color3 value
  78756. * @param amount defines the gradient value between start and end
  78757. * @returns a new Color3 object
  78758. */
  78759. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78760. /**
  78761. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78762. * @param left defines the start value
  78763. * @param right defines the end value
  78764. * @param amount defines the gradient factor
  78765. * @param result defines the Color3 object where to store the result
  78766. */
  78767. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78768. /**
  78769. * Returns a Color3 value containing a red color
  78770. * @returns a new Color3 object
  78771. */
  78772. static Red(): Color3;
  78773. /**
  78774. * Returns a Color3 value containing a green color
  78775. * @returns a new Color3 object
  78776. */
  78777. static Green(): Color3;
  78778. /**
  78779. * Returns a Color3 value containing a blue color
  78780. * @returns a new Color3 object
  78781. */
  78782. static Blue(): Color3;
  78783. /**
  78784. * Returns a Color3 value containing a black color
  78785. * @returns a new Color3 object
  78786. */
  78787. static Black(): Color3;
  78788. /**
  78789. * Gets a Color3 value containing a black color that must not be updated
  78790. */
  78791. static get BlackReadOnly(): DeepImmutable<Color3>;
  78792. /**
  78793. * Returns a Color3 value containing a white color
  78794. * @returns a new Color3 object
  78795. */
  78796. static White(): Color3;
  78797. /**
  78798. * Returns a Color3 value containing a purple color
  78799. * @returns a new Color3 object
  78800. */
  78801. static Purple(): Color3;
  78802. /**
  78803. * Returns a Color3 value containing a magenta color
  78804. * @returns a new Color3 object
  78805. */
  78806. static Magenta(): Color3;
  78807. /**
  78808. * Returns a Color3 value containing a yellow color
  78809. * @returns a new Color3 object
  78810. */
  78811. static Yellow(): Color3;
  78812. /**
  78813. * Returns a Color3 value containing a gray color
  78814. * @returns a new Color3 object
  78815. */
  78816. static Gray(): Color3;
  78817. /**
  78818. * Returns a Color3 value containing a teal color
  78819. * @returns a new Color3 object
  78820. */
  78821. static Teal(): Color3;
  78822. /**
  78823. * Returns a Color3 value containing a random color
  78824. * @returns a new Color3 object
  78825. */
  78826. static Random(): Color3;
  78827. }
  78828. /**
  78829. * Class used to hold a RBGA color
  78830. */
  78831. export class Color4 {
  78832. /**
  78833. * Defines the red component (between 0 and 1, default is 0)
  78834. */
  78835. r: number;
  78836. /**
  78837. * Defines the green component (between 0 and 1, default is 0)
  78838. */
  78839. g: number;
  78840. /**
  78841. * Defines the blue component (between 0 and 1, default is 0)
  78842. */
  78843. b: number;
  78844. /**
  78845. * Defines the alpha component (between 0 and 1, default is 1)
  78846. */
  78847. a: number;
  78848. /**
  78849. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78850. * @param r defines the red component (between 0 and 1, default is 0)
  78851. * @param g defines the green component (between 0 and 1, default is 0)
  78852. * @param b defines the blue component (between 0 and 1, default is 0)
  78853. * @param a defines the alpha component (between 0 and 1, default is 1)
  78854. */
  78855. constructor(
  78856. /**
  78857. * Defines the red component (between 0 and 1, default is 0)
  78858. */
  78859. r?: number,
  78860. /**
  78861. * Defines the green component (between 0 and 1, default is 0)
  78862. */
  78863. g?: number,
  78864. /**
  78865. * Defines the blue component (between 0 and 1, default is 0)
  78866. */
  78867. b?: number,
  78868. /**
  78869. * Defines the alpha component (between 0 and 1, default is 1)
  78870. */
  78871. a?: number);
  78872. /**
  78873. * Adds in place the given Color4 values to the current Color4 object
  78874. * @param right defines the second operand
  78875. * @returns the current updated Color4 object
  78876. */
  78877. addInPlace(right: DeepImmutable<Color4>): Color4;
  78878. /**
  78879. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78880. * @returns the new array
  78881. */
  78882. asArray(): number[];
  78883. /**
  78884. * Stores from the starting index in the given array the Color4 successive values
  78885. * @param array defines the array where to store the r,g,b components
  78886. * @param index defines an optional index in the target array to define where to start storing values
  78887. * @returns the current Color4 object
  78888. */
  78889. toArray(array: number[], index?: number): Color4;
  78890. /**
  78891. * Determines equality between Color4 objects
  78892. * @param otherColor defines the second operand
  78893. * @returns true if the rgba values are equal to the given ones
  78894. */
  78895. equals(otherColor: DeepImmutable<Color4>): boolean;
  78896. /**
  78897. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78898. * @param right defines the second operand
  78899. * @returns a new Color4 object
  78900. */
  78901. add(right: DeepImmutable<Color4>): Color4;
  78902. /**
  78903. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78904. * @param right defines the second operand
  78905. * @returns a new Color4 object
  78906. */
  78907. subtract(right: DeepImmutable<Color4>): Color4;
  78908. /**
  78909. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78910. * @param right defines the second operand
  78911. * @param result defines the Color4 object where to store the result
  78912. * @returns the current Color4 object
  78913. */
  78914. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78915. /**
  78916. * Creates a new Color4 with the current Color4 values multiplied by scale
  78917. * @param scale defines the scaling factor to apply
  78918. * @returns a new Color4 object
  78919. */
  78920. scale(scale: number): Color4;
  78921. /**
  78922. * Multiplies the current Color4 values by scale and stores the result in "result"
  78923. * @param scale defines the scaling factor to apply
  78924. * @param result defines the Color4 object where to store the result
  78925. * @returns the current unmodified Color4
  78926. */
  78927. scaleToRef(scale: number, result: Color4): Color4;
  78928. /**
  78929. * Scale the current Color4 values by a factor and add the result to a given Color4
  78930. * @param scale defines the scale factor
  78931. * @param result defines the Color4 object where to store the result
  78932. * @returns the unmodified current Color4
  78933. */
  78934. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78935. /**
  78936. * Clamps the rgb values by the min and max values and stores the result into "result"
  78937. * @param min defines minimum clamping value (default is 0)
  78938. * @param max defines maximum clamping value (default is 1)
  78939. * @param result defines color to store the result into.
  78940. * @returns the cuurent Color4
  78941. */
  78942. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78943. /**
  78944. * Multipy an Color4 value by another and return a new Color4 object
  78945. * @param color defines the Color4 value to multiply by
  78946. * @returns a new Color4 object
  78947. */
  78948. multiply(color: Color4): Color4;
  78949. /**
  78950. * Multipy a Color4 value by another and push the result in a reference value
  78951. * @param color defines the Color4 value to multiply by
  78952. * @param result defines the Color4 to fill the result in
  78953. * @returns the result Color4
  78954. */
  78955. multiplyToRef(color: Color4, result: Color4): Color4;
  78956. /**
  78957. * Creates a string with the Color4 current values
  78958. * @returns the string representation of the Color4 object
  78959. */
  78960. toString(): string;
  78961. /**
  78962. * Returns the string "Color4"
  78963. * @returns "Color4"
  78964. */
  78965. getClassName(): string;
  78966. /**
  78967. * Compute the Color4 hash code
  78968. * @returns an unique number that can be used to hash Color4 objects
  78969. */
  78970. getHashCode(): number;
  78971. /**
  78972. * Creates a new Color4 copied from the current one
  78973. * @returns a new Color4 object
  78974. */
  78975. clone(): Color4;
  78976. /**
  78977. * Copies the given Color4 values into the current one
  78978. * @param source defines the source Color4 object
  78979. * @returns the current updated Color4 object
  78980. */
  78981. copyFrom(source: Color4): Color4;
  78982. /**
  78983. * Copies the given float values into the current one
  78984. * @param r defines the red component to read from
  78985. * @param g defines the green component to read from
  78986. * @param b defines the blue component to read from
  78987. * @param a defines the alpha component to read from
  78988. * @returns the current updated Color4 object
  78989. */
  78990. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78991. /**
  78992. * Copies the given float values into the current one
  78993. * @param r defines the red component to read from
  78994. * @param g defines the green component to read from
  78995. * @param b defines the blue component to read from
  78996. * @param a defines the alpha component to read from
  78997. * @returns the current updated Color4 object
  78998. */
  78999. set(r: number, g: number, b: number, a: number): Color4;
  79000. /**
  79001. * Compute the Color4 hexadecimal code as a string
  79002. * @returns a string containing the hexadecimal representation of the Color4 object
  79003. */
  79004. toHexString(): string;
  79005. /**
  79006. * Computes a new Color4 converted from the current one to linear space
  79007. * @returns a new Color4 object
  79008. */
  79009. toLinearSpace(): Color4;
  79010. /**
  79011. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79012. * @param convertedColor defines the Color4 object where to store the linear space version
  79013. * @returns the unmodified Color4
  79014. */
  79015. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79016. /**
  79017. * Computes a new Color4 converted from the current one to gamma space
  79018. * @returns a new Color4 object
  79019. */
  79020. toGammaSpace(): Color4;
  79021. /**
  79022. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79023. * @param convertedColor defines the Color4 object where to store the gamma space version
  79024. * @returns the unmodified Color4
  79025. */
  79026. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79027. /**
  79028. * Creates a new Color4 from the string containing valid hexadecimal values
  79029. * @param hex defines a string containing valid hexadecimal values
  79030. * @returns a new Color4 object
  79031. */
  79032. static FromHexString(hex: string): Color4;
  79033. /**
  79034. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79035. * @param left defines the start value
  79036. * @param right defines the end value
  79037. * @param amount defines the gradient factor
  79038. * @returns a new Color4 object
  79039. */
  79040. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79041. /**
  79042. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79043. * @param left defines the start value
  79044. * @param right defines the end value
  79045. * @param amount defines the gradient factor
  79046. * @param result defines the Color4 object where to store data
  79047. */
  79048. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79049. /**
  79050. * Creates a new Color4 from a Color3 and an alpha value
  79051. * @param color3 defines the source Color3 to read from
  79052. * @param alpha defines the alpha component (1.0 by default)
  79053. * @returns a new Color4 object
  79054. */
  79055. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79056. /**
  79057. * Creates a new Color4 from the starting index element of the given array
  79058. * @param array defines the source array to read from
  79059. * @param offset defines the offset in the source array
  79060. * @returns a new Color4 object
  79061. */
  79062. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79063. /**
  79064. * Creates a new Color3 from integer values (< 256)
  79065. * @param r defines the red component to read from (value between 0 and 255)
  79066. * @param g defines the green component to read from (value between 0 and 255)
  79067. * @param b defines the blue component to read from (value between 0 and 255)
  79068. * @param a defines the alpha component to read from (value between 0 and 255)
  79069. * @returns a new Color3 object
  79070. */
  79071. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79072. /**
  79073. * Check the content of a given array and convert it to an array containing RGBA data
  79074. * If the original array was already containing count * 4 values then it is returned directly
  79075. * @param colors defines the array to check
  79076. * @param count defines the number of RGBA data to expect
  79077. * @returns an array containing count * 4 values (RGBA)
  79078. */
  79079. static CheckColors4(colors: number[], count: number): number[];
  79080. }
  79081. /**
  79082. * @hidden
  79083. */
  79084. export class TmpColors {
  79085. static Color3: Color3[];
  79086. static Color4: Color4[];
  79087. }
  79088. }
  79089. declare module BABYLON {
  79090. /**
  79091. * Defines an interface which represents an animation key frame
  79092. */
  79093. export interface IAnimationKey {
  79094. /**
  79095. * Frame of the key frame
  79096. */
  79097. frame: number;
  79098. /**
  79099. * Value at the specifies key frame
  79100. */
  79101. value: any;
  79102. /**
  79103. * The input tangent for the cubic hermite spline
  79104. */
  79105. inTangent?: any;
  79106. /**
  79107. * The output tangent for the cubic hermite spline
  79108. */
  79109. outTangent?: any;
  79110. /**
  79111. * The animation interpolation type
  79112. */
  79113. interpolation?: AnimationKeyInterpolation;
  79114. }
  79115. /**
  79116. * Enum for the animation key frame interpolation type
  79117. */
  79118. export enum AnimationKeyInterpolation {
  79119. /**
  79120. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79121. */
  79122. STEP = 1
  79123. }
  79124. }
  79125. declare module BABYLON {
  79126. /**
  79127. * Represents the range of an animation
  79128. */
  79129. export class AnimationRange {
  79130. /**The name of the animation range**/
  79131. name: string;
  79132. /**The starting frame of the animation */
  79133. from: number;
  79134. /**The ending frame of the animation*/
  79135. to: number;
  79136. /**
  79137. * Initializes the range of an animation
  79138. * @param name The name of the animation range
  79139. * @param from The starting frame of the animation
  79140. * @param to The ending frame of the animation
  79141. */
  79142. constructor(
  79143. /**The name of the animation range**/
  79144. name: string,
  79145. /**The starting frame of the animation */
  79146. from: number,
  79147. /**The ending frame of the animation*/
  79148. to: number);
  79149. /**
  79150. * Makes a copy of the animation range
  79151. * @returns A copy of the animation range
  79152. */
  79153. clone(): AnimationRange;
  79154. }
  79155. }
  79156. declare module BABYLON {
  79157. /**
  79158. * Composed of a frame, and an action function
  79159. */
  79160. export class AnimationEvent {
  79161. /** The frame for which the event is triggered **/
  79162. frame: number;
  79163. /** The event to perform when triggered **/
  79164. action: (currentFrame: number) => void;
  79165. /** Specifies if the event should be triggered only once**/
  79166. onlyOnce?: boolean | undefined;
  79167. /**
  79168. * Specifies if the animation event is done
  79169. */
  79170. isDone: boolean;
  79171. /**
  79172. * Initializes the animation event
  79173. * @param frame The frame for which the event is triggered
  79174. * @param action The event to perform when triggered
  79175. * @param onlyOnce Specifies if the event should be triggered only once
  79176. */
  79177. constructor(
  79178. /** The frame for which the event is triggered **/
  79179. frame: number,
  79180. /** The event to perform when triggered **/
  79181. action: (currentFrame: number) => void,
  79182. /** Specifies if the event should be triggered only once**/
  79183. onlyOnce?: boolean | undefined);
  79184. /** @hidden */
  79185. _clone(): AnimationEvent;
  79186. }
  79187. }
  79188. declare module BABYLON {
  79189. /**
  79190. * Interface used to define a behavior
  79191. */
  79192. export interface Behavior<T> {
  79193. /** gets or sets behavior's name */
  79194. name: string;
  79195. /**
  79196. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79197. */
  79198. init(): void;
  79199. /**
  79200. * Called when the behavior is attached to a target
  79201. * @param target defines the target where the behavior is attached to
  79202. */
  79203. attach(target: T): void;
  79204. /**
  79205. * Called when the behavior is detached from its target
  79206. */
  79207. detach(): void;
  79208. }
  79209. /**
  79210. * Interface implemented by classes supporting behaviors
  79211. */
  79212. export interface IBehaviorAware<T> {
  79213. /**
  79214. * Attach a behavior
  79215. * @param behavior defines the behavior to attach
  79216. * @returns the current host
  79217. */
  79218. addBehavior(behavior: Behavior<T>): T;
  79219. /**
  79220. * Remove a behavior from the current object
  79221. * @param behavior defines the behavior to detach
  79222. * @returns the current host
  79223. */
  79224. removeBehavior(behavior: Behavior<T>): T;
  79225. /**
  79226. * Gets a behavior using its name to search
  79227. * @param name defines the name to search
  79228. * @returns the behavior or null if not found
  79229. */
  79230. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79231. }
  79232. }
  79233. declare module BABYLON {
  79234. /**
  79235. * Defines an array and its length.
  79236. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79237. */
  79238. export interface ISmartArrayLike<T> {
  79239. /**
  79240. * The data of the array.
  79241. */
  79242. data: Array<T>;
  79243. /**
  79244. * The active length of the array.
  79245. */
  79246. length: number;
  79247. }
  79248. /**
  79249. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79250. */
  79251. export class SmartArray<T> implements ISmartArrayLike<T> {
  79252. /**
  79253. * The full set of data from the array.
  79254. */
  79255. data: Array<T>;
  79256. /**
  79257. * The active length of the array.
  79258. */
  79259. length: number;
  79260. protected _id: number;
  79261. /**
  79262. * Instantiates a Smart Array.
  79263. * @param capacity defines the default capacity of the array.
  79264. */
  79265. constructor(capacity: number);
  79266. /**
  79267. * Pushes a value at the end of the active data.
  79268. * @param value defines the object to push in the array.
  79269. */
  79270. push(value: T): void;
  79271. /**
  79272. * Iterates over the active data and apply the lambda to them.
  79273. * @param func defines the action to apply on each value.
  79274. */
  79275. forEach(func: (content: T) => void): void;
  79276. /**
  79277. * Sorts the full sets of data.
  79278. * @param compareFn defines the comparison function to apply.
  79279. */
  79280. sort(compareFn: (a: T, b: T) => number): void;
  79281. /**
  79282. * Resets the active data to an empty array.
  79283. */
  79284. reset(): void;
  79285. /**
  79286. * Releases all the data from the array as well as the array.
  79287. */
  79288. dispose(): void;
  79289. /**
  79290. * Concats the active data with a given array.
  79291. * @param array defines the data to concatenate with.
  79292. */
  79293. concat(array: any): void;
  79294. /**
  79295. * Returns the position of a value in the active data.
  79296. * @param value defines the value to find the index for
  79297. * @returns the index if found in the active data otherwise -1
  79298. */
  79299. indexOf(value: T): number;
  79300. /**
  79301. * Returns whether an element is part of the active data.
  79302. * @param value defines the value to look for
  79303. * @returns true if found in the active data otherwise false
  79304. */
  79305. contains(value: T): boolean;
  79306. private static _GlobalId;
  79307. }
  79308. /**
  79309. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79310. * The data in this array can only be present once
  79311. */
  79312. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79313. private _duplicateId;
  79314. /**
  79315. * Pushes a value at the end of the active data.
  79316. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79317. * @param value defines the object to push in the array.
  79318. */
  79319. push(value: T): void;
  79320. /**
  79321. * Pushes a value at the end of the active data.
  79322. * If the data is already present, it won t be added again
  79323. * @param value defines the object to push in the array.
  79324. * @returns true if added false if it was already present
  79325. */
  79326. pushNoDuplicate(value: T): boolean;
  79327. /**
  79328. * Resets the active data to an empty array.
  79329. */
  79330. reset(): void;
  79331. /**
  79332. * Concats the active data with a given array.
  79333. * This ensures no dupplicate will be present in the result.
  79334. * @param array defines the data to concatenate with.
  79335. */
  79336. concatWithNoDuplicate(array: any): void;
  79337. }
  79338. }
  79339. declare module BABYLON {
  79340. /**
  79341. * @ignore
  79342. * This is a list of all the different input types that are available in the application.
  79343. * Fo instance: ArcRotateCameraGamepadInput...
  79344. */
  79345. export var CameraInputTypes: {};
  79346. /**
  79347. * This is the contract to implement in order to create a new input class.
  79348. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79349. */
  79350. export interface ICameraInput<TCamera extends Camera> {
  79351. /**
  79352. * Defines the camera the input is attached to.
  79353. */
  79354. camera: Nullable<TCamera>;
  79355. /**
  79356. * Gets the class name of the current intput.
  79357. * @returns the class name
  79358. */
  79359. getClassName(): string;
  79360. /**
  79361. * Get the friendly name associated with the input class.
  79362. * @returns the input friendly name
  79363. */
  79364. getSimpleName(): string;
  79365. /**
  79366. * Attach the input controls to a specific dom element to get the input from.
  79367. * @param element Defines the element the controls should be listened from
  79368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79369. */
  79370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79371. /**
  79372. * Detach the current controls from the specified dom element.
  79373. * @param element Defines the element to stop listening the inputs from
  79374. */
  79375. detachControl(element: Nullable<HTMLElement>): void;
  79376. /**
  79377. * Update the current camera state depending on the inputs that have been used this frame.
  79378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79379. */
  79380. checkInputs?: () => void;
  79381. }
  79382. /**
  79383. * Represents a map of input types to input instance or input index to input instance.
  79384. */
  79385. export interface CameraInputsMap<TCamera extends Camera> {
  79386. /**
  79387. * Accessor to the input by input type.
  79388. */
  79389. [name: string]: ICameraInput<TCamera>;
  79390. /**
  79391. * Accessor to the input by input index.
  79392. */
  79393. [idx: number]: ICameraInput<TCamera>;
  79394. }
  79395. /**
  79396. * This represents the input manager used within a camera.
  79397. * It helps dealing with all the different kind of input attached to a camera.
  79398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79399. */
  79400. export class CameraInputsManager<TCamera extends Camera> {
  79401. /**
  79402. * Defines the list of inputs attahed to the camera.
  79403. */
  79404. attached: CameraInputsMap<TCamera>;
  79405. /**
  79406. * Defines the dom element the camera is collecting inputs from.
  79407. * This is null if the controls have not been attached.
  79408. */
  79409. attachedElement: Nullable<HTMLElement>;
  79410. /**
  79411. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79412. */
  79413. noPreventDefault: boolean;
  79414. /**
  79415. * Defined the camera the input manager belongs to.
  79416. */
  79417. camera: TCamera;
  79418. /**
  79419. * Update the current camera state depending on the inputs that have been used this frame.
  79420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79421. */
  79422. checkInputs: () => void;
  79423. /**
  79424. * Instantiate a new Camera Input Manager.
  79425. * @param camera Defines the camera the input manager blongs to
  79426. */
  79427. constructor(camera: TCamera);
  79428. /**
  79429. * Add an input method to a camera
  79430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79431. * @param input camera input method
  79432. */
  79433. add(input: ICameraInput<TCamera>): void;
  79434. /**
  79435. * Remove a specific input method from a camera
  79436. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79437. * @param inputToRemove camera input method
  79438. */
  79439. remove(inputToRemove: ICameraInput<TCamera>): void;
  79440. /**
  79441. * Remove a specific input type from a camera
  79442. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79443. * @param inputType the type of the input to remove
  79444. */
  79445. removeByType(inputType: string): void;
  79446. private _addCheckInputs;
  79447. /**
  79448. * Attach the input controls to the currently attached dom element to listen the events from.
  79449. * @param input Defines the input to attach
  79450. */
  79451. attachInput(input: ICameraInput<TCamera>): void;
  79452. /**
  79453. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79454. * @param element Defines the dom element to collect the events from
  79455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79456. */
  79457. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79458. /**
  79459. * Detach the current manager inputs controls from a specific dom element.
  79460. * @param element Defines the dom element to collect the events from
  79461. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79462. */
  79463. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79464. /**
  79465. * Rebuild the dynamic inputCheck function from the current list of
  79466. * defined inputs in the manager.
  79467. */
  79468. rebuildInputCheck(): void;
  79469. /**
  79470. * Remove all attached input methods from a camera
  79471. */
  79472. clear(): void;
  79473. /**
  79474. * Serialize the current input manager attached to a camera.
  79475. * This ensures than once parsed,
  79476. * the input associated to the camera will be identical to the current ones
  79477. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79478. */
  79479. serialize(serializedCamera: any): void;
  79480. /**
  79481. * Parses an input manager serialized JSON to restore the previous list of inputs
  79482. * and states associated to a camera.
  79483. * @param parsedCamera Defines the JSON to parse
  79484. */
  79485. parse(parsedCamera: any): void;
  79486. }
  79487. }
  79488. declare module BABYLON {
  79489. /**
  79490. * Class used to store data that will be store in GPU memory
  79491. */
  79492. export class Buffer {
  79493. private _engine;
  79494. private _buffer;
  79495. /** @hidden */
  79496. _data: Nullable<DataArray>;
  79497. private _updatable;
  79498. private _instanced;
  79499. private _divisor;
  79500. /**
  79501. * Gets the byte stride.
  79502. */
  79503. readonly byteStride: number;
  79504. /**
  79505. * Constructor
  79506. * @param engine the engine
  79507. * @param data the data to use for this buffer
  79508. * @param updatable whether the data is updatable
  79509. * @param stride the stride (optional)
  79510. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79511. * @param instanced whether the buffer is instanced (optional)
  79512. * @param useBytes set to true if the stride in in bytes (optional)
  79513. * @param divisor sets an optional divisor for instances (1 by default)
  79514. */
  79515. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79516. /**
  79517. * Create a new VertexBuffer based on the current buffer
  79518. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79519. * @param offset defines offset in the buffer (0 by default)
  79520. * @param size defines the size in floats of attributes (position is 3 for instance)
  79521. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79522. * @param instanced defines if the vertex buffer contains indexed data
  79523. * @param useBytes defines if the offset and stride are in bytes *
  79524. * @param divisor sets an optional divisor for instances (1 by default)
  79525. * @returns the new vertex buffer
  79526. */
  79527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79528. /**
  79529. * Gets a boolean indicating if the Buffer is updatable?
  79530. * @returns true if the buffer is updatable
  79531. */
  79532. isUpdatable(): boolean;
  79533. /**
  79534. * Gets current buffer's data
  79535. * @returns a DataArray or null
  79536. */
  79537. getData(): Nullable<DataArray>;
  79538. /**
  79539. * Gets underlying native buffer
  79540. * @returns underlying native buffer
  79541. */
  79542. getBuffer(): Nullable<DataBuffer>;
  79543. /**
  79544. * Gets the stride in float32 units (i.e. byte stride / 4).
  79545. * May not be an integer if the byte stride is not divisible by 4.
  79546. * @returns the stride in float32 units
  79547. * @deprecated Please use byteStride instead.
  79548. */
  79549. getStrideSize(): number;
  79550. /**
  79551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79552. * @param data defines the data to store
  79553. */
  79554. create(data?: Nullable<DataArray>): void;
  79555. /** @hidden */
  79556. _rebuild(): void;
  79557. /**
  79558. * Update current buffer data
  79559. * @param data defines the data to store
  79560. */
  79561. update(data: DataArray): void;
  79562. /**
  79563. * Updates the data directly.
  79564. * @param data the new data
  79565. * @param offset the new offset
  79566. * @param vertexCount the vertex count (optional)
  79567. * @param useBytes set to true if the offset is in bytes
  79568. */
  79569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79570. /**
  79571. * Release all resources
  79572. */
  79573. dispose(): void;
  79574. }
  79575. /**
  79576. * Specialized buffer used to store vertex data
  79577. */
  79578. export class VertexBuffer {
  79579. /** @hidden */
  79580. _buffer: Buffer;
  79581. private _kind;
  79582. private _size;
  79583. private _ownsBuffer;
  79584. private _instanced;
  79585. private _instanceDivisor;
  79586. /**
  79587. * The byte type.
  79588. */
  79589. static readonly BYTE: number;
  79590. /**
  79591. * The unsigned byte type.
  79592. */
  79593. static readonly UNSIGNED_BYTE: number;
  79594. /**
  79595. * The short type.
  79596. */
  79597. static readonly SHORT: number;
  79598. /**
  79599. * The unsigned short type.
  79600. */
  79601. static readonly UNSIGNED_SHORT: number;
  79602. /**
  79603. * The integer type.
  79604. */
  79605. static readonly INT: number;
  79606. /**
  79607. * The unsigned integer type.
  79608. */
  79609. static readonly UNSIGNED_INT: number;
  79610. /**
  79611. * The float type.
  79612. */
  79613. static readonly FLOAT: number;
  79614. /**
  79615. * Gets or sets the instance divisor when in instanced mode
  79616. */
  79617. get instanceDivisor(): number;
  79618. set instanceDivisor(value: number);
  79619. /**
  79620. * Gets the byte stride.
  79621. */
  79622. readonly byteStride: number;
  79623. /**
  79624. * Gets the byte offset.
  79625. */
  79626. readonly byteOffset: number;
  79627. /**
  79628. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79629. */
  79630. readonly normalized: boolean;
  79631. /**
  79632. * Gets the data type of each component in the array.
  79633. */
  79634. readonly type: number;
  79635. /**
  79636. * Constructor
  79637. * @param engine the engine
  79638. * @param data the data to use for this vertex buffer
  79639. * @param kind the vertex buffer kind
  79640. * @param updatable whether the data is updatable
  79641. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79642. * @param stride the stride (optional)
  79643. * @param instanced whether the buffer is instanced (optional)
  79644. * @param offset the offset of the data (optional)
  79645. * @param size the number of components (optional)
  79646. * @param type the type of the component (optional)
  79647. * @param normalized whether the data contains normalized data (optional)
  79648. * @param useBytes set to true if stride and offset are in bytes (optional)
  79649. * @param divisor defines the instance divisor to use (1 by default)
  79650. */
  79651. 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);
  79652. /** @hidden */
  79653. _rebuild(): void;
  79654. /**
  79655. * Returns the kind of the VertexBuffer (string)
  79656. * @returns a string
  79657. */
  79658. getKind(): string;
  79659. /**
  79660. * Gets a boolean indicating if the VertexBuffer is updatable?
  79661. * @returns true if the buffer is updatable
  79662. */
  79663. isUpdatable(): boolean;
  79664. /**
  79665. * Gets current buffer's data
  79666. * @returns a DataArray or null
  79667. */
  79668. getData(): Nullable<DataArray>;
  79669. /**
  79670. * Gets underlying native buffer
  79671. * @returns underlying native buffer
  79672. */
  79673. getBuffer(): Nullable<DataBuffer>;
  79674. /**
  79675. * Gets the stride in float32 units (i.e. byte stride / 4).
  79676. * May not be an integer if the byte stride is not divisible by 4.
  79677. * @returns the stride in float32 units
  79678. * @deprecated Please use byteStride instead.
  79679. */
  79680. getStrideSize(): number;
  79681. /**
  79682. * Returns the offset as a multiple of the type byte length.
  79683. * @returns the offset in bytes
  79684. * @deprecated Please use byteOffset instead.
  79685. */
  79686. getOffset(): number;
  79687. /**
  79688. * Returns the number of components per vertex attribute (integer)
  79689. * @returns the size in float
  79690. */
  79691. getSize(): number;
  79692. /**
  79693. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79694. * @returns true if this buffer is instanced
  79695. */
  79696. getIsInstanced(): boolean;
  79697. /**
  79698. * Returns the instancing divisor, zero for non-instanced (integer).
  79699. * @returns a number
  79700. */
  79701. getInstanceDivisor(): number;
  79702. /**
  79703. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79704. * @param data defines the data to store
  79705. */
  79706. create(data?: DataArray): void;
  79707. /**
  79708. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79709. * This function will create a new buffer if the current one is not updatable
  79710. * @param data defines the data to store
  79711. */
  79712. update(data: DataArray): void;
  79713. /**
  79714. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79715. * Returns the directly updated WebGLBuffer.
  79716. * @param data the new data
  79717. * @param offset the new offset
  79718. * @param useBytes set to true if the offset is in bytes
  79719. */
  79720. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79721. /**
  79722. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79723. */
  79724. dispose(): void;
  79725. /**
  79726. * Enumerates each value of this vertex buffer as numbers.
  79727. * @param count the number of values to enumerate
  79728. * @param callback the callback function called for each value
  79729. */
  79730. forEach(count: number, callback: (value: number, index: number) => void): void;
  79731. /**
  79732. * Positions
  79733. */
  79734. static readonly PositionKind: string;
  79735. /**
  79736. * Normals
  79737. */
  79738. static readonly NormalKind: string;
  79739. /**
  79740. * Tangents
  79741. */
  79742. static readonly TangentKind: string;
  79743. /**
  79744. * Texture coordinates
  79745. */
  79746. static readonly UVKind: string;
  79747. /**
  79748. * Texture coordinates 2
  79749. */
  79750. static readonly UV2Kind: string;
  79751. /**
  79752. * Texture coordinates 3
  79753. */
  79754. static readonly UV3Kind: string;
  79755. /**
  79756. * Texture coordinates 4
  79757. */
  79758. static readonly UV4Kind: string;
  79759. /**
  79760. * Texture coordinates 5
  79761. */
  79762. static readonly UV5Kind: string;
  79763. /**
  79764. * Texture coordinates 6
  79765. */
  79766. static readonly UV6Kind: string;
  79767. /**
  79768. * Colors
  79769. */
  79770. static readonly ColorKind: string;
  79771. /**
  79772. * Matrix indices (for bones)
  79773. */
  79774. static readonly MatricesIndicesKind: string;
  79775. /**
  79776. * Matrix weights (for bones)
  79777. */
  79778. static readonly MatricesWeightsKind: string;
  79779. /**
  79780. * Additional matrix indices (for bones)
  79781. */
  79782. static readonly MatricesIndicesExtraKind: string;
  79783. /**
  79784. * Additional matrix weights (for bones)
  79785. */
  79786. static readonly MatricesWeightsExtraKind: string;
  79787. /**
  79788. * Deduces the stride given a kind.
  79789. * @param kind The kind string to deduce
  79790. * @returns The deduced stride
  79791. */
  79792. static DeduceStride(kind: string): number;
  79793. /**
  79794. * Gets the byte length of the given type.
  79795. * @param type the type
  79796. * @returns the number of bytes
  79797. */
  79798. static GetTypeByteLength(type: number): number;
  79799. /**
  79800. * Enumerates each value of the given parameters as numbers.
  79801. * @param data the data to enumerate
  79802. * @param byteOffset the byte offset of the data
  79803. * @param byteStride the byte stride of the data
  79804. * @param componentCount the number of components per element
  79805. * @param componentType the type of the component
  79806. * @param count the number of values to enumerate
  79807. * @param normalized whether the data is normalized
  79808. * @param callback the callback function called for each value
  79809. */
  79810. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79811. private static _GetFloatValue;
  79812. }
  79813. }
  79814. declare module BABYLON {
  79815. /**
  79816. * @hidden
  79817. */
  79818. export class IntersectionInfo {
  79819. bu: Nullable<number>;
  79820. bv: Nullable<number>;
  79821. distance: number;
  79822. faceId: number;
  79823. subMeshId: number;
  79824. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79825. }
  79826. }
  79827. declare module BABYLON {
  79828. /**
  79829. * Represens a plane by the equation ax + by + cz + d = 0
  79830. */
  79831. export class Plane {
  79832. private static _TmpMatrix;
  79833. /**
  79834. * Normal of the plane (a,b,c)
  79835. */
  79836. normal: Vector3;
  79837. /**
  79838. * d component of the plane
  79839. */
  79840. d: number;
  79841. /**
  79842. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79843. * @param a a component of the plane
  79844. * @param b b component of the plane
  79845. * @param c c component of the plane
  79846. * @param d d component of the plane
  79847. */
  79848. constructor(a: number, b: number, c: number, d: number);
  79849. /**
  79850. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79851. */
  79852. asArray(): number[];
  79853. /**
  79854. * @returns a new plane copied from the current Plane.
  79855. */
  79856. clone(): Plane;
  79857. /**
  79858. * @returns the string "Plane".
  79859. */
  79860. getClassName(): string;
  79861. /**
  79862. * @returns the Plane hash code.
  79863. */
  79864. getHashCode(): number;
  79865. /**
  79866. * Normalize the current Plane in place.
  79867. * @returns the updated Plane.
  79868. */
  79869. normalize(): Plane;
  79870. /**
  79871. * Applies a transformation the plane and returns the result
  79872. * @param transformation the transformation matrix to be applied to the plane
  79873. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79874. */
  79875. transform(transformation: DeepImmutable<Matrix>): Plane;
  79876. /**
  79877. * Calcualtte the dot product between the point and the plane normal
  79878. * @param point point to calculate the dot product with
  79879. * @returns the dot product (float) of the point coordinates and the plane normal.
  79880. */
  79881. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79882. /**
  79883. * Updates the current Plane from the plane defined by the three given points.
  79884. * @param point1 one of the points used to contruct the plane
  79885. * @param point2 one of the points used to contruct the plane
  79886. * @param point3 one of the points used to contruct the plane
  79887. * @returns the updated Plane.
  79888. */
  79889. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79890. /**
  79891. * Checks if the plane is facing a given direction
  79892. * @param direction the direction to check if the plane is facing
  79893. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79894. * @returns True is the vector "direction" is the same side than the plane normal.
  79895. */
  79896. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79897. /**
  79898. * Calculates the distance to a point
  79899. * @param point point to calculate distance to
  79900. * @returns the signed distance (float) from the given point to the Plane.
  79901. */
  79902. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79903. /**
  79904. * Creates a plane from an array
  79905. * @param array the array to create a plane from
  79906. * @returns a new Plane from the given array.
  79907. */
  79908. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79909. /**
  79910. * Creates a plane from three points
  79911. * @param point1 point used to create the plane
  79912. * @param point2 point used to create the plane
  79913. * @param point3 point used to create the plane
  79914. * @returns a new Plane defined by the three given points.
  79915. */
  79916. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79917. /**
  79918. * Creates a plane from an origin point and a normal
  79919. * @param origin origin of the plane to be constructed
  79920. * @param normal normal of the plane to be constructed
  79921. * @returns a new Plane the normal vector to this plane at the given origin point.
  79922. * Note : the vector "normal" is updated because normalized.
  79923. */
  79924. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79925. /**
  79926. * Calculates the distance from a plane and a point
  79927. * @param origin origin of the plane to be constructed
  79928. * @param normal normal of the plane to be constructed
  79929. * @param point point to calculate distance to
  79930. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79931. */
  79932. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79933. }
  79934. }
  79935. declare module BABYLON {
  79936. /**
  79937. * Class used to store bounding sphere information
  79938. */
  79939. export class BoundingSphere {
  79940. /**
  79941. * Gets the center of the bounding sphere in local space
  79942. */
  79943. readonly center: Vector3;
  79944. /**
  79945. * Radius of the bounding sphere in local space
  79946. */
  79947. radius: number;
  79948. /**
  79949. * Gets the center of the bounding sphere in world space
  79950. */
  79951. readonly centerWorld: Vector3;
  79952. /**
  79953. * Radius of the bounding sphere in world space
  79954. */
  79955. radiusWorld: number;
  79956. /**
  79957. * Gets the minimum vector in local space
  79958. */
  79959. readonly minimum: Vector3;
  79960. /**
  79961. * Gets the maximum vector in local space
  79962. */
  79963. readonly maximum: Vector3;
  79964. private _worldMatrix;
  79965. private static readonly TmpVector3;
  79966. /**
  79967. * Creates a new bounding sphere
  79968. * @param min defines the minimum vector (in local space)
  79969. * @param max defines the maximum vector (in local space)
  79970. * @param worldMatrix defines the new world matrix
  79971. */
  79972. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79973. /**
  79974. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79975. * @param min defines the new minimum vector (in local space)
  79976. * @param max defines the new maximum vector (in local space)
  79977. * @param worldMatrix defines the new world matrix
  79978. */
  79979. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79980. /**
  79981. * Scale the current bounding sphere by applying a scale factor
  79982. * @param factor defines the scale factor to apply
  79983. * @returns the current bounding box
  79984. */
  79985. scale(factor: number): BoundingSphere;
  79986. /**
  79987. * Gets the world matrix of the bounding box
  79988. * @returns a matrix
  79989. */
  79990. getWorldMatrix(): DeepImmutable<Matrix>;
  79991. /** @hidden */
  79992. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79993. /**
  79994. * Tests if the bounding sphere is intersecting the frustum planes
  79995. * @param frustumPlanes defines the frustum planes to test
  79996. * @returns true if there is an intersection
  79997. */
  79998. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79999. /**
  80000. * Tests if the bounding sphere center is in between the frustum planes.
  80001. * Used for optimistic fast inclusion.
  80002. * @param frustumPlanes defines the frustum planes to test
  80003. * @returns true if the sphere center is in between the frustum planes
  80004. */
  80005. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80006. /**
  80007. * Tests if a point is inside the bounding sphere
  80008. * @param point defines the point to test
  80009. * @returns true if the point is inside the bounding sphere
  80010. */
  80011. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80012. /**
  80013. * Checks if two sphere intersct
  80014. * @param sphere0 sphere 0
  80015. * @param sphere1 sphere 1
  80016. * @returns true if the speres intersect
  80017. */
  80018. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80019. }
  80020. }
  80021. declare module BABYLON {
  80022. /**
  80023. * Class used to store bounding box information
  80024. */
  80025. export class BoundingBox implements ICullable {
  80026. /**
  80027. * Gets the 8 vectors representing the bounding box in local space
  80028. */
  80029. readonly vectors: Vector3[];
  80030. /**
  80031. * Gets the center of the bounding box in local space
  80032. */
  80033. readonly center: Vector3;
  80034. /**
  80035. * Gets the center of the bounding box in world space
  80036. */
  80037. readonly centerWorld: Vector3;
  80038. /**
  80039. * Gets the extend size in local space
  80040. */
  80041. readonly extendSize: Vector3;
  80042. /**
  80043. * Gets the extend size in world space
  80044. */
  80045. readonly extendSizeWorld: Vector3;
  80046. /**
  80047. * Gets the OBB (object bounding box) directions
  80048. */
  80049. readonly directions: Vector3[];
  80050. /**
  80051. * Gets the 8 vectors representing the bounding box in world space
  80052. */
  80053. readonly vectorsWorld: Vector3[];
  80054. /**
  80055. * Gets the minimum vector in world space
  80056. */
  80057. readonly minimumWorld: Vector3;
  80058. /**
  80059. * Gets the maximum vector in world space
  80060. */
  80061. readonly maximumWorld: Vector3;
  80062. /**
  80063. * Gets the minimum vector in local space
  80064. */
  80065. readonly minimum: Vector3;
  80066. /**
  80067. * Gets the maximum vector in local space
  80068. */
  80069. readonly maximum: Vector3;
  80070. private _worldMatrix;
  80071. private static readonly TmpVector3;
  80072. /**
  80073. * @hidden
  80074. */
  80075. _tag: number;
  80076. /**
  80077. * Creates a new bounding box
  80078. * @param min defines the minimum vector (in local space)
  80079. * @param max defines the maximum vector (in local space)
  80080. * @param worldMatrix defines the new world matrix
  80081. */
  80082. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80083. /**
  80084. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80085. * @param min defines the new minimum vector (in local space)
  80086. * @param max defines the new maximum vector (in local space)
  80087. * @param worldMatrix defines the new world matrix
  80088. */
  80089. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80090. /**
  80091. * Scale the current bounding box by applying a scale factor
  80092. * @param factor defines the scale factor to apply
  80093. * @returns the current bounding box
  80094. */
  80095. scale(factor: number): BoundingBox;
  80096. /**
  80097. * Gets the world matrix of the bounding box
  80098. * @returns a matrix
  80099. */
  80100. getWorldMatrix(): DeepImmutable<Matrix>;
  80101. /** @hidden */
  80102. _update(world: DeepImmutable<Matrix>): void;
  80103. /**
  80104. * Tests if the bounding box is intersecting the frustum planes
  80105. * @param frustumPlanes defines the frustum planes to test
  80106. * @returns true if there is an intersection
  80107. */
  80108. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80109. /**
  80110. * Tests if the bounding box is entirely inside the frustum planes
  80111. * @param frustumPlanes defines the frustum planes to test
  80112. * @returns true if there is an inclusion
  80113. */
  80114. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80115. /**
  80116. * Tests if a point is inside the bounding box
  80117. * @param point defines the point to test
  80118. * @returns true if the point is inside the bounding box
  80119. */
  80120. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80121. /**
  80122. * Tests if the bounding box intersects with a bounding sphere
  80123. * @param sphere defines the sphere to test
  80124. * @returns true if there is an intersection
  80125. */
  80126. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80127. /**
  80128. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80129. * @param min defines the min vector to use
  80130. * @param max defines the max vector to use
  80131. * @returns true if there is an intersection
  80132. */
  80133. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80134. /**
  80135. * Tests if two bounding boxes are intersections
  80136. * @param box0 defines the first box to test
  80137. * @param box1 defines the second box to test
  80138. * @returns true if there is an intersection
  80139. */
  80140. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80141. /**
  80142. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80143. * @param minPoint defines the minimum vector of the bounding box
  80144. * @param maxPoint defines the maximum vector of the bounding box
  80145. * @param sphereCenter defines the sphere center
  80146. * @param sphereRadius defines the sphere radius
  80147. * @returns true if there is an intersection
  80148. */
  80149. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80150. /**
  80151. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80152. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80153. * @param frustumPlanes defines the frustum planes to test
  80154. * @return true if there is an inclusion
  80155. */
  80156. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80157. /**
  80158. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80159. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80160. * @param frustumPlanes defines the frustum planes to test
  80161. * @return true if there is an intersection
  80162. */
  80163. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80164. }
  80165. }
  80166. declare module BABYLON {
  80167. /** @hidden */
  80168. export class Collider {
  80169. /** Define if a collision was found */
  80170. collisionFound: boolean;
  80171. /**
  80172. * Define last intersection point in local space
  80173. */
  80174. intersectionPoint: Vector3;
  80175. /**
  80176. * Define last collided mesh
  80177. */
  80178. collidedMesh: Nullable<AbstractMesh>;
  80179. private _collisionPoint;
  80180. private _planeIntersectionPoint;
  80181. private _tempVector;
  80182. private _tempVector2;
  80183. private _tempVector3;
  80184. private _tempVector4;
  80185. private _edge;
  80186. private _baseToVertex;
  80187. private _destinationPoint;
  80188. private _slidePlaneNormal;
  80189. private _displacementVector;
  80190. /** @hidden */
  80191. _radius: Vector3;
  80192. /** @hidden */
  80193. _retry: number;
  80194. private _velocity;
  80195. private _basePoint;
  80196. private _epsilon;
  80197. /** @hidden */
  80198. _velocityWorldLength: number;
  80199. /** @hidden */
  80200. _basePointWorld: Vector3;
  80201. private _velocityWorld;
  80202. private _normalizedVelocity;
  80203. /** @hidden */
  80204. _initialVelocity: Vector3;
  80205. /** @hidden */
  80206. _initialPosition: Vector3;
  80207. private _nearestDistance;
  80208. private _collisionMask;
  80209. get collisionMask(): number;
  80210. set collisionMask(mask: number);
  80211. /**
  80212. * Gets the plane normal used to compute the sliding response (in local space)
  80213. */
  80214. get slidePlaneNormal(): Vector3;
  80215. /** @hidden */
  80216. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80217. /** @hidden */
  80218. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80219. /** @hidden */
  80220. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80221. /** @hidden */
  80222. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80223. /** @hidden */
  80224. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80225. /** @hidden */
  80226. _getResponse(pos: Vector3, vel: Vector3): void;
  80227. }
  80228. }
  80229. declare module BABYLON {
  80230. /**
  80231. * Interface for cullable objects
  80232. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80233. */
  80234. export interface ICullable {
  80235. /**
  80236. * Checks if the object or part of the object is in the frustum
  80237. * @param frustumPlanes Camera near/planes
  80238. * @returns true if the object is in frustum otherwise false
  80239. */
  80240. isInFrustum(frustumPlanes: Plane[]): boolean;
  80241. /**
  80242. * Checks if a cullable object (mesh...) is in the camera frustum
  80243. * Unlike isInFrustum this cheks the full bounding box
  80244. * @param frustumPlanes Camera near/planes
  80245. * @returns true if the object is in frustum otherwise false
  80246. */
  80247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80248. }
  80249. /**
  80250. * Info for a bounding data of a mesh
  80251. */
  80252. export class BoundingInfo implements ICullable {
  80253. /**
  80254. * Bounding box for the mesh
  80255. */
  80256. readonly boundingBox: BoundingBox;
  80257. /**
  80258. * Bounding sphere for the mesh
  80259. */
  80260. readonly boundingSphere: BoundingSphere;
  80261. private _isLocked;
  80262. private static readonly TmpVector3;
  80263. /**
  80264. * Constructs bounding info
  80265. * @param minimum min vector of the bounding box/sphere
  80266. * @param maximum max vector of the bounding box/sphere
  80267. * @param worldMatrix defines the new world matrix
  80268. */
  80269. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80270. /**
  80271. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80272. * @param min defines the new minimum vector (in local space)
  80273. * @param max defines the new maximum vector (in local space)
  80274. * @param worldMatrix defines the new world matrix
  80275. */
  80276. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80277. /**
  80278. * min vector of the bounding box/sphere
  80279. */
  80280. get minimum(): Vector3;
  80281. /**
  80282. * max vector of the bounding box/sphere
  80283. */
  80284. get maximum(): Vector3;
  80285. /**
  80286. * If the info is locked and won't be updated to avoid perf overhead
  80287. */
  80288. get isLocked(): boolean;
  80289. set isLocked(value: boolean);
  80290. /**
  80291. * Updates the bounding sphere and box
  80292. * @param world world matrix to be used to update
  80293. */
  80294. update(world: DeepImmutable<Matrix>): void;
  80295. /**
  80296. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80297. * @param center New center of the bounding info
  80298. * @param extend New extend of the bounding info
  80299. * @returns the current bounding info
  80300. */
  80301. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80302. /**
  80303. * Scale the current bounding info by applying a scale factor
  80304. * @param factor defines the scale factor to apply
  80305. * @returns the current bounding info
  80306. */
  80307. scale(factor: number): BoundingInfo;
  80308. /**
  80309. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80310. * @param frustumPlanes defines the frustum to test
  80311. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80312. * @returns true if the bounding info is in the frustum planes
  80313. */
  80314. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80315. /**
  80316. * Gets the world distance between the min and max points of the bounding box
  80317. */
  80318. get diagonalLength(): number;
  80319. /**
  80320. * Checks if a cullable object (mesh...) is in the camera frustum
  80321. * Unlike isInFrustum this cheks the full bounding box
  80322. * @param frustumPlanes Camera near/planes
  80323. * @returns true if the object is in frustum otherwise false
  80324. */
  80325. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80326. /** @hidden */
  80327. _checkCollision(collider: Collider): boolean;
  80328. /**
  80329. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80330. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80331. * @param point the point to check intersection with
  80332. * @returns if the point intersects
  80333. */
  80334. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80335. /**
  80336. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80337. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80338. * @param boundingInfo the bounding info to check intersection with
  80339. * @param precise if the intersection should be done using OBB
  80340. * @returns if the bounding info intersects
  80341. */
  80342. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80343. }
  80344. }
  80345. declare module BABYLON {
  80346. /**
  80347. * Extracts minimum and maximum values from a list of indexed positions
  80348. * @param positions defines the positions to use
  80349. * @param indices defines the indices to the positions
  80350. * @param indexStart defines the start index
  80351. * @param indexCount defines the end index
  80352. * @param bias defines bias value to add to the result
  80353. * @return minimum and maximum values
  80354. */
  80355. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80356. minimum: Vector3;
  80357. maximum: Vector3;
  80358. };
  80359. /**
  80360. * Extracts minimum and maximum values from a list of positions
  80361. * @param positions defines the positions to use
  80362. * @param start defines the start index in the positions array
  80363. * @param count defines the number of positions to handle
  80364. * @param bias defines bias value to add to the result
  80365. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80366. * @return minimum and maximum values
  80367. */
  80368. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80369. minimum: Vector3;
  80370. maximum: Vector3;
  80371. };
  80372. }
  80373. declare module BABYLON {
  80374. /** @hidden */
  80375. export class WebGLDataBuffer extends DataBuffer {
  80376. private _buffer;
  80377. constructor(resource: WebGLBuffer);
  80378. get underlyingResource(): any;
  80379. }
  80380. }
  80381. declare module BABYLON {
  80382. /** @hidden */
  80383. export class WebGLPipelineContext implements IPipelineContext {
  80384. engine: ThinEngine;
  80385. program: Nullable<WebGLProgram>;
  80386. context?: WebGLRenderingContext;
  80387. vertexShader?: WebGLShader;
  80388. fragmentShader?: WebGLShader;
  80389. isParallelCompiled: boolean;
  80390. onCompiled?: () => void;
  80391. transformFeedback?: WebGLTransformFeedback | null;
  80392. vertexCompilationError: Nullable<string>;
  80393. fragmentCompilationError: Nullable<string>;
  80394. programLinkError: Nullable<string>;
  80395. programValidationError: Nullable<string>;
  80396. get isAsync(): boolean;
  80397. get isReady(): boolean;
  80398. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80399. }
  80400. }
  80401. declare module BABYLON {
  80402. interface ThinEngine {
  80403. /**
  80404. * Create an uniform buffer
  80405. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80406. * @param elements defines the content of the uniform buffer
  80407. * @returns the webGL uniform buffer
  80408. */
  80409. createUniformBuffer(elements: FloatArray): DataBuffer;
  80410. /**
  80411. * Create a dynamic uniform buffer
  80412. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80413. * @param elements defines the content of the uniform buffer
  80414. * @returns the webGL uniform buffer
  80415. */
  80416. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80417. /**
  80418. * Update an existing uniform buffer
  80419. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80420. * @param uniformBuffer defines the target uniform buffer
  80421. * @param elements defines the content to update
  80422. * @param offset defines the offset in the uniform buffer where update should start
  80423. * @param count defines the size of the data to update
  80424. */
  80425. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80426. /**
  80427. * Bind an uniform buffer to the current webGL context
  80428. * @param buffer defines the buffer to bind
  80429. */
  80430. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80431. /**
  80432. * Bind a buffer to the current webGL context at a given location
  80433. * @param buffer defines the buffer to bind
  80434. * @param location defines the index where to bind the buffer
  80435. */
  80436. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80437. /**
  80438. * Bind a specific block at a given index in a specific shader program
  80439. * @param pipelineContext defines the pipeline context to use
  80440. * @param blockName defines the block name
  80441. * @param index defines the index where to bind the block
  80442. */
  80443. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80444. }
  80445. }
  80446. declare module BABYLON {
  80447. /**
  80448. * Uniform buffer objects.
  80449. *
  80450. * Handles blocks of uniform on the GPU.
  80451. *
  80452. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80453. *
  80454. * For more information, please refer to :
  80455. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80456. */
  80457. export class UniformBuffer {
  80458. private _engine;
  80459. private _buffer;
  80460. private _data;
  80461. private _bufferData;
  80462. private _dynamic?;
  80463. private _uniformLocations;
  80464. private _uniformSizes;
  80465. private _uniformLocationPointer;
  80466. private _needSync;
  80467. private _noUBO;
  80468. private _currentEffect;
  80469. /** @hidden */
  80470. _alreadyBound: boolean;
  80471. private static _MAX_UNIFORM_SIZE;
  80472. private static _tempBuffer;
  80473. /**
  80474. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80475. * This is dynamic to allow compat with webgl 1 and 2.
  80476. * You will need to pass the name of the uniform as well as the value.
  80477. */
  80478. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80479. /**
  80480. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80481. * This is dynamic to allow compat with webgl 1 and 2.
  80482. * You will need to pass the name of the uniform as well as the value.
  80483. */
  80484. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80485. /**
  80486. * Lambda to Update a single float in a uniform buffer.
  80487. * This is dynamic to allow compat with webgl 1 and 2.
  80488. * You will need to pass the name of the uniform as well as the value.
  80489. */
  80490. updateFloat: (name: string, x: number) => void;
  80491. /**
  80492. * Lambda to Update a vec2 of float in a uniform buffer.
  80493. * This is dynamic to allow compat with webgl 1 and 2.
  80494. * You will need to pass the name of the uniform as well as the value.
  80495. */
  80496. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80497. /**
  80498. * Lambda to Update a vec3 of float in a uniform buffer.
  80499. * This is dynamic to allow compat with webgl 1 and 2.
  80500. * You will need to pass the name of the uniform as well as the value.
  80501. */
  80502. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80503. /**
  80504. * Lambda to Update a vec4 of float in a uniform buffer.
  80505. * This is dynamic to allow compat with webgl 1 and 2.
  80506. * You will need to pass the name of the uniform as well as the value.
  80507. */
  80508. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80509. /**
  80510. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80511. * This is dynamic to allow compat with webgl 1 and 2.
  80512. * You will need to pass the name of the uniform as well as the value.
  80513. */
  80514. updateMatrix: (name: string, mat: Matrix) => void;
  80515. /**
  80516. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80517. * This is dynamic to allow compat with webgl 1 and 2.
  80518. * You will need to pass the name of the uniform as well as the value.
  80519. */
  80520. updateVector3: (name: string, vector: Vector3) => void;
  80521. /**
  80522. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80523. * This is dynamic to allow compat with webgl 1 and 2.
  80524. * You will need to pass the name of the uniform as well as the value.
  80525. */
  80526. updateVector4: (name: string, vector: Vector4) => void;
  80527. /**
  80528. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80529. * This is dynamic to allow compat with webgl 1 and 2.
  80530. * You will need to pass the name of the uniform as well as the value.
  80531. */
  80532. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80533. /**
  80534. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80535. * This is dynamic to allow compat with webgl 1 and 2.
  80536. * You will need to pass the name of the uniform as well as the value.
  80537. */
  80538. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80539. /**
  80540. * Instantiates a new Uniform buffer objects.
  80541. *
  80542. * Handles blocks of uniform on the GPU.
  80543. *
  80544. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80545. *
  80546. * For more information, please refer to :
  80547. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80548. * @param engine Define the engine the buffer is associated with
  80549. * @param data Define the data contained in the buffer
  80550. * @param dynamic Define if the buffer is updatable
  80551. */
  80552. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80553. /**
  80554. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80555. * or just falling back on setUniformXXX calls.
  80556. */
  80557. get useUbo(): boolean;
  80558. /**
  80559. * Indicates if the WebGL underlying uniform buffer is in sync
  80560. * with the javascript cache data.
  80561. */
  80562. get isSync(): boolean;
  80563. /**
  80564. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80565. * Also, a dynamic UniformBuffer will disable cache verification and always
  80566. * update the underlying WebGL uniform buffer to the GPU.
  80567. * @returns if Dynamic, otherwise false
  80568. */
  80569. isDynamic(): boolean;
  80570. /**
  80571. * The data cache on JS side.
  80572. * @returns the underlying data as a float array
  80573. */
  80574. getData(): Float32Array;
  80575. /**
  80576. * The underlying WebGL Uniform buffer.
  80577. * @returns the webgl buffer
  80578. */
  80579. getBuffer(): Nullable<DataBuffer>;
  80580. /**
  80581. * std140 layout specifies how to align data within an UBO structure.
  80582. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80583. * for specs.
  80584. */
  80585. private _fillAlignment;
  80586. /**
  80587. * Adds an uniform in the buffer.
  80588. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80589. * for the layout to be correct !
  80590. * @param name Name of the uniform, as used in the uniform block in the shader.
  80591. * @param size Data size, or data directly.
  80592. */
  80593. addUniform(name: string, size: number | number[]): void;
  80594. /**
  80595. * Adds a Matrix 4x4 to the uniform buffer.
  80596. * @param name Name of the uniform, as used in the uniform block in the shader.
  80597. * @param mat A 4x4 matrix.
  80598. */
  80599. addMatrix(name: string, mat: Matrix): void;
  80600. /**
  80601. * Adds a vec2 to the uniform buffer.
  80602. * @param name Name of the uniform, as used in the uniform block in the shader.
  80603. * @param x Define the x component value of the vec2
  80604. * @param y Define the y component value of the vec2
  80605. */
  80606. addFloat2(name: string, x: number, y: number): void;
  80607. /**
  80608. * Adds a vec3 to the uniform buffer.
  80609. * @param name Name of the uniform, as used in the uniform block in the shader.
  80610. * @param x Define the x component value of the vec3
  80611. * @param y Define the y component value of the vec3
  80612. * @param z Define the z component value of the vec3
  80613. */
  80614. addFloat3(name: string, x: number, y: number, z: number): void;
  80615. /**
  80616. * Adds a vec3 to the uniform buffer.
  80617. * @param name Name of the uniform, as used in the uniform block in the shader.
  80618. * @param color Define the vec3 from a Color
  80619. */
  80620. addColor3(name: string, color: Color3): void;
  80621. /**
  80622. * Adds a vec4 to the uniform buffer.
  80623. * @param name Name of the uniform, as used in the uniform block in the shader.
  80624. * @param color Define the rgb components from a Color
  80625. * @param alpha Define the a component of the vec4
  80626. */
  80627. addColor4(name: string, color: Color3, alpha: number): void;
  80628. /**
  80629. * Adds a vec3 to the uniform buffer.
  80630. * @param name Name of the uniform, as used in the uniform block in the shader.
  80631. * @param vector Define the vec3 components from a Vector
  80632. */
  80633. addVector3(name: string, vector: Vector3): void;
  80634. /**
  80635. * Adds a Matrix 3x3 to the uniform buffer.
  80636. * @param name Name of the uniform, as used in the uniform block in the shader.
  80637. */
  80638. addMatrix3x3(name: string): void;
  80639. /**
  80640. * Adds a Matrix 2x2 to the uniform buffer.
  80641. * @param name Name of the uniform, as used in the uniform block in the shader.
  80642. */
  80643. addMatrix2x2(name: string): void;
  80644. /**
  80645. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80646. */
  80647. create(): void;
  80648. /** @hidden */
  80649. _rebuild(): void;
  80650. /**
  80651. * Updates the WebGL Uniform Buffer on the GPU.
  80652. * If the `dynamic` flag is set to true, no cache comparison is done.
  80653. * Otherwise, the buffer will be updated only if the cache differs.
  80654. */
  80655. update(): void;
  80656. /**
  80657. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80658. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80659. * @param data Define the flattened data
  80660. * @param size Define the size of the data.
  80661. */
  80662. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80663. private _valueCache;
  80664. private _cacheMatrix;
  80665. private _updateMatrix3x3ForUniform;
  80666. private _updateMatrix3x3ForEffect;
  80667. private _updateMatrix2x2ForEffect;
  80668. private _updateMatrix2x2ForUniform;
  80669. private _updateFloatForEffect;
  80670. private _updateFloatForUniform;
  80671. private _updateFloat2ForEffect;
  80672. private _updateFloat2ForUniform;
  80673. private _updateFloat3ForEffect;
  80674. private _updateFloat3ForUniform;
  80675. private _updateFloat4ForEffect;
  80676. private _updateFloat4ForUniform;
  80677. private _updateMatrixForEffect;
  80678. private _updateMatrixForUniform;
  80679. private _updateVector3ForEffect;
  80680. private _updateVector3ForUniform;
  80681. private _updateVector4ForEffect;
  80682. private _updateVector4ForUniform;
  80683. private _updateColor3ForEffect;
  80684. private _updateColor3ForUniform;
  80685. private _updateColor4ForEffect;
  80686. private _updateColor4ForUniform;
  80687. /**
  80688. * Sets a sampler uniform on the effect.
  80689. * @param name Define the name of the sampler.
  80690. * @param texture Define the texture to set in the sampler
  80691. */
  80692. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80693. /**
  80694. * Directly updates the value of the uniform in the cache AND on the GPU.
  80695. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80696. * @param data Define the flattened data
  80697. */
  80698. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80699. /**
  80700. * Binds this uniform buffer to an effect.
  80701. * @param effect Define the effect to bind the buffer to
  80702. * @param name Name of the uniform block in the shader.
  80703. */
  80704. bindToEffect(effect: Effect, name: string): void;
  80705. /**
  80706. * Disposes the uniform buffer.
  80707. */
  80708. dispose(): void;
  80709. }
  80710. }
  80711. declare module BABYLON {
  80712. /**
  80713. * Enum that determines the text-wrapping mode to use.
  80714. */
  80715. export enum InspectableType {
  80716. /**
  80717. * Checkbox for booleans
  80718. */
  80719. Checkbox = 0,
  80720. /**
  80721. * Sliders for numbers
  80722. */
  80723. Slider = 1,
  80724. /**
  80725. * Vector3
  80726. */
  80727. Vector3 = 2,
  80728. /**
  80729. * Quaternions
  80730. */
  80731. Quaternion = 3,
  80732. /**
  80733. * Color3
  80734. */
  80735. Color3 = 4,
  80736. /**
  80737. * String
  80738. */
  80739. String = 5
  80740. }
  80741. /**
  80742. * Interface used to define custom inspectable properties.
  80743. * This interface is used by the inspector to display custom property grids
  80744. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80745. */
  80746. export interface IInspectable {
  80747. /**
  80748. * Gets the label to display
  80749. */
  80750. label: string;
  80751. /**
  80752. * Gets the name of the property to edit
  80753. */
  80754. propertyName: string;
  80755. /**
  80756. * Gets the type of the editor to use
  80757. */
  80758. type: InspectableType;
  80759. /**
  80760. * Gets the minimum value of the property when using in "slider" mode
  80761. */
  80762. min?: number;
  80763. /**
  80764. * Gets the maximum value of the property when using in "slider" mode
  80765. */
  80766. max?: number;
  80767. /**
  80768. * Gets the setp to use when using in "slider" mode
  80769. */
  80770. step?: number;
  80771. }
  80772. }
  80773. declare module BABYLON {
  80774. /**
  80775. * Class used to provide helper for timing
  80776. */
  80777. export class TimingTools {
  80778. /**
  80779. * Polyfill for setImmediate
  80780. * @param action defines the action to execute after the current execution block
  80781. */
  80782. static SetImmediate(action: () => void): void;
  80783. }
  80784. }
  80785. declare module BABYLON {
  80786. /**
  80787. * Class used to enable instatition of objects by class name
  80788. */
  80789. export class InstantiationTools {
  80790. /**
  80791. * Use this object to register external classes like custom textures or material
  80792. * to allow the laoders to instantiate them
  80793. */
  80794. static RegisteredExternalClasses: {
  80795. [key: string]: Object;
  80796. };
  80797. /**
  80798. * Tries to instantiate a new object from a given class name
  80799. * @param className defines the class name to instantiate
  80800. * @returns the new object or null if the system was not able to do the instantiation
  80801. */
  80802. static Instantiate(className: string): any;
  80803. }
  80804. }
  80805. declare module BABYLON {
  80806. /**
  80807. * Define options used to create a depth texture
  80808. */
  80809. export class DepthTextureCreationOptions {
  80810. /** Specifies whether or not a stencil should be allocated in the texture */
  80811. generateStencil?: boolean;
  80812. /** Specifies whether or not bilinear filtering is enable on the texture */
  80813. bilinearFiltering?: boolean;
  80814. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80815. comparisonFunction?: number;
  80816. /** Specifies if the created texture is a cube texture */
  80817. isCube?: boolean;
  80818. }
  80819. }
  80820. declare module BABYLON {
  80821. interface ThinEngine {
  80822. /**
  80823. * Creates a depth stencil cube texture.
  80824. * This is only available in WebGL 2.
  80825. * @param size The size of face edge in the cube texture.
  80826. * @param options The options defining the cube texture.
  80827. * @returns The cube texture
  80828. */
  80829. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80830. /**
  80831. * Creates a cube texture
  80832. * @param rootUrl defines the url where the files to load is located
  80833. * @param scene defines the current scene
  80834. * @param files defines the list of files to load (1 per face)
  80835. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80836. * @param onLoad defines an optional callback raised when the texture is loaded
  80837. * @param onError defines an optional callback raised if there is an issue to load the texture
  80838. * @param format defines the format of the data
  80839. * @param forcedExtension defines the extension to use to pick the right loader
  80840. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80843. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80844. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80845. * @returns the cube texture as an InternalTexture
  80846. */
  80847. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  80848. /**
  80849. * Creates a cube texture
  80850. * @param rootUrl defines the url where the files to load is located
  80851. * @param scene defines the current scene
  80852. * @param files defines the list of files to load (1 per face)
  80853. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80854. * @param onLoad defines an optional callback raised when the texture is loaded
  80855. * @param onError defines an optional callback raised if there is an issue to load the texture
  80856. * @param format defines the format of the data
  80857. * @param forcedExtension defines the extension to use to pick the right loader
  80858. * @returns the cube texture as an InternalTexture
  80859. */
  80860. 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;
  80861. /**
  80862. * Creates a cube texture
  80863. * @param rootUrl defines the url where the files to load is located
  80864. * @param scene defines the current scene
  80865. * @param files defines the list of files to load (1 per face)
  80866. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80867. * @param onLoad defines an optional callback raised when the texture is loaded
  80868. * @param onError defines an optional callback raised if there is an issue to load the texture
  80869. * @param format defines the format of the data
  80870. * @param forcedExtension defines the extension to use to pick the right loader
  80871. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80872. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80873. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80874. * @returns the cube texture as an InternalTexture
  80875. */
  80876. 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;
  80877. /** @hidden */
  80878. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80879. /** @hidden */
  80880. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80881. /** @hidden */
  80882. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80883. /** @hidden */
  80884. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80885. /**
  80886. * @hidden
  80887. */
  80888. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80889. }
  80890. }
  80891. declare module BABYLON {
  80892. /**
  80893. * Class for creating a cube texture
  80894. */
  80895. export class CubeTexture extends BaseTexture {
  80896. private _delayedOnLoad;
  80897. /**
  80898. * The url of the texture
  80899. */
  80900. url: string;
  80901. /**
  80902. * Gets or sets the center of the bounding box associated with the cube texture.
  80903. * It must define where the camera used to render the texture was set
  80904. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80905. */
  80906. boundingBoxPosition: Vector3;
  80907. private _boundingBoxSize;
  80908. /**
  80909. * Gets or sets the size of the bounding box associated with the cube texture
  80910. * When defined, the cubemap will switch to local mode
  80911. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80912. * @example https://www.babylonjs-playground.com/#RNASML
  80913. */
  80914. set boundingBoxSize(value: Vector3);
  80915. /**
  80916. * Returns the bounding box size
  80917. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80918. */
  80919. get boundingBoxSize(): Vector3;
  80920. protected _rotationY: number;
  80921. /**
  80922. * Sets texture matrix rotation angle around Y axis in radians.
  80923. */
  80924. set rotationY(value: number);
  80925. /**
  80926. * Gets texture matrix rotation angle around Y axis radians.
  80927. */
  80928. get rotationY(): number;
  80929. /**
  80930. * Are mip maps generated for this texture or not.
  80931. */
  80932. get noMipmap(): boolean;
  80933. private _noMipmap;
  80934. private _files;
  80935. protected _forcedExtension: Nullable<string>;
  80936. private _extensions;
  80937. private _textureMatrix;
  80938. private _format;
  80939. private _createPolynomials;
  80940. /** @hidden */
  80941. _prefiltered: boolean;
  80942. /**
  80943. * Creates a cube texture from an array of image urls
  80944. * @param files defines an array of image urls
  80945. * @param scene defines the hosting scene
  80946. * @param noMipmap specifies if mip maps are not used
  80947. * @returns a cube texture
  80948. */
  80949. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80950. /**
  80951. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80952. * @param url defines the url of the prefiltered texture
  80953. * @param scene defines the scene the texture is attached to
  80954. * @param forcedExtension defines the extension of the file if different from the url
  80955. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80956. * @return the prefiltered texture
  80957. */
  80958. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80959. /**
  80960. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80961. * as prefiltered data.
  80962. * @param rootUrl defines the url of the texture or the root name of the six images
  80963. * @param scene defines the scene the texture is attached to
  80964. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80965. * @param noMipmap defines if mipmaps should be created or not
  80966. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80967. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80968. * @param onError defines a callback triggered in case of error during load
  80969. * @param format defines the internal format to use for the texture once loaded
  80970. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80971. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80972. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80973. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80974. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80975. * @return the cube texture
  80976. */
  80977. 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);
  80978. /**
  80979. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80980. */
  80981. get isPrefiltered(): boolean;
  80982. /**
  80983. * Get the current class name of the texture useful for serialization or dynamic coding.
  80984. * @returns "CubeTexture"
  80985. */
  80986. getClassName(): string;
  80987. /**
  80988. * Update the url (and optional buffer) of this texture if url was null during construction.
  80989. * @param url the url of the texture
  80990. * @param forcedExtension defines the extension to use
  80991. * @param onLoad callback called when the texture is loaded (defaults to null)
  80992. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80993. */
  80994. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80995. /**
  80996. * Delays loading of the cube texture
  80997. * @param forcedExtension defines the extension to use
  80998. */
  80999. delayLoad(forcedExtension?: string): void;
  81000. /**
  81001. * Returns the reflection texture matrix
  81002. * @returns the reflection texture matrix
  81003. */
  81004. getReflectionTextureMatrix(): Matrix;
  81005. /**
  81006. * Sets the reflection texture matrix
  81007. * @param value Reflection texture matrix
  81008. */
  81009. setReflectionTextureMatrix(value: Matrix): void;
  81010. /**
  81011. * Parses text to create a cube texture
  81012. * @param parsedTexture define the serialized text to read from
  81013. * @param scene defines the hosting scene
  81014. * @param rootUrl defines the root url of the cube texture
  81015. * @returns a cube texture
  81016. */
  81017. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81018. /**
  81019. * Makes a clone, or deep copy, of the cube texture
  81020. * @returns a new cube texture
  81021. */
  81022. clone(): CubeTexture;
  81023. }
  81024. }
  81025. declare module BABYLON {
  81026. /**
  81027. * Manages the defines for the Material
  81028. */
  81029. export class MaterialDefines {
  81030. /** @hidden */
  81031. protected _keys: string[];
  81032. private _isDirty;
  81033. /** @hidden */
  81034. _renderId: number;
  81035. /** @hidden */
  81036. _areLightsDirty: boolean;
  81037. /** @hidden */
  81038. _areLightsDisposed: boolean;
  81039. /** @hidden */
  81040. _areAttributesDirty: boolean;
  81041. /** @hidden */
  81042. _areTexturesDirty: boolean;
  81043. /** @hidden */
  81044. _areFresnelDirty: boolean;
  81045. /** @hidden */
  81046. _areMiscDirty: boolean;
  81047. /** @hidden */
  81048. _areImageProcessingDirty: boolean;
  81049. /** @hidden */
  81050. _normals: boolean;
  81051. /** @hidden */
  81052. _uvs: boolean;
  81053. /** @hidden */
  81054. _needNormals: boolean;
  81055. /** @hidden */
  81056. _needUVs: boolean;
  81057. [id: string]: any;
  81058. /**
  81059. * Specifies if the material needs to be re-calculated
  81060. */
  81061. get isDirty(): boolean;
  81062. /**
  81063. * Marks the material to indicate that it has been re-calculated
  81064. */
  81065. markAsProcessed(): void;
  81066. /**
  81067. * Marks the material to indicate that it needs to be re-calculated
  81068. */
  81069. markAsUnprocessed(): void;
  81070. /**
  81071. * Marks the material to indicate all of its defines need to be re-calculated
  81072. */
  81073. markAllAsDirty(): void;
  81074. /**
  81075. * Marks the material to indicate that image processing needs to be re-calculated
  81076. */
  81077. markAsImageProcessingDirty(): void;
  81078. /**
  81079. * Marks the material to indicate the lights need to be re-calculated
  81080. * @param disposed Defines whether the light is dirty due to dispose or not
  81081. */
  81082. markAsLightDirty(disposed?: boolean): void;
  81083. /**
  81084. * Marks the attribute state as changed
  81085. */
  81086. markAsAttributesDirty(): void;
  81087. /**
  81088. * Marks the texture state as changed
  81089. */
  81090. markAsTexturesDirty(): void;
  81091. /**
  81092. * Marks the fresnel state as changed
  81093. */
  81094. markAsFresnelDirty(): void;
  81095. /**
  81096. * Marks the misc state as changed
  81097. */
  81098. markAsMiscDirty(): void;
  81099. /**
  81100. * Rebuilds the material defines
  81101. */
  81102. rebuild(): void;
  81103. /**
  81104. * Specifies if two material defines are equal
  81105. * @param other - A material define instance to compare to
  81106. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81107. */
  81108. isEqual(other: MaterialDefines): boolean;
  81109. /**
  81110. * Clones this instance's defines to another instance
  81111. * @param other - material defines to clone values to
  81112. */
  81113. cloneTo(other: MaterialDefines): void;
  81114. /**
  81115. * Resets the material define values
  81116. */
  81117. reset(): void;
  81118. /**
  81119. * Converts the material define values to a string
  81120. * @returns - String of material define information
  81121. */
  81122. toString(): string;
  81123. }
  81124. }
  81125. declare module BABYLON {
  81126. /**
  81127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81129. * 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;
  81130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81131. */
  81132. export class ColorCurves {
  81133. private _dirty;
  81134. private _tempColor;
  81135. private _globalCurve;
  81136. private _highlightsCurve;
  81137. private _midtonesCurve;
  81138. private _shadowsCurve;
  81139. private _positiveCurve;
  81140. private _negativeCurve;
  81141. private _globalHue;
  81142. private _globalDensity;
  81143. private _globalSaturation;
  81144. private _globalExposure;
  81145. /**
  81146. * Gets the global Hue value.
  81147. * 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).
  81148. */
  81149. get globalHue(): number;
  81150. /**
  81151. * Sets the global Hue value.
  81152. * 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).
  81153. */
  81154. set globalHue(value: number);
  81155. /**
  81156. * Gets the global Density value.
  81157. * 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.
  81158. * Values less than zero provide a filter of opposite hue.
  81159. */
  81160. get globalDensity(): number;
  81161. /**
  81162. * Sets the global Density value.
  81163. * 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.
  81164. * Values less than zero provide a filter of opposite hue.
  81165. */
  81166. set globalDensity(value: number);
  81167. /**
  81168. * Gets the global Saturation value.
  81169. * 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.
  81170. */
  81171. get globalSaturation(): number;
  81172. /**
  81173. * Sets the global Saturation value.
  81174. * 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.
  81175. */
  81176. set globalSaturation(value: number);
  81177. /**
  81178. * Gets the global Exposure value.
  81179. * 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.
  81180. */
  81181. get globalExposure(): number;
  81182. /**
  81183. * Sets the global Exposure value.
  81184. * 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.
  81185. */
  81186. set globalExposure(value: number);
  81187. private _highlightsHue;
  81188. private _highlightsDensity;
  81189. private _highlightsSaturation;
  81190. private _highlightsExposure;
  81191. /**
  81192. * Gets the highlights 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. get highlightsHue(): number;
  81196. /**
  81197. * Sets the highlights Hue value.
  81198. * 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).
  81199. */
  81200. set highlightsHue(value: number);
  81201. /**
  81202. * Gets the highlights Density value.
  81203. * 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.
  81204. * Values less than zero provide a filter of opposite hue.
  81205. */
  81206. get highlightsDensity(): number;
  81207. /**
  81208. * Sets the highlights Density value.
  81209. * 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.
  81210. * Values less than zero provide a filter of opposite hue.
  81211. */
  81212. set highlightsDensity(value: number);
  81213. /**
  81214. * Gets the highlights 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. get highlightsSaturation(): number;
  81218. /**
  81219. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  81221. */
  81222. set highlightsSaturation(value: number);
  81223. /**
  81224. * Gets the highlights 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. get highlightsExposure(): number;
  81228. /**
  81229. * Sets the highlights Exposure value.
  81230. * 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.
  81231. */
  81232. set highlightsExposure(value: number);
  81233. private _midtonesHue;
  81234. private _midtonesDensity;
  81235. private _midtonesSaturation;
  81236. private _midtonesExposure;
  81237. /**
  81238. * Gets the midtones 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. get midtonesHue(): number;
  81242. /**
  81243. * Sets the midtones Hue value.
  81244. * 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).
  81245. */
  81246. set midtonesHue(value: number);
  81247. /**
  81248. * Gets the midtones Density value.
  81249. * 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.
  81250. * Values less than zero provide a filter of opposite hue.
  81251. */
  81252. get midtonesDensity(): number;
  81253. /**
  81254. * Sets the midtones Density value.
  81255. * 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.
  81256. * Values less than zero provide a filter of opposite hue.
  81257. */
  81258. set midtonesDensity(value: number);
  81259. /**
  81260. * Gets the midtones 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. get midtonesSaturation(): number;
  81264. /**
  81265. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  81267. */
  81268. set midtonesSaturation(value: number);
  81269. /**
  81270. * Gets the midtones 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. get midtonesExposure(): number;
  81274. /**
  81275. * Sets the midtones Exposure value.
  81276. * 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.
  81277. */
  81278. set midtonesExposure(value: number);
  81279. private _shadowsHue;
  81280. private _shadowsDensity;
  81281. private _shadowsSaturation;
  81282. private _shadowsExposure;
  81283. /**
  81284. * Gets the shadows 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. get shadowsHue(): number;
  81288. /**
  81289. * Sets the shadows Hue value.
  81290. * 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).
  81291. */
  81292. set shadowsHue(value: number);
  81293. /**
  81294. * Gets the shadows Density value.
  81295. * 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.
  81296. * Values less than zero provide a filter of opposite hue.
  81297. */
  81298. get shadowsDensity(): number;
  81299. /**
  81300. * Sets the shadows Density value.
  81301. * 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.
  81302. * Values less than zero provide a filter of opposite hue.
  81303. */
  81304. set shadowsDensity(value: number);
  81305. /**
  81306. * Gets the shadows 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. get shadowsSaturation(): number;
  81310. /**
  81311. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  81313. */
  81314. set shadowsSaturation(value: number);
  81315. /**
  81316. * Gets the shadows 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. get shadowsExposure(): number;
  81320. /**
  81321. * Sets the shadows Exposure value.
  81322. * 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.
  81323. */
  81324. set shadowsExposure(value: number);
  81325. /**
  81326. * Returns the class name
  81327. * @returns The class name
  81328. */
  81329. getClassName(): string;
  81330. /**
  81331. * Binds the color curves to the shader.
  81332. * @param colorCurves The color curve to bind
  81333. * @param effect The effect to bind to
  81334. * @param positiveUniform The positive uniform shader parameter
  81335. * @param neutralUniform The neutral uniform shader parameter
  81336. * @param negativeUniform The negative uniform shader parameter
  81337. */
  81338. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81339. /**
  81340. * Prepare the list of uniforms associated with the ColorCurves effects.
  81341. * @param uniformsList The list of uniforms used in the effect
  81342. */
  81343. static PrepareUniforms(uniformsList: string[]): void;
  81344. /**
  81345. * Returns color grading data based on a hue, density, saturation and exposure value.
  81346. * @param filterHue The hue of the color filter.
  81347. * @param filterDensity The density of the color filter.
  81348. * @param saturation The saturation.
  81349. * @param exposure The exposure.
  81350. * @param result The result data container.
  81351. */
  81352. private getColorGradingDataToRef;
  81353. /**
  81354. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81355. * @param value The input slider value in range [-100,100].
  81356. * @returns Adjusted value.
  81357. */
  81358. private static applyColorGradingSliderNonlinear;
  81359. /**
  81360. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81361. * @param hue The hue (H) input.
  81362. * @param saturation The saturation (S) input.
  81363. * @param brightness The brightness (B) input.
  81364. * @result An RGBA color represented as Vector4.
  81365. */
  81366. private static fromHSBToRef;
  81367. /**
  81368. * Returns a value clamped between min and max
  81369. * @param value The value to clamp
  81370. * @param min The minimum of value
  81371. * @param max The maximum of value
  81372. * @returns The clamped value.
  81373. */
  81374. private static clamp;
  81375. /**
  81376. * Clones the current color curve instance.
  81377. * @return The cloned curves
  81378. */
  81379. clone(): ColorCurves;
  81380. /**
  81381. * Serializes the current color curve instance to a json representation.
  81382. * @return a JSON representation
  81383. */
  81384. serialize(): any;
  81385. /**
  81386. * Parses the color curve from a json representation.
  81387. * @param source the JSON source to parse
  81388. * @return The parsed curves
  81389. */
  81390. static Parse(source: any): ColorCurves;
  81391. }
  81392. }
  81393. declare module BABYLON {
  81394. /**
  81395. * Interface to follow in your material defines to integrate easily the
  81396. * Image proccessing functions.
  81397. * @hidden
  81398. */
  81399. export interface IImageProcessingConfigurationDefines {
  81400. IMAGEPROCESSING: boolean;
  81401. VIGNETTE: boolean;
  81402. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81403. VIGNETTEBLENDMODEOPAQUE: boolean;
  81404. TONEMAPPING: boolean;
  81405. TONEMAPPING_ACES: boolean;
  81406. CONTRAST: boolean;
  81407. EXPOSURE: boolean;
  81408. COLORCURVES: boolean;
  81409. COLORGRADING: boolean;
  81410. COLORGRADING3D: boolean;
  81411. SAMPLER3DGREENDEPTH: boolean;
  81412. SAMPLER3DBGRMAP: boolean;
  81413. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81414. }
  81415. /**
  81416. * @hidden
  81417. */
  81418. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81419. IMAGEPROCESSING: boolean;
  81420. VIGNETTE: boolean;
  81421. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81422. VIGNETTEBLENDMODEOPAQUE: boolean;
  81423. TONEMAPPING: boolean;
  81424. TONEMAPPING_ACES: boolean;
  81425. CONTRAST: boolean;
  81426. COLORCURVES: boolean;
  81427. COLORGRADING: boolean;
  81428. COLORGRADING3D: boolean;
  81429. SAMPLER3DGREENDEPTH: boolean;
  81430. SAMPLER3DBGRMAP: boolean;
  81431. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81432. EXPOSURE: boolean;
  81433. constructor();
  81434. }
  81435. /**
  81436. * This groups together the common properties used for image processing either in direct forward pass
  81437. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81438. * or not.
  81439. */
  81440. export class ImageProcessingConfiguration {
  81441. /**
  81442. * Default tone mapping applied in BabylonJS.
  81443. */
  81444. static readonly TONEMAPPING_STANDARD: number;
  81445. /**
  81446. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81447. * to other engines rendering to increase portability.
  81448. */
  81449. static readonly TONEMAPPING_ACES: number;
  81450. /**
  81451. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81452. */
  81453. colorCurves: Nullable<ColorCurves>;
  81454. private _colorCurvesEnabled;
  81455. /**
  81456. * Gets wether the color curves effect is enabled.
  81457. */
  81458. get colorCurvesEnabled(): boolean;
  81459. /**
  81460. * Sets wether the color curves effect is enabled.
  81461. */
  81462. set colorCurvesEnabled(value: boolean);
  81463. private _colorGradingTexture;
  81464. /**
  81465. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81466. */
  81467. get colorGradingTexture(): Nullable<BaseTexture>;
  81468. /**
  81469. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81470. */
  81471. set colorGradingTexture(value: Nullable<BaseTexture>);
  81472. private _colorGradingEnabled;
  81473. /**
  81474. * Gets wether the color grading effect is enabled.
  81475. */
  81476. get colorGradingEnabled(): boolean;
  81477. /**
  81478. * Sets wether the color grading effect is enabled.
  81479. */
  81480. set colorGradingEnabled(value: boolean);
  81481. private _colorGradingWithGreenDepth;
  81482. /**
  81483. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81484. */
  81485. get colorGradingWithGreenDepth(): boolean;
  81486. /**
  81487. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81488. */
  81489. set colorGradingWithGreenDepth(value: boolean);
  81490. private _colorGradingBGR;
  81491. /**
  81492. * Gets wether the color grading texture contains BGR values.
  81493. */
  81494. get colorGradingBGR(): boolean;
  81495. /**
  81496. * Sets wether the color grading texture contains BGR values.
  81497. */
  81498. set colorGradingBGR(value: boolean);
  81499. /** @hidden */
  81500. _exposure: number;
  81501. /**
  81502. * Gets the Exposure used in the effect.
  81503. */
  81504. get exposure(): number;
  81505. /**
  81506. * Sets the Exposure used in the effect.
  81507. */
  81508. set exposure(value: number);
  81509. private _toneMappingEnabled;
  81510. /**
  81511. * Gets wether the tone mapping effect is enabled.
  81512. */
  81513. get toneMappingEnabled(): boolean;
  81514. /**
  81515. * Sets wether the tone mapping effect is enabled.
  81516. */
  81517. set toneMappingEnabled(value: boolean);
  81518. private _toneMappingType;
  81519. /**
  81520. * Gets the type of tone mapping effect.
  81521. */
  81522. get toneMappingType(): number;
  81523. /**
  81524. * Sets the type of tone mapping effect used in BabylonJS.
  81525. */
  81526. set toneMappingType(value: number);
  81527. protected _contrast: number;
  81528. /**
  81529. * Gets the contrast used in the effect.
  81530. */
  81531. get contrast(): number;
  81532. /**
  81533. * Sets the contrast used in the effect.
  81534. */
  81535. set contrast(value: number);
  81536. /**
  81537. * Vignette stretch size.
  81538. */
  81539. vignetteStretch: number;
  81540. /**
  81541. * Vignette centre X Offset.
  81542. */
  81543. vignetteCentreX: number;
  81544. /**
  81545. * Vignette centre Y Offset.
  81546. */
  81547. vignetteCentreY: number;
  81548. /**
  81549. * Vignette weight or intensity of the vignette effect.
  81550. */
  81551. vignetteWeight: number;
  81552. /**
  81553. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81554. * if vignetteEnabled is set to true.
  81555. */
  81556. vignetteColor: Color4;
  81557. /**
  81558. * Camera field of view used by the Vignette effect.
  81559. */
  81560. vignetteCameraFov: number;
  81561. private _vignetteBlendMode;
  81562. /**
  81563. * Gets the vignette blend mode allowing different kind of effect.
  81564. */
  81565. get vignetteBlendMode(): number;
  81566. /**
  81567. * Sets the vignette blend mode allowing different kind of effect.
  81568. */
  81569. set vignetteBlendMode(value: number);
  81570. private _vignetteEnabled;
  81571. /**
  81572. * Gets wether the vignette effect is enabled.
  81573. */
  81574. get vignetteEnabled(): boolean;
  81575. /**
  81576. * Sets wether the vignette effect is enabled.
  81577. */
  81578. set vignetteEnabled(value: boolean);
  81579. private _applyByPostProcess;
  81580. /**
  81581. * Gets wether the image processing is applied through a post process or not.
  81582. */
  81583. get applyByPostProcess(): boolean;
  81584. /**
  81585. * Sets wether the image processing is applied through a post process or not.
  81586. */
  81587. set applyByPostProcess(value: boolean);
  81588. private _isEnabled;
  81589. /**
  81590. * Gets wether the image processing is enabled or not.
  81591. */
  81592. get isEnabled(): boolean;
  81593. /**
  81594. * Sets wether the image processing is enabled or not.
  81595. */
  81596. set isEnabled(value: boolean);
  81597. /**
  81598. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81599. */
  81600. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81601. /**
  81602. * Method called each time the image processing information changes requires to recompile the effect.
  81603. */
  81604. protected _updateParameters(): void;
  81605. /**
  81606. * Gets the current class name.
  81607. * @return "ImageProcessingConfiguration"
  81608. */
  81609. getClassName(): string;
  81610. /**
  81611. * Prepare the list of uniforms associated with the Image Processing effects.
  81612. * @param uniforms The list of uniforms used in the effect
  81613. * @param defines the list of defines currently in use
  81614. */
  81615. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81616. /**
  81617. * Prepare the list of samplers associated with the Image Processing effects.
  81618. * @param samplersList The list of uniforms used in the effect
  81619. * @param defines the list of defines currently in use
  81620. */
  81621. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81622. /**
  81623. * Prepare the list of defines associated to the shader.
  81624. * @param defines the list of defines to complete
  81625. * @param forPostProcess Define if we are currently in post process mode or not
  81626. */
  81627. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81628. /**
  81629. * Returns true if all the image processing information are ready.
  81630. * @returns True if ready, otherwise, false
  81631. */
  81632. isReady(): boolean;
  81633. /**
  81634. * Binds the image processing to the shader.
  81635. * @param effect The effect to bind to
  81636. * @param overrideAspectRatio Override the aspect ratio of the effect
  81637. */
  81638. bind(effect: Effect, overrideAspectRatio?: number): void;
  81639. /**
  81640. * Clones the current image processing instance.
  81641. * @return The cloned image processing
  81642. */
  81643. clone(): ImageProcessingConfiguration;
  81644. /**
  81645. * Serializes the current image processing instance to a json representation.
  81646. * @return a JSON representation
  81647. */
  81648. serialize(): any;
  81649. /**
  81650. * Parses the image processing from a json representation.
  81651. * @param source the JSON source to parse
  81652. * @return The parsed image processing
  81653. */
  81654. static Parse(source: any): ImageProcessingConfiguration;
  81655. private static _VIGNETTEMODE_MULTIPLY;
  81656. private static _VIGNETTEMODE_OPAQUE;
  81657. /**
  81658. * Used to apply the vignette as a mix with the pixel color.
  81659. */
  81660. static get VIGNETTEMODE_MULTIPLY(): number;
  81661. /**
  81662. * Used to apply the vignette as a replacement of the pixel color.
  81663. */
  81664. static get VIGNETTEMODE_OPAQUE(): number;
  81665. }
  81666. }
  81667. declare module BABYLON {
  81668. /** @hidden */
  81669. export var postprocessVertexShader: {
  81670. name: string;
  81671. shader: string;
  81672. };
  81673. }
  81674. declare module BABYLON {
  81675. interface ThinEngine {
  81676. /**
  81677. * Creates a new render target texture
  81678. * @param size defines the size of the texture
  81679. * @param options defines the options used to create the texture
  81680. * @returns a new render target texture stored in an InternalTexture
  81681. */
  81682. createRenderTargetTexture(size: number | {
  81683. width: number;
  81684. height: number;
  81685. layers?: number;
  81686. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81687. /**
  81688. * Creates a depth stencil texture.
  81689. * This is only available in WebGL 2 or with the depth texture extension available.
  81690. * @param size The size of face edge in the texture.
  81691. * @param options The options defining the texture.
  81692. * @returns The texture
  81693. */
  81694. createDepthStencilTexture(size: number | {
  81695. width: number;
  81696. height: number;
  81697. layers?: number;
  81698. }, options: DepthTextureCreationOptions): InternalTexture;
  81699. /** @hidden */
  81700. _createDepthStencilTexture(size: number | {
  81701. width: number;
  81702. height: number;
  81703. layers?: number;
  81704. }, options: DepthTextureCreationOptions): InternalTexture;
  81705. }
  81706. }
  81707. declare module BABYLON {
  81708. /** Defines supported spaces */
  81709. export enum Space {
  81710. /** Local (object) space */
  81711. LOCAL = 0,
  81712. /** World space */
  81713. WORLD = 1,
  81714. /** Bone space */
  81715. BONE = 2
  81716. }
  81717. /** Defines the 3 main axes */
  81718. export class Axis {
  81719. /** X axis */
  81720. static X: Vector3;
  81721. /** Y axis */
  81722. static Y: Vector3;
  81723. /** Z axis */
  81724. static Z: Vector3;
  81725. }
  81726. }
  81727. declare module BABYLON {
  81728. /**
  81729. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81730. * This is the base of the follow, arc rotate cameras and Free camera
  81731. * @see http://doc.babylonjs.com/features/cameras
  81732. */
  81733. export class TargetCamera extends Camera {
  81734. private static _RigCamTransformMatrix;
  81735. private static _TargetTransformMatrix;
  81736. private static _TargetFocalPoint;
  81737. /**
  81738. * Define the current direction the camera is moving to
  81739. */
  81740. cameraDirection: Vector3;
  81741. /**
  81742. * Define the current rotation the camera is rotating to
  81743. */
  81744. cameraRotation: Vector2;
  81745. /**
  81746. * When set, the up vector of the camera will be updated by the rotation of the camera
  81747. */
  81748. updateUpVectorFromRotation: boolean;
  81749. private _tmpQuaternion;
  81750. /**
  81751. * Define the current rotation of the camera
  81752. */
  81753. rotation: Vector3;
  81754. /**
  81755. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81756. */
  81757. rotationQuaternion: Quaternion;
  81758. /**
  81759. * Define the current speed of the camera
  81760. */
  81761. speed: number;
  81762. /**
  81763. * Add constraint to the camera to prevent it to move freely in all directions and
  81764. * around all axis.
  81765. */
  81766. noRotationConstraint: boolean;
  81767. /**
  81768. * Define the current target of the camera as an object or a position.
  81769. */
  81770. lockedTarget: any;
  81771. /** @hidden */
  81772. _currentTarget: Vector3;
  81773. /** @hidden */
  81774. _initialFocalDistance: number;
  81775. /** @hidden */
  81776. _viewMatrix: Matrix;
  81777. /** @hidden */
  81778. _camMatrix: Matrix;
  81779. /** @hidden */
  81780. _cameraTransformMatrix: Matrix;
  81781. /** @hidden */
  81782. _cameraRotationMatrix: Matrix;
  81783. /** @hidden */
  81784. _referencePoint: Vector3;
  81785. /** @hidden */
  81786. _transformedReferencePoint: Vector3;
  81787. protected _globalCurrentTarget: Vector3;
  81788. protected _globalCurrentUpVector: Vector3;
  81789. /** @hidden */
  81790. _reset: () => void;
  81791. private _defaultUp;
  81792. /**
  81793. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81794. * This is the base of the follow, arc rotate cameras and Free camera
  81795. * @see http://doc.babylonjs.com/features/cameras
  81796. * @param name Defines the name of the camera in the scene
  81797. * @param position Defines the start position of the camera in the scene
  81798. * @param scene Defines the scene the camera belongs to
  81799. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81800. */
  81801. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81802. /**
  81803. * Gets the position in front of the camera at a given distance.
  81804. * @param distance The distance from the camera we want the position to be
  81805. * @returns the position
  81806. */
  81807. getFrontPosition(distance: number): Vector3;
  81808. /** @hidden */
  81809. _getLockedTargetPosition(): Nullable<Vector3>;
  81810. private _storedPosition;
  81811. private _storedRotation;
  81812. private _storedRotationQuaternion;
  81813. /**
  81814. * Store current camera state of the camera (fov, position, rotation, etc..)
  81815. * @returns the camera
  81816. */
  81817. storeState(): Camera;
  81818. /**
  81819. * Restored camera state. You must call storeState() first
  81820. * @returns whether it was successful or not
  81821. * @hidden
  81822. */
  81823. _restoreStateValues(): boolean;
  81824. /** @hidden */
  81825. _initCache(): void;
  81826. /** @hidden */
  81827. _updateCache(ignoreParentClass?: boolean): void;
  81828. /** @hidden */
  81829. _isSynchronizedViewMatrix(): boolean;
  81830. /** @hidden */
  81831. _computeLocalCameraSpeed(): number;
  81832. /**
  81833. * Defines the target the camera should look at.
  81834. * @param target Defines the new target as a Vector or a mesh
  81835. */
  81836. setTarget(target: Vector3): void;
  81837. /**
  81838. * Return the current target position of the camera. This value is expressed in local space.
  81839. * @returns the target position
  81840. */
  81841. getTarget(): Vector3;
  81842. /** @hidden */
  81843. _decideIfNeedsToMove(): boolean;
  81844. /** @hidden */
  81845. _updatePosition(): void;
  81846. /** @hidden */
  81847. _checkInputs(): void;
  81848. protected _updateCameraRotationMatrix(): void;
  81849. /**
  81850. * 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)
  81851. * @returns the current camera
  81852. */
  81853. private _rotateUpVectorWithCameraRotationMatrix;
  81854. private _cachedRotationZ;
  81855. private _cachedQuaternionRotationZ;
  81856. /** @hidden */
  81857. _getViewMatrix(): Matrix;
  81858. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81859. /**
  81860. * @hidden
  81861. */
  81862. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81863. /**
  81864. * @hidden
  81865. */
  81866. _updateRigCameras(): void;
  81867. private _getRigCamPositionAndTarget;
  81868. /**
  81869. * Gets the current object class name.
  81870. * @return the class name
  81871. */
  81872. getClassName(): string;
  81873. }
  81874. }
  81875. declare module BABYLON {
  81876. /**
  81877. * Gather the list of keyboard event types as constants.
  81878. */
  81879. export class KeyboardEventTypes {
  81880. /**
  81881. * The keydown event is fired when a key becomes active (pressed).
  81882. */
  81883. static readonly KEYDOWN: number;
  81884. /**
  81885. * The keyup event is fired when a key has been released.
  81886. */
  81887. static readonly KEYUP: number;
  81888. }
  81889. /**
  81890. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81891. */
  81892. export class KeyboardInfo {
  81893. /**
  81894. * Defines the type of event (KeyboardEventTypes)
  81895. */
  81896. type: number;
  81897. /**
  81898. * Defines the related dom event
  81899. */
  81900. event: KeyboardEvent;
  81901. /**
  81902. * Instantiates a new keyboard info.
  81903. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81904. * @param type Defines the type of event (KeyboardEventTypes)
  81905. * @param event Defines the related dom event
  81906. */
  81907. constructor(
  81908. /**
  81909. * Defines the type of event (KeyboardEventTypes)
  81910. */
  81911. type: number,
  81912. /**
  81913. * Defines the related dom event
  81914. */
  81915. event: KeyboardEvent);
  81916. }
  81917. /**
  81918. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81919. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81920. */
  81921. export class KeyboardInfoPre extends KeyboardInfo {
  81922. /**
  81923. * Defines the type of event (KeyboardEventTypes)
  81924. */
  81925. type: number;
  81926. /**
  81927. * Defines the related dom event
  81928. */
  81929. event: KeyboardEvent;
  81930. /**
  81931. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81932. */
  81933. skipOnPointerObservable: boolean;
  81934. /**
  81935. * Instantiates a new keyboard pre info.
  81936. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81937. * @param type Defines the type of event (KeyboardEventTypes)
  81938. * @param event Defines the related dom event
  81939. */
  81940. constructor(
  81941. /**
  81942. * Defines the type of event (KeyboardEventTypes)
  81943. */
  81944. type: number,
  81945. /**
  81946. * Defines the related dom event
  81947. */
  81948. event: KeyboardEvent);
  81949. }
  81950. }
  81951. declare module BABYLON {
  81952. /**
  81953. * Manage the keyboard inputs to control the movement of a free camera.
  81954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81955. */
  81956. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81957. /**
  81958. * Defines the camera the input is attached to.
  81959. */
  81960. camera: FreeCamera;
  81961. /**
  81962. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81963. */
  81964. keysUp: number[];
  81965. /**
  81966. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81967. */
  81968. keysDown: number[];
  81969. /**
  81970. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81971. */
  81972. keysLeft: number[];
  81973. /**
  81974. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81975. */
  81976. keysRight: number[];
  81977. private _keys;
  81978. private _onCanvasBlurObserver;
  81979. private _onKeyboardObserver;
  81980. private _engine;
  81981. private _scene;
  81982. /**
  81983. * Attach the input controls to a specific dom element to get the input from.
  81984. * @param element Defines the element the controls should be listened from
  81985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81986. */
  81987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81988. /**
  81989. * Detach the current controls from the specified dom element.
  81990. * @param element Defines the element to stop listening the inputs from
  81991. */
  81992. detachControl(element: Nullable<HTMLElement>): void;
  81993. /**
  81994. * Update the current camera state depending on the inputs that have been used this frame.
  81995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81996. */
  81997. checkInputs(): void;
  81998. /**
  81999. * Gets the class name of the current intput.
  82000. * @returns the class name
  82001. */
  82002. getClassName(): string;
  82003. /** @hidden */
  82004. _onLostFocus(): void;
  82005. /**
  82006. * Get the friendly name associated with the input class.
  82007. * @returns the input friendly name
  82008. */
  82009. getSimpleName(): string;
  82010. }
  82011. }
  82012. declare module BABYLON {
  82013. /**
  82014. * Interface describing all the common properties and methods a shadow light needs to implement.
  82015. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82016. * as well as binding the different shadow properties to the effects.
  82017. */
  82018. export interface IShadowLight extends Light {
  82019. /**
  82020. * The light id in the scene (used in scene.findLighById for instance)
  82021. */
  82022. id: string;
  82023. /**
  82024. * The position the shdow will be casted from.
  82025. */
  82026. position: Vector3;
  82027. /**
  82028. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82029. */
  82030. direction: Vector3;
  82031. /**
  82032. * The transformed position. Position of the light in world space taking parenting in account.
  82033. */
  82034. transformedPosition: Vector3;
  82035. /**
  82036. * The transformed direction. Direction of the light in world space taking parenting in account.
  82037. */
  82038. transformedDirection: Vector3;
  82039. /**
  82040. * The friendly name of the light in the scene.
  82041. */
  82042. name: string;
  82043. /**
  82044. * Defines the shadow projection clipping minimum z value.
  82045. */
  82046. shadowMinZ: number;
  82047. /**
  82048. * Defines the shadow projection clipping maximum z value.
  82049. */
  82050. shadowMaxZ: number;
  82051. /**
  82052. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82053. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82054. */
  82055. computeTransformedInformation(): boolean;
  82056. /**
  82057. * Gets the scene the light belongs to.
  82058. * @returns The scene
  82059. */
  82060. getScene(): Scene;
  82061. /**
  82062. * Callback defining a custom Projection Matrix Builder.
  82063. * This can be used to override the default projection matrix computation.
  82064. */
  82065. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82066. /**
  82067. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82068. * @param matrix The materix to updated with the projection information
  82069. * @param viewMatrix The transform matrix of the light
  82070. * @param renderList The list of mesh to render in the map
  82071. * @returns The current light
  82072. */
  82073. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82074. /**
  82075. * Gets the current depth scale used in ESM.
  82076. * @returns The scale
  82077. */
  82078. getDepthScale(): number;
  82079. /**
  82080. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82081. * @returns true if a cube texture needs to be use
  82082. */
  82083. needCube(): boolean;
  82084. /**
  82085. * Detects if the projection matrix requires to be recomputed this frame.
  82086. * @returns true if it requires to be recomputed otherwise, false.
  82087. */
  82088. needProjectionMatrixCompute(): boolean;
  82089. /**
  82090. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82091. */
  82092. forceProjectionMatrixCompute(): void;
  82093. /**
  82094. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82095. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82096. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82097. */
  82098. getShadowDirection(faceIndex?: number): Vector3;
  82099. /**
  82100. * Gets the minZ used for shadow according to both the scene and the light.
  82101. * @param activeCamera The camera we are returning the min for
  82102. * @returns the depth min z
  82103. */
  82104. getDepthMinZ(activeCamera: Camera): number;
  82105. /**
  82106. * Gets the maxZ used for shadow according to both the scene and the light.
  82107. * @param activeCamera The camera we are returning the max for
  82108. * @returns the depth max z
  82109. */
  82110. getDepthMaxZ(activeCamera: Camera): number;
  82111. }
  82112. /**
  82113. * Base implementation IShadowLight
  82114. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82115. */
  82116. export abstract class ShadowLight extends Light implements IShadowLight {
  82117. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82118. protected _position: Vector3;
  82119. protected _setPosition(value: Vector3): void;
  82120. /**
  82121. * Sets the position the shadow will be casted from. Also use as the light position for both
  82122. * point and spot lights.
  82123. */
  82124. get position(): Vector3;
  82125. /**
  82126. * Sets the position the shadow will be casted from. Also use as the light position for both
  82127. * point and spot lights.
  82128. */
  82129. set position(value: Vector3);
  82130. protected _direction: Vector3;
  82131. protected _setDirection(value: Vector3): void;
  82132. /**
  82133. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82134. * Also use as the light direction on spot and directional lights.
  82135. */
  82136. get direction(): Vector3;
  82137. /**
  82138. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82139. * Also use as the light direction on spot and directional lights.
  82140. */
  82141. set direction(value: Vector3);
  82142. protected _shadowMinZ: number;
  82143. /**
  82144. * Gets the shadow projection clipping minimum z value.
  82145. */
  82146. get shadowMinZ(): number;
  82147. /**
  82148. * Sets the shadow projection clipping minimum z value.
  82149. */
  82150. set shadowMinZ(value: number);
  82151. protected _shadowMaxZ: number;
  82152. /**
  82153. * Sets the shadow projection clipping maximum z value.
  82154. */
  82155. get shadowMaxZ(): number;
  82156. /**
  82157. * Gets the shadow projection clipping maximum z value.
  82158. */
  82159. set shadowMaxZ(value: number);
  82160. /**
  82161. * Callback defining a custom Projection Matrix Builder.
  82162. * This can be used to override the default projection matrix computation.
  82163. */
  82164. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82165. /**
  82166. * The transformed position. Position of the light in world space taking parenting in account.
  82167. */
  82168. transformedPosition: Vector3;
  82169. /**
  82170. * The transformed direction. Direction of the light in world space taking parenting in account.
  82171. */
  82172. transformedDirection: Vector3;
  82173. private _needProjectionMatrixCompute;
  82174. /**
  82175. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82176. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82177. */
  82178. computeTransformedInformation(): boolean;
  82179. /**
  82180. * Return the depth scale used for the shadow map.
  82181. * @returns the depth scale.
  82182. */
  82183. getDepthScale(): number;
  82184. /**
  82185. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82186. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82187. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82188. */
  82189. getShadowDirection(faceIndex?: number): Vector3;
  82190. /**
  82191. * Returns the ShadowLight absolute position in the World.
  82192. * @returns the position vector in world space
  82193. */
  82194. getAbsolutePosition(): Vector3;
  82195. /**
  82196. * Sets the ShadowLight direction toward the passed target.
  82197. * @param target The point to target in local space
  82198. * @returns the updated ShadowLight direction
  82199. */
  82200. setDirectionToTarget(target: Vector3): Vector3;
  82201. /**
  82202. * Returns the light rotation in euler definition.
  82203. * @returns the x y z rotation in local space.
  82204. */
  82205. getRotation(): Vector3;
  82206. /**
  82207. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82208. * @returns true if a cube texture needs to be use
  82209. */
  82210. needCube(): boolean;
  82211. /**
  82212. * Detects if the projection matrix requires to be recomputed this frame.
  82213. * @returns true if it requires to be recomputed otherwise, false.
  82214. */
  82215. needProjectionMatrixCompute(): boolean;
  82216. /**
  82217. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82218. */
  82219. forceProjectionMatrixCompute(): void;
  82220. /** @hidden */
  82221. _initCache(): void;
  82222. /** @hidden */
  82223. _isSynchronized(): boolean;
  82224. /**
  82225. * Computes the world matrix of the node
  82226. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82227. * @returns the world matrix
  82228. */
  82229. computeWorldMatrix(force?: boolean): Matrix;
  82230. /**
  82231. * Gets the minZ used for shadow according to both the scene and the light.
  82232. * @param activeCamera The camera we are returning the min for
  82233. * @returns the depth min z
  82234. */
  82235. getDepthMinZ(activeCamera: Camera): number;
  82236. /**
  82237. * Gets the maxZ used for shadow according to both the scene and the light.
  82238. * @param activeCamera The camera we are returning the max for
  82239. * @returns the depth max z
  82240. */
  82241. getDepthMaxZ(activeCamera: Camera): number;
  82242. /**
  82243. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82244. * @param matrix The materix to updated with the projection information
  82245. * @param viewMatrix The transform matrix of the light
  82246. * @param renderList The list of mesh to render in the map
  82247. * @returns The current light
  82248. */
  82249. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82250. }
  82251. }
  82252. declare module BABYLON {
  82253. /**
  82254. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82255. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82256. */
  82257. export class EffectFallbacks implements IEffectFallbacks {
  82258. private _defines;
  82259. private _currentRank;
  82260. private _maxRank;
  82261. private _mesh;
  82262. /**
  82263. * Removes the fallback from the bound mesh.
  82264. */
  82265. unBindMesh(): void;
  82266. /**
  82267. * Adds a fallback on the specified property.
  82268. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82269. * @param define The name of the define in the shader
  82270. */
  82271. addFallback(rank: number, define: string): void;
  82272. /**
  82273. * Sets the mesh to use CPU skinning when needing to fallback.
  82274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82275. * @param mesh The mesh to use the fallbacks.
  82276. */
  82277. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82278. /**
  82279. * Checks to see if more fallbacks are still availible.
  82280. */
  82281. get hasMoreFallbacks(): boolean;
  82282. /**
  82283. * Removes the defines that should be removed when falling back.
  82284. * @param currentDefines defines the current define statements for the shader.
  82285. * @param effect defines the current effect we try to compile
  82286. * @returns The resulting defines with defines of the current rank removed.
  82287. */
  82288. reduce(currentDefines: string, effect: Effect): string;
  82289. }
  82290. }
  82291. declare module BABYLON {
  82292. /**
  82293. * "Static Class" containing the most commonly used helper while dealing with material for
  82294. * rendering purpose.
  82295. *
  82296. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82297. *
  82298. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82299. */
  82300. export class MaterialHelper {
  82301. /**
  82302. * Bind the current view position to an effect.
  82303. * @param effect The effect to be bound
  82304. * @param scene The scene the eyes position is used from
  82305. */
  82306. static BindEyePosition(effect: Effect, scene: Scene): void;
  82307. /**
  82308. * Helps preparing the defines values about the UVs in used in the effect.
  82309. * UVs are shared as much as we can accross channels in the shaders.
  82310. * @param texture The texture we are preparing the UVs for
  82311. * @param defines The defines to update
  82312. * @param key The channel key "diffuse", "specular"... used in the shader
  82313. */
  82314. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82315. /**
  82316. * Binds a texture matrix value to its corrsponding uniform
  82317. * @param texture The texture to bind the matrix for
  82318. * @param uniformBuffer The uniform buffer receivin the data
  82319. * @param key The channel key "diffuse", "specular"... used in the shader
  82320. */
  82321. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82322. /**
  82323. * Gets the current status of the fog (should it be enabled?)
  82324. * @param mesh defines the mesh to evaluate for fog support
  82325. * @param scene defines the hosting scene
  82326. * @returns true if fog must be enabled
  82327. */
  82328. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82329. /**
  82330. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82331. * @param mesh defines the current mesh
  82332. * @param scene defines the current scene
  82333. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82334. * @param pointsCloud defines if point cloud rendering has to be turned on
  82335. * @param fogEnabled defines if fog has to be turned on
  82336. * @param alphaTest defines if alpha testing has to be turned on
  82337. * @param defines defines the current list of defines
  82338. */
  82339. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82340. /**
  82341. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82342. * @param scene defines the current scene
  82343. * @param engine defines the current engine
  82344. * @param defines specifies the list of active defines
  82345. * @param useInstances defines if instances have to be turned on
  82346. * @param useClipPlane defines if clip plane have to be turned on
  82347. */
  82348. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82349. /**
  82350. * Prepares the defines for bones
  82351. * @param mesh The mesh containing the geometry data we will draw
  82352. * @param defines The defines to update
  82353. */
  82354. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82355. /**
  82356. * Prepares the defines for morph targets
  82357. * @param mesh The mesh containing the geometry data we will draw
  82358. * @param defines The defines to update
  82359. */
  82360. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82361. /**
  82362. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82363. * @param mesh The mesh containing the geometry data we will draw
  82364. * @param defines The defines to update
  82365. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82366. * @param useBones Precise whether bones should be used or not (override mesh info)
  82367. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82368. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82369. * @returns false if defines are considered not dirty and have not been checked
  82370. */
  82371. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82372. /**
  82373. * Prepares the defines related to multiview
  82374. * @param scene The scene we are intending to draw
  82375. * @param defines The defines to update
  82376. */
  82377. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82378. /**
  82379. * Prepares the defines related to the light information passed in parameter
  82380. * @param scene The scene we are intending to draw
  82381. * @param mesh The mesh the effect is compiling for
  82382. * @param light The light the effect is compiling for
  82383. * @param lightIndex The index of the light
  82384. * @param defines The defines to update
  82385. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82386. * @param state Defines the current state regarding what is needed (normals, etc...)
  82387. */
  82388. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82389. needNormals: boolean;
  82390. needRebuild: boolean;
  82391. shadowEnabled: boolean;
  82392. specularEnabled: boolean;
  82393. lightmapMode: boolean;
  82394. }): void;
  82395. /**
  82396. * Prepares the defines related to the light information passed in parameter
  82397. * @param scene The scene we are intending to draw
  82398. * @param mesh The mesh the effect is compiling for
  82399. * @param defines The defines to update
  82400. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82401. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82402. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82403. * @returns true if normals will be required for the rest of the effect
  82404. */
  82405. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82406. /**
  82407. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82408. * @param lightIndex defines the light index
  82409. * @param uniformsList The uniform list
  82410. * @param samplersList The sampler list
  82411. * @param projectedLightTexture defines if projected texture must be used
  82412. * @param uniformBuffersList defines an optional list of uniform buffers
  82413. */
  82414. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82415. /**
  82416. * Prepares the uniforms and samplers list to be used in the effect
  82417. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82418. * @param samplersList The sampler list
  82419. * @param defines The defines helping in the list generation
  82420. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82421. */
  82422. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82423. /**
  82424. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82425. * @param defines The defines to update while falling back
  82426. * @param fallbacks The authorized effect fallbacks
  82427. * @param maxSimultaneousLights The maximum number of lights allowed
  82428. * @param rank the current rank of the Effect
  82429. * @returns The newly affected rank
  82430. */
  82431. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82432. private static _TmpMorphInfluencers;
  82433. /**
  82434. * Prepares the list of attributes required for morph targets according to the effect defines.
  82435. * @param attribs The current list of supported attribs
  82436. * @param mesh The mesh to prepare the morph targets attributes for
  82437. * @param influencers The number of influencers
  82438. */
  82439. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82440. /**
  82441. * Prepares the list of attributes required for morph targets according to the effect defines.
  82442. * @param attribs The current list of supported attribs
  82443. * @param mesh The mesh to prepare the morph targets attributes for
  82444. * @param defines The current Defines of the effect
  82445. */
  82446. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82447. /**
  82448. * Prepares the list of attributes required for bones according to the effect defines.
  82449. * @param attribs The current list of supported attribs
  82450. * @param mesh The mesh to prepare the bones attributes for
  82451. * @param defines The current Defines of the effect
  82452. * @param fallbacks The current efffect fallback strategy
  82453. */
  82454. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82455. /**
  82456. * Check and prepare the list of attributes required for instances according to the effect defines.
  82457. * @param attribs The current list of supported attribs
  82458. * @param defines The current MaterialDefines of the effect
  82459. */
  82460. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82461. /**
  82462. * Add the list of attributes required for instances to the attribs array.
  82463. * @param attribs The current list of supported attribs
  82464. */
  82465. static PushAttributesForInstances(attribs: string[]): void;
  82466. /**
  82467. * Binds the light information to the effect.
  82468. * @param light The light containing the generator
  82469. * @param effect The effect we are binding the data to
  82470. * @param lightIndex The light index in the effect used to render
  82471. */
  82472. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82473. /**
  82474. * Binds the lights information from the scene to the effect for the given mesh.
  82475. * @param light Light to bind
  82476. * @param lightIndex Light index
  82477. * @param scene The scene where the light belongs to
  82478. * @param effect The effect we are binding the data to
  82479. * @param useSpecular Defines if specular is supported
  82480. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82481. */
  82482. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82483. /**
  82484. * Binds the lights information from the scene to the effect for the given mesh.
  82485. * @param scene The scene the lights belongs to
  82486. * @param mesh The mesh we are binding the information to render
  82487. * @param effect The effect we are binding the data to
  82488. * @param defines The generated defines for the effect
  82489. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82490. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82491. */
  82492. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82493. private static _tempFogColor;
  82494. /**
  82495. * Binds the fog information from the scene to the effect for the given mesh.
  82496. * @param scene The scene the lights belongs to
  82497. * @param mesh The mesh we are binding the information to render
  82498. * @param effect The effect we are binding the data to
  82499. * @param linearSpace Defines if the fog effect is applied in linear space
  82500. */
  82501. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82502. /**
  82503. * Binds the bones information from the mesh to the effect.
  82504. * @param mesh The mesh we are binding the information to render
  82505. * @param effect The effect we are binding the data to
  82506. */
  82507. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82508. /**
  82509. * Binds the morph targets information from the mesh to the effect.
  82510. * @param abstractMesh The mesh we are binding the information to render
  82511. * @param effect The effect we are binding the data to
  82512. */
  82513. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82514. /**
  82515. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82516. * @param defines The generated defines used in the effect
  82517. * @param effect The effect we are binding the data to
  82518. * @param scene The scene we are willing to render with logarithmic scale for
  82519. */
  82520. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82521. /**
  82522. * Binds the clip plane information from the scene to the effect.
  82523. * @param scene The scene the clip plane information are extracted from
  82524. * @param effect The effect we are binding the data to
  82525. */
  82526. static BindClipPlane(effect: Effect, scene: Scene): void;
  82527. }
  82528. }
  82529. declare module BABYLON {
  82530. /** @hidden */
  82531. export var packingFunctions: {
  82532. name: string;
  82533. shader: string;
  82534. };
  82535. }
  82536. declare module BABYLON {
  82537. /** @hidden */
  82538. export var clipPlaneFragmentDeclaration: {
  82539. name: string;
  82540. shader: string;
  82541. };
  82542. }
  82543. declare module BABYLON {
  82544. /** @hidden */
  82545. export var clipPlaneFragment: {
  82546. name: string;
  82547. shader: string;
  82548. };
  82549. }
  82550. declare module BABYLON {
  82551. /** @hidden */
  82552. export var shadowMapPixelShader: {
  82553. name: string;
  82554. shader: string;
  82555. };
  82556. }
  82557. declare module BABYLON {
  82558. /** @hidden */
  82559. export var bonesDeclaration: {
  82560. name: string;
  82561. shader: string;
  82562. };
  82563. }
  82564. declare module BABYLON {
  82565. /** @hidden */
  82566. export var morphTargetsVertexGlobalDeclaration: {
  82567. name: string;
  82568. shader: string;
  82569. };
  82570. }
  82571. declare module BABYLON {
  82572. /** @hidden */
  82573. export var morphTargetsVertexDeclaration: {
  82574. name: string;
  82575. shader: string;
  82576. };
  82577. }
  82578. declare module BABYLON {
  82579. /** @hidden */
  82580. export var instancesDeclaration: {
  82581. name: string;
  82582. shader: string;
  82583. };
  82584. }
  82585. declare module BABYLON {
  82586. /** @hidden */
  82587. export var helperFunctions: {
  82588. name: string;
  82589. shader: string;
  82590. };
  82591. }
  82592. declare module BABYLON {
  82593. /** @hidden */
  82594. export var clipPlaneVertexDeclaration: {
  82595. name: string;
  82596. shader: string;
  82597. };
  82598. }
  82599. declare module BABYLON {
  82600. /** @hidden */
  82601. export var morphTargetsVertex: {
  82602. name: string;
  82603. shader: string;
  82604. };
  82605. }
  82606. declare module BABYLON {
  82607. /** @hidden */
  82608. export var instancesVertex: {
  82609. name: string;
  82610. shader: string;
  82611. };
  82612. }
  82613. declare module BABYLON {
  82614. /** @hidden */
  82615. export var bonesVertex: {
  82616. name: string;
  82617. shader: string;
  82618. };
  82619. }
  82620. declare module BABYLON {
  82621. /** @hidden */
  82622. export var clipPlaneVertex: {
  82623. name: string;
  82624. shader: string;
  82625. };
  82626. }
  82627. declare module BABYLON {
  82628. /** @hidden */
  82629. export var shadowMapVertexShader: {
  82630. name: string;
  82631. shader: string;
  82632. };
  82633. }
  82634. declare module BABYLON {
  82635. /** @hidden */
  82636. export var depthBoxBlurPixelShader: {
  82637. name: string;
  82638. shader: string;
  82639. };
  82640. }
  82641. declare module BABYLON {
  82642. /**
  82643. * Defines the options associated with the creation of a custom shader for a shadow generator.
  82644. */
  82645. export interface ICustomShaderOptions {
  82646. /**
  82647. * Gets or sets the custom shader name to use
  82648. */
  82649. shaderName: string;
  82650. /**
  82651. * The list of attribute names used in the shader
  82652. */
  82653. attributes?: string[];
  82654. /**
  82655. * The list of unifrom names used in the shader
  82656. */
  82657. uniforms?: string[];
  82658. /**
  82659. * The list of sampler names used in the shader
  82660. */
  82661. samplers?: string[];
  82662. /**
  82663. * The list of defines used in the shader
  82664. */
  82665. defines?: string[];
  82666. }
  82667. /**
  82668. * Interface to implement to create a shadow generator compatible with BJS.
  82669. */
  82670. export interface IShadowGenerator {
  82671. /**
  82672. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82673. * @returns The render target texture if present otherwise, null
  82674. */
  82675. getShadowMap(): Nullable<RenderTargetTexture>;
  82676. /**
  82677. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82678. * @param subMesh The submesh we want to render in the shadow map
  82679. * @param useInstances Defines wether will draw in the map using instances
  82680. * @returns true if ready otherwise, false
  82681. */
  82682. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82683. /**
  82684. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82685. * @param defines Defines of the material we want to update
  82686. * @param lightIndex Index of the light in the enabled light list of the material
  82687. */
  82688. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  82689. /**
  82690. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82691. * defined in the generator but impacting the effect).
  82692. * It implies the unifroms available on the materials are the standard BJS ones.
  82693. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82694. * @param effect The effect we are binfing the information for
  82695. */
  82696. bindShadowLight(lightIndex: string, effect: Effect): void;
  82697. /**
  82698. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82699. * (eq to shadow prjection matrix * light transform matrix)
  82700. * @returns The transform matrix used to create the shadow map
  82701. */
  82702. getTransformMatrix(): Matrix;
  82703. /**
  82704. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82705. * Cube and 2D textures for instance.
  82706. */
  82707. recreateShadowMap(): void;
  82708. /**
  82709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82710. * @param onCompiled Callback triggered at the and of the effects compilation
  82711. * @param options Sets of optional options forcing the compilation with different modes
  82712. */
  82713. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82714. useInstances: boolean;
  82715. }>): void;
  82716. /**
  82717. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82718. * @param options Sets of optional options forcing the compilation with different modes
  82719. * @returns A promise that resolves when the compilation completes
  82720. */
  82721. forceCompilationAsync(options?: Partial<{
  82722. useInstances: boolean;
  82723. }>): Promise<void>;
  82724. /**
  82725. * Serializes the shadow generator setup to a json object.
  82726. * @returns The serialized JSON object
  82727. */
  82728. serialize(): any;
  82729. /**
  82730. * Disposes the Shadow map and related Textures and effects.
  82731. */
  82732. dispose(): void;
  82733. }
  82734. /**
  82735. * Default implementation IShadowGenerator.
  82736. * This is the main object responsible of generating shadows in the framework.
  82737. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  82738. */
  82739. export class ShadowGenerator implements IShadowGenerator {
  82740. /**
  82741. * Name of the shadow generator class
  82742. */
  82743. static CLASSNAME: string;
  82744. /**
  82745. * Shadow generator mode None: no filtering applied.
  82746. */
  82747. static readonly FILTER_NONE: number;
  82748. /**
  82749. * Shadow generator mode ESM: Exponential Shadow Mapping.
  82750. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82751. */
  82752. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  82753. /**
  82754. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  82755. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  82756. */
  82757. static readonly FILTER_POISSONSAMPLING: number;
  82758. /**
  82759. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  82760. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82761. */
  82762. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  82763. /**
  82764. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  82765. * edge artifacts on steep falloff.
  82766. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82767. */
  82768. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  82769. /**
  82770. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  82771. * edge artifacts on steep falloff.
  82772. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82773. */
  82774. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  82775. /**
  82776. * Shadow generator mode PCF: Percentage Closer Filtering
  82777. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82778. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  82779. */
  82780. static readonly FILTER_PCF: number;
  82781. /**
  82782. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  82783. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82784. * Contact Hardening
  82785. */
  82786. static readonly FILTER_PCSS: number;
  82787. /**
  82788. * Reserved for PCF and PCSS
  82789. * Highest Quality.
  82790. *
  82791. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  82792. *
  82793. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  82794. */
  82795. static readonly QUALITY_HIGH: number;
  82796. /**
  82797. * Reserved for PCF and PCSS
  82798. * Good tradeoff for quality/perf cross devices
  82799. *
  82800. * Execute PCF on a 3*3 kernel.
  82801. *
  82802. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  82803. */
  82804. static readonly QUALITY_MEDIUM: number;
  82805. /**
  82806. * Reserved for PCF and PCSS
  82807. * The lowest quality but the fastest.
  82808. *
  82809. * Execute PCF on a 1*1 kernel.
  82810. *
  82811. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  82812. */
  82813. static readonly QUALITY_LOW: number;
  82814. /** Gets or sets the custom shader name to use */
  82815. customShaderOptions: ICustomShaderOptions;
  82816. /**
  82817. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  82818. */
  82819. onBeforeShadowMapRenderObservable: Observable<Effect>;
  82820. /**
  82821. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  82822. */
  82823. onAfterShadowMapRenderObservable: Observable<Effect>;
  82824. /**
  82825. * Observable triggered before a mesh is rendered in the shadow map.
  82826. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  82827. */
  82828. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  82829. /**
  82830. * Observable triggered after a mesh is rendered in the shadow map.
  82831. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  82832. */
  82833. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  82834. protected _bias: number;
  82835. /**
  82836. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  82837. */
  82838. get bias(): number;
  82839. /**
  82840. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  82841. */
  82842. set bias(bias: number);
  82843. protected _normalBias: number;
  82844. /**
  82845. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82846. */
  82847. get normalBias(): number;
  82848. /**
  82849. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82850. */
  82851. set normalBias(normalBias: number);
  82852. protected _blurBoxOffset: number;
  82853. /**
  82854. * Gets the blur box offset: offset applied during the blur pass.
  82855. * Only useful if useKernelBlur = false
  82856. */
  82857. get blurBoxOffset(): number;
  82858. /**
  82859. * Sets the blur box offset: offset applied during the blur pass.
  82860. * Only useful if useKernelBlur = false
  82861. */
  82862. set blurBoxOffset(value: number);
  82863. protected _blurScale: number;
  82864. /**
  82865. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  82866. * 2 means half of the size.
  82867. */
  82868. get blurScale(): number;
  82869. /**
  82870. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  82871. * 2 means half of the size.
  82872. */
  82873. set blurScale(value: number);
  82874. protected _blurKernel: number;
  82875. /**
  82876. * Gets the blur kernel: kernel size of the blur pass.
  82877. * Only useful if useKernelBlur = true
  82878. */
  82879. get blurKernel(): number;
  82880. /**
  82881. * Sets the blur kernel: kernel size of the blur pass.
  82882. * Only useful if useKernelBlur = true
  82883. */
  82884. set blurKernel(value: number);
  82885. protected _useKernelBlur: boolean;
  82886. /**
  82887. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  82888. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82889. */
  82890. get useKernelBlur(): boolean;
  82891. /**
  82892. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  82893. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82894. */
  82895. set useKernelBlur(value: boolean);
  82896. protected _depthScale: number;
  82897. /**
  82898. * Gets the depth scale used in ESM mode.
  82899. */
  82900. get depthScale(): number;
  82901. /**
  82902. * Sets the depth scale used in ESM mode.
  82903. * This can override the scale stored on the light.
  82904. */
  82905. set depthScale(value: number);
  82906. protected _validateFilter(filter: number): number;
  82907. protected _filter: number;
  82908. /**
  82909. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  82910. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82911. */
  82912. get filter(): number;
  82913. /**
  82914. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  82915. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82916. */
  82917. set filter(value: number);
  82918. /**
  82919. * Gets if the current filter is set to Poisson Sampling.
  82920. */
  82921. get usePoissonSampling(): boolean;
  82922. /**
  82923. * Sets the current filter to Poisson Sampling.
  82924. */
  82925. set usePoissonSampling(value: boolean);
  82926. /**
  82927. * Gets if the current filter is set to ESM.
  82928. */
  82929. get useExponentialShadowMap(): boolean;
  82930. /**
  82931. * Sets the current filter is to ESM.
  82932. */
  82933. set useExponentialShadowMap(value: boolean);
  82934. /**
  82935. * Gets if the current filter is set to filtered ESM.
  82936. */
  82937. get useBlurExponentialShadowMap(): boolean;
  82938. /**
  82939. * Gets if the current filter is set to filtered ESM.
  82940. */
  82941. set useBlurExponentialShadowMap(value: boolean);
  82942. /**
  82943. * Gets if the current filter is set to "close ESM" (using the inverse of the
  82944. * exponential to prevent steep falloff artifacts).
  82945. */
  82946. get useCloseExponentialShadowMap(): boolean;
  82947. /**
  82948. * Sets the current filter to "close ESM" (using the inverse of the
  82949. * exponential to prevent steep falloff artifacts).
  82950. */
  82951. set useCloseExponentialShadowMap(value: boolean);
  82952. /**
  82953. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  82954. * exponential to prevent steep falloff artifacts).
  82955. */
  82956. get useBlurCloseExponentialShadowMap(): boolean;
  82957. /**
  82958. * Sets the current filter to filtered "close ESM" (using the inverse of the
  82959. * exponential to prevent steep falloff artifacts).
  82960. */
  82961. set useBlurCloseExponentialShadowMap(value: boolean);
  82962. /**
  82963. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  82964. */
  82965. get usePercentageCloserFiltering(): boolean;
  82966. /**
  82967. * Sets the current filter to "PCF" (percentage closer filtering).
  82968. */
  82969. set usePercentageCloserFiltering(value: boolean);
  82970. protected _filteringQuality: number;
  82971. /**
  82972. * Gets the PCF or PCSS Quality.
  82973. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82974. */
  82975. get filteringQuality(): number;
  82976. /**
  82977. * Sets the PCF or PCSS Quality.
  82978. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82979. */
  82980. set filteringQuality(filteringQuality: number);
  82981. /**
  82982. * Gets if the current filter is set to "PCSS" (contact hardening).
  82983. */
  82984. get useContactHardeningShadow(): boolean;
  82985. /**
  82986. * Sets the current filter to "PCSS" (contact hardening).
  82987. */
  82988. set useContactHardeningShadow(value: boolean);
  82989. protected _contactHardeningLightSizeUVRatio: number;
  82990. /**
  82991. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82992. * Using a ratio helps keeping shape stability independently of the map size.
  82993. *
  82994. * It does not account for the light projection as it was having too much
  82995. * instability during the light setup or during light position changes.
  82996. *
  82997. * Only valid if useContactHardeningShadow is true.
  82998. */
  82999. get contactHardeningLightSizeUVRatio(): number;
  83000. /**
  83001. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  83002. * Using a ratio helps keeping shape stability independently of the map size.
  83003. *
  83004. * It does not account for the light projection as it was having too much
  83005. * instability during the light setup or during light position changes.
  83006. *
  83007. * Only valid if useContactHardeningShadow is true.
  83008. */
  83009. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  83010. protected _darkness: number;
  83011. /** Gets or sets the actual darkness of a shadow */
  83012. get darkness(): number;
  83013. set darkness(value: number);
  83014. /**
  83015. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  83016. * 0 means strongest and 1 would means no shadow.
  83017. * @returns the darkness.
  83018. */
  83019. getDarkness(): number;
  83020. /**
  83021. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  83022. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  83023. * @returns the shadow generator allowing fluent coding.
  83024. */
  83025. setDarkness(darkness: number): ShadowGenerator;
  83026. protected _transparencyShadow: boolean;
  83027. /** Gets or sets the ability to have transparent shadow */
  83028. get transparencyShadow(): boolean;
  83029. set transparencyShadow(value: boolean);
  83030. /**
  83031. * Sets the ability to have transparent shadow (boolean).
  83032. * @param transparent True if transparent else False
  83033. * @returns the shadow generator allowing fluent coding
  83034. */
  83035. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  83036. protected _shadowMap: Nullable<RenderTargetTexture>;
  83037. protected _shadowMap2: Nullable<RenderTargetTexture>;
  83038. /**
  83039. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  83040. * @returns The render target texture if present otherwise, null
  83041. */
  83042. getShadowMap(): Nullable<RenderTargetTexture>;
  83043. /**
  83044. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  83045. * @returns The render target texture if the shadow map is present otherwise, null
  83046. */
  83047. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  83048. /**
  83049. * Gets the class name of that object
  83050. * @returns "ShadowGenerator"
  83051. */
  83052. getClassName(): string;
  83053. /**
  83054. * Helper function to add a mesh and its descendants to the list of shadow casters.
  83055. * @param mesh Mesh to add
  83056. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  83057. * @returns the Shadow Generator itself
  83058. */
  83059. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  83060. /**
  83061. * Helper function to remove a mesh and its descendants from the list of shadow casters
  83062. * @param mesh Mesh to remove
  83063. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  83064. * @returns the Shadow Generator itself
  83065. */
  83066. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  83067. /**
  83068. * Controls the extent to which the shadows fade out at the edge of the frustum
  83069. */
  83070. frustumEdgeFalloff: number;
  83071. protected _light: IShadowLight;
  83072. /**
  83073. * Returns the associated light object.
  83074. * @returns the light generating the shadow
  83075. */
  83076. getLight(): IShadowLight;
  83077. /**
  83078. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  83079. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  83080. * It might on the other hand introduce peter panning.
  83081. */
  83082. forceBackFacesOnly: boolean;
  83083. protected _scene: Scene;
  83084. protected _lightDirection: Vector3;
  83085. protected _effect: Effect;
  83086. protected _viewMatrix: Matrix;
  83087. protected _projectionMatrix: Matrix;
  83088. protected _transformMatrix: Matrix;
  83089. protected _cachedPosition: Vector3;
  83090. protected _cachedDirection: Vector3;
  83091. protected _cachedDefines: string;
  83092. protected _currentRenderID: number;
  83093. protected _boxBlurPostprocess: Nullable<PostProcess>;
  83094. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  83095. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  83096. protected _blurPostProcesses: PostProcess[];
  83097. protected _mapSize: number;
  83098. protected _currentFaceIndex: number;
  83099. protected _currentFaceIndexCache: number;
  83100. protected _textureType: number;
  83101. protected _defaultTextureMatrix: Matrix;
  83102. protected _storedUniqueId: Nullable<number>;
  83103. /** @hidden */
  83104. static _SceneComponentInitialization: (scene: Scene) => void;
  83105. /**
  83106. * Creates a ShadowGenerator object.
  83107. * A ShadowGenerator is the required tool to use the shadows.
  83108. * Each light casting shadows needs to use its own ShadowGenerator.
  83109. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  83110. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  83111. * @param light The light object generating the shadows.
  83112. * @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.
  83113. */
  83114. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  83115. protected _initializeGenerator(): void;
  83116. protected _createTargetRenderTexture(): void;
  83117. protected _initializeShadowMap(): void;
  83118. protected _initializeBlurRTTAndPostProcesses(): void;
  83119. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  83120. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  83121. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  83122. protected _applyFilterValues(): void;
  83123. /**
  83124. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  83125. * @param onCompiled Callback triggered at the and of the effects compilation
  83126. * @param options Sets of optional options forcing the compilation with different modes
  83127. */
  83128. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  83129. useInstances: boolean;
  83130. }>): void;
  83131. /**
  83132. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  83133. * @param options Sets of optional options forcing the compilation with different modes
  83134. * @returns A promise that resolves when the compilation completes
  83135. */
  83136. forceCompilationAsync(options?: Partial<{
  83137. useInstances: boolean;
  83138. }>): Promise<void>;
  83139. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  83140. /**
  83141. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  83142. * @param subMesh The submesh we want to render in the shadow map
  83143. * @param useInstances Defines wether will draw in the map using instances
  83144. * @returns true if ready otherwise, false
  83145. */
  83146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  83147. /**
  83148. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  83149. * @param defines Defines of the material we want to update
  83150. * @param lightIndex Index of the light in the enabled light list of the material
  83151. */
  83152. prepareDefines(defines: any, lightIndex: number): void;
  83153. /**
  83154. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  83155. * defined in the generator but impacting the effect).
  83156. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  83157. * @param effect The effect we are binfing the information for
  83158. */
  83159. bindShadowLight(lightIndex: string, effect: Effect): void;
  83160. /**
  83161. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  83162. * (eq to shadow prjection matrix * light transform matrix)
  83163. * @returns The transform matrix used to create the shadow map
  83164. */
  83165. getTransformMatrix(): Matrix;
  83166. /**
  83167. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  83168. * Cube and 2D textures for instance.
  83169. */
  83170. recreateShadowMap(): void;
  83171. protected _disposeBlurPostProcesses(): void;
  83172. protected _disposeRTTandPostProcesses(): void;
  83173. /**
  83174. * Disposes the ShadowGenerator.
  83175. * Returns nothing.
  83176. */
  83177. dispose(): void;
  83178. /**
  83179. * Serializes the shadow generator setup to a json object.
  83180. * @returns The serialized JSON object
  83181. */
  83182. serialize(): any;
  83183. /**
  83184. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  83185. * @param parsedShadowGenerator The JSON object to parse
  83186. * @param scene The scene to create the shadow map for
  83187. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  83188. * @returns The parsed shadow generator
  83189. */
  83190. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  83191. }
  83192. }
  83193. declare module BABYLON {
  83194. /**
  83195. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  83196. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  83197. * 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.
  83198. */
  83199. export abstract class Light extends Node {
  83200. /**
  83201. * Falloff Default: light is falling off following the material specification:
  83202. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  83203. */
  83204. static readonly FALLOFF_DEFAULT: number;
  83205. /**
  83206. * Falloff Physical: light is falling off following the inverse squared distance law.
  83207. */
  83208. static readonly FALLOFF_PHYSICAL: number;
  83209. /**
  83210. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  83211. * to enhance interoperability with other engines.
  83212. */
  83213. static readonly FALLOFF_GLTF: number;
  83214. /**
  83215. * Falloff Standard: light is falling off like in the standard material
  83216. * to enhance interoperability with other materials.
  83217. */
  83218. static readonly FALLOFF_STANDARD: number;
  83219. /**
  83220. * If every light affecting the material is in this lightmapMode,
  83221. * material.lightmapTexture adds or multiplies
  83222. * (depends on material.useLightmapAsShadowmap)
  83223. * after every other light calculations.
  83224. */
  83225. static readonly LIGHTMAP_DEFAULT: number;
  83226. /**
  83227. * material.lightmapTexture as only diffuse lighting from this light
  83228. * adds only specular lighting from this light
  83229. * adds dynamic shadows
  83230. */
  83231. static readonly LIGHTMAP_SPECULAR: number;
  83232. /**
  83233. * material.lightmapTexture as only lighting
  83234. * no light calculation from this light
  83235. * only adds dynamic shadows from this light
  83236. */
  83237. static readonly LIGHTMAP_SHADOWSONLY: number;
  83238. /**
  83239. * Each light type uses the default quantity according to its type:
  83240. * point/spot lights use luminous intensity
  83241. * directional lights use illuminance
  83242. */
  83243. static readonly INTENSITYMODE_AUTOMATIC: number;
  83244. /**
  83245. * lumen (lm)
  83246. */
  83247. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  83248. /**
  83249. * candela (lm/sr)
  83250. */
  83251. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  83252. /**
  83253. * lux (lm/m^2)
  83254. */
  83255. static readonly INTENSITYMODE_ILLUMINANCE: number;
  83256. /**
  83257. * nit (cd/m^2)
  83258. */
  83259. static readonly INTENSITYMODE_LUMINANCE: number;
  83260. /**
  83261. * Light type const id of the point light.
  83262. */
  83263. static readonly LIGHTTYPEID_POINTLIGHT: number;
  83264. /**
  83265. * Light type const id of the directional light.
  83266. */
  83267. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  83268. /**
  83269. * Light type const id of the spot light.
  83270. */
  83271. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  83272. /**
  83273. * Light type const id of the hemispheric light.
  83274. */
  83275. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  83276. /**
  83277. * Diffuse gives the basic color to an object.
  83278. */
  83279. diffuse: Color3;
  83280. /**
  83281. * Specular produces a highlight color on an object.
  83282. * Note: This is note affecting PBR materials.
  83283. */
  83284. specular: Color3;
  83285. /**
  83286. * Defines the falloff type for this light. This lets overrriding how punctual light are
  83287. * falling off base on range or angle.
  83288. * This can be set to any values in Light.FALLOFF_x.
  83289. *
  83290. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  83291. * other types of materials.
  83292. */
  83293. falloffType: number;
  83294. /**
  83295. * Strength of the light.
  83296. * Note: By default it is define in the framework own unit.
  83297. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  83298. */
  83299. intensity: number;
  83300. private _range;
  83301. protected _inverseSquaredRange: number;
  83302. /**
  83303. * Defines how far from the source the light is impacting in scene units.
  83304. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  83305. */
  83306. get range(): number;
  83307. /**
  83308. * Defines how far from the source the light is impacting in scene units.
  83309. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  83310. */
  83311. set range(value: number);
  83312. /**
  83313. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  83314. * of light.
  83315. */
  83316. private _photometricScale;
  83317. private _intensityMode;
  83318. /**
  83319. * Gets the photometric scale used to interpret the intensity.
  83320. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  83321. */
  83322. get intensityMode(): number;
  83323. /**
  83324. * Sets the photometric scale used to interpret the intensity.
  83325. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  83326. */
  83327. set intensityMode(value: number);
  83328. private _radius;
  83329. /**
  83330. * Gets the light radius used by PBR Materials to simulate soft area lights.
  83331. */
  83332. get radius(): number;
  83333. /**
  83334. * sets the light radius used by PBR Materials to simulate soft area lights.
  83335. */
  83336. set radius(value: number);
  83337. private _renderPriority;
  83338. /**
  83339. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  83340. * exceeding the number allowed of the materials.
  83341. */
  83342. renderPriority: number;
  83343. private _shadowEnabled;
  83344. /**
  83345. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  83346. * the current shadow generator.
  83347. */
  83348. get shadowEnabled(): boolean;
  83349. /**
  83350. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  83351. * the current shadow generator.
  83352. */
  83353. set shadowEnabled(value: boolean);
  83354. private _includedOnlyMeshes;
  83355. /**
  83356. * Gets the only meshes impacted by this light.
  83357. */
  83358. get includedOnlyMeshes(): AbstractMesh[];
  83359. /**
  83360. * Sets the only meshes impacted by this light.
  83361. */
  83362. set includedOnlyMeshes(value: AbstractMesh[]);
  83363. private _excludedMeshes;
  83364. /**
  83365. * Gets the meshes not impacted by this light.
  83366. */
  83367. get excludedMeshes(): AbstractMesh[];
  83368. /**
  83369. * Sets the meshes not impacted by this light.
  83370. */
  83371. set excludedMeshes(value: AbstractMesh[]);
  83372. private _excludeWithLayerMask;
  83373. /**
  83374. * Gets the layer id use to find what meshes are not impacted by the light.
  83375. * Inactive if 0
  83376. */
  83377. get excludeWithLayerMask(): number;
  83378. /**
  83379. * Sets the layer id use to find what meshes are not impacted by the light.
  83380. * Inactive if 0
  83381. */
  83382. set excludeWithLayerMask(value: number);
  83383. private _includeOnlyWithLayerMask;
  83384. /**
  83385. * Gets the layer id use to find what meshes are impacted by the light.
  83386. * Inactive if 0
  83387. */
  83388. get includeOnlyWithLayerMask(): number;
  83389. /**
  83390. * Sets the layer id use to find what meshes are impacted by the light.
  83391. * Inactive if 0
  83392. */
  83393. set includeOnlyWithLayerMask(value: number);
  83394. private _lightmapMode;
  83395. /**
  83396. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  83397. */
  83398. get lightmapMode(): number;
  83399. /**
  83400. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  83401. */
  83402. set lightmapMode(value: number);
  83403. /**
  83404. * Shadow generator associted to the light.
  83405. * @hidden Internal use only.
  83406. */
  83407. _shadowGenerator: Nullable<IShadowGenerator>;
  83408. /**
  83409. * @hidden Internal use only.
  83410. */
  83411. _excludedMeshesIds: string[];
  83412. /**
  83413. * @hidden Internal use only.
  83414. */
  83415. _includedOnlyMeshesIds: string[];
  83416. /**
  83417. * The current light unifom buffer.
  83418. * @hidden Internal use only.
  83419. */
  83420. _uniformBuffer: UniformBuffer;
  83421. /** @hidden */
  83422. _renderId: number;
  83423. /**
  83424. * Creates a Light object in the scene.
  83425. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83426. * @param name The firendly name of the light
  83427. * @param scene The scene the light belongs too
  83428. */
  83429. constructor(name: string, scene: Scene);
  83430. protected abstract _buildUniformLayout(): void;
  83431. /**
  83432. * Sets the passed Effect "effect" with the Light information.
  83433. * @param effect The effect to update
  83434. * @param lightIndex The index of the light in the effect to update
  83435. * @returns The light
  83436. */
  83437. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  83438. /**
  83439. * Sets the passed Effect "effect" with the Light textures.
  83440. * @param effect The effect to update
  83441. * @param lightIndex The index of the light in the effect to update
  83442. * @returns The light
  83443. */
  83444. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  83445. /**
  83446. * Binds the lights information from the scene to the effect for the given mesh.
  83447. * @param lightIndex Light index
  83448. * @param scene The scene where the light belongs to
  83449. * @param effect The effect we are binding the data to
  83450. * @param useSpecular Defines if specular is supported
  83451. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83452. */
  83453. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83454. /**
  83455. * Sets the passed Effect "effect" with the Light information.
  83456. * @param effect The effect to update
  83457. * @param lightDataUniformName The uniform used to store light data (position or direction)
  83458. * @returns The light
  83459. */
  83460. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  83461. /**
  83462. * Returns the string "Light".
  83463. * @returns the class name
  83464. */
  83465. getClassName(): string;
  83466. /** @hidden */
  83467. readonly _isLight: boolean;
  83468. /**
  83469. * Converts the light information to a readable string for debug purpose.
  83470. * @param fullDetails Supports for multiple levels of logging within scene loading
  83471. * @returns the human readable light info
  83472. */
  83473. toString(fullDetails?: boolean): string;
  83474. /** @hidden */
  83475. protected _syncParentEnabledState(): void;
  83476. /**
  83477. * Set the enabled state of this node.
  83478. * @param value - the new enabled state
  83479. */
  83480. setEnabled(value: boolean): void;
  83481. /**
  83482. * Returns the Light associated shadow generator if any.
  83483. * @return the associated shadow generator.
  83484. */
  83485. getShadowGenerator(): Nullable<IShadowGenerator>;
  83486. /**
  83487. * Returns a Vector3, the absolute light position in the World.
  83488. * @returns the world space position of the light
  83489. */
  83490. getAbsolutePosition(): Vector3;
  83491. /**
  83492. * Specifies if the light will affect the passed mesh.
  83493. * @param mesh The mesh to test against the light
  83494. * @return true the mesh is affected otherwise, false.
  83495. */
  83496. canAffectMesh(mesh: AbstractMesh): boolean;
  83497. /**
  83498. * Sort function to order lights for rendering.
  83499. * @param a First Light object to compare to second.
  83500. * @param b Second Light object to compare first.
  83501. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  83502. */
  83503. static CompareLightsPriority(a: Light, b: Light): number;
  83504. /**
  83505. * Releases resources associated with this node.
  83506. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83507. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83508. */
  83509. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83510. /**
  83511. * Returns the light type ID (integer).
  83512. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83513. */
  83514. getTypeID(): number;
  83515. /**
  83516. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  83517. * @returns the scaled intensity in intensity mode unit
  83518. */
  83519. getScaledIntensity(): number;
  83520. /**
  83521. * Returns a new Light object, named "name", from the current one.
  83522. * @param name The name of the cloned light
  83523. * @returns the new created light
  83524. */
  83525. clone(name: string): Nullable<Light>;
  83526. /**
  83527. * Serializes the current light into a Serialization object.
  83528. * @returns the serialized object.
  83529. */
  83530. serialize(): any;
  83531. /**
  83532. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  83533. * This new light is named "name" and added to the passed scene.
  83534. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  83535. * @param name The friendly name of the light
  83536. * @param scene The scene the new light will belong to
  83537. * @returns the constructor function
  83538. */
  83539. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  83540. /**
  83541. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  83542. * @param parsedLight The JSON representation of the light
  83543. * @param scene The scene to create the parsed light in
  83544. * @returns the created light after parsing
  83545. */
  83546. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  83547. private _hookArrayForExcluded;
  83548. private _hookArrayForIncludedOnly;
  83549. private _resyncMeshes;
  83550. /**
  83551. * Forces the meshes to update their light related information in their rendering used effects
  83552. * @hidden Internal Use Only
  83553. */
  83554. _markMeshesAsLightDirty(): void;
  83555. /**
  83556. * Recomputes the cached photometric scale if needed.
  83557. */
  83558. private _computePhotometricScale;
  83559. /**
  83560. * Returns the Photometric Scale according to the light type and intensity mode.
  83561. */
  83562. private _getPhotometricScale;
  83563. /**
  83564. * Reorder the light in the scene according to their defined priority.
  83565. * @hidden Internal Use Only
  83566. */
  83567. _reorderLightsInScene(): void;
  83568. /**
  83569. * Prepares the list of defines specific to the light type.
  83570. * @param defines the list of defines
  83571. * @param lightIndex defines the index of the light for the effect
  83572. */
  83573. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83574. }
  83575. }
  83576. declare module BABYLON {
  83577. /**
  83578. * Interface used to define Action
  83579. */
  83580. export interface IAction {
  83581. /**
  83582. * Trigger for the action
  83583. */
  83584. trigger: number;
  83585. /** Options of the trigger */
  83586. triggerOptions: any;
  83587. /**
  83588. * Gets the trigger parameters
  83589. * @returns the trigger parameters
  83590. */
  83591. getTriggerParameter(): any;
  83592. /**
  83593. * Internal only - executes current action event
  83594. * @hidden
  83595. */
  83596. _executeCurrent(evt?: ActionEvent): void;
  83597. /**
  83598. * Serialize placeholder for child classes
  83599. * @param parent of child
  83600. * @returns the serialized object
  83601. */
  83602. serialize(parent: any): any;
  83603. /**
  83604. * Internal only
  83605. * @hidden
  83606. */
  83607. _prepare(): void;
  83608. /**
  83609. * Internal only - manager for action
  83610. * @hidden
  83611. */
  83612. _actionManager: AbstractActionManager;
  83613. /**
  83614. * Adds action to chain of actions, may be a DoNothingAction
  83615. * @param action defines the next action to execute
  83616. * @returns The action passed in
  83617. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83618. */
  83619. then(action: IAction): IAction;
  83620. }
  83621. /**
  83622. * The action to be carried out following a trigger
  83623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  83624. */
  83625. export class Action implements IAction {
  83626. /** the trigger, with or without parameters, for the action */
  83627. triggerOptions: any;
  83628. /**
  83629. * Trigger for the action
  83630. */
  83631. trigger: number;
  83632. /**
  83633. * Internal only - manager for action
  83634. * @hidden
  83635. */
  83636. _actionManager: ActionManager;
  83637. private _nextActiveAction;
  83638. private _child;
  83639. private _condition?;
  83640. private _triggerParameter;
  83641. /**
  83642. * An event triggered prior to action being executed.
  83643. */
  83644. onBeforeExecuteObservable: Observable<Action>;
  83645. /**
  83646. * Creates a new Action
  83647. * @param triggerOptions the trigger, with or without parameters, for the action
  83648. * @param condition an optional determinant of action
  83649. */
  83650. constructor(
  83651. /** the trigger, with or without parameters, for the action */
  83652. triggerOptions: any, condition?: Condition);
  83653. /**
  83654. * Internal only
  83655. * @hidden
  83656. */
  83657. _prepare(): void;
  83658. /**
  83659. * Gets the trigger parameters
  83660. * @returns the trigger parameters
  83661. */
  83662. getTriggerParameter(): any;
  83663. /**
  83664. * Internal only - executes current action event
  83665. * @hidden
  83666. */
  83667. _executeCurrent(evt?: ActionEvent): void;
  83668. /**
  83669. * Execute placeholder for child classes
  83670. * @param evt optional action event
  83671. */
  83672. execute(evt?: ActionEvent): void;
  83673. /**
  83674. * Skips to next active action
  83675. */
  83676. skipToNextActiveAction(): void;
  83677. /**
  83678. * Adds action to chain of actions, may be a DoNothingAction
  83679. * @param action defines the next action to execute
  83680. * @returns The action passed in
  83681. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83682. */
  83683. then(action: Action): Action;
  83684. /**
  83685. * Internal only
  83686. * @hidden
  83687. */
  83688. _getProperty(propertyPath: string): string;
  83689. /**
  83690. * Internal only
  83691. * @hidden
  83692. */
  83693. _getEffectiveTarget(target: any, propertyPath: string): any;
  83694. /**
  83695. * Serialize placeholder for child classes
  83696. * @param parent of child
  83697. * @returns the serialized object
  83698. */
  83699. serialize(parent: any): any;
  83700. /**
  83701. * Internal only called by serialize
  83702. * @hidden
  83703. */
  83704. protected _serialize(serializedAction: any, parent?: any): any;
  83705. /**
  83706. * Internal only
  83707. * @hidden
  83708. */
  83709. static _SerializeValueAsString: (value: any) => string;
  83710. /**
  83711. * Internal only
  83712. * @hidden
  83713. */
  83714. static _GetTargetProperty: (target: Node | Scene) => {
  83715. name: string;
  83716. targetType: string;
  83717. value: string;
  83718. };
  83719. }
  83720. }
  83721. declare module BABYLON {
  83722. /**
  83723. * A Condition applied to an Action
  83724. */
  83725. export class Condition {
  83726. /**
  83727. * Internal only - manager for action
  83728. * @hidden
  83729. */
  83730. _actionManager: ActionManager;
  83731. /**
  83732. * Internal only
  83733. * @hidden
  83734. */
  83735. _evaluationId: number;
  83736. /**
  83737. * Internal only
  83738. * @hidden
  83739. */
  83740. _currentResult: boolean;
  83741. /**
  83742. * Creates a new Condition
  83743. * @param actionManager the manager of the action the condition is applied to
  83744. */
  83745. constructor(actionManager: ActionManager);
  83746. /**
  83747. * Check if the current condition is valid
  83748. * @returns a boolean
  83749. */
  83750. isValid(): boolean;
  83751. /**
  83752. * Internal only
  83753. * @hidden
  83754. */
  83755. _getProperty(propertyPath: string): string;
  83756. /**
  83757. * Internal only
  83758. * @hidden
  83759. */
  83760. _getEffectiveTarget(target: any, propertyPath: string): any;
  83761. /**
  83762. * Serialize placeholder for child classes
  83763. * @returns the serialized object
  83764. */
  83765. serialize(): any;
  83766. /**
  83767. * Internal only
  83768. * @hidden
  83769. */
  83770. protected _serialize(serializedCondition: any): any;
  83771. }
  83772. /**
  83773. * Defines specific conditional operators as extensions of Condition
  83774. */
  83775. export class ValueCondition extends Condition {
  83776. /** path to specify the property of the target the conditional operator uses */
  83777. propertyPath: string;
  83778. /** the value compared by the conditional operator against the current value of the property */
  83779. value: any;
  83780. /** the conditional operator, default ValueCondition.IsEqual */
  83781. operator: number;
  83782. /**
  83783. * Internal only
  83784. * @hidden
  83785. */
  83786. private static _IsEqual;
  83787. /**
  83788. * Internal only
  83789. * @hidden
  83790. */
  83791. private static _IsDifferent;
  83792. /**
  83793. * Internal only
  83794. * @hidden
  83795. */
  83796. private static _IsGreater;
  83797. /**
  83798. * Internal only
  83799. * @hidden
  83800. */
  83801. private static _IsLesser;
  83802. /**
  83803. * returns the number for IsEqual
  83804. */
  83805. static get IsEqual(): number;
  83806. /**
  83807. * Returns the number for IsDifferent
  83808. */
  83809. static get IsDifferent(): number;
  83810. /**
  83811. * Returns the number for IsGreater
  83812. */
  83813. static get IsGreater(): number;
  83814. /**
  83815. * Returns the number for IsLesser
  83816. */
  83817. static get IsLesser(): number;
  83818. /**
  83819. * Internal only The action manager for the condition
  83820. * @hidden
  83821. */
  83822. _actionManager: ActionManager;
  83823. /**
  83824. * Internal only
  83825. * @hidden
  83826. */
  83827. private _target;
  83828. /**
  83829. * Internal only
  83830. * @hidden
  83831. */
  83832. private _effectiveTarget;
  83833. /**
  83834. * Internal only
  83835. * @hidden
  83836. */
  83837. private _property;
  83838. /**
  83839. * Creates a new ValueCondition
  83840. * @param actionManager manager for the action the condition applies to
  83841. * @param target for the action
  83842. * @param propertyPath path to specify the property of the target the conditional operator uses
  83843. * @param value the value compared by the conditional operator against the current value of the property
  83844. * @param operator the conditional operator, default ValueCondition.IsEqual
  83845. */
  83846. constructor(actionManager: ActionManager, target: any,
  83847. /** path to specify the property of the target the conditional operator uses */
  83848. propertyPath: string,
  83849. /** the value compared by the conditional operator against the current value of the property */
  83850. value: any,
  83851. /** the conditional operator, default ValueCondition.IsEqual */
  83852. operator?: number);
  83853. /**
  83854. * Compares the given value with the property value for the specified conditional operator
  83855. * @returns the result of the comparison
  83856. */
  83857. isValid(): boolean;
  83858. /**
  83859. * Serialize the ValueCondition into a JSON compatible object
  83860. * @returns serialization object
  83861. */
  83862. serialize(): any;
  83863. /**
  83864. * Gets the name of the conditional operator for the ValueCondition
  83865. * @param operator the conditional operator
  83866. * @returns the name
  83867. */
  83868. static GetOperatorName(operator: number): string;
  83869. }
  83870. /**
  83871. * Defines a predicate condition as an extension of Condition
  83872. */
  83873. export class PredicateCondition extends Condition {
  83874. /** defines the predicate function used to validate the condition */
  83875. predicate: () => boolean;
  83876. /**
  83877. * Internal only - manager for action
  83878. * @hidden
  83879. */
  83880. _actionManager: ActionManager;
  83881. /**
  83882. * Creates a new PredicateCondition
  83883. * @param actionManager manager for the action the condition applies to
  83884. * @param predicate defines the predicate function used to validate the condition
  83885. */
  83886. constructor(actionManager: ActionManager,
  83887. /** defines the predicate function used to validate the condition */
  83888. predicate: () => boolean);
  83889. /**
  83890. * @returns the validity of the predicate condition
  83891. */
  83892. isValid(): boolean;
  83893. }
  83894. /**
  83895. * Defines a state condition as an extension of Condition
  83896. */
  83897. export class StateCondition extends Condition {
  83898. /** Value to compare with target state */
  83899. value: string;
  83900. /**
  83901. * Internal only - manager for action
  83902. * @hidden
  83903. */
  83904. _actionManager: ActionManager;
  83905. /**
  83906. * Internal only
  83907. * @hidden
  83908. */
  83909. private _target;
  83910. /**
  83911. * Creates a new StateCondition
  83912. * @param actionManager manager for the action the condition applies to
  83913. * @param target of the condition
  83914. * @param value to compare with target state
  83915. */
  83916. constructor(actionManager: ActionManager, target: any,
  83917. /** Value to compare with target state */
  83918. value: string);
  83919. /**
  83920. * Gets a boolean indicating if the current condition is met
  83921. * @returns the validity of the state
  83922. */
  83923. isValid(): boolean;
  83924. /**
  83925. * Serialize the StateCondition into a JSON compatible object
  83926. * @returns serialization object
  83927. */
  83928. serialize(): any;
  83929. }
  83930. }
  83931. declare module BABYLON {
  83932. /**
  83933. * This defines an action responsible to toggle a boolean once triggered.
  83934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83935. */
  83936. export class SwitchBooleanAction extends Action {
  83937. /**
  83938. * The path to the boolean property in the target object
  83939. */
  83940. propertyPath: string;
  83941. private _target;
  83942. private _effectiveTarget;
  83943. private _property;
  83944. /**
  83945. * Instantiate the action
  83946. * @param triggerOptions defines the trigger options
  83947. * @param target defines the object containing the boolean
  83948. * @param propertyPath defines the path to the boolean property in the target object
  83949. * @param condition defines the trigger related conditions
  83950. */
  83951. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  83952. /** @hidden */
  83953. _prepare(): void;
  83954. /**
  83955. * Execute the action toggle the boolean value.
  83956. */
  83957. execute(): void;
  83958. /**
  83959. * Serializes the actions and its related information.
  83960. * @param parent defines the object to serialize in
  83961. * @returns the serialized object
  83962. */
  83963. serialize(parent: any): any;
  83964. }
  83965. /**
  83966. * This defines an action responsible to set a the state field of the target
  83967. * to a desired value once triggered.
  83968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83969. */
  83970. export class SetStateAction extends Action {
  83971. /**
  83972. * The value to store in the state field.
  83973. */
  83974. value: string;
  83975. private _target;
  83976. /**
  83977. * Instantiate the action
  83978. * @param triggerOptions defines the trigger options
  83979. * @param target defines the object containing the state property
  83980. * @param value defines the value to store in the state field
  83981. * @param condition defines the trigger related conditions
  83982. */
  83983. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  83984. /**
  83985. * Execute the action and store the value on the target state property.
  83986. */
  83987. execute(): void;
  83988. /**
  83989. * Serializes the actions and its related information.
  83990. * @param parent defines the object to serialize in
  83991. * @returns the serialized object
  83992. */
  83993. serialize(parent: any): any;
  83994. }
  83995. /**
  83996. * This defines an action responsible to set a property of the target
  83997. * to a desired value once triggered.
  83998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83999. */
  84000. export class SetValueAction extends Action {
  84001. /**
  84002. * The path of the property to set in the target.
  84003. */
  84004. propertyPath: string;
  84005. /**
  84006. * The value to set in the property
  84007. */
  84008. value: any;
  84009. private _target;
  84010. private _effectiveTarget;
  84011. private _property;
  84012. /**
  84013. * Instantiate the action
  84014. * @param triggerOptions defines the trigger options
  84015. * @param target defines the object containing the property
  84016. * @param propertyPath defines the path of the property to set in the target
  84017. * @param value defines the value to set in the property
  84018. * @param condition defines the trigger related conditions
  84019. */
  84020. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  84021. /** @hidden */
  84022. _prepare(): void;
  84023. /**
  84024. * Execute the action and set the targetted property to the desired value.
  84025. */
  84026. execute(): void;
  84027. /**
  84028. * Serializes the actions and its related information.
  84029. * @param parent defines the object to serialize in
  84030. * @returns the serialized object
  84031. */
  84032. serialize(parent: any): any;
  84033. }
  84034. /**
  84035. * This defines an action responsible to increment the target value
  84036. * to a desired value once triggered.
  84037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84038. */
  84039. export class IncrementValueAction extends Action {
  84040. /**
  84041. * The path of the property to increment in the target.
  84042. */
  84043. propertyPath: string;
  84044. /**
  84045. * The value we should increment the property by.
  84046. */
  84047. value: any;
  84048. private _target;
  84049. private _effectiveTarget;
  84050. private _property;
  84051. /**
  84052. * Instantiate the action
  84053. * @param triggerOptions defines the trigger options
  84054. * @param target defines the object containing the property
  84055. * @param propertyPath defines the path of the property to increment in the target
  84056. * @param value defines the value value we should increment the property by
  84057. * @param condition defines the trigger related conditions
  84058. */
  84059. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  84060. /** @hidden */
  84061. _prepare(): void;
  84062. /**
  84063. * Execute the action and increment the target of the value amount.
  84064. */
  84065. execute(): void;
  84066. /**
  84067. * Serializes the actions and its related information.
  84068. * @param parent defines the object to serialize in
  84069. * @returns the serialized object
  84070. */
  84071. serialize(parent: any): any;
  84072. }
  84073. /**
  84074. * This defines an action responsible to start an animation once triggered.
  84075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84076. */
  84077. export class PlayAnimationAction extends Action {
  84078. /**
  84079. * Where the animation should start (animation frame)
  84080. */
  84081. from: number;
  84082. /**
  84083. * Where the animation should stop (animation frame)
  84084. */
  84085. to: number;
  84086. /**
  84087. * Define if the animation should loop or stop after the first play.
  84088. */
  84089. loop?: boolean;
  84090. private _target;
  84091. /**
  84092. * Instantiate the action
  84093. * @param triggerOptions defines the trigger options
  84094. * @param target defines the target animation or animation name
  84095. * @param from defines from where the animation should start (animation frame)
  84096. * @param end defines where the animation should stop (animation frame)
  84097. * @param loop defines if the animation should loop or stop after the first play
  84098. * @param condition defines the trigger related conditions
  84099. */
  84100. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  84101. /** @hidden */
  84102. _prepare(): void;
  84103. /**
  84104. * Execute the action and play the animation.
  84105. */
  84106. execute(): void;
  84107. /**
  84108. * Serializes the actions and its related information.
  84109. * @param parent defines the object to serialize in
  84110. * @returns the serialized object
  84111. */
  84112. serialize(parent: any): any;
  84113. }
  84114. /**
  84115. * This defines an action responsible to stop an animation once triggered.
  84116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84117. */
  84118. export class StopAnimationAction extends Action {
  84119. private _target;
  84120. /**
  84121. * Instantiate the action
  84122. * @param triggerOptions defines the trigger options
  84123. * @param target defines the target animation or animation name
  84124. * @param condition defines the trigger related conditions
  84125. */
  84126. constructor(triggerOptions: any, target: any, condition?: Condition);
  84127. /** @hidden */
  84128. _prepare(): void;
  84129. /**
  84130. * Execute the action and stop the animation.
  84131. */
  84132. execute(): void;
  84133. /**
  84134. * Serializes the actions and its related information.
  84135. * @param parent defines the object to serialize in
  84136. * @returns the serialized object
  84137. */
  84138. serialize(parent: any): any;
  84139. }
  84140. /**
  84141. * This defines an action responsible that does nothing once triggered.
  84142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84143. */
  84144. export class DoNothingAction extends Action {
  84145. /**
  84146. * Instantiate the action
  84147. * @param triggerOptions defines the trigger options
  84148. * @param condition defines the trigger related conditions
  84149. */
  84150. constructor(triggerOptions?: any, condition?: Condition);
  84151. /**
  84152. * Execute the action and do nothing.
  84153. */
  84154. execute(): void;
  84155. /**
  84156. * Serializes the actions and its related information.
  84157. * @param parent defines the object to serialize in
  84158. * @returns the serialized object
  84159. */
  84160. serialize(parent: any): any;
  84161. }
  84162. /**
  84163. * This defines an action responsible to trigger several actions once triggered.
  84164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84165. */
  84166. export class CombineAction extends Action {
  84167. /**
  84168. * The list of aggregated animations to run.
  84169. */
  84170. children: Action[];
  84171. /**
  84172. * Instantiate the action
  84173. * @param triggerOptions defines the trigger options
  84174. * @param children defines the list of aggregated animations to run
  84175. * @param condition defines the trigger related conditions
  84176. */
  84177. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  84178. /** @hidden */
  84179. _prepare(): void;
  84180. /**
  84181. * Execute the action and executes all the aggregated actions.
  84182. */
  84183. execute(evt: ActionEvent): void;
  84184. /**
  84185. * Serializes the actions and its related information.
  84186. * @param parent defines the object to serialize in
  84187. * @returns the serialized object
  84188. */
  84189. serialize(parent: any): any;
  84190. }
  84191. /**
  84192. * This defines an action responsible to run code (external event) once triggered.
  84193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84194. */
  84195. export class ExecuteCodeAction extends Action {
  84196. /**
  84197. * The callback function to run.
  84198. */
  84199. func: (evt: ActionEvent) => void;
  84200. /**
  84201. * Instantiate the action
  84202. * @param triggerOptions defines the trigger options
  84203. * @param func defines the callback function to run
  84204. * @param condition defines the trigger related conditions
  84205. */
  84206. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  84207. /**
  84208. * Execute the action and run the attached code.
  84209. */
  84210. execute(evt: ActionEvent): void;
  84211. }
  84212. /**
  84213. * This defines an action responsible to set the parent property of the target once triggered.
  84214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84215. */
  84216. export class SetParentAction extends Action {
  84217. private _parent;
  84218. private _target;
  84219. /**
  84220. * Instantiate the action
  84221. * @param triggerOptions defines the trigger options
  84222. * @param target defines the target containing the parent property
  84223. * @param parent defines from where the animation should start (animation frame)
  84224. * @param condition defines the trigger related conditions
  84225. */
  84226. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  84227. /** @hidden */
  84228. _prepare(): void;
  84229. /**
  84230. * Execute the action and set the parent property.
  84231. */
  84232. execute(): void;
  84233. /**
  84234. * Serializes the actions and its related information.
  84235. * @param parent defines the object to serialize in
  84236. * @returns the serialized object
  84237. */
  84238. serialize(parent: any): any;
  84239. }
  84240. }
  84241. declare module BABYLON {
  84242. /**
  84243. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  84244. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  84245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84246. */
  84247. export class ActionManager extends AbstractActionManager {
  84248. /**
  84249. * Nothing
  84250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84251. */
  84252. static readonly NothingTrigger: number;
  84253. /**
  84254. * On pick
  84255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84256. */
  84257. static readonly OnPickTrigger: number;
  84258. /**
  84259. * On left pick
  84260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84261. */
  84262. static readonly OnLeftPickTrigger: number;
  84263. /**
  84264. * On right pick
  84265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84266. */
  84267. static readonly OnRightPickTrigger: number;
  84268. /**
  84269. * On center pick
  84270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84271. */
  84272. static readonly OnCenterPickTrigger: number;
  84273. /**
  84274. * On pick down
  84275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84276. */
  84277. static readonly OnPickDownTrigger: number;
  84278. /**
  84279. * On double pick
  84280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84281. */
  84282. static readonly OnDoublePickTrigger: number;
  84283. /**
  84284. * On pick up
  84285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84286. */
  84287. static readonly OnPickUpTrigger: number;
  84288. /**
  84289. * On pick out.
  84290. * This trigger will only be raised if you also declared a OnPickDown
  84291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84292. */
  84293. static readonly OnPickOutTrigger: number;
  84294. /**
  84295. * On long press
  84296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84297. */
  84298. static readonly OnLongPressTrigger: number;
  84299. /**
  84300. * On pointer over
  84301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84302. */
  84303. static readonly OnPointerOverTrigger: number;
  84304. /**
  84305. * On pointer out
  84306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84307. */
  84308. static readonly OnPointerOutTrigger: number;
  84309. /**
  84310. * On every frame
  84311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84312. */
  84313. static readonly OnEveryFrameTrigger: number;
  84314. /**
  84315. * On intersection enter
  84316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84317. */
  84318. static readonly OnIntersectionEnterTrigger: number;
  84319. /**
  84320. * On intersection exit
  84321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84322. */
  84323. static readonly OnIntersectionExitTrigger: number;
  84324. /**
  84325. * On key down
  84326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84327. */
  84328. static readonly OnKeyDownTrigger: number;
  84329. /**
  84330. * On key up
  84331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  84332. */
  84333. static readonly OnKeyUpTrigger: number;
  84334. private _scene;
  84335. /**
  84336. * Creates a new action manager
  84337. * @param scene defines the hosting scene
  84338. */
  84339. constructor(scene: Scene);
  84340. /**
  84341. * Releases all associated resources
  84342. */
  84343. dispose(): void;
  84344. /**
  84345. * Gets hosting scene
  84346. * @returns the hosting scene
  84347. */
  84348. getScene(): Scene;
  84349. /**
  84350. * Does this action manager handles actions of any of the given triggers
  84351. * @param triggers defines the triggers to be tested
  84352. * @return a boolean indicating whether one (or more) of the triggers is handled
  84353. */
  84354. hasSpecificTriggers(triggers: number[]): boolean;
  84355. /**
  84356. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84357. * speed.
  84358. * @param triggerA defines the trigger to be tested
  84359. * @param triggerB defines the trigger to be tested
  84360. * @return a boolean indicating whether one (or more) of the triggers is handled
  84361. */
  84362. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84363. /**
  84364. * Does this action manager handles actions of a given trigger
  84365. * @param trigger defines the trigger to be tested
  84366. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84367. * @return whether the trigger is handled
  84368. */
  84369. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84370. /**
  84371. * Does this action manager has pointer triggers
  84372. */
  84373. get hasPointerTriggers(): boolean;
  84374. /**
  84375. * Does this action manager has pick triggers
  84376. */
  84377. get hasPickTriggers(): boolean;
  84378. /**
  84379. * Registers an action to this action manager
  84380. * @param action defines the action to be registered
  84381. * @return the action amended (prepared) after registration
  84382. */
  84383. registerAction(action: IAction): Nullable<IAction>;
  84384. /**
  84385. * Unregisters an action to this action manager
  84386. * @param action defines the action to be unregistered
  84387. * @return a boolean indicating whether the action has been unregistered
  84388. */
  84389. unregisterAction(action: IAction): Boolean;
  84390. /**
  84391. * Process a specific trigger
  84392. * @param trigger defines the trigger to process
  84393. * @param evt defines the event details to be processed
  84394. */
  84395. processTrigger(trigger: number, evt?: IActionEvent): void;
  84396. /** @hidden */
  84397. _getEffectiveTarget(target: any, propertyPath: string): any;
  84398. /** @hidden */
  84399. _getProperty(propertyPath: string): string;
  84400. /**
  84401. * Serialize this manager to a JSON object
  84402. * @param name defines the property name to store this manager
  84403. * @returns a JSON representation of this manager
  84404. */
  84405. serialize(name: string): any;
  84406. /**
  84407. * Creates a new ActionManager from a JSON data
  84408. * @param parsedActions defines the JSON data to read from
  84409. * @param object defines the hosting mesh
  84410. * @param scene defines the hosting scene
  84411. */
  84412. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  84413. /**
  84414. * Get a trigger name by index
  84415. * @param trigger defines the trigger index
  84416. * @returns a trigger name
  84417. */
  84418. static GetTriggerName(trigger: number): string;
  84419. }
  84420. }
  84421. declare module BABYLON {
  84422. /**
  84423. * Class representing a ray with position and direction
  84424. */
  84425. export class Ray {
  84426. /** origin point */
  84427. origin: Vector3;
  84428. /** direction */
  84429. direction: Vector3;
  84430. /** length of the ray */
  84431. length: number;
  84432. private static readonly TmpVector3;
  84433. private _tmpRay;
  84434. /**
  84435. * Creates a new ray
  84436. * @param origin origin point
  84437. * @param direction direction
  84438. * @param length length of the ray
  84439. */
  84440. constructor(
  84441. /** origin point */
  84442. origin: Vector3,
  84443. /** direction */
  84444. direction: Vector3,
  84445. /** length of the ray */
  84446. length?: number);
  84447. /**
  84448. * Checks if the ray intersects a box
  84449. * @param minimum bound of the box
  84450. * @param maximum bound of the box
  84451. * @param intersectionTreshold extra extend to be added to the box in all direction
  84452. * @returns if the box was hit
  84453. */
  84454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  84455. /**
  84456. * Checks if the ray intersects a box
  84457. * @param box the bounding box to check
  84458. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  84459. * @returns if the box was hit
  84460. */
  84461. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  84462. /**
  84463. * If the ray hits a sphere
  84464. * @param sphere the bounding sphere to check
  84465. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  84466. * @returns true if it hits the sphere
  84467. */
  84468. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  84469. /**
  84470. * If the ray hits a triange
  84471. * @param vertex0 triangle vertex
  84472. * @param vertex1 triangle vertex
  84473. * @param vertex2 triangle vertex
  84474. * @returns intersection information if hit
  84475. */
  84476. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  84477. /**
  84478. * Checks if ray intersects a plane
  84479. * @param plane the plane to check
  84480. * @returns the distance away it was hit
  84481. */
  84482. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  84483. /**
  84484. * Calculate the intercept of a ray on a given axis
  84485. * @param axis to check 'x' | 'y' | 'z'
  84486. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  84487. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  84488. */
  84489. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  84490. /**
  84491. * Checks if ray intersects a mesh
  84492. * @param mesh the mesh to check
  84493. * @param fastCheck if only the bounding box should checked
  84494. * @returns picking info of the intersecton
  84495. */
  84496. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  84497. /**
  84498. * Checks if ray intersects a mesh
  84499. * @param meshes the meshes to check
  84500. * @param fastCheck if only the bounding box should checked
  84501. * @param results array to store result in
  84502. * @returns Array of picking infos
  84503. */
  84504. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  84505. private _comparePickingInfo;
  84506. private static smallnum;
  84507. private static rayl;
  84508. /**
  84509. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  84510. * @param sega the first point of the segment to test the intersection against
  84511. * @param segb the second point of the segment to test the intersection against
  84512. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  84513. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  84514. */
  84515. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  84516. /**
  84517. * Update the ray from viewport position
  84518. * @param x position
  84519. * @param y y position
  84520. * @param viewportWidth viewport width
  84521. * @param viewportHeight viewport height
  84522. * @param world world matrix
  84523. * @param view view matrix
  84524. * @param projection projection matrix
  84525. * @returns this ray updated
  84526. */
  84527. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84528. /**
  84529. * Creates a ray with origin and direction of 0,0,0
  84530. * @returns the new ray
  84531. */
  84532. static Zero(): Ray;
  84533. /**
  84534. * Creates a new ray from screen space and viewport
  84535. * @param x position
  84536. * @param y y position
  84537. * @param viewportWidth viewport width
  84538. * @param viewportHeight viewport height
  84539. * @param world world matrix
  84540. * @param view view matrix
  84541. * @param projection projection matrix
  84542. * @returns new ray
  84543. */
  84544. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84545. /**
  84546. * 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
  84547. * transformed to the given world matrix.
  84548. * @param origin The origin point
  84549. * @param end The end point
  84550. * @param world a matrix to transform the ray to. Default is the identity matrix.
  84551. * @returns the new ray
  84552. */
  84553. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  84554. /**
  84555. * Transforms a ray by a matrix
  84556. * @param ray ray to transform
  84557. * @param matrix matrix to apply
  84558. * @returns the resulting new ray
  84559. */
  84560. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  84561. /**
  84562. * Transforms a ray by a matrix
  84563. * @param ray ray to transform
  84564. * @param matrix matrix to apply
  84565. * @param result ray to store result in
  84566. */
  84567. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  84568. /**
  84569. * Unproject a ray from screen space to object space
  84570. * @param sourceX defines the screen space x coordinate to use
  84571. * @param sourceY defines the screen space y coordinate to use
  84572. * @param viewportWidth defines the current width of the viewport
  84573. * @param viewportHeight defines the current height of the viewport
  84574. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84575. * @param view defines the view matrix to use
  84576. * @param projection defines the projection matrix to use
  84577. */
  84578. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  84579. }
  84580. /**
  84581. * Type used to define predicate used to select faces when a mesh intersection is detected
  84582. */
  84583. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  84584. interface Scene {
  84585. /** @hidden */
  84586. _tempPickingRay: Nullable<Ray>;
  84587. /** @hidden */
  84588. _cachedRayForTransform: Ray;
  84589. /** @hidden */
  84590. _pickWithRayInverseMatrix: Matrix;
  84591. /** @hidden */
  84592. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  84593. /** @hidden */
  84594. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  84595. }
  84596. }
  84597. declare module BABYLON {
  84598. /**
  84599. * Groups all the scene component constants in one place to ease maintenance.
  84600. * @hidden
  84601. */
  84602. export class SceneComponentConstants {
  84603. static readonly NAME_EFFECTLAYER: string;
  84604. static readonly NAME_LAYER: string;
  84605. static readonly NAME_LENSFLARESYSTEM: string;
  84606. static readonly NAME_BOUNDINGBOXRENDERER: string;
  84607. static readonly NAME_PARTICLESYSTEM: string;
  84608. static readonly NAME_GAMEPAD: string;
  84609. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  84610. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  84611. static readonly NAME_DEPTHRENDERER: string;
  84612. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  84613. static readonly NAME_SPRITE: string;
  84614. static readonly NAME_OUTLINERENDERER: string;
  84615. static readonly NAME_PROCEDURALTEXTURE: string;
  84616. static readonly NAME_SHADOWGENERATOR: string;
  84617. static readonly NAME_OCTREE: string;
  84618. static readonly NAME_PHYSICSENGINE: string;
  84619. static readonly NAME_AUDIO: string;
  84620. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  84621. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84622. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  84623. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84624. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  84625. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  84626. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  84627. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  84628. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  84629. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  84630. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  84631. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  84632. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  84633. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  84634. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  84635. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  84636. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  84637. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  84638. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  84639. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  84640. static readonly STEP_AFTERRENDER_AUDIO: number;
  84641. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  84642. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  84643. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  84644. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  84645. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  84646. static readonly STEP_POINTERMOVE_SPRITE: number;
  84647. static readonly STEP_POINTERDOWN_SPRITE: number;
  84648. static readonly STEP_POINTERUP_SPRITE: number;
  84649. }
  84650. /**
  84651. * This represents a scene component.
  84652. *
  84653. * This is used to decouple the dependency the scene is having on the different workloads like
  84654. * layers, post processes...
  84655. */
  84656. export interface ISceneComponent {
  84657. /**
  84658. * The name of the component. Each component must have a unique name.
  84659. */
  84660. name: string;
  84661. /**
  84662. * The scene the component belongs to.
  84663. */
  84664. scene: Scene;
  84665. /**
  84666. * Register the component to one instance of a scene.
  84667. */
  84668. register(): void;
  84669. /**
  84670. * Rebuilds the elements related to this component in case of
  84671. * context lost for instance.
  84672. */
  84673. rebuild(): void;
  84674. /**
  84675. * Disposes the component and the associated ressources.
  84676. */
  84677. dispose(): void;
  84678. }
  84679. /**
  84680. * This represents a SERIALIZABLE scene component.
  84681. *
  84682. * This extends Scene Component to add Serialization methods on top.
  84683. */
  84684. export interface ISceneSerializableComponent extends ISceneComponent {
  84685. /**
  84686. * Adds all the elements from the container to the scene
  84687. * @param container the container holding the elements
  84688. */
  84689. addFromContainer(container: AbstractScene): void;
  84690. /**
  84691. * Removes all the elements in the container from the scene
  84692. * @param container contains the elements to remove
  84693. * @param dispose if the removed element should be disposed (default: false)
  84694. */
  84695. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84696. /**
  84697. * Serializes the component data to the specified json object
  84698. * @param serializationObject The object to serialize to
  84699. */
  84700. serialize(serializationObject: any): void;
  84701. }
  84702. /**
  84703. * Strong typing of a Mesh related stage step action
  84704. */
  84705. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84706. /**
  84707. * Strong typing of a Evaluate Sub Mesh related stage step action
  84708. */
  84709. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84710. /**
  84711. * Strong typing of a Active Mesh related stage step action
  84712. */
  84713. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84714. /**
  84715. * Strong typing of a Camera related stage step action
  84716. */
  84717. export type CameraStageAction = (camera: Camera) => void;
  84718. /**
  84719. * Strong typing of a Camera Frame buffer related stage step action
  84720. */
  84721. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84722. /**
  84723. * Strong typing of a Render Target related stage step action
  84724. */
  84725. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84726. /**
  84727. * Strong typing of a RenderingGroup related stage step action
  84728. */
  84729. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84730. /**
  84731. * Strong typing of a Mesh Render related stage step action
  84732. */
  84733. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84734. /**
  84735. * Strong typing of a simple stage step action
  84736. */
  84737. export type SimpleStageAction = () => void;
  84738. /**
  84739. * Strong typing of a render target action.
  84740. */
  84741. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84742. /**
  84743. * Strong typing of a pointer move action.
  84744. */
  84745. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84746. /**
  84747. * Strong typing of a pointer up/down action.
  84748. */
  84749. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84750. /**
  84751. * Representation of a stage in the scene (Basically a list of ordered steps)
  84752. * @hidden
  84753. */
  84754. export class Stage<T extends Function> extends Array<{
  84755. index: number;
  84756. component: ISceneComponent;
  84757. action: T;
  84758. }> {
  84759. /**
  84760. * Hide ctor from the rest of the world.
  84761. * @param items The items to add.
  84762. */
  84763. private constructor();
  84764. /**
  84765. * Creates a new Stage.
  84766. * @returns A new instance of a Stage
  84767. */
  84768. static Create<T extends Function>(): Stage<T>;
  84769. /**
  84770. * Registers a step in an ordered way in the targeted stage.
  84771. * @param index Defines the position to register the step in
  84772. * @param component Defines the component attached to the step
  84773. * @param action Defines the action to launch during the step
  84774. */
  84775. registerStep(index: number, component: ISceneComponent, action: T): void;
  84776. /**
  84777. * Clears all the steps from the stage.
  84778. */
  84779. clear(): void;
  84780. }
  84781. }
  84782. declare module BABYLON {
  84783. interface Scene {
  84784. /** @hidden */
  84785. _pointerOverSprite: Nullable<Sprite>;
  84786. /** @hidden */
  84787. _pickedDownSprite: Nullable<Sprite>;
  84788. /** @hidden */
  84789. _tempSpritePickingRay: Nullable<Ray>;
  84790. /**
  84791. * All of the sprite managers added to this scene
  84792. * @see http://doc.babylonjs.com/babylon101/sprites
  84793. */
  84794. spriteManagers: Array<ISpriteManager>;
  84795. /**
  84796. * An event triggered when sprites rendering is about to start
  84797. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84798. */
  84799. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84800. /**
  84801. * An event triggered when sprites rendering is done
  84802. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84803. */
  84804. onAfterSpritesRenderingObservable: Observable<Scene>;
  84805. /** @hidden */
  84806. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84807. /** Launch a ray to try to pick a sprite in the scene
  84808. * @param x position on screen
  84809. * @param y position on screen
  84810. * @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
  84811. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84812. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84813. * @returns a PickingInfo
  84814. */
  84815. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84816. /** Use the given ray to pick a sprite in the scene
  84817. * @param ray The ray (in world space) to use to pick meshes
  84818. * @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
  84819. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84820. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84821. * @returns a PickingInfo
  84822. */
  84823. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84824. /** @hidden */
  84825. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84826. /** Launch a ray to try to pick sprites in the scene
  84827. * @param x position on screen
  84828. * @param y position on screen
  84829. * @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
  84830. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84831. * @returns a PickingInfo array
  84832. */
  84833. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84834. /** Use the given ray to pick sprites in the scene
  84835. * @param ray The ray (in world space) to use to pick meshes
  84836. * @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
  84837. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84838. * @returns a PickingInfo array
  84839. */
  84840. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84841. /**
  84842. * Force the sprite under the pointer
  84843. * @param sprite defines the sprite to use
  84844. */
  84845. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84846. /**
  84847. * Gets the sprite under the pointer
  84848. * @returns a Sprite or null if no sprite is under the pointer
  84849. */
  84850. getPointerOverSprite(): Nullable<Sprite>;
  84851. }
  84852. /**
  84853. * Defines the sprite scene component responsible to manage sprites
  84854. * in a given scene.
  84855. */
  84856. export class SpriteSceneComponent implements ISceneComponent {
  84857. /**
  84858. * The component name helpfull to identify the component in the list of scene components.
  84859. */
  84860. readonly name: string;
  84861. /**
  84862. * The scene the component belongs to.
  84863. */
  84864. scene: Scene;
  84865. /** @hidden */
  84866. private _spritePredicate;
  84867. /**
  84868. * Creates a new instance of the component for the given scene
  84869. * @param scene Defines the scene to register the component in
  84870. */
  84871. constructor(scene: Scene);
  84872. /**
  84873. * Registers the component in a given scene
  84874. */
  84875. register(): void;
  84876. /**
  84877. * Rebuilds the elements related to this component in case of
  84878. * context lost for instance.
  84879. */
  84880. rebuild(): void;
  84881. /**
  84882. * Disposes the component and the associated ressources.
  84883. */
  84884. dispose(): void;
  84885. private _pickSpriteButKeepRay;
  84886. private _pointerMove;
  84887. private _pointerDown;
  84888. private _pointerUp;
  84889. }
  84890. }
  84891. declare module BABYLON {
  84892. /** @hidden */
  84893. export var fogFragmentDeclaration: {
  84894. name: string;
  84895. shader: string;
  84896. };
  84897. }
  84898. declare module BABYLON {
  84899. /** @hidden */
  84900. export var fogFragment: {
  84901. name: string;
  84902. shader: string;
  84903. };
  84904. }
  84905. declare module BABYLON {
  84906. /** @hidden */
  84907. export var spritesPixelShader: {
  84908. name: string;
  84909. shader: string;
  84910. };
  84911. }
  84912. declare module BABYLON {
  84913. /** @hidden */
  84914. export var fogVertexDeclaration: {
  84915. name: string;
  84916. shader: string;
  84917. };
  84918. }
  84919. declare module BABYLON {
  84920. /** @hidden */
  84921. export var spritesVertexShader: {
  84922. name: string;
  84923. shader: string;
  84924. };
  84925. }
  84926. declare module BABYLON {
  84927. /**
  84928. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84929. */
  84930. export interface ISpriteManager extends IDisposable {
  84931. /**
  84932. * Restricts the camera to viewing objects with the same layerMask.
  84933. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84934. */
  84935. layerMask: number;
  84936. /**
  84937. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84938. */
  84939. isPickable: boolean;
  84940. /**
  84941. * Specifies the rendering group id for this mesh (0 by default)
  84942. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84943. */
  84944. renderingGroupId: number;
  84945. /**
  84946. * Defines the list of sprites managed by the manager.
  84947. */
  84948. sprites: Array<Sprite>;
  84949. /**
  84950. * Tests the intersection of a sprite with a specific ray.
  84951. * @param ray The ray we are sending to test the collision
  84952. * @param camera The camera space we are sending rays in
  84953. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84954. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84955. * @returns picking info or null.
  84956. */
  84957. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84958. /**
  84959. * Intersects the sprites with a ray
  84960. * @param ray defines the ray to intersect with
  84961. * @param camera defines the current active camera
  84962. * @param predicate defines a predicate used to select candidate sprites
  84963. * @returns null if no hit or a PickingInfo array
  84964. */
  84965. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84966. /**
  84967. * Renders the list of sprites on screen.
  84968. */
  84969. render(): void;
  84970. }
  84971. /**
  84972. * Class used to manage multiple sprites on the same spritesheet
  84973. * @see http://doc.babylonjs.com/babylon101/sprites
  84974. */
  84975. export class SpriteManager implements ISpriteManager {
  84976. /** defines the manager's name */
  84977. name: string;
  84978. /** Gets the list of sprites */
  84979. sprites: Sprite[];
  84980. /** Gets or sets the rendering group id (0 by default) */
  84981. renderingGroupId: number;
  84982. /** Gets or sets camera layer mask */
  84983. layerMask: number;
  84984. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84985. fogEnabled: boolean;
  84986. /** Gets or sets a boolean indicating if the sprites are pickable */
  84987. isPickable: boolean;
  84988. /** Defines the default width of a cell in the spritesheet */
  84989. cellWidth: number;
  84990. /** Defines the default height of a cell in the spritesheet */
  84991. cellHeight: number;
  84992. /** Associative array from JSON sprite data file */
  84993. private _cellData;
  84994. /** Array of sprite names from JSON sprite data file */
  84995. private _spriteMap;
  84996. /** True when packed cell data from JSON file is ready*/
  84997. private _packedAndReady;
  84998. /**
  84999. * An event triggered when the manager is disposed.
  85000. */
  85001. onDisposeObservable: Observable<SpriteManager>;
  85002. private _onDisposeObserver;
  85003. /**
  85004. * Callback called when the manager is disposed
  85005. */
  85006. set onDispose(callback: () => void);
  85007. private _capacity;
  85008. private _fromPacked;
  85009. private _spriteTexture;
  85010. private _epsilon;
  85011. private _scene;
  85012. private _vertexData;
  85013. private _buffer;
  85014. private _vertexBuffers;
  85015. private _indexBuffer;
  85016. private _effectBase;
  85017. private _effectFog;
  85018. /**
  85019. * Gets or sets the spritesheet texture
  85020. */
  85021. get texture(): Texture;
  85022. set texture(value: Texture);
  85023. /**
  85024. * Creates a new sprite manager
  85025. * @param name defines the manager's name
  85026. * @param imgUrl defines the sprite sheet url
  85027. * @param capacity defines the maximum allowed number of sprites
  85028. * @param cellSize defines the size of a sprite cell
  85029. * @param scene defines the hosting scene
  85030. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  85031. * @param samplingMode defines the smapling mode to use with spritesheet
  85032. * @param fromPacked set to false; do not alter
  85033. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  85034. */
  85035. constructor(
  85036. /** defines the manager's name */
  85037. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  85038. private _makePacked;
  85039. private _appendSpriteVertex;
  85040. /**
  85041. * Intersects the sprites with a ray
  85042. * @param ray defines the ray to intersect with
  85043. * @param camera defines the current active camera
  85044. * @param predicate defines a predicate used to select candidate sprites
  85045. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  85046. * @returns null if no hit or a PickingInfo
  85047. */
  85048. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  85049. /**
  85050. * Intersects the sprites with a ray
  85051. * @param ray defines the ray to intersect with
  85052. * @param camera defines the current active camera
  85053. * @param predicate defines a predicate used to select candidate sprites
  85054. * @returns null if no hit or a PickingInfo array
  85055. */
  85056. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  85057. /**
  85058. * Render all child sprites
  85059. */
  85060. render(): void;
  85061. /**
  85062. * Release associated resources
  85063. */
  85064. dispose(): void;
  85065. }
  85066. }
  85067. declare module BABYLON {
  85068. /**
  85069. * Class used to represent a sprite
  85070. * @see http://doc.babylonjs.com/babylon101/sprites
  85071. */
  85072. export class Sprite {
  85073. /** defines the name */
  85074. name: string;
  85075. /** Gets or sets the current world position */
  85076. position: Vector3;
  85077. /** Gets or sets the main color */
  85078. color: Color4;
  85079. /** Gets or sets the width */
  85080. width: number;
  85081. /** Gets or sets the height */
  85082. height: number;
  85083. /** Gets or sets rotation angle */
  85084. angle: number;
  85085. /** Gets or sets the cell index in the sprite sheet */
  85086. cellIndex: number;
  85087. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  85088. cellRef: string;
  85089. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  85090. invertU: number;
  85091. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  85092. invertV: number;
  85093. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  85094. disposeWhenFinishedAnimating: boolean;
  85095. /** Gets the list of attached animations */
  85096. animations: Animation[];
  85097. /** Gets or sets a boolean indicating if the sprite can be picked */
  85098. isPickable: boolean;
  85099. /**
  85100. * Gets or sets the associated action manager
  85101. */
  85102. actionManager: Nullable<ActionManager>;
  85103. private _animationStarted;
  85104. private _loopAnimation;
  85105. private _fromIndex;
  85106. private _toIndex;
  85107. private _delay;
  85108. private _direction;
  85109. private _manager;
  85110. private _time;
  85111. private _onAnimationEnd;
  85112. /**
  85113. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  85114. */
  85115. isVisible: boolean;
  85116. /**
  85117. * Gets or sets the sprite size
  85118. */
  85119. get size(): number;
  85120. set size(value: number);
  85121. /**
  85122. * Creates a new Sprite
  85123. * @param name defines the name
  85124. * @param manager defines the manager
  85125. */
  85126. constructor(
  85127. /** defines the name */
  85128. name: string, manager: ISpriteManager);
  85129. /**
  85130. * Starts an animation
  85131. * @param from defines the initial key
  85132. * @param to defines the end key
  85133. * @param loop defines if the animation must loop
  85134. * @param delay defines the start delay (in ms)
  85135. * @param onAnimationEnd defines a callback to call when animation ends
  85136. */
  85137. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  85138. /** Stops current animation (if any) */
  85139. stopAnimation(): void;
  85140. /** @hidden */
  85141. _animate(deltaTime: number): void;
  85142. /** Release associated resources */
  85143. dispose(): void;
  85144. }
  85145. }
  85146. declare module BABYLON {
  85147. /**
  85148. * Information about the result of picking within a scene
  85149. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  85150. */
  85151. export class PickingInfo {
  85152. /** @hidden */
  85153. _pickingUnavailable: boolean;
  85154. /**
  85155. * If the pick collided with an object
  85156. */
  85157. hit: boolean;
  85158. /**
  85159. * Distance away where the pick collided
  85160. */
  85161. distance: number;
  85162. /**
  85163. * The location of pick collision
  85164. */
  85165. pickedPoint: Nullable<Vector3>;
  85166. /**
  85167. * The mesh corresponding the the pick collision
  85168. */
  85169. pickedMesh: Nullable<AbstractMesh>;
  85170. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  85171. bu: number;
  85172. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  85173. bv: number;
  85174. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  85175. faceId: number;
  85176. /** Id of the the submesh that was picked */
  85177. subMeshId: number;
  85178. /** If a sprite was picked, this will be the sprite the pick collided with */
  85179. pickedSprite: Nullable<Sprite>;
  85180. /**
  85181. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  85182. */
  85183. originMesh: Nullable<AbstractMesh>;
  85184. /**
  85185. * The ray that was used to perform the picking.
  85186. */
  85187. ray: Nullable<Ray>;
  85188. /**
  85189. * Gets the normal correspodning to the face the pick collided with
  85190. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  85191. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  85192. * @returns The normal correspodning to the face the pick collided with
  85193. */
  85194. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  85195. /**
  85196. * Gets the texture coordinates of where the pick occured
  85197. * @returns the vector containing the coordnates of the texture
  85198. */
  85199. getTextureCoordinates(): Nullable<Vector2>;
  85200. }
  85201. }
  85202. declare module BABYLON {
  85203. /**
  85204. * Gather the list of pointer event types as constants.
  85205. */
  85206. export class PointerEventTypes {
  85207. /**
  85208. * 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.
  85209. */
  85210. static readonly POINTERDOWN: number;
  85211. /**
  85212. * The pointerup event is fired when a pointer is no longer active.
  85213. */
  85214. static readonly POINTERUP: number;
  85215. /**
  85216. * The pointermove event is fired when a pointer changes coordinates.
  85217. */
  85218. static readonly POINTERMOVE: number;
  85219. /**
  85220. * The pointerwheel event is fired when a mouse wheel has been rotated.
  85221. */
  85222. static readonly POINTERWHEEL: number;
  85223. /**
  85224. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  85225. */
  85226. static readonly POINTERPICK: number;
  85227. /**
  85228. * The pointertap event is fired when a the object has been touched and released without drag.
  85229. */
  85230. static readonly POINTERTAP: number;
  85231. /**
  85232. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  85233. */
  85234. static readonly POINTERDOUBLETAP: number;
  85235. }
  85236. /**
  85237. * Base class of pointer info types.
  85238. */
  85239. export class PointerInfoBase {
  85240. /**
  85241. * Defines the type of event (PointerEventTypes)
  85242. */
  85243. type: number;
  85244. /**
  85245. * Defines the related dom event
  85246. */
  85247. event: PointerEvent | MouseWheelEvent;
  85248. /**
  85249. * Instantiates the base class of pointers info.
  85250. * @param type Defines the type of event (PointerEventTypes)
  85251. * @param event Defines the related dom event
  85252. */
  85253. constructor(
  85254. /**
  85255. * Defines the type of event (PointerEventTypes)
  85256. */
  85257. type: number,
  85258. /**
  85259. * Defines the related dom event
  85260. */
  85261. event: PointerEvent | MouseWheelEvent);
  85262. }
  85263. /**
  85264. * This class is used to store pointer related info for the onPrePointerObservable event.
  85265. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  85266. */
  85267. export class PointerInfoPre extends PointerInfoBase {
  85268. /**
  85269. * Ray from a pointer if availible (eg. 6dof controller)
  85270. */
  85271. ray: Nullable<Ray>;
  85272. /**
  85273. * Defines the local position of the pointer on the canvas.
  85274. */
  85275. localPosition: Vector2;
  85276. /**
  85277. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  85278. */
  85279. skipOnPointerObservable: boolean;
  85280. /**
  85281. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  85282. * @param type Defines the type of event (PointerEventTypes)
  85283. * @param event Defines the related dom event
  85284. * @param localX Defines the local x coordinates of the pointer when the event occured
  85285. * @param localY Defines the local y coordinates of the pointer when the event occured
  85286. */
  85287. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  85288. }
  85289. /**
  85290. * This type contains all the data related to a pointer event in Babylon.js.
  85291. * 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.
  85292. */
  85293. export class PointerInfo extends PointerInfoBase {
  85294. /**
  85295. * Defines the picking info associated to the info (if any)\
  85296. */
  85297. pickInfo: Nullable<PickingInfo>;
  85298. /**
  85299. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  85300. * @param type Defines the type of event (PointerEventTypes)
  85301. * @param event Defines the related dom event
  85302. * @param pickInfo Defines the picking info associated to the info (if any)\
  85303. */
  85304. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  85305. /**
  85306. * Defines the picking info associated to the info (if any)\
  85307. */
  85308. pickInfo: Nullable<PickingInfo>);
  85309. }
  85310. /**
  85311. * Data relating to a touch event on the screen.
  85312. */
  85313. export interface PointerTouch {
  85314. /**
  85315. * X coordinate of touch.
  85316. */
  85317. x: number;
  85318. /**
  85319. * Y coordinate of touch.
  85320. */
  85321. y: number;
  85322. /**
  85323. * Id of touch. Unique for each finger.
  85324. */
  85325. pointerId: number;
  85326. /**
  85327. * Event type passed from DOM.
  85328. */
  85329. type: any;
  85330. }
  85331. }
  85332. declare module BABYLON {
  85333. /**
  85334. * Manage the mouse inputs to control the movement of a free camera.
  85335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85336. */
  85337. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  85338. /**
  85339. * Define if touch is enabled in the mouse input
  85340. */
  85341. touchEnabled: boolean;
  85342. /**
  85343. * Defines the camera the input is attached to.
  85344. */
  85345. camera: FreeCamera;
  85346. /**
  85347. * Defines the buttons associated with the input to handle camera move.
  85348. */
  85349. buttons: number[];
  85350. /**
  85351. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  85352. */
  85353. angularSensibility: number;
  85354. private _pointerInput;
  85355. private _onMouseMove;
  85356. private _observer;
  85357. private previousPosition;
  85358. /**
  85359. * Observable for when a pointer move event occurs containing the move offset
  85360. */
  85361. onPointerMovedObservable: Observable<{
  85362. offsetX: number;
  85363. offsetY: number;
  85364. }>;
  85365. /**
  85366. * @hidden
  85367. * If the camera should be rotated automatically based on pointer movement
  85368. */
  85369. _allowCameraRotation: boolean;
  85370. /**
  85371. * Manage the mouse inputs to control the movement of a free camera.
  85372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85373. * @param touchEnabled Defines if touch is enabled or not
  85374. */
  85375. constructor(
  85376. /**
  85377. * Define if touch is enabled in the mouse input
  85378. */
  85379. touchEnabled?: boolean);
  85380. /**
  85381. * Attach the input controls to a specific dom element to get the input from.
  85382. * @param element Defines the element the controls should be listened from
  85383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85384. */
  85385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85386. /**
  85387. * Called on JS contextmenu event.
  85388. * Override this method to provide functionality.
  85389. */
  85390. protected onContextMenu(evt: PointerEvent): void;
  85391. /**
  85392. * Detach the current controls from the specified dom element.
  85393. * @param element Defines the element to stop listening the inputs from
  85394. */
  85395. detachControl(element: Nullable<HTMLElement>): void;
  85396. /**
  85397. * Gets the class name of the current intput.
  85398. * @returns the class name
  85399. */
  85400. getClassName(): string;
  85401. /**
  85402. * Get the friendly name associated with the input class.
  85403. * @returns the input friendly name
  85404. */
  85405. getSimpleName(): string;
  85406. }
  85407. }
  85408. declare module BABYLON {
  85409. /**
  85410. * Manage the touch inputs to control the movement of a free camera.
  85411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85412. */
  85413. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  85414. /**
  85415. * Defines the camera the input is attached to.
  85416. */
  85417. camera: FreeCamera;
  85418. /**
  85419. * Defines the touch sensibility for rotation.
  85420. * The higher the faster.
  85421. */
  85422. touchAngularSensibility: number;
  85423. /**
  85424. * Defines the touch sensibility for move.
  85425. * The higher the faster.
  85426. */
  85427. touchMoveSensibility: number;
  85428. private _offsetX;
  85429. private _offsetY;
  85430. private _pointerPressed;
  85431. private _pointerInput;
  85432. private _observer;
  85433. private _onLostFocus;
  85434. /**
  85435. * Attach the input controls to a specific dom element to get the input from.
  85436. * @param element Defines the element the controls should be listened from
  85437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85438. */
  85439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85440. /**
  85441. * Detach the current controls from the specified dom element.
  85442. * @param element Defines the element to stop listening the inputs from
  85443. */
  85444. detachControl(element: Nullable<HTMLElement>): void;
  85445. /**
  85446. * Update the current camera state depending on the inputs that have been used this frame.
  85447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85448. */
  85449. checkInputs(): void;
  85450. /**
  85451. * Gets the class name of the current intput.
  85452. * @returns the class name
  85453. */
  85454. getClassName(): string;
  85455. /**
  85456. * Get the friendly name associated with the input class.
  85457. * @returns the input friendly name
  85458. */
  85459. getSimpleName(): string;
  85460. }
  85461. }
  85462. declare module BABYLON {
  85463. /**
  85464. * Default Inputs manager for the FreeCamera.
  85465. * It groups all the default supported inputs for ease of use.
  85466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85467. */
  85468. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  85469. /**
  85470. * @hidden
  85471. */
  85472. _mouseInput: Nullable<FreeCameraMouseInput>;
  85473. /**
  85474. * Instantiates a new FreeCameraInputsManager.
  85475. * @param camera Defines the camera the inputs belong to
  85476. */
  85477. constructor(camera: FreeCamera);
  85478. /**
  85479. * Add keyboard input support to the input manager.
  85480. * @returns the current input manager
  85481. */
  85482. addKeyboard(): FreeCameraInputsManager;
  85483. /**
  85484. * Add mouse input support to the input manager.
  85485. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  85486. * @returns the current input manager
  85487. */
  85488. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  85489. /**
  85490. * Removes the mouse input support from the manager
  85491. * @returns the current input manager
  85492. */
  85493. removeMouse(): FreeCameraInputsManager;
  85494. /**
  85495. * Add touch input support to the input manager.
  85496. * @returns the current input manager
  85497. */
  85498. addTouch(): FreeCameraInputsManager;
  85499. /**
  85500. * Remove all attached input methods from a camera
  85501. */
  85502. clear(): void;
  85503. }
  85504. }
  85505. declare module BABYLON {
  85506. /**
  85507. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  85508. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  85509. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  85510. */
  85511. export class FreeCamera extends TargetCamera {
  85512. /**
  85513. * Define the collision ellipsoid of the camera.
  85514. * This is helpful to simulate a camera body like the player body around the camera
  85515. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  85516. */
  85517. ellipsoid: Vector3;
  85518. /**
  85519. * Define an offset for the position of the ellipsoid around the camera.
  85520. * This can be helpful to determine the center of the body near the gravity center of the body
  85521. * instead of its head.
  85522. */
  85523. ellipsoidOffset: Vector3;
  85524. /**
  85525. * Enable or disable collisions of the camera with the rest of the scene objects.
  85526. */
  85527. checkCollisions: boolean;
  85528. /**
  85529. * Enable or disable gravity on the camera.
  85530. */
  85531. applyGravity: boolean;
  85532. /**
  85533. * Define the input manager associated to the camera.
  85534. */
  85535. inputs: FreeCameraInputsManager;
  85536. /**
  85537. * Gets the input sensibility for a mouse input. (default is 2000.0)
  85538. * Higher values reduce sensitivity.
  85539. */
  85540. get angularSensibility(): number;
  85541. /**
  85542. * Sets the input sensibility for a mouse input. (default is 2000.0)
  85543. * Higher values reduce sensitivity.
  85544. */
  85545. set angularSensibility(value: number);
  85546. /**
  85547. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  85548. */
  85549. get keysUp(): number[];
  85550. set keysUp(value: number[]);
  85551. /**
  85552. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  85553. */
  85554. get keysDown(): number[];
  85555. set keysDown(value: number[]);
  85556. /**
  85557. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  85558. */
  85559. get keysLeft(): number[];
  85560. set keysLeft(value: number[]);
  85561. /**
  85562. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  85563. */
  85564. get keysRight(): number[];
  85565. set keysRight(value: number[]);
  85566. /**
  85567. * Event raised when the camera collide with a mesh in the scene.
  85568. */
  85569. onCollide: (collidedMesh: AbstractMesh) => void;
  85570. private _collider;
  85571. private _needMoveForGravity;
  85572. private _oldPosition;
  85573. private _diffPosition;
  85574. private _newPosition;
  85575. /** @hidden */
  85576. _localDirection: Vector3;
  85577. /** @hidden */
  85578. _transformedDirection: Vector3;
  85579. /**
  85580. * Instantiates a Free Camera.
  85581. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  85582. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  85583. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  85584. * @param name Define the name of the camera in the scene
  85585. * @param position Define the start position of the camera in the scene
  85586. * @param scene Define the scene the camera belongs to
  85587. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  85588. */
  85589. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  85590. /**
  85591. * Attached controls to the current camera.
  85592. * @param element Defines the element the controls should be listened from
  85593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85594. */
  85595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85596. /**
  85597. * Detach the current controls from the camera.
  85598. * The camera will stop reacting to inputs.
  85599. * @param element Defines the element to stop listening the inputs from
  85600. */
  85601. detachControl(element: HTMLElement): void;
  85602. private _collisionMask;
  85603. /**
  85604. * Define a collision mask to limit the list of object the camera can collide with
  85605. */
  85606. get collisionMask(): number;
  85607. set collisionMask(mask: number);
  85608. /** @hidden */
  85609. _collideWithWorld(displacement: Vector3): void;
  85610. private _onCollisionPositionChange;
  85611. /** @hidden */
  85612. _checkInputs(): void;
  85613. /** @hidden */
  85614. _decideIfNeedsToMove(): boolean;
  85615. /** @hidden */
  85616. _updatePosition(): void;
  85617. /**
  85618. * Destroy the camera and release the current resources hold by it.
  85619. */
  85620. dispose(): void;
  85621. /**
  85622. * Gets the current object class name.
  85623. * @return the class name
  85624. */
  85625. getClassName(): string;
  85626. }
  85627. }
  85628. declare module BABYLON {
  85629. /**
  85630. * Represents a gamepad control stick position
  85631. */
  85632. export class StickValues {
  85633. /**
  85634. * The x component of the control stick
  85635. */
  85636. x: number;
  85637. /**
  85638. * The y component of the control stick
  85639. */
  85640. y: number;
  85641. /**
  85642. * Initializes the gamepad x and y control stick values
  85643. * @param x The x component of the gamepad control stick value
  85644. * @param y The y component of the gamepad control stick value
  85645. */
  85646. constructor(
  85647. /**
  85648. * The x component of the control stick
  85649. */
  85650. x: number,
  85651. /**
  85652. * The y component of the control stick
  85653. */
  85654. y: number);
  85655. }
  85656. /**
  85657. * An interface which manages callbacks for gamepad button changes
  85658. */
  85659. export interface GamepadButtonChanges {
  85660. /**
  85661. * Called when a gamepad has been changed
  85662. */
  85663. changed: boolean;
  85664. /**
  85665. * Called when a gamepad press event has been triggered
  85666. */
  85667. pressChanged: boolean;
  85668. /**
  85669. * Called when a touch event has been triggered
  85670. */
  85671. touchChanged: boolean;
  85672. /**
  85673. * Called when a value has changed
  85674. */
  85675. valueChanged: boolean;
  85676. }
  85677. /**
  85678. * Represents a gamepad
  85679. */
  85680. export class Gamepad {
  85681. /**
  85682. * The id of the gamepad
  85683. */
  85684. id: string;
  85685. /**
  85686. * The index of the gamepad
  85687. */
  85688. index: number;
  85689. /**
  85690. * The browser gamepad
  85691. */
  85692. browserGamepad: any;
  85693. /**
  85694. * Specifies what type of gamepad this represents
  85695. */
  85696. type: number;
  85697. private _leftStick;
  85698. private _rightStick;
  85699. /** @hidden */
  85700. _isConnected: boolean;
  85701. private _leftStickAxisX;
  85702. private _leftStickAxisY;
  85703. private _rightStickAxisX;
  85704. private _rightStickAxisY;
  85705. /**
  85706. * Triggered when the left control stick has been changed
  85707. */
  85708. private _onleftstickchanged;
  85709. /**
  85710. * Triggered when the right control stick has been changed
  85711. */
  85712. private _onrightstickchanged;
  85713. /**
  85714. * Represents a gamepad controller
  85715. */
  85716. static GAMEPAD: number;
  85717. /**
  85718. * Represents a generic controller
  85719. */
  85720. static GENERIC: number;
  85721. /**
  85722. * Represents an XBox controller
  85723. */
  85724. static XBOX: number;
  85725. /**
  85726. * Represents a pose-enabled controller
  85727. */
  85728. static POSE_ENABLED: number;
  85729. /**
  85730. * Represents an Dual Shock controller
  85731. */
  85732. static DUALSHOCK: number;
  85733. /**
  85734. * Specifies whether the left control stick should be Y-inverted
  85735. */
  85736. protected _invertLeftStickY: boolean;
  85737. /**
  85738. * Specifies if the gamepad has been connected
  85739. */
  85740. get isConnected(): boolean;
  85741. /**
  85742. * Initializes the gamepad
  85743. * @param id The id of the gamepad
  85744. * @param index The index of the gamepad
  85745. * @param browserGamepad The browser gamepad
  85746. * @param leftStickX The x component of the left joystick
  85747. * @param leftStickY The y component of the left joystick
  85748. * @param rightStickX The x component of the right joystick
  85749. * @param rightStickY The y component of the right joystick
  85750. */
  85751. constructor(
  85752. /**
  85753. * The id of the gamepad
  85754. */
  85755. id: string,
  85756. /**
  85757. * The index of the gamepad
  85758. */
  85759. index: number,
  85760. /**
  85761. * The browser gamepad
  85762. */
  85763. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  85764. /**
  85765. * Callback triggered when the left joystick has changed
  85766. * @param callback
  85767. */
  85768. onleftstickchanged(callback: (values: StickValues) => void): void;
  85769. /**
  85770. * Callback triggered when the right joystick has changed
  85771. * @param callback
  85772. */
  85773. onrightstickchanged(callback: (values: StickValues) => void): void;
  85774. /**
  85775. * Gets the left joystick
  85776. */
  85777. get leftStick(): StickValues;
  85778. /**
  85779. * Sets the left joystick values
  85780. */
  85781. set leftStick(newValues: StickValues);
  85782. /**
  85783. * Gets the right joystick
  85784. */
  85785. get rightStick(): StickValues;
  85786. /**
  85787. * Sets the right joystick value
  85788. */
  85789. set rightStick(newValues: StickValues);
  85790. /**
  85791. * Updates the gamepad joystick positions
  85792. */
  85793. update(): void;
  85794. /**
  85795. * Disposes the gamepad
  85796. */
  85797. dispose(): void;
  85798. }
  85799. /**
  85800. * Represents a generic gamepad
  85801. */
  85802. export class GenericPad extends Gamepad {
  85803. private _buttons;
  85804. private _onbuttondown;
  85805. private _onbuttonup;
  85806. /**
  85807. * Observable triggered when a button has been pressed
  85808. */
  85809. onButtonDownObservable: Observable<number>;
  85810. /**
  85811. * Observable triggered when a button has been released
  85812. */
  85813. onButtonUpObservable: Observable<number>;
  85814. /**
  85815. * Callback triggered when a button has been pressed
  85816. * @param callback Called when a button has been pressed
  85817. */
  85818. onbuttondown(callback: (buttonPressed: number) => void): void;
  85819. /**
  85820. * Callback triggered when a button has been released
  85821. * @param callback Called when a button has been released
  85822. */
  85823. onbuttonup(callback: (buttonReleased: number) => void): void;
  85824. /**
  85825. * Initializes the generic gamepad
  85826. * @param id The id of the generic gamepad
  85827. * @param index The index of the generic gamepad
  85828. * @param browserGamepad The browser gamepad
  85829. */
  85830. constructor(id: string, index: number, browserGamepad: any);
  85831. private _setButtonValue;
  85832. /**
  85833. * Updates the generic gamepad
  85834. */
  85835. update(): void;
  85836. /**
  85837. * Disposes the generic gamepad
  85838. */
  85839. dispose(): void;
  85840. }
  85841. }
  85842. declare module BABYLON {
  85843. interface Engine {
  85844. /**
  85845. * Creates a raw texture
  85846. * @param data defines the data to store in the texture
  85847. * @param width defines the width of the texture
  85848. * @param height defines the height of the texture
  85849. * @param format defines the format of the data
  85850. * @param generateMipMaps defines if the engine should generate the mip levels
  85851. * @param invertY defines if data must be stored with Y axis inverted
  85852. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85853. * @param compression defines the compression used (null by default)
  85854. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85855. * @returns the raw texture inside an InternalTexture
  85856. */
  85857. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85858. /**
  85859. * Update a raw texture
  85860. * @param texture defines the texture to update
  85861. * @param data defines the data to store in the texture
  85862. * @param format defines the format of the data
  85863. * @param invertY defines if data must be stored with Y axis inverted
  85864. */
  85865. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85866. /**
  85867. * Update a raw texture
  85868. * @param texture defines the texture to update
  85869. * @param data defines the data to store in the texture
  85870. * @param format defines the format of the data
  85871. * @param invertY defines if data must be stored with Y axis inverted
  85872. * @param compression defines the compression used (null by default)
  85873. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85874. */
  85875. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85876. /**
  85877. * Creates a new raw cube texture
  85878. * @param data defines the array of data to use to create each face
  85879. * @param size defines the size of the textures
  85880. * @param format defines the format of the data
  85881. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85882. * @param generateMipMaps defines if the engine should generate the mip levels
  85883. * @param invertY defines if data must be stored with Y axis inverted
  85884. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85885. * @param compression defines the compression used (null by default)
  85886. * @returns the cube texture as an InternalTexture
  85887. */
  85888. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85889. /**
  85890. * Update a raw cube texture
  85891. * @param texture defines the texture to udpdate
  85892. * @param data defines the data to store
  85893. * @param format defines the data format
  85894. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85895. * @param invertY defines if data must be stored with Y axis inverted
  85896. */
  85897. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85898. /**
  85899. * Update a raw cube texture
  85900. * @param texture defines the texture to udpdate
  85901. * @param data defines the data to store
  85902. * @param format defines the data format
  85903. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85904. * @param invertY defines if data must be stored with Y axis inverted
  85905. * @param compression defines the compression used (null by default)
  85906. */
  85907. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85908. /**
  85909. * Update a raw cube texture
  85910. * @param texture defines the texture to udpdate
  85911. * @param data defines the data to store
  85912. * @param format defines the data format
  85913. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85914. * @param invertY defines if data must be stored with Y axis inverted
  85915. * @param compression defines the compression used (null by default)
  85916. * @param level defines which level of the texture to update
  85917. */
  85918. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85919. /**
  85920. * Creates a new raw cube texture from a specified url
  85921. * @param url defines the url where the data is located
  85922. * @param scene defines the current scene
  85923. * @param size defines the size of the textures
  85924. * @param format defines the format of the data
  85925. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85926. * @param noMipmap defines if the engine should avoid generating the mip levels
  85927. * @param callback defines a callback used to extract texture data from loaded data
  85928. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85929. * @param onLoad defines a callback called when texture is loaded
  85930. * @param onError defines a callback called if there is an error
  85931. * @returns the cube texture as an InternalTexture
  85932. */
  85933. 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;
  85934. /**
  85935. * Creates a new raw cube texture from a specified url
  85936. * @param url defines the url where the data is located
  85937. * @param scene defines the current scene
  85938. * @param size defines the size of the textures
  85939. * @param format defines the format of the data
  85940. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85941. * @param noMipmap defines if the engine should avoid generating the mip levels
  85942. * @param callback defines a callback used to extract texture data from loaded data
  85943. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85944. * @param onLoad defines a callback called when texture is loaded
  85945. * @param onError defines a callback called if there is an error
  85946. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85947. * @param invertY defines if data must be stored with Y axis inverted
  85948. * @returns the cube texture as an InternalTexture
  85949. */
  85950. 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;
  85951. /**
  85952. * Creates a new raw 3D texture
  85953. * @param data defines the data used to create the texture
  85954. * @param width defines the width of the texture
  85955. * @param height defines the height of the texture
  85956. * @param depth defines the depth of the texture
  85957. * @param format defines the format of the texture
  85958. * @param generateMipMaps defines if the engine must generate mip levels
  85959. * @param invertY defines if data must be stored with Y axis inverted
  85960. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85961. * @param compression defines the compressed used (can be null)
  85962. * @param textureType defines the compressed used (can be null)
  85963. * @returns a new raw 3D texture (stored in an InternalTexture)
  85964. */
  85965. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85966. /**
  85967. * Update a raw 3D texture
  85968. * @param texture defines the texture to update
  85969. * @param data defines the data to store
  85970. * @param format defines the data format
  85971. * @param invertY defines if data must be stored with Y axis inverted
  85972. */
  85973. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85974. /**
  85975. * Update a raw 3D texture
  85976. * @param texture defines the texture to update
  85977. * @param data defines the data to store
  85978. * @param format defines the data format
  85979. * @param invertY defines if data must be stored with Y axis inverted
  85980. * @param compression defines the used compression (can be null)
  85981. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85982. */
  85983. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85984. /**
  85985. * Creates a new raw 2D array texture
  85986. * @param data defines the data used to create the texture
  85987. * @param width defines the width of the texture
  85988. * @param height defines the height of the texture
  85989. * @param depth defines the number of layers of the texture
  85990. * @param format defines the format of the texture
  85991. * @param generateMipMaps defines if the engine must generate mip levels
  85992. * @param invertY defines if data must be stored with Y axis inverted
  85993. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85994. * @param compression defines the compressed used (can be null)
  85995. * @param textureType defines the compressed used (can be null)
  85996. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85997. */
  85998. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85999. /**
  86000. * Update a raw 2D array texture
  86001. * @param texture defines the texture to update
  86002. * @param data defines the data to store
  86003. * @param format defines the data format
  86004. * @param invertY defines if data must be stored with Y axis inverted
  86005. */
  86006. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86007. /**
  86008. * Update a raw 2D array texture
  86009. * @param texture defines the texture to update
  86010. * @param data defines the data to store
  86011. * @param format defines the data format
  86012. * @param invertY defines if data must be stored with Y axis inverted
  86013. * @param compression defines the used compression (can be null)
  86014. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86015. */
  86016. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86017. }
  86018. }
  86019. declare module BABYLON {
  86020. /**
  86021. * Raw texture can help creating a texture directly from an array of data.
  86022. * This can be super useful if you either get the data from an uncompressed source or
  86023. * if you wish to create your texture pixel by pixel.
  86024. */
  86025. export class RawTexture extends Texture {
  86026. /**
  86027. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86028. */
  86029. format: number;
  86030. private _engine;
  86031. /**
  86032. * Instantiates a new RawTexture.
  86033. * Raw texture can help creating a texture directly from an array of data.
  86034. * This can be super useful if you either get the data from an uncompressed source or
  86035. * if you wish to create your texture pixel by pixel.
  86036. * @param data define the array of data to use to create the texture
  86037. * @param width define the width of the texture
  86038. * @param height define the height of the texture
  86039. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86040. * @param scene define the scene the texture belongs to
  86041. * @param generateMipMaps define whether mip maps should be generated or not
  86042. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86043. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86044. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86045. */
  86046. constructor(data: ArrayBufferView, width: number, height: number,
  86047. /**
  86048. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86049. */
  86050. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86051. /**
  86052. * Updates the texture underlying data.
  86053. * @param data Define the new data of the texture
  86054. */
  86055. update(data: ArrayBufferView): void;
  86056. /**
  86057. * Creates a luminance texture from some data.
  86058. * @param data Define the texture data
  86059. * @param width Define the width of the texture
  86060. * @param height Define the height of the texture
  86061. * @param scene Define the scene the texture belongs to
  86062. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86063. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86064. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86065. * @returns the luminance texture
  86066. */
  86067. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86068. /**
  86069. * Creates a luminance alpha texture from some data.
  86070. * @param data Define the texture data
  86071. * @param width Define the width of the texture
  86072. * @param height Define the height of the texture
  86073. * @param scene Define the scene the texture belongs to
  86074. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86075. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86076. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86077. * @returns the luminance alpha texture
  86078. */
  86079. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86080. /**
  86081. * Creates an alpha texture from some data.
  86082. * @param data Define the texture data
  86083. * @param width Define the width of the texture
  86084. * @param height Define the height of the texture
  86085. * @param scene Define the scene the texture belongs to
  86086. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86087. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86088. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86089. * @returns the alpha texture
  86090. */
  86091. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86092. /**
  86093. * Creates a RGB texture from some data.
  86094. * @param data Define the texture data
  86095. * @param width Define the width of the texture
  86096. * @param height Define the height of the texture
  86097. * @param scene Define the scene the texture belongs to
  86098. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86099. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86100. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86101. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86102. * @returns the RGB alpha texture
  86103. */
  86104. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86105. /**
  86106. * Creates a RGBA texture from some data.
  86107. * @param data Define the texture data
  86108. * @param width Define the width of the texture
  86109. * @param height Define the height of the texture
  86110. * @param scene Define the scene the texture belongs to
  86111. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86112. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86113. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86114. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86115. * @returns the RGBA texture
  86116. */
  86117. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86118. /**
  86119. * Creates a R texture from some data.
  86120. * @param data Define the texture data
  86121. * @param width Define the width of the texture
  86122. * @param height Define the height of the texture
  86123. * @param scene Define the scene the texture belongs to
  86124. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86125. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86126. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86127. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86128. * @returns the R texture
  86129. */
  86130. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86131. }
  86132. }
  86133. declare module BABYLON {
  86134. /**
  86135. * Interface for the size containing width and height
  86136. */
  86137. export interface ISize {
  86138. /**
  86139. * Width
  86140. */
  86141. width: number;
  86142. /**
  86143. * Heighht
  86144. */
  86145. height: number;
  86146. }
  86147. /**
  86148. * Size containing widht and height
  86149. */
  86150. export class Size implements ISize {
  86151. /**
  86152. * Width
  86153. */
  86154. width: number;
  86155. /**
  86156. * Height
  86157. */
  86158. height: number;
  86159. /**
  86160. * Creates a Size object from the given width and height (floats).
  86161. * @param width width of the new size
  86162. * @param height height of the new size
  86163. */
  86164. constructor(width: number, height: number);
  86165. /**
  86166. * Returns a string with the Size width and height
  86167. * @returns a string with the Size width and height
  86168. */
  86169. toString(): string;
  86170. /**
  86171. * "Size"
  86172. * @returns the string "Size"
  86173. */
  86174. getClassName(): string;
  86175. /**
  86176. * Returns the Size hash code.
  86177. * @returns a hash code for a unique width and height
  86178. */
  86179. getHashCode(): number;
  86180. /**
  86181. * Updates the current size from the given one.
  86182. * @param src the given size
  86183. */
  86184. copyFrom(src: Size): void;
  86185. /**
  86186. * Updates in place the current Size from the given floats.
  86187. * @param width width of the new size
  86188. * @param height height of the new size
  86189. * @returns the updated Size.
  86190. */
  86191. copyFromFloats(width: number, height: number): Size;
  86192. /**
  86193. * Updates in place the current Size from the given floats.
  86194. * @param width width to set
  86195. * @param height height to set
  86196. * @returns the updated Size.
  86197. */
  86198. set(width: number, height: number): Size;
  86199. /**
  86200. * Multiplies the width and height by numbers
  86201. * @param w factor to multiple the width by
  86202. * @param h factor to multiple the height by
  86203. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86204. */
  86205. multiplyByFloats(w: number, h: number): Size;
  86206. /**
  86207. * Clones the size
  86208. * @returns a new Size copied from the given one.
  86209. */
  86210. clone(): Size;
  86211. /**
  86212. * True if the current Size and the given one width and height are strictly equal.
  86213. * @param other the other size to compare against
  86214. * @returns True if the current Size and the given one width and height are strictly equal.
  86215. */
  86216. equals(other: Size): boolean;
  86217. /**
  86218. * The surface of the Size : width * height (float).
  86219. */
  86220. get surface(): number;
  86221. /**
  86222. * Create a new size of zero
  86223. * @returns a new Size set to (0.0, 0.0)
  86224. */
  86225. static Zero(): Size;
  86226. /**
  86227. * Sums the width and height of two sizes
  86228. * @param otherSize size to add to this size
  86229. * @returns a new Size set as the addition result of the current Size and the given one.
  86230. */
  86231. add(otherSize: Size): Size;
  86232. /**
  86233. * Subtracts the width and height of two
  86234. * @param otherSize size to subtract to this size
  86235. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86236. */
  86237. subtract(otherSize: Size): Size;
  86238. /**
  86239. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86240. * @param start starting size to lerp between
  86241. * @param end end size to lerp between
  86242. * @param amount amount to lerp between the start and end values
  86243. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86244. */
  86245. static Lerp(start: Size, end: Size, amount: number): Size;
  86246. }
  86247. }
  86248. declare module BABYLON {
  86249. /**
  86250. * Defines a runtime animation
  86251. */
  86252. export class RuntimeAnimation {
  86253. private _events;
  86254. /**
  86255. * The current frame of the runtime animation
  86256. */
  86257. private _currentFrame;
  86258. /**
  86259. * The animation used by the runtime animation
  86260. */
  86261. private _animation;
  86262. /**
  86263. * The target of the runtime animation
  86264. */
  86265. private _target;
  86266. /**
  86267. * The initiating animatable
  86268. */
  86269. private _host;
  86270. /**
  86271. * The original value of the runtime animation
  86272. */
  86273. private _originalValue;
  86274. /**
  86275. * The original blend value of the runtime animation
  86276. */
  86277. private _originalBlendValue;
  86278. /**
  86279. * The offsets cache of the runtime animation
  86280. */
  86281. private _offsetsCache;
  86282. /**
  86283. * The high limits cache of the runtime animation
  86284. */
  86285. private _highLimitsCache;
  86286. /**
  86287. * Specifies if the runtime animation has been stopped
  86288. */
  86289. private _stopped;
  86290. /**
  86291. * The blending factor of the runtime animation
  86292. */
  86293. private _blendingFactor;
  86294. /**
  86295. * The BabylonJS scene
  86296. */
  86297. private _scene;
  86298. /**
  86299. * The current value of the runtime animation
  86300. */
  86301. private _currentValue;
  86302. /** @hidden */
  86303. _animationState: _IAnimationState;
  86304. /**
  86305. * The active target of the runtime animation
  86306. */
  86307. private _activeTargets;
  86308. private _currentActiveTarget;
  86309. private _directTarget;
  86310. /**
  86311. * The target path of the runtime animation
  86312. */
  86313. private _targetPath;
  86314. /**
  86315. * The weight of the runtime animation
  86316. */
  86317. private _weight;
  86318. /**
  86319. * The ratio offset of the runtime animation
  86320. */
  86321. private _ratioOffset;
  86322. /**
  86323. * The previous delay of the runtime animation
  86324. */
  86325. private _previousDelay;
  86326. /**
  86327. * The previous ratio of the runtime animation
  86328. */
  86329. private _previousRatio;
  86330. private _enableBlending;
  86331. private _keys;
  86332. private _minFrame;
  86333. private _maxFrame;
  86334. private _minValue;
  86335. private _maxValue;
  86336. private _targetIsArray;
  86337. /**
  86338. * Gets the current frame of the runtime animation
  86339. */
  86340. get currentFrame(): number;
  86341. /**
  86342. * Gets the weight of the runtime animation
  86343. */
  86344. get weight(): number;
  86345. /**
  86346. * Gets the current value of the runtime animation
  86347. */
  86348. get currentValue(): any;
  86349. /**
  86350. * Gets the target path of the runtime animation
  86351. */
  86352. get targetPath(): string;
  86353. /**
  86354. * Gets the actual target of the runtime animation
  86355. */
  86356. get target(): any;
  86357. /** @hidden */
  86358. _onLoop: () => void;
  86359. /**
  86360. * Create a new RuntimeAnimation object
  86361. * @param target defines the target of the animation
  86362. * @param animation defines the source animation object
  86363. * @param scene defines the hosting scene
  86364. * @param host defines the initiating Animatable
  86365. */
  86366. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  86367. private _preparePath;
  86368. /**
  86369. * Gets the animation from the runtime animation
  86370. */
  86371. get animation(): Animation;
  86372. /**
  86373. * Resets the runtime animation to the beginning
  86374. * @param restoreOriginal defines whether to restore the target property to the original value
  86375. */
  86376. reset(restoreOriginal?: boolean): void;
  86377. /**
  86378. * Specifies if the runtime animation is stopped
  86379. * @returns Boolean specifying if the runtime animation is stopped
  86380. */
  86381. isStopped(): boolean;
  86382. /**
  86383. * Disposes of the runtime animation
  86384. */
  86385. dispose(): void;
  86386. /**
  86387. * Apply the interpolated value to the target
  86388. * @param currentValue defines the value computed by the animation
  86389. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  86390. */
  86391. setValue(currentValue: any, weight: number): void;
  86392. private _getOriginalValues;
  86393. private _setValue;
  86394. /**
  86395. * Gets the loop pmode of the runtime animation
  86396. * @returns Loop Mode
  86397. */
  86398. private _getCorrectLoopMode;
  86399. /**
  86400. * Move the current animation to a given frame
  86401. * @param frame defines the frame to move to
  86402. */
  86403. goToFrame(frame: number): void;
  86404. /**
  86405. * @hidden Internal use only
  86406. */
  86407. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  86408. /**
  86409. * Execute the current animation
  86410. * @param delay defines the delay to add to the current frame
  86411. * @param from defines the lower bound of the animation range
  86412. * @param to defines the upper bound of the animation range
  86413. * @param loop defines if the current animation must loop
  86414. * @param speedRatio defines the current speed ratio
  86415. * @param weight defines the weight of the animation (default is -1 so no weight)
  86416. * @param onLoop optional callback called when animation loops
  86417. * @returns a boolean indicating if the animation is running
  86418. */
  86419. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  86420. }
  86421. }
  86422. declare module BABYLON {
  86423. /**
  86424. * Class used to store an actual running animation
  86425. */
  86426. export class Animatable {
  86427. /** defines the target object */
  86428. target: any;
  86429. /** defines the starting frame number (default is 0) */
  86430. fromFrame: number;
  86431. /** defines the ending frame number (default is 100) */
  86432. toFrame: number;
  86433. /** defines if the animation must loop (default is false) */
  86434. loopAnimation: boolean;
  86435. /** defines a callback to call when animation ends if it is not looping */
  86436. onAnimationEnd?: (() => void) | null | undefined;
  86437. /** defines a callback to call when animation loops */
  86438. onAnimationLoop?: (() => void) | null | undefined;
  86439. private _localDelayOffset;
  86440. private _pausedDelay;
  86441. private _runtimeAnimations;
  86442. private _paused;
  86443. private _scene;
  86444. private _speedRatio;
  86445. private _weight;
  86446. private _syncRoot;
  86447. /**
  86448. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  86449. * This will only apply for non looping animation (default is true)
  86450. */
  86451. disposeOnEnd: boolean;
  86452. /**
  86453. * Gets a boolean indicating if the animation has started
  86454. */
  86455. animationStarted: boolean;
  86456. /**
  86457. * Observer raised when the animation ends
  86458. */
  86459. onAnimationEndObservable: Observable<Animatable>;
  86460. /**
  86461. * Observer raised when the animation loops
  86462. */
  86463. onAnimationLoopObservable: Observable<Animatable>;
  86464. /**
  86465. * Gets the root Animatable used to synchronize and normalize animations
  86466. */
  86467. get syncRoot(): Nullable<Animatable>;
  86468. /**
  86469. * Gets the current frame of the first RuntimeAnimation
  86470. * Used to synchronize Animatables
  86471. */
  86472. get masterFrame(): number;
  86473. /**
  86474. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  86475. */
  86476. get weight(): number;
  86477. set weight(value: number);
  86478. /**
  86479. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  86480. */
  86481. get speedRatio(): number;
  86482. set speedRatio(value: number);
  86483. /**
  86484. * Creates a new Animatable
  86485. * @param scene defines the hosting scene
  86486. * @param target defines the target object
  86487. * @param fromFrame defines the starting frame number (default is 0)
  86488. * @param toFrame defines the ending frame number (default is 100)
  86489. * @param loopAnimation defines if the animation must loop (default is false)
  86490. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  86491. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  86492. * @param animations defines a group of animation to add to the new Animatable
  86493. * @param onAnimationLoop defines a callback to call when animation loops
  86494. */
  86495. constructor(scene: Scene,
  86496. /** defines the target object */
  86497. target: any,
  86498. /** defines the starting frame number (default is 0) */
  86499. fromFrame?: number,
  86500. /** defines the ending frame number (default is 100) */
  86501. toFrame?: number,
  86502. /** defines if the animation must loop (default is false) */
  86503. loopAnimation?: boolean, speedRatio?: number,
  86504. /** defines a callback to call when animation ends if it is not looping */
  86505. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  86506. /** defines a callback to call when animation loops */
  86507. onAnimationLoop?: (() => void) | null | undefined);
  86508. /**
  86509. * Synchronize and normalize current Animatable with a source Animatable
  86510. * This is useful when using animation weights and when animations are not of the same length
  86511. * @param root defines the root Animatable to synchronize with
  86512. * @returns the current Animatable
  86513. */
  86514. syncWith(root: Animatable): Animatable;
  86515. /**
  86516. * Gets the list of runtime animations
  86517. * @returns an array of RuntimeAnimation
  86518. */
  86519. getAnimations(): RuntimeAnimation[];
  86520. /**
  86521. * Adds more animations to the current animatable
  86522. * @param target defines the target of the animations
  86523. * @param animations defines the new animations to add
  86524. */
  86525. appendAnimations(target: any, animations: Animation[]): void;
  86526. /**
  86527. * Gets the source animation for a specific property
  86528. * @param property defines the propertyu to look for
  86529. * @returns null or the source animation for the given property
  86530. */
  86531. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  86532. /**
  86533. * Gets the runtime animation for a specific property
  86534. * @param property defines the propertyu to look for
  86535. * @returns null or the runtime animation for the given property
  86536. */
  86537. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  86538. /**
  86539. * Resets the animatable to its original state
  86540. */
  86541. reset(): void;
  86542. /**
  86543. * Allows the animatable to blend with current running animations
  86544. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86545. * @param blendingSpeed defines the blending speed to use
  86546. */
  86547. enableBlending(blendingSpeed: number): void;
  86548. /**
  86549. * Disable animation blending
  86550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86551. */
  86552. disableBlending(): void;
  86553. /**
  86554. * Jump directly to a given frame
  86555. * @param frame defines the frame to jump to
  86556. */
  86557. goToFrame(frame: number): void;
  86558. /**
  86559. * Pause the animation
  86560. */
  86561. pause(): void;
  86562. /**
  86563. * Restart the animation
  86564. */
  86565. restart(): void;
  86566. private _raiseOnAnimationEnd;
  86567. /**
  86568. * Stop and delete the current animation
  86569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  86570. * @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)
  86571. */
  86572. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  86573. /**
  86574. * Wait asynchronously for the animation to end
  86575. * @returns a promise which will be fullfilled when the animation ends
  86576. */
  86577. waitAsync(): Promise<Animatable>;
  86578. /** @hidden */
  86579. _animate(delay: number): boolean;
  86580. }
  86581. interface Scene {
  86582. /** @hidden */
  86583. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  86584. /** @hidden */
  86585. _processLateAnimationBindingsForMatrices(holder: {
  86586. totalWeight: number;
  86587. animations: RuntimeAnimation[];
  86588. originalValue: Matrix;
  86589. }): any;
  86590. /** @hidden */
  86591. _processLateAnimationBindingsForQuaternions(holder: {
  86592. totalWeight: number;
  86593. animations: RuntimeAnimation[];
  86594. originalValue: Quaternion;
  86595. }, refQuaternion: Quaternion): Quaternion;
  86596. /** @hidden */
  86597. _processLateAnimationBindings(): void;
  86598. /**
  86599. * Will start the animation sequence of a given target
  86600. * @param target defines the target
  86601. * @param from defines from which frame should animation start
  86602. * @param to defines until which frame should animation run.
  86603. * @param weight defines the weight to apply to the animation (1.0 by default)
  86604. * @param loop defines if the animation loops
  86605. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86606. * @param onAnimationEnd defines the function to be executed when the animation ends
  86607. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86608. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86609. * @param onAnimationLoop defines the callback to call when an animation loops
  86610. * @returns the animatable object created for this animation
  86611. */
  86612. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86613. /**
  86614. * Will start the animation sequence of a given target
  86615. * @param target defines the target
  86616. * @param from defines from which frame should animation start
  86617. * @param to defines until which frame should animation run.
  86618. * @param loop defines if the animation loops
  86619. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86620. * @param onAnimationEnd defines the function to be executed when the animation ends
  86621. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86622. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86623. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  86624. * @param onAnimationLoop defines the callback to call when an animation loops
  86625. * @returns the animatable object created for this animation
  86626. */
  86627. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86628. /**
  86629. * Will start the animation sequence of a given target and its hierarchy
  86630. * @param target defines the target
  86631. * @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.
  86632. * @param from defines from which frame should animation start
  86633. * @param to defines until which frame should animation run.
  86634. * @param loop defines if the animation loops
  86635. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86636. * @param onAnimationEnd defines the function to be executed when the animation ends
  86637. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86638. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86639. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86640. * @param onAnimationLoop defines the callback to call when an animation loops
  86641. * @returns the list of created animatables
  86642. */
  86643. 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[];
  86644. /**
  86645. * Begin a new animation on a given node
  86646. * @param target defines the target where the animation will take place
  86647. * @param animations defines the list of animations to start
  86648. * @param from defines the initial value
  86649. * @param to defines the final value
  86650. * @param loop defines if you want animation to loop (off by default)
  86651. * @param speedRatio defines the speed ratio to apply to all animations
  86652. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86653. * @param onAnimationLoop defines the callback to call when an animation loops
  86654. * @returns the list of created animatables
  86655. */
  86656. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  86657. /**
  86658. * Begin a new animation on a given node and its hierarchy
  86659. * @param target defines the root node where the animation will take place
  86660. * @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.
  86661. * @param animations defines the list of animations to start
  86662. * @param from defines the initial value
  86663. * @param to defines the final value
  86664. * @param loop defines if you want animation to loop (off by default)
  86665. * @param speedRatio defines the speed ratio to apply to all animations
  86666. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86667. * @param onAnimationLoop defines the callback to call when an animation loops
  86668. * @returns the list of animatables created for all nodes
  86669. */
  86670. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  86671. /**
  86672. * Gets the animatable associated with a specific target
  86673. * @param target defines the target of the animatable
  86674. * @returns the required animatable if found
  86675. */
  86676. getAnimatableByTarget(target: any): Nullable<Animatable>;
  86677. /**
  86678. * Gets all animatables associated with a given target
  86679. * @param target defines the target to look animatables for
  86680. * @returns an array of Animatables
  86681. */
  86682. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  86683. /**
  86684. * Stops and removes all animations that have been applied to the scene
  86685. */
  86686. stopAllAnimations(): void;
  86687. /**
  86688. * Gets the current delta time used by animation engine
  86689. */
  86690. deltaTime: number;
  86691. }
  86692. interface Bone {
  86693. /**
  86694. * Copy an animation range from another bone
  86695. * @param source defines the source bone
  86696. * @param rangeName defines the range name to copy
  86697. * @param frameOffset defines the frame offset
  86698. * @param rescaleAsRequired defines if rescaling must be applied if required
  86699. * @param skelDimensionsRatio defines the scaling ratio
  86700. * @returns true if operation was successful
  86701. */
  86702. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  86703. }
  86704. }
  86705. declare module BABYLON {
  86706. /**
  86707. * Class used to override all child animations of a given target
  86708. */
  86709. export class AnimationPropertiesOverride {
  86710. /**
  86711. * Gets or sets a value indicating if animation blending must be used
  86712. */
  86713. enableBlending: boolean;
  86714. /**
  86715. * Gets or sets the blending speed to use when enableBlending is true
  86716. */
  86717. blendingSpeed: number;
  86718. /**
  86719. * Gets or sets the default loop mode to use
  86720. */
  86721. loopMode: number;
  86722. }
  86723. }
  86724. declare module BABYLON {
  86725. /**
  86726. * Class used to handle skinning animations
  86727. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86728. */
  86729. export class Skeleton implements IAnimatable {
  86730. /** defines the skeleton name */
  86731. name: string;
  86732. /** defines the skeleton Id */
  86733. id: string;
  86734. /**
  86735. * Defines the list of child bones
  86736. */
  86737. bones: Bone[];
  86738. /**
  86739. * Defines an estimate of the dimension of the skeleton at rest
  86740. */
  86741. dimensionsAtRest: Vector3;
  86742. /**
  86743. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  86744. */
  86745. needInitialSkinMatrix: boolean;
  86746. /**
  86747. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  86748. */
  86749. overrideMesh: Nullable<AbstractMesh>;
  86750. /**
  86751. * Gets the list of animations attached to this skeleton
  86752. */
  86753. animations: Array<Animation>;
  86754. private _scene;
  86755. private _isDirty;
  86756. private _transformMatrices;
  86757. private _transformMatrixTexture;
  86758. private _meshesWithPoseMatrix;
  86759. private _animatables;
  86760. private _identity;
  86761. private _synchronizedWithMesh;
  86762. private _ranges;
  86763. private _lastAbsoluteTransformsUpdateId;
  86764. private _canUseTextureForBones;
  86765. private _uniqueId;
  86766. /** @hidden */
  86767. _numBonesWithLinkedTransformNode: number;
  86768. /** @hidden */
  86769. _hasWaitingData: Nullable<boolean>;
  86770. /**
  86771. * Specifies if the skeleton should be serialized
  86772. */
  86773. doNotSerialize: boolean;
  86774. private _useTextureToStoreBoneMatrices;
  86775. /**
  86776. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  86777. * Please note that this option is not available if the hardware does not support it
  86778. */
  86779. get useTextureToStoreBoneMatrices(): boolean;
  86780. set useTextureToStoreBoneMatrices(value: boolean);
  86781. private _animationPropertiesOverride;
  86782. /**
  86783. * Gets or sets the animation properties override
  86784. */
  86785. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86786. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  86787. /**
  86788. * List of inspectable custom properties (used by the Inspector)
  86789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86790. */
  86791. inspectableCustomProperties: IInspectable[];
  86792. /**
  86793. * An observable triggered before computing the skeleton's matrices
  86794. */
  86795. onBeforeComputeObservable: Observable<Skeleton>;
  86796. /**
  86797. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  86798. */
  86799. get isUsingTextureForMatrices(): boolean;
  86800. /**
  86801. * Gets the unique ID of this skeleton
  86802. */
  86803. get uniqueId(): number;
  86804. /**
  86805. * Creates a new skeleton
  86806. * @param name defines the skeleton name
  86807. * @param id defines the skeleton Id
  86808. * @param scene defines the hosting scene
  86809. */
  86810. constructor(
  86811. /** defines the skeleton name */
  86812. name: string,
  86813. /** defines the skeleton Id */
  86814. id: string, scene: Scene);
  86815. /**
  86816. * Gets the current object class name.
  86817. * @return the class name
  86818. */
  86819. getClassName(): string;
  86820. /**
  86821. * Returns an array containing the root bones
  86822. * @returns an array containing the root bones
  86823. */
  86824. getChildren(): Array<Bone>;
  86825. /**
  86826. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  86827. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86828. * @returns a Float32Array containing matrices data
  86829. */
  86830. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  86831. /**
  86832. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  86833. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86834. * @returns a raw texture containing the data
  86835. */
  86836. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  86837. /**
  86838. * Gets the current hosting scene
  86839. * @returns a scene object
  86840. */
  86841. getScene(): Scene;
  86842. /**
  86843. * Gets a string representing the current skeleton data
  86844. * @param fullDetails defines a boolean indicating if we want a verbose version
  86845. * @returns a string representing the current skeleton data
  86846. */
  86847. toString(fullDetails?: boolean): string;
  86848. /**
  86849. * Get bone's index searching by name
  86850. * @param name defines bone's name to search for
  86851. * @return the indice of the bone. Returns -1 if not found
  86852. */
  86853. getBoneIndexByName(name: string): number;
  86854. /**
  86855. * Creater a new animation range
  86856. * @param name defines the name of the range
  86857. * @param from defines the start key
  86858. * @param to defines the end key
  86859. */
  86860. createAnimationRange(name: string, from: number, to: number): void;
  86861. /**
  86862. * Delete a specific animation range
  86863. * @param name defines the name of the range
  86864. * @param deleteFrames defines if frames must be removed as well
  86865. */
  86866. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  86867. /**
  86868. * Gets a specific animation range
  86869. * @param name defines the name of the range to look for
  86870. * @returns the requested animation range or null if not found
  86871. */
  86872. getAnimationRange(name: string): Nullable<AnimationRange>;
  86873. /**
  86874. * Gets the list of all animation ranges defined on this skeleton
  86875. * @returns an array
  86876. */
  86877. getAnimationRanges(): Nullable<AnimationRange>[];
  86878. /**
  86879. * Copy animation range from a source skeleton.
  86880. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  86881. * @param source defines the source skeleton
  86882. * @param name defines the name of the range to copy
  86883. * @param rescaleAsRequired defines if rescaling must be applied if required
  86884. * @returns true if operation was successful
  86885. */
  86886. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  86887. /**
  86888. * Forces the skeleton to go to rest pose
  86889. */
  86890. returnToRest(): void;
  86891. private _getHighestAnimationFrame;
  86892. /**
  86893. * Begin a specific animation range
  86894. * @param name defines the name of the range to start
  86895. * @param loop defines if looping must be turned on (false by default)
  86896. * @param speedRatio defines the speed ratio to apply (1 by default)
  86897. * @param onAnimationEnd defines a callback which will be called when animation will end
  86898. * @returns a new animatable
  86899. */
  86900. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  86901. /** @hidden */
  86902. _markAsDirty(): void;
  86903. /** @hidden */
  86904. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86905. /** @hidden */
  86906. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86907. private _computeTransformMatrices;
  86908. /**
  86909. * Build all resources required to render a skeleton
  86910. */
  86911. prepare(): void;
  86912. /**
  86913. * Gets the list of animatables currently running for this skeleton
  86914. * @returns an array of animatables
  86915. */
  86916. getAnimatables(): IAnimatable[];
  86917. /**
  86918. * Clone the current skeleton
  86919. * @param name defines the name of the new skeleton
  86920. * @param id defines the id of the new skeleton
  86921. * @returns the new skeleton
  86922. */
  86923. clone(name: string, id?: string): Skeleton;
  86924. /**
  86925. * Enable animation blending for this skeleton
  86926. * @param blendingSpeed defines the blending speed to apply
  86927. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86928. */
  86929. enableBlending(blendingSpeed?: number): void;
  86930. /**
  86931. * Releases all resources associated with the current skeleton
  86932. */
  86933. dispose(): void;
  86934. /**
  86935. * Serialize the skeleton in a JSON object
  86936. * @returns a JSON object
  86937. */
  86938. serialize(): any;
  86939. /**
  86940. * Creates a new skeleton from serialized data
  86941. * @param parsedSkeleton defines the serialized data
  86942. * @param scene defines the hosting scene
  86943. * @returns a new skeleton
  86944. */
  86945. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  86946. /**
  86947. * Compute all node absolute transforms
  86948. * @param forceUpdate defines if computation must be done even if cache is up to date
  86949. */
  86950. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  86951. /**
  86952. * Gets the root pose matrix
  86953. * @returns a matrix
  86954. */
  86955. getPoseMatrix(): Nullable<Matrix>;
  86956. /**
  86957. * Sorts bones per internal index
  86958. */
  86959. sortBones(): void;
  86960. private _sortBones;
  86961. }
  86962. }
  86963. declare module BABYLON {
  86964. /**
  86965. * Class used to store bone information
  86966. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86967. */
  86968. export class Bone extends Node {
  86969. /**
  86970. * defines the bone name
  86971. */
  86972. name: string;
  86973. private static _tmpVecs;
  86974. private static _tmpQuat;
  86975. private static _tmpMats;
  86976. /**
  86977. * Gets the list of child bones
  86978. */
  86979. children: Bone[];
  86980. /** Gets the animations associated with this bone */
  86981. animations: Animation[];
  86982. /**
  86983. * Gets or sets bone length
  86984. */
  86985. length: number;
  86986. /**
  86987. * @hidden Internal only
  86988. * Set this value to map this bone to a different index in the transform matrices
  86989. * Set this value to -1 to exclude the bone from the transform matrices
  86990. */
  86991. _index: Nullable<number>;
  86992. private _skeleton;
  86993. private _localMatrix;
  86994. private _restPose;
  86995. private _baseMatrix;
  86996. private _absoluteTransform;
  86997. private _invertedAbsoluteTransform;
  86998. private _parent;
  86999. private _scalingDeterminant;
  87000. private _worldTransform;
  87001. private _localScaling;
  87002. private _localRotation;
  87003. private _localPosition;
  87004. private _needToDecompose;
  87005. private _needToCompose;
  87006. /** @hidden */
  87007. _linkedTransformNode: Nullable<TransformNode>;
  87008. /** @hidden */
  87009. _waitingTransformNodeId: Nullable<string>;
  87010. /** @hidden */
  87011. get _matrix(): Matrix;
  87012. /** @hidden */
  87013. set _matrix(value: Matrix);
  87014. /**
  87015. * Create a new bone
  87016. * @param name defines the bone name
  87017. * @param skeleton defines the parent skeleton
  87018. * @param parentBone defines the parent (can be null if the bone is the root)
  87019. * @param localMatrix defines the local matrix
  87020. * @param restPose defines the rest pose matrix
  87021. * @param baseMatrix defines the base matrix
  87022. * @param index defines index of the bone in the hiearchy
  87023. */
  87024. constructor(
  87025. /**
  87026. * defines the bone name
  87027. */
  87028. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87029. /**
  87030. * Gets the current object class name.
  87031. * @return the class name
  87032. */
  87033. getClassName(): string;
  87034. /**
  87035. * Gets the parent skeleton
  87036. * @returns a skeleton
  87037. */
  87038. getSkeleton(): Skeleton;
  87039. /**
  87040. * Gets parent bone
  87041. * @returns a bone or null if the bone is the root of the bone hierarchy
  87042. */
  87043. getParent(): Nullable<Bone>;
  87044. /**
  87045. * Returns an array containing the root bones
  87046. * @returns an array containing the root bones
  87047. */
  87048. getChildren(): Array<Bone>;
  87049. /**
  87050. * Gets the node index in matrix array generated for rendering
  87051. * @returns the node index
  87052. */
  87053. getIndex(): number;
  87054. /**
  87055. * Sets the parent bone
  87056. * @param parent defines the parent (can be null if the bone is the root)
  87057. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87058. */
  87059. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87060. /**
  87061. * Gets the local matrix
  87062. * @returns a matrix
  87063. */
  87064. getLocalMatrix(): Matrix;
  87065. /**
  87066. * Gets the base matrix (initial matrix which remains unchanged)
  87067. * @returns a matrix
  87068. */
  87069. getBaseMatrix(): Matrix;
  87070. /**
  87071. * Gets the rest pose matrix
  87072. * @returns a matrix
  87073. */
  87074. getRestPose(): Matrix;
  87075. /**
  87076. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87077. */
  87078. getWorldMatrix(): Matrix;
  87079. /**
  87080. * Sets the local matrix to rest pose matrix
  87081. */
  87082. returnToRest(): void;
  87083. /**
  87084. * Gets the inverse of the absolute transform matrix.
  87085. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87086. * @returns a matrix
  87087. */
  87088. getInvertedAbsoluteTransform(): Matrix;
  87089. /**
  87090. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87091. * @returns a matrix
  87092. */
  87093. getAbsoluteTransform(): Matrix;
  87094. /**
  87095. * Links with the given transform node.
  87096. * The local matrix of this bone is copied from the transform node every frame.
  87097. * @param transformNode defines the transform node to link to
  87098. */
  87099. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87100. /**
  87101. * Gets the node used to drive the bone's transformation
  87102. * @returns a transform node or null
  87103. */
  87104. getTransformNode(): Nullable<TransformNode>;
  87105. /** Gets or sets current position (in local space) */
  87106. get position(): Vector3;
  87107. set position(newPosition: Vector3);
  87108. /** Gets or sets current rotation (in local space) */
  87109. get rotation(): Vector3;
  87110. set rotation(newRotation: Vector3);
  87111. /** Gets or sets current rotation quaternion (in local space) */
  87112. get rotationQuaternion(): Quaternion;
  87113. set rotationQuaternion(newRotation: Quaternion);
  87114. /** Gets or sets current scaling (in local space) */
  87115. get scaling(): Vector3;
  87116. set scaling(newScaling: Vector3);
  87117. /**
  87118. * Gets the animation properties override
  87119. */
  87120. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87121. private _decompose;
  87122. private _compose;
  87123. /**
  87124. * Update the base and local matrices
  87125. * @param matrix defines the new base or local matrix
  87126. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87127. * @param updateLocalMatrix defines if the local matrix should be updated
  87128. */
  87129. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87130. /** @hidden */
  87131. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87132. /**
  87133. * Flag the bone as dirty (Forcing it to update everything)
  87134. */
  87135. markAsDirty(): void;
  87136. /** @hidden */
  87137. _markAsDirtyAndCompose(): void;
  87138. private _markAsDirtyAndDecompose;
  87139. /**
  87140. * Translate the bone in local or world space
  87141. * @param vec The amount to translate the bone
  87142. * @param space The space that the translation is in
  87143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87144. */
  87145. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87146. /**
  87147. * Set the postion of the bone in local or world space
  87148. * @param position The position to set the bone
  87149. * @param space The space that the position is in
  87150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87151. */
  87152. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87153. /**
  87154. * Set the absolute position of the bone (world space)
  87155. * @param position The position to set the bone
  87156. * @param mesh The mesh that this bone is attached to
  87157. */
  87158. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87159. /**
  87160. * Scale the bone on the x, y and z axes (in local space)
  87161. * @param x The amount to scale the bone on the x axis
  87162. * @param y The amount to scale the bone on the y axis
  87163. * @param z The amount to scale the bone on the z axis
  87164. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87165. */
  87166. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87167. /**
  87168. * Set the bone scaling in local space
  87169. * @param scale defines the scaling vector
  87170. */
  87171. setScale(scale: Vector3): void;
  87172. /**
  87173. * Gets the current scaling in local space
  87174. * @returns the current scaling vector
  87175. */
  87176. getScale(): Vector3;
  87177. /**
  87178. * Gets the current scaling in local space and stores it in a target vector
  87179. * @param result defines the target vector
  87180. */
  87181. getScaleToRef(result: Vector3): void;
  87182. /**
  87183. * Set the yaw, pitch, and roll of the bone in local or world space
  87184. * @param yaw The rotation of the bone on the y axis
  87185. * @param pitch The rotation of the bone on the x axis
  87186. * @param roll The rotation of the bone on the z axis
  87187. * @param space The space that the axes of rotation are in
  87188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87189. */
  87190. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87191. /**
  87192. * Add a rotation to the bone on an axis in local or world space
  87193. * @param axis The axis to rotate the bone on
  87194. * @param amount The amount to rotate the bone
  87195. * @param space The space that the axis is in
  87196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87197. */
  87198. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87199. /**
  87200. * Set the rotation of the bone to a particular axis angle in local or world space
  87201. * @param axis The axis to rotate the bone on
  87202. * @param angle The angle that the bone should be rotated to
  87203. * @param space The space that the axis is in
  87204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87205. */
  87206. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87207. /**
  87208. * Set the euler rotation of the bone in local of world space
  87209. * @param rotation The euler rotation that the bone should be set to
  87210. * @param space The space that the rotation is in
  87211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87212. */
  87213. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87214. /**
  87215. * Set the quaternion rotation of the bone in local of world space
  87216. * @param quat The quaternion rotation that the bone should be set to
  87217. * @param space The space that the rotation is in
  87218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87219. */
  87220. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87221. /**
  87222. * Set the rotation matrix of the bone in local of world space
  87223. * @param rotMat The rotation matrix that the bone should be set to
  87224. * @param space The space that the rotation is in
  87225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87226. */
  87227. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87228. private _rotateWithMatrix;
  87229. private _getNegativeRotationToRef;
  87230. /**
  87231. * Get the position of the bone in local or world space
  87232. * @param space The space that the returned position is in
  87233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87234. * @returns The position of the bone
  87235. */
  87236. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87237. /**
  87238. * Copy the position of the bone to a vector3 in local or world space
  87239. * @param space The space that the returned position is in
  87240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87241. * @param result The vector3 to copy the position to
  87242. */
  87243. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87244. /**
  87245. * Get the absolute position of the bone (world space)
  87246. * @param mesh The mesh that this bone is attached to
  87247. * @returns The absolute position of the bone
  87248. */
  87249. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87250. /**
  87251. * Copy the absolute position of the bone (world space) to the result param
  87252. * @param mesh The mesh that this bone is attached to
  87253. * @param result The vector3 to copy the absolute position to
  87254. */
  87255. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87256. /**
  87257. * Compute the absolute transforms of this bone and its children
  87258. */
  87259. computeAbsoluteTransforms(): void;
  87260. /**
  87261. * Get the world direction from an axis that is in the local space of the bone
  87262. * @param localAxis The local direction that is used to compute the world direction
  87263. * @param mesh The mesh that this bone is attached to
  87264. * @returns The world direction
  87265. */
  87266. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87267. /**
  87268. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87269. * @param localAxis The local direction that is used to compute the world direction
  87270. * @param mesh The mesh that this bone is attached to
  87271. * @param result The vector3 that the world direction will be copied to
  87272. */
  87273. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87274. /**
  87275. * Get the euler rotation of the bone in local or world space
  87276. * @param space The space that the rotation should be in
  87277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87278. * @returns The euler rotation
  87279. */
  87280. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87281. /**
  87282. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87283. * @param space The space that the rotation should be in
  87284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87285. * @param result The vector3 that the rotation should be copied to
  87286. */
  87287. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87288. /**
  87289. * Get the quaternion rotation of the bone in either local or world space
  87290. * @param space The space that the rotation should be in
  87291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87292. * @returns The quaternion rotation
  87293. */
  87294. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87295. /**
  87296. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87297. * @param space The space that the rotation should be in
  87298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87299. * @param result The quaternion that the rotation should be copied to
  87300. */
  87301. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87302. /**
  87303. * Get the rotation matrix of the bone in local or world space
  87304. * @param space The space that the rotation should be in
  87305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87306. * @returns The rotation matrix
  87307. */
  87308. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87309. /**
  87310. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87311. * @param space The space that the rotation should be in
  87312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87313. * @param result The quaternion that the rotation should be copied to
  87314. */
  87315. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87316. /**
  87317. * Get the world position of a point that is in the local space of the bone
  87318. * @param position The local position
  87319. * @param mesh The mesh that this bone is attached to
  87320. * @returns The world position
  87321. */
  87322. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87323. /**
  87324. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87325. * @param position The local position
  87326. * @param mesh The mesh that this bone is attached to
  87327. * @param result The vector3 that the world position should be copied to
  87328. */
  87329. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87330. /**
  87331. * Get the local position of a point that is in world space
  87332. * @param position The world position
  87333. * @param mesh The mesh that this bone is attached to
  87334. * @returns The local position
  87335. */
  87336. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87337. /**
  87338. * Get the local position of a point that is in world space and copy it to the result param
  87339. * @param position The world position
  87340. * @param mesh The mesh that this bone is attached to
  87341. * @param result The vector3 that the local position should be copied to
  87342. */
  87343. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87344. }
  87345. }
  87346. declare module BABYLON {
  87347. /**
  87348. * 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.
  87349. * @see https://doc.babylonjs.com/how_to/transformnode
  87350. */
  87351. export class TransformNode extends Node {
  87352. /**
  87353. * Object will not rotate to face the camera
  87354. */
  87355. static BILLBOARDMODE_NONE: number;
  87356. /**
  87357. * Object will rotate to face the camera but only on the x axis
  87358. */
  87359. static BILLBOARDMODE_X: number;
  87360. /**
  87361. * Object will rotate to face the camera but only on the y axis
  87362. */
  87363. static BILLBOARDMODE_Y: number;
  87364. /**
  87365. * Object will rotate to face the camera but only on the z axis
  87366. */
  87367. static BILLBOARDMODE_Z: number;
  87368. /**
  87369. * Object will rotate to face the camera
  87370. */
  87371. static BILLBOARDMODE_ALL: number;
  87372. /**
  87373. * Object will rotate to face the camera's position instead of orientation
  87374. */
  87375. static BILLBOARDMODE_USE_POSITION: number;
  87376. private _forward;
  87377. private _forwardInverted;
  87378. private _up;
  87379. private _right;
  87380. private _rightInverted;
  87381. private _position;
  87382. private _rotation;
  87383. private _rotationQuaternion;
  87384. protected _scaling: Vector3;
  87385. protected _isDirty: boolean;
  87386. private _transformToBoneReferal;
  87387. private _isAbsoluteSynced;
  87388. private _billboardMode;
  87389. /**
  87390. * Gets or sets the billboard mode. Default is 0.
  87391. *
  87392. * | Value | Type | Description |
  87393. * | --- | --- | --- |
  87394. * | 0 | BILLBOARDMODE_NONE | |
  87395. * | 1 | BILLBOARDMODE_X | |
  87396. * | 2 | BILLBOARDMODE_Y | |
  87397. * | 4 | BILLBOARDMODE_Z | |
  87398. * | 7 | BILLBOARDMODE_ALL | |
  87399. *
  87400. */
  87401. get billboardMode(): number;
  87402. set billboardMode(value: number);
  87403. private _preserveParentRotationForBillboard;
  87404. /**
  87405. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87406. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87407. */
  87408. get preserveParentRotationForBillboard(): boolean;
  87409. set preserveParentRotationForBillboard(value: boolean);
  87410. /**
  87411. * 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
  87412. */
  87413. scalingDeterminant: number;
  87414. private _infiniteDistance;
  87415. /**
  87416. * Gets or sets the distance of the object to max, often used by skybox
  87417. */
  87418. get infiniteDistance(): boolean;
  87419. set infiniteDistance(value: boolean);
  87420. /**
  87421. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87422. * By default the system will update normals to compensate
  87423. */
  87424. ignoreNonUniformScaling: boolean;
  87425. /**
  87426. * 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
  87427. */
  87428. reIntegrateRotationIntoRotationQuaternion: boolean;
  87429. /** @hidden */
  87430. _poseMatrix: Nullable<Matrix>;
  87431. /** @hidden */
  87432. _localMatrix: Matrix;
  87433. private _usePivotMatrix;
  87434. private _absolutePosition;
  87435. private _absoluteScaling;
  87436. private _absoluteRotationQuaternion;
  87437. private _pivotMatrix;
  87438. private _pivotMatrixInverse;
  87439. protected _postMultiplyPivotMatrix: boolean;
  87440. protected _isWorldMatrixFrozen: boolean;
  87441. /** @hidden */
  87442. _indexInSceneTransformNodesArray: number;
  87443. /**
  87444. * An event triggered after the world matrix is updated
  87445. */
  87446. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87447. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87448. /**
  87449. * Gets a string identifying the name of the class
  87450. * @returns "TransformNode" string
  87451. */
  87452. getClassName(): string;
  87453. /**
  87454. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87455. */
  87456. get position(): Vector3;
  87457. set position(newPosition: Vector3);
  87458. /**
  87459. * 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)).
  87460. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87461. */
  87462. get rotation(): Vector3;
  87463. set rotation(newRotation: Vector3);
  87464. /**
  87465. * 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)).
  87466. */
  87467. get scaling(): Vector3;
  87468. set scaling(newScaling: Vector3);
  87469. /**
  87470. * 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).
  87471. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87472. */
  87473. get rotationQuaternion(): Nullable<Quaternion>;
  87474. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87475. /**
  87476. * The forward direction of that transform in world space.
  87477. */
  87478. get forward(): Vector3;
  87479. /**
  87480. * The up direction of that transform in world space.
  87481. */
  87482. get up(): Vector3;
  87483. /**
  87484. * The right direction of that transform in world space.
  87485. */
  87486. get right(): Vector3;
  87487. /**
  87488. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87489. * @param matrix the matrix to copy the pose from
  87490. * @returns this TransformNode.
  87491. */
  87492. updatePoseMatrix(matrix: Matrix): TransformNode;
  87493. /**
  87494. * Returns the mesh Pose matrix.
  87495. * @returns the pose matrix
  87496. */
  87497. getPoseMatrix(): Matrix;
  87498. /** @hidden */
  87499. _isSynchronized(): boolean;
  87500. /** @hidden */
  87501. _initCache(): void;
  87502. /**
  87503. * Flag the transform node as dirty (Forcing it to update everything)
  87504. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87505. * @returns this transform node
  87506. */
  87507. markAsDirty(property: string): TransformNode;
  87508. /**
  87509. * Returns the current mesh absolute position.
  87510. * Returns a Vector3.
  87511. */
  87512. get absolutePosition(): Vector3;
  87513. /**
  87514. * Returns the current mesh absolute scaling.
  87515. * Returns a Vector3.
  87516. */
  87517. get absoluteScaling(): Vector3;
  87518. /**
  87519. * Returns the current mesh absolute rotation.
  87520. * Returns a Quaternion.
  87521. */
  87522. get absoluteRotationQuaternion(): Quaternion;
  87523. /**
  87524. * Sets a new matrix to apply before all other transformation
  87525. * @param matrix defines the transform matrix
  87526. * @returns the current TransformNode
  87527. */
  87528. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87529. /**
  87530. * Sets a new pivot matrix to the current node
  87531. * @param matrix defines the new pivot matrix to use
  87532. * @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
  87533. * @returns the current TransformNode
  87534. */
  87535. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87536. /**
  87537. * Returns the mesh pivot matrix.
  87538. * Default : Identity.
  87539. * @returns the matrix
  87540. */
  87541. getPivotMatrix(): Matrix;
  87542. /**
  87543. * Instantiate (when possible) or clone that node with its hierarchy
  87544. * @param newParent defines the new parent to use for the instance (or clone)
  87545. * @param options defines options to configure how copy is done
  87546. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87547. * @returns an instance (or a clone) of the current node with its hiearchy
  87548. */
  87549. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87550. doNotInstantiate: boolean;
  87551. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87552. /**
  87553. * Prevents the World matrix to be computed any longer
  87554. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87555. * @returns the TransformNode.
  87556. */
  87557. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87558. /**
  87559. * Allows back the World matrix computation.
  87560. * @returns the TransformNode.
  87561. */
  87562. unfreezeWorldMatrix(): this;
  87563. /**
  87564. * True if the World matrix has been frozen.
  87565. */
  87566. get isWorldMatrixFrozen(): boolean;
  87567. /**
  87568. * Retuns the mesh absolute position in the World.
  87569. * @returns a Vector3.
  87570. */
  87571. getAbsolutePosition(): Vector3;
  87572. /**
  87573. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87574. * @param absolutePosition the absolute position to set
  87575. * @returns the TransformNode.
  87576. */
  87577. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87578. /**
  87579. * Sets the mesh position in its local space.
  87580. * @param vector3 the position to set in localspace
  87581. * @returns the TransformNode.
  87582. */
  87583. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87584. /**
  87585. * Returns the mesh position in the local space from the current World matrix values.
  87586. * @returns a new Vector3.
  87587. */
  87588. getPositionExpressedInLocalSpace(): Vector3;
  87589. /**
  87590. * Translates the mesh along the passed Vector3 in its local space.
  87591. * @param vector3 the distance to translate in localspace
  87592. * @returns the TransformNode.
  87593. */
  87594. locallyTranslate(vector3: Vector3): TransformNode;
  87595. private static _lookAtVectorCache;
  87596. /**
  87597. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87598. * @param targetPoint the position (must be in same space as current mesh) to look at
  87599. * @param yawCor optional yaw (y-axis) correction in radians
  87600. * @param pitchCor optional pitch (x-axis) correction in radians
  87601. * @param rollCor optional roll (z-axis) correction in radians
  87602. * @param space the choosen space of the target
  87603. * @returns the TransformNode.
  87604. */
  87605. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87606. /**
  87607. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87608. * This Vector3 is expressed in the World space.
  87609. * @param localAxis axis to rotate
  87610. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87611. */
  87612. getDirection(localAxis: Vector3): Vector3;
  87613. /**
  87614. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87615. * localAxis is expressed in the mesh local space.
  87616. * result is computed in the Wordl space from the mesh World matrix.
  87617. * @param localAxis axis to rotate
  87618. * @param result the resulting transformnode
  87619. * @returns this TransformNode.
  87620. */
  87621. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87622. /**
  87623. * Sets this transform node rotation to the given local axis.
  87624. * @param localAxis the axis in local space
  87625. * @param yawCor optional yaw (y-axis) correction in radians
  87626. * @param pitchCor optional pitch (x-axis) correction in radians
  87627. * @param rollCor optional roll (z-axis) correction in radians
  87628. * @returns this TransformNode
  87629. */
  87630. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87631. /**
  87632. * Sets a new pivot point to the current node
  87633. * @param point defines the new pivot point to use
  87634. * @param space defines if the point is in world or local space (local by default)
  87635. * @returns the current TransformNode
  87636. */
  87637. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87638. /**
  87639. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87640. * @returns the pivot point
  87641. */
  87642. getPivotPoint(): Vector3;
  87643. /**
  87644. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87645. * @param result the vector3 to store the result
  87646. * @returns this TransformNode.
  87647. */
  87648. getPivotPointToRef(result: Vector3): TransformNode;
  87649. /**
  87650. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87651. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87652. */
  87653. getAbsolutePivotPoint(): Vector3;
  87654. /**
  87655. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87656. * @param result vector3 to store the result
  87657. * @returns this TransformNode.
  87658. */
  87659. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87660. /**
  87661. * Defines the passed node as the parent of the current node.
  87662. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87663. * @see https://doc.babylonjs.com/how_to/parenting
  87664. * @param node the node ot set as the parent
  87665. * @returns this TransformNode.
  87666. */
  87667. setParent(node: Nullable<Node>): TransformNode;
  87668. private _nonUniformScaling;
  87669. /**
  87670. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87671. */
  87672. get nonUniformScaling(): boolean;
  87673. /** @hidden */
  87674. _updateNonUniformScalingState(value: boolean): boolean;
  87675. /**
  87676. * Attach the current TransformNode to another TransformNode associated with a bone
  87677. * @param bone Bone affecting the TransformNode
  87678. * @param affectedTransformNode TransformNode associated with the bone
  87679. * @returns this object
  87680. */
  87681. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87682. /**
  87683. * Detach the transform node if its associated with a bone
  87684. * @returns this object
  87685. */
  87686. detachFromBone(): TransformNode;
  87687. private static _rotationAxisCache;
  87688. /**
  87689. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87690. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87691. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87692. * The passed axis is also normalized.
  87693. * @param axis the axis to rotate around
  87694. * @param amount the amount to rotate in radians
  87695. * @param space Space to rotate in (Default: local)
  87696. * @returns the TransformNode.
  87697. */
  87698. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87699. /**
  87700. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87701. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87702. * The passed axis is also normalized. .
  87703. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87704. * @param point the point to rotate around
  87705. * @param axis the axis to rotate around
  87706. * @param amount the amount to rotate in radians
  87707. * @returns the TransformNode
  87708. */
  87709. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87710. /**
  87711. * Translates the mesh along the axis vector for the passed distance in the given space.
  87712. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87713. * @param axis the axis to translate in
  87714. * @param distance the distance to translate
  87715. * @param space Space to rotate in (Default: local)
  87716. * @returns the TransformNode.
  87717. */
  87718. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87719. /**
  87720. * Adds a rotation step to the mesh current rotation.
  87721. * x, y, z are Euler angles expressed in radians.
  87722. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87723. * This means this rotation is made in the mesh local space only.
  87724. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87725. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87726. * ```javascript
  87727. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87728. * ```
  87729. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87730. * 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.
  87731. * @param x Rotation to add
  87732. * @param y Rotation to add
  87733. * @param z Rotation to add
  87734. * @returns the TransformNode.
  87735. */
  87736. addRotation(x: number, y: number, z: number): TransformNode;
  87737. /**
  87738. * @hidden
  87739. */
  87740. protected _getEffectiveParent(): Nullable<Node>;
  87741. /**
  87742. * Computes the world matrix of the node
  87743. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87744. * @returns the world matrix
  87745. */
  87746. computeWorldMatrix(force?: boolean): Matrix;
  87747. /**
  87748. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87749. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87750. */
  87751. resetLocalMatrix(independentOfChildren?: boolean): void;
  87752. protected _afterComputeWorldMatrix(): void;
  87753. /**
  87754. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87755. * @param func callback function to add
  87756. *
  87757. * @returns the TransformNode.
  87758. */
  87759. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87760. /**
  87761. * Removes a registered callback function.
  87762. * @param func callback function to remove
  87763. * @returns the TransformNode.
  87764. */
  87765. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87766. /**
  87767. * Gets the position of the current mesh in camera space
  87768. * @param camera defines the camera to use
  87769. * @returns a position
  87770. */
  87771. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87772. /**
  87773. * Returns the distance from the mesh to the active camera
  87774. * @param camera defines the camera to use
  87775. * @returns the distance
  87776. */
  87777. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87778. /**
  87779. * Clone the current transform node
  87780. * @param name Name of the new clone
  87781. * @param newParent New parent for the clone
  87782. * @param doNotCloneChildren Do not clone children hierarchy
  87783. * @returns the new transform node
  87784. */
  87785. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87786. /**
  87787. * Serializes the objects information.
  87788. * @param currentSerializationObject defines the object to serialize in
  87789. * @returns the serialized object
  87790. */
  87791. serialize(currentSerializationObject?: any): any;
  87792. /**
  87793. * Returns a new TransformNode object parsed from the source provided.
  87794. * @param parsedTransformNode is the source.
  87795. * @param scene the scne the object belongs to
  87796. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87797. * @returns a new TransformNode object parsed from the source provided.
  87798. */
  87799. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87800. /**
  87801. * Get all child-transformNodes of this node
  87802. * @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
  87803. * @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
  87804. * @returns an array of TransformNode
  87805. */
  87806. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87807. /**
  87808. * Releases resources associated with this transform node.
  87809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87811. */
  87812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87813. /**
  87814. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87815. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87816. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87817. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87818. * @returns the current mesh
  87819. */
  87820. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87821. private _syncAbsoluteScalingAndRotation;
  87822. }
  87823. }
  87824. declare module BABYLON {
  87825. /**
  87826. * Defines the types of pose enabled controllers that are supported
  87827. */
  87828. export enum PoseEnabledControllerType {
  87829. /**
  87830. * HTC Vive
  87831. */
  87832. VIVE = 0,
  87833. /**
  87834. * Oculus Rift
  87835. */
  87836. OCULUS = 1,
  87837. /**
  87838. * Windows mixed reality
  87839. */
  87840. WINDOWS = 2,
  87841. /**
  87842. * Samsung gear VR
  87843. */
  87844. GEAR_VR = 3,
  87845. /**
  87846. * Google Daydream
  87847. */
  87848. DAYDREAM = 4,
  87849. /**
  87850. * Generic
  87851. */
  87852. GENERIC = 5
  87853. }
  87854. /**
  87855. * Defines the MutableGamepadButton interface for the state of a gamepad button
  87856. */
  87857. export interface MutableGamepadButton {
  87858. /**
  87859. * Value of the button/trigger
  87860. */
  87861. value: number;
  87862. /**
  87863. * If the button/trigger is currently touched
  87864. */
  87865. touched: boolean;
  87866. /**
  87867. * If the button/trigger is currently pressed
  87868. */
  87869. pressed: boolean;
  87870. }
  87871. /**
  87872. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  87873. * @hidden
  87874. */
  87875. export interface ExtendedGamepadButton extends GamepadButton {
  87876. /**
  87877. * If the button/trigger is currently pressed
  87878. */
  87879. readonly pressed: boolean;
  87880. /**
  87881. * If the button/trigger is currently touched
  87882. */
  87883. readonly touched: boolean;
  87884. /**
  87885. * Value of the button/trigger
  87886. */
  87887. readonly value: number;
  87888. }
  87889. /** @hidden */
  87890. export interface _GamePadFactory {
  87891. /**
  87892. * Returns whether or not the current gamepad can be created for this type of controller.
  87893. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  87894. * @returns true if it can be created, otherwise false
  87895. */
  87896. canCreate(gamepadInfo: any): boolean;
  87897. /**
  87898. * Creates a new instance of the Gamepad.
  87899. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  87900. * @returns the new gamepad instance
  87901. */
  87902. create(gamepadInfo: any): Gamepad;
  87903. }
  87904. /**
  87905. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87906. */
  87907. export class PoseEnabledControllerHelper {
  87908. /** @hidden */
  87909. static _ControllerFactories: _GamePadFactory[];
  87910. /** @hidden */
  87911. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  87912. /**
  87913. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87914. * @param vrGamepad the gamepad to initialized
  87915. * @returns a vr controller of the type the gamepad identified as
  87916. */
  87917. static InitiateController(vrGamepad: any): Gamepad;
  87918. }
  87919. /**
  87920. * Defines the PoseEnabledController object that contains state of a vr capable controller
  87921. */
  87922. export class PoseEnabledController extends Gamepad implements PoseControlled {
  87923. /**
  87924. * If the controller is used in a webXR session
  87925. */
  87926. isXR: boolean;
  87927. private _deviceRoomPosition;
  87928. private _deviceRoomRotationQuaternion;
  87929. /**
  87930. * The device position in babylon space
  87931. */
  87932. devicePosition: Vector3;
  87933. /**
  87934. * The device rotation in babylon space
  87935. */
  87936. deviceRotationQuaternion: Quaternion;
  87937. /**
  87938. * The scale factor of the device in babylon space
  87939. */
  87940. deviceScaleFactor: number;
  87941. /**
  87942. * (Likely devicePosition should be used instead) The device position in its room space
  87943. */
  87944. position: Vector3;
  87945. /**
  87946. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  87947. */
  87948. rotationQuaternion: Quaternion;
  87949. /**
  87950. * The type of controller (Eg. Windows mixed reality)
  87951. */
  87952. controllerType: PoseEnabledControllerType;
  87953. protected _calculatedPosition: Vector3;
  87954. private _calculatedRotation;
  87955. /**
  87956. * The raw pose from the device
  87957. */
  87958. rawPose: DevicePose;
  87959. private _trackPosition;
  87960. private _maxRotationDistFromHeadset;
  87961. private _draggedRoomRotation;
  87962. /**
  87963. * @hidden
  87964. */
  87965. _disableTrackPosition(fixedPosition: Vector3): void;
  87966. /**
  87967. * Internal, the mesh attached to the controller
  87968. * @hidden
  87969. */
  87970. _mesh: Nullable<AbstractMesh>;
  87971. private _poseControlledCamera;
  87972. private _leftHandSystemQuaternion;
  87973. /**
  87974. * Internal, matrix used to convert room space to babylon space
  87975. * @hidden
  87976. */
  87977. _deviceToWorld: Matrix;
  87978. /**
  87979. * Node to be used when casting a ray from the controller
  87980. * @hidden
  87981. */
  87982. _pointingPoseNode: Nullable<TransformNode>;
  87983. /**
  87984. * Name of the child mesh that can be used to cast a ray from the controller
  87985. */
  87986. static readonly POINTING_POSE: string;
  87987. /**
  87988. * Creates a new PoseEnabledController from a gamepad
  87989. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  87990. */
  87991. constructor(browserGamepad: any);
  87992. private _workingMatrix;
  87993. /**
  87994. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  87995. */
  87996. update(): void;
  87997. /**
  87998. * Updates only the pose device and mesh without doing any button event checking
  87999. */
  88000. protected _updatePoseAndMesh(): void;
  88001. /**
  88002. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  88003. * @param poseData raw pose fromthe device
  88004. */
  88005. updateFromDevice(poseData: DevicePose): void;
  88006. /**
  88007. * @hidden
  88008. */
  88009. _meshAttachedObservable: Observable<AbstractMesh>;
  88010. /**
  88011. * Attaches a mesh to the controller
  88012. * @param mesh the mesh to be attached
  88013. */
  88014. attachToMesh(mesh: AbstractMesh): void;
  88015. /**
  88016. * Attaches the controllers mesh to a camera
  88017. * @param camera the camera the mesh should be attached to
  88018. */
  88019. attachToPoseControlledCamera(camera: TargetCamera): void;
  88020. /**
  88021. * Disposes of the controller
  88022. */
  88023. dispose(): void;
  88024. /**
  88025. * The mesh that is attached to the controller
  88026. */
  88027. get mesh(): Nullable<AbstractMesh>;
  88028. /**
  88029. * Gets the ray of the controller in the direction the controller is pointing
  88030. * @param length the length the resulting ray should be
  88031. * @returns a ray in the direction the controller is pointing
  88032. */
  88033. getForwardRay(length?: number): Ray;
  88034. }
  88035. }
  88036. declare module BABYLON {
  88037. /**
  88038. * Defines the WebVRController object that represents controllers tracked in 3D space
  88039. */
  88040. export abstract class WebVRController extends PoseEnabledController {
  88041. /**
  88042. * Internal, the default controller model for the controller
  88043. */
  88044. protected _defaultModel: Nullable<AbstractMesh>;
  88045. /**
  88046. * Fired when the trigger state has changed
  88047. */
  88048. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  88049. /**
  88050. * Fired when the main button state has changed
  88051. */
  88052. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  88053. /**
  88054. * Fired when the secondary button state has changed
  88055. */
  88056. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  88057. /**
  88058. * Fired when the pad state has changed
  88059. */
  88060. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  88061. /**
  88062. * Fired when controllers stick values have changed
  88063. */
  88064. onPadValuesChangedObservable: Observable<StickValues>;
  88065. /**
  88066. * Array of button availible on the controller
  88067. */
  88068. protected _buttons: Array<MutableGamepadButton>;
  88069. private _onButtonStateChange;
  88070. /**
  88071. * Fired when a controller button's state has changed
  88072. * @param callback the callback containing the button that was modified
  88073. */
  88074. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  88075. /**
  88076. * X and Y axis corresponding to the controllers joystick
  88077. */
  88078. pad: StickValues;
  88079. /**
  88080. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  88081. */
  88082. hand: string;
  88083. /**
  88084. * The default controller model for the controller
  88085. */
  88086. get defaultModel(): Nullable<AbstractMesh>;
  88087. /**
  88088. * Creates a new WebVRController from a gamepad
  88089. * @param vrGamepad the gamepad that the WebVRController should be created from
  88090. */
  88091. constructor(vrGamepad: any);
  88092. /**
  88093. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  88094. */
  88095. update(): void;
  88096. /**
  88097. * Function to be called when a button is modified
  88098. */
  88099. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  88100. /**
  88101. * Loads a mesh and attaches it to the controller
  88102. * @param scene the scene the mesh should be added to
  88103. * @param meshLoaded callback for when the mesh has been loaded
  88104. */
  88105. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  88106. private _setButtonValue;
  88107. private _changes;
  88108. private _checkChanges;
  88109. /**
  88110. * Disposes of th webVRCOntroller
  88111. */
  88112. dispose(): void;
  88113. }
  88114. }
  88115. declare module BABYLON {
  88116. /**
  88117. * The HemisphericLight simulates the ambient environment light,
  88118. * so the passed direction is the light reflection direction, not the incoming direction.
  88119. */
  88120. export class HemisphericLight extends Light {
  88121. /**
  88122. * The groundColor is the light in the opposite direction to the one specified during creation.
  88123. * 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.
  88124. */
  88125. groundColor: Color3;
  88126. /**
  88127. * The light reflection direction, not the incoming direction.
  88128. */
  88129. direction: Vector3;
  88130. /**
  88131. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  88132. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  88133. * The HemisphericLight can't cast shadows.
  88134. * Documentation : https://doc.babylonjs.com/babylon101/lights
  88135. * @param name The friendly name of the light
  88136. * @param direction The direction of the light reflection
  88137. * @param scene The scene the light belongs to
  88138. */
  88139. constructor(name: string, direction: Vector3, scene: Scene);
  88140. protected _buildUniformLayout(): void;
  88141. /**
  88142. * Returns the string "HemisphericLight".
  88143. * @return The class name
  88144. */
  88145. getClassName(): string;
  88146. /**
  88147. * Sets the HemisphericLight direction towards the passed target (Vector3).
  88148. * Returns the updated direction.
  88149. * @param target The target the direction should point to
  88150. * @return The computed direction
  88151. */
  88152. setDirectionToTarget(target: Vector3): Vector3;
  88153. /**
  88154. * Returns the shadow generator associated to the light.
  88155. * @returns Always null for hemispheric lights because it does not support shadows.
  88156. */
  88157. getShadowGenerator(): Nullable<IShadowGenerator>;
  88158. /**
  88159. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  88160. * @param effect The effect to update
  88161. * @param lightIndex The index of the light in the effect to update
  88162. * @returns The hemispheric light
  88163. */
  88164. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  88165. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  88166. /**
  88167. * Computes the world matrix of the node
  88168. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88169. * @param useWasUpdatedFlag defines a reserved property
  88170. * @returns the world matrix
  88171. */
  88172. computeWorldMatrix(): Matrix;
  88173. /**
  88174. * Returns the integer 3.
  88175. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  88176. */
  88177. getTypeID(): number;
  88178. /**
  88179. * Prepares the list of defines specific to the light type.
  88180. * @param defines the list of defines
  88181. * @param lightIndex defines the index of the light for the effect
  88182. */
  88183. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  88184. }
  88185. }
  88186. declare module BABYLON {
  88187. /** @hidden */
  88188. export var vrMultiviewToSingleviewPixelShader: {
  88189. name: string;
  88190. shader: string;
  88191. };
  88192. }
  88193. declare module BABYLON {
  88194. /**
  88195. * Renders to multiple views with a single draw call
  88196. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  88197. */
  88198. export class MultiviewRenderTarget extends RenderTargetTexture {
  88199. /**
  88200. * Creates a multiview render target
  88201. * @param scene scene used with the render target
  88202. * @param size the size of the render target (used for each view)
  88203. */
  88204. constructor(scene: Scene, size?: number | {
  88205. width: number;
  88206. height: number;
  88207. } | {
  88208. ratio: number;
  88209. });
  88210. /**
  88211. * @hidden
  88212. * @param faceIndex the face index, if its a cube texture
  88213. */
  88214. _bindFrameBuffer(faceIndex?: number): void;
  88215. /**
  88216. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88217. * @returns the view count
  88218. */
  88219. getViewCount(): number;
  88220. }
  88221. }
  88222. declare module BABYLON {
  88223. /**
  88224. * Represents a camera frustum
  88225. */
  88226. export class Frustum {
  88227. /**
  88228. * Gets the planes representing the frustum
  88229. * @param transform matrix to be applied to the returned planes
  88230. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88231. */
  88232. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88233. /**
  88234. * Gets the near frustum plane transformed by the transform matrix
  88235. * @param transform transformation matrix to be applied to the resulting frustum plane
  88236. * @param frustumPlane the resuling frustum plane
  88237. */
  88238. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88239. /**
  88240. * Gets the far frustum plane transformed by the transform matrix
  88241. * @param transform transformation matrix to be applied to the resulting frustum plane
  88242. * @param frustumPlane the resuling frustum plane
  88243. */
  88244. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88245. /**
  88246. * Gets the left frustum plane transformed by the transform matrix
  88247. * @param transform transformation matrix to be applied to the resulting frustum plane
  88248. * @param frustumPlane the resuling frustum plane
  88249. */
  88250. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88251. /**
  88252. * Gets the right frustum plane transformed by the transform matrix
  88253. * @param transform transformation matrix to be applied to the resulting frustum plane
  88254. * @param frustumPlane the resuling frustum plane
  88255. */
  88256. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88257. /**
  88258. * Gets the top frustum plane transformed by the transform matrix
  88259. * @param transform transformation matrix to be applied to the resulting frustum plane
  88260. * @param frustumPlane the resuling frustum plane
  88261. */
  88262. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88263. /**
  88264. * Gets the bottom frustum plane transformed by the transform matrix
  88265. * @param transform transformation matrix to be applied to the resulting frustum plane
  88266. * @param frustumPlane the resuling frustum plane
  88267. */
  88268. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88269. /**
  88270. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88271. * @param transform transformation matrix to be applied to the resulting frustum planes
  88272. * @param frustumPlanes the resuling frustum planes
  88273. */
  88274. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88275. }
  88276. }
  88277. declare module BABYLON {
  88278. interface Engine {
  88279. /**
  88280. * Creates a new multiview render target
  88281. * @param width defines the width of the texture
  88282. * @param height defines the height of the texture
  88283. * @returns the created multiview texture
  88284. */
  88285. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  88286. /**
  88287. * Binds a multiview framebuffer to be drawn to
  88288. * @param multiviewTexture texture to bind
  88289. */
  88290. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  88291. }
  88292. interface Camera {
  88293. /**
  88294. * @hidden
  88295. * 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)
  88296. */
  88297. _useMultiviewToSingleView: boolean;
  88298. /**
  88299. * @hidden
  88300. * 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)
  88301. */
  88302. _multiviewTexture: Nullable<RenderTargetTexture>;
  88303. /**
  88304. * @hidden
  88305. * ensures the multiview texture of the camera exists and has the specified width/height
  88306. * @param width height to set on the multiview texture
  88307. * @param height width to set on the multiview texture
  88308. */
  88309. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  88310. }
  88311. interface Scene {
  88312. /** @hidden */
  88313. _transformMatrixR: Matrix;
  88314. /** @hidden */
  88315. _multiviewSceneUbo: Nullable<UniformBuffer>;
  88316. /** @hidden */
  88317. _createMultiviewUbo(): void;
  88318. /** @hidden */
  88319. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  88320. /** @hidden */
  88321. _renderMultiviewToSingleView(camera: Camera): void;
  88322. }
  88323. }
  88324. declare module BABYLON {
  88325. /**
  88326. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  88327. * This will not be used for webXR as it supports displaying texture arrays directly
  88328. */
  88329. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  88330. /**
  88331. * Initializes a VRMultiviewToSingleview
  88332. * @param name name of the post process
  88333. * @param camera camera to be applied to
  88334. * @param scaleFactor scaling factor to the size of the output texture
  88335. */
  88336. constructor(name: string, camera: Camera, scaleFactor: number);
  88337. }
  88338. }
  88339. declare module BABYLON {
  88340. /**
  88341. * Interface used to define additional presentation attributes
  88342. */
  88343. export interface IVRPresentationAttributes {
  88344. /**
  88345. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  88346. */
  88347. highRefreshRate: boolean;
  88348. /**
  88349. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  88350. */
  88351. foveationLevel: number;
  88352. }
  88353. interface Engine {
  88354. /** @hidden */
  88355. _vrDisplay: any;
  88356. /** @hidden */
  88357. _vrSupported: boolean;
  88358. /** @hidden */
  88359. _oldSize: Size;
  88360. /** @hidden */
  88361. _oldHardwareScaleFactor: number;
  88362. /** @hidden */
  88363. _vrExclusivePointerMode: boolean;
  88364. /** @hidden */
  88365. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  88366. /** @hidden */
  88367. _onVRDisplayPointerRestricted: () => void;
  88368. /** @hidden */
  88369. _onVRDisplayPointerUnrestricted: () => void;
  88370. /** @hidden */
  88371. _onVrDisplayConnect: Nullable<(display: any) => void>;
  88372. /** @hidden */
  88373. _onVrDisplayDisconnect: Nullable<() => void>;
  88374. /** @hidden */
  88375. _onVrDisplayPresentChange: Nullable<() => void>;
  88376. /**
  88377. * Observable signaled when VR display mode changes
  88378. */
  88379. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  88380. /**
  88381. * Observable signaled when VR request present is complete
  88382. */
  88383. onVRRequestPresentComplete: Observable<boolean>;
  88384. /**
  88385. * Observable signaled when VR request present starts
  88386. */
  88387. onVRRequestPresentStart: Observable<Engine>;
  88388. /**
  88389. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  88390. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  88391. */
  88392. isInVRExclusivePointerMode: boolean;
  88393. /**
  88394. * Gets a boolean indicating if a webVR device was detected
  88395. * @returns true if a webVR device was detected
  88396. */
  88397. isVRDevicePresent(): boolean;
  88398. /**
  88399. * Gets the current webVR device
  88400. * @returns the current webVR device (or null)
  88401. */
  88402. getVRDevice(): any;
  88403. /**
  88404. * Initializes a webVR display and starts listening to display change events
  88405. * The onVRDisplayChangedObservable will be notified upon these changes
  88406. * @returns A promise containing a VRDisplay and if vr is supported
  88407. */
  88408. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  88409. /** @hidden */
  88410. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  88411. /**
  88412. * Gets or sets the presentation attributes used to configure VR rendering
  88413. */
  88414. vrPresentationAttributes?: IVRPresentationAttributes;
  88415. /**
  88416. * Call this function to switch to webVR mode
  88417. * Will do nothing if webVR is not supported or if there is no webVR device
  88418. * @param options the webvr options provided to the camera. mainly used for multiview
  88419. * @see http://doc.babylonjs.com/how_to/webvr_camera
  88420. */
  88421. enableVR(options: WebVROptions): void;
  88422. /** @hidden */
  88423. _onVRFullScreenTriggered(): void;
  88424. }
  88425. }
  88426. declare module BABYLON {
  88427. /**
  88428. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  88429. * IMPORTANT!! The data is right-hand data.
  88430. * @export
  88431. * @interface DevicePose
  88432. */
  88433. export interface DevicePose {
  88434. /**
  88435. * The position of the device, values in array are [x,y,z].
  88436. */
  88437. readonly position: Nullable<Float32Array>;
  88438. /**
  88439. * The linearVelocity of the device, values in array are [x,y,z].
  88440. */
  88441. readonly linearVelocity: Nullable<Float32Array>;
  88442. /**
  88443. * The linearAcceleration of the device, values in array are [x,y,z].
  88444. */
  88445. readonly linearAcceleration: Nullable<Float32Array>;
  88446. /**
  88447. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  88448. */
  88449. readonly orientation: Nullable<Float32Array>;
  88450. /**
  88451. * The angularVelocity of the device, values in array are [x,y,z].
  88452. */
  88453. readonly angularVelocity: Nullable<Float32Array>;
  88454. /**
  88455. * The angularAcceleration of the device, values in array are [x,y,z].
  88456. */
  88457. readonly angularAcceleration: Nullable<Float32Array>;
  88458. }
  88459. /**
  88460. * Interface representing a pose controlled object in Babylon.
  88461. * A pose controlled object has both regular pose values as well as pose values
  88462. * from an external device such as a VR head mounted display
  88463. */
  88464. export interface PoseControlled {
  88465. /**
  88466. * The position of the object in babylon space.
  88467. */
  88468. position: Vector3;
  88469. /**
  88470. * The rotation quaternion of the object in babylon space.
  88471. */
  88472. rotationQuaternion: Quaternion;
  88473. /**
  88474. * The position of the device in babylon space.
  88475. */
  88476. devicePosition?: Vector3;
  88477. /**
  88478. * The rotation quaternion of the device in babylon space.
  88479. */
  88480. deviceRotationQuaternion: Quaternion;
  88481. /**
  88482. * The raw pose coming from the device.
  88483. */
  88484. rawPose: Nullable<DevicePose>;
  88485. /**
  88486. * The scale of the device to be used when translating from device space to babylon space.
  88487. */
  88488. deviceScaleFactor: number;
  88489. /**
  88490. * Updates the poseControlled values based on the input device pose.
  88491. * @param poseData the pose data to update the object with
  88492. */
  88493. updateFromDevice(poseData: DevicePose): void;
  88494. }
  88495. /**
  88496. * Set of options to customize the webVRCamera
  88497. */
  88498. export interface WebVROptions {
  88499. /**
  88500. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  88501. */
  88502. trackPosition?: boolean;
  88503. /**
  88504. * Sets the scale of the vrDevice in babylon space. (default: 1)
  88505. */
  88506. positionScale?: number;
  88507. /**
  88508. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  88509. */
  88510. displayName?: string;
  88511. /**
  88512. * Should the native controller meshes be initialized. (default: true)
  88513. */
  88514. controllerMeshes?: boolean;
  88515. /**
  88516. * Creating a default HemiLight only on controllers. (default: true)
  88517. */
  88518. defaultLightingOnControllers?: boolean;
  88519. /**
  88520. * If you don't want to use the default VR button of the helper. (default: false)
  88521. */
  88522. useCustomVRButton?: boolean;
  88523. /**
  88524. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  88525. */
  88526. customVRButton?: HTMLButtonElement;
  88527. /**
  88528. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  88529. */
  88530. rayLength?: number;
  88531. /**
  88532. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  88533. */
  88534. defaultHeight?: number;
  88535. /**
  88536. * If multiview should be used if availible (default: false)
  88537. */
  88538. useMultiview?: boolean;
  88539. }
  88540. /**
  88541. * This represents a WebVR camera.
  88542. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  88543. * @example http://doc.babylonjs.com/how_to/webvr_camera
  88544. */
  88545. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  88546. private webVROptions;
  88547. /**
  88548. * @hidden
  88549. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  88550. */
  88551. _vrDevice: any;
  88552. /**
  88553. * The rawPose of the vrDevice.
  88554. */
  88555. rawPose: Nullable<DevicePose>;
  88556. private _onVREnabled;
  88557. private _specsVersion;
  88558. private _attached;
  88559. private _frameData;
  88560. protected _descendants: Array<Node>;
  88561. private _deviceRoomPosition;
  88562. /** @hidden */
  88563. _deviceRoomRotationQuaternion: Quaternion;
  88564. private _standingMatrix;
  88565. /**
  88566. * Represents device position in babylon space.
  88567. */
  88568. devicePosition: Vector3;
  88569. /**
  88570. * Represents device rotation in babylon space.
  88571. */
  88572. deviceRotationQuaternion: Quaternion;
  88573. /**
  88574. * The scale of the device to be used when translating from device space to babylon space.
  88575. */
  88576. deviceScaleFactor: number;
  88577. private _deviceToWorld;
  88578. private _worldToDevice;
  88579. /**
  88580. * References to the webVR controllers for the vrDevice.
  88581. */
  88582. controllers: Array<WebVRController>;
  88583. /**
  88584. * Emits an event when a controller is attached.
  88585. */
  88586. onControllersAttachedObservable: Observable<WebVRController[]>;
  88587. /**
  88588. * Emits an event when a controller's mesh has been loaded;
  88589. */
  88590. onControllerMeshLoadedObservable: Observable<WebVRController>;
  88591. /**
  88592. * Emits an event when the HMD's pose has been updated.
  88593. */
  88594. onPoseUpdatedFromDeviceObservable: Observable<any>;
  88595. private _poseSet;
  88596. /**
  88597. * If the rig cameras be used as parent instead of this camera.
  88598. */
  88599. rigParenting: boolean;
  88600. private _lightOnControllers;
  88601. private _defaultHeight?;
  88602. /**
  88603. * Instantiates a WebVRFreeCamera.
  88604. * @param name The name of the WebVRFreeCamera
  88605. * @param position The starting anchor position for the camera
  88606. * @param scene The scene the camera belongs to
  88607. * @param webVROptions a set of customizable options for the webVRCamera
  88608. */
  88609. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  88610. /**
  88611. * Gets the device distance from the ground in meters.
  88612. * @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.
  88613. */
  88614. deviceDistanceToRoomGround(): number;
  88615. /**
  88616. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88617. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  88618. */
  88619. useStandingMatrix(callback?: (bool: boolean) => void): void;
  88620. /**
  88621. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88622. * @returns A promise with a boolean set to if the standing matrix is supported.
  88623. */
  88624. useStandingMatrixAsync(): Promise<boolean>;
  88625. /**
  88626. * Disposes the camera
  88627. */
  88628. dispose(): void;
  88629. /**
  88630. * Gets a vrController by name.
  88631. * @param name The name of the controller to retreive
  88632. * @returns the controller matching the name specified or null if not found
  88633. */
  88634. getControllerByName(name: string): Nullable<WebVRController>;
  88635. private _leftController;
  88636. /**
  88637. * The controller corresponding to the users left hand.
  88638. */
  88639. get leftController(): Nullable<WebVRController>;
  88640. private _rightController;
  88641. /**
  88642. * The controller corresponding to the users right hand.
  88643. */
  88644. get rightController(): Nullable<WebVRController>;
  88645. /**
  88646. * Casts a ray forward from the vrCamera's gaze.
  88647. * @param length Length of the ray (default: 100)
  88648. * @returns the ray corresponding to the gaze
  88649. */
  88650. getForwardRay(length?: number): Ray;
  88651. /**
  88652. * @hidden
  88653. * Updates the camera based on device's frame data
  88654. */
  88655. _checkInputs(): void;
  88656. /**
  88657. * Updates the poseControlled values based on the input device pose.
  88658. * @param poseData Pose coming from the device
  88659. */
  88660. updateFromDevice(poseData: DevicePose): void;
  88661. private _htmlElementAttached;
  88662. private _detachIfAttached;
  88663. /**
  88664. * WebVR's attach control will start broadcasting frames to the device.
  88665. * Note that in certain browsers (chrome for example) this function must be called
  88666. * within a user-interaction callback. Example:
  88667. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  88668. *
  88669. * @param element html element to attach the vrDevice to
  88670. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  88671. */
  88672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88673. /**
  88674. * Detaches the camera from the html element and disables VR
  88675. *
  88676. * @param element html element to detach from
  88677. */
  88678. detachControl(element: HTMLElement): void;
  88679. /**
  88680. * @returns the name of this class
  88681. */
  88682. getClassName(): string;
  88683. /**
  88684. * Calls resetPose on the vrDisplay
  88685. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  88686. */
  88687. resetToCurrentRotation(): void;
  88688. /**
  88689. * @hidden
  88690. * Updates the rig cameras (left and right eye)
  88691. */
  88692. _updateRigCameras(): void;
  88693. private _workingVector;
  88694. private _oneVector;
  88695. private _workingMatrix;
  88696. private updateCacheCalled;
  88697. private _correctPositionIfNotTrackPosition;
  88698. /**
  88699. * @hidden
  88700. * Updates the cached values of the camera
  88701. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  88702. */
  88703. _updateCache(ignoreParentClass?: boolean): void;
  88704. /**
  88705. * @hidden
  88706. * Get current device position in babylon world
  88707. */
  88708. _computeDevicePosition(): void;
  88709. /**
  88710. * Updates the current device position and rotation in the babylon world
  88711. */
  88712. update(): void;
  88713. /**
  88714. * @hidden
  88715. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  88716. * @returns an identity matrix
  88717. */
  88718. _getViewMatrix(): Matrix;
  88719. private _tmpMatrix;
  88720. /**
  88721. * This function is called by the two RIG cameras.
  88722. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  88723. * @hidden
  88724. */
  88725. _getWebVRViewMatrix(): Matrix;
  88726. /** @hidden */
  88727. _getWebVRProjectionMatrix(): Matrix;
  88728. private _onGamepadConnectedObserver;
  88729. private _onGamepadDisconnectedObserver;
  88730. private _updateCacheWhenTrackingDisabledObserver;
  88731. /**
  88732. * Initializes the controllers and their meshes
  88733. */
  88734. initControllers(): void;
  88735. }
  88736. }
  88737. declare module BABYLON {
  88738. /**
  88739. * Size options for a post process
  88740. */
  88741. export type PostProcessOptions = {
  88742. width: number;
  88743. height: number;
  88744. };
  88745. /**
  88746. * PostProcess can be used to apply a shader to a texture after it has been rendered
  88747. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88748. */
  88749. export class PostProcess {
  88750. /** Name of the PostProcess. */
  88751. name: string;
  88752. /**
  88753. * Gets or sets the unique id of the post process
  88754. */
  88755. uniqueId: number;
  88756. /**
  88757. * Width of the texture to apply the post process on
  88758. */
  88759. width: number;
  88760. /**
  88761. * Height of the texture to apply the post process on
  88762. */
  88763. height: number;
  88764. /**
  88765. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  88766. * @hidden
  88767. */
  88768. _outputTexture: Nullable<InternalTexture>;
  88769. /**
  88770. * Sampling mode used by the shader
  88771. * See https://doc.babylonjs.com/classes/3.1/texture
  88772. */
  88773. renderTargetSamplingMode: number;
  88774. /**
  88775. * Clear color to use when screen clearing
  88776. */
  88777. clearColor: Color4;
  88778. /**
  88779. * If the buffer needs to be cleared before applying the post process. (default: true)
  88780. * Should be set to false if shader will overwrite all previous pixels.
  88781. */
  88782. autoClear: boolean;
  88783. /**
  88784. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  88785. */
  88786. alphaMode: number;
  88787. /**
  88788. * Sets the setAlphaBlendConstants of the babylon engine
  88789. */
  88790. alphaConstants: Color4;
  88791. /**
  88792. * Animations to be used for the post processing
  88793. */
  88794. animations: Animation[];
  88795. /**
  88796. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  88797. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  88798. */
  88799. enablePixelPerfectMode: boolean;
  88800. /**
  88801. * Force the postprocess to be applied without taking in account viewport
  88802. */
  88803. forceFullscreenViewport: boolean;
  88804. /**
  88805. * List of inspectable custom properties (used by the Inspector)
  88806. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88807. */
  88808. inspectableCustomProperties: IInspectable[];
  88809. /**
  88810. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  88811. *
  88812. * | Value | Type | Description |
  88813. * | ----- | ----------------------------------- | ----------- |
  88814. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  88815. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  88816. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  88817. *
  88818. */
  88819. scaleMode: number;
  88820. /**
  88821. * Force textures to be a power of two (default: false)
  88822. */
  88823. alwaysForcePOT: boolean;
  88824. private _samples;
  88825. /**
  88826. * Number of sample textures (default: 1)
  88827. */
  88828. get samples(): number;
  88829. set samples(n: number);
  88830. /**
  88831. * Modify the scale of the post process to be the same as the viewport (default: false)
  88832. */
  88833. adaptScaleToCurrentViewport: boolean;
  88834. private _camera;
  88835. private _scene;
  88836. private _engine;
  88837. private _options;
  88838. private _reusable;
  88839. private _textureType;
  88840. private _textureFormat;
  88841. /**
  88842. * Smart array of input and output textures for the post process.
  88843. * @hidden
  88844. */
  88845. _textures: SmartArray<InternalTexture>;
  88846. /**
  88847. * The index in _textures that corresponds to the output texture.
  88848. * @hidden
  88849. */
  88850. _currentRenderTextureInd: number;
  88851. private _effect;
  88852. private _samplers;
  88853. private _fragmentUrl;
  88854. private _vertexUrl;
  88855. private _parameters;
  88856. private _scaleRatio;
  88857. protected _indexParameters: any;
  88858. private _shareOutputWithPostProcess;
  88859. private _texelSize;
  88860. private _forcedOutputTexture;
  88861. /**
  88862. * Returns the fragment url or shader name used in the post process.
  88863. * @returns the fragment url or name in the shader store.
  88864. */
  88865. getEffectName(): string;
  88866. /**
  88867. * An event triggered when the postprocess is activated.
  88868. */
  88869. onActivateObservable: Observable<Camera>;
  88870. private _onActivateObserver;
  88871. /**
  88872. * A function that is added to the onActivateObservable
  88873. */
  88874. set onActivate(callback: Nullable<(camera: Camera) => void>);
  88875. /**
  88876. * An event triggered when the postprocess changes its size.
  88877. */
  88878. onSizeChangedObservable: Observable<PostProcess>;
  88879. private _onSizeChangedObserver;
  88880. /**
  88881. * A function that is added to the onSizeChangedObservable
  88882. */
  88883. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  88884. /**
  88885. * An event triggered when the postprocess applies its effect.
  88886. */
  88887. onApplyObservable: Observable<Effect>;
  88888. private _onApplyObserver;
  88889. /**
  88890. * A function that is added to the onApplyObservable
  88891. */
  88892. set onApply(callback: (effect: Effect) => void);
  88893. /**
  88894. * An event triggered before rendering the postprocess
  88895. */
  88896. onBeforeRenderObservable: Observable<Effect>;
  88897. private _onBeforeRenderObserver;
  88898. /**
  88899. * A function that is added to the onBeforeRenderObservable
  88900. */
  88901. set onBeforeRender(callback: (effect: Effect) => void);
  88902. /**
  88903. * An event triggered after rendering the postprocess
  88904. */
  88905. onAfterRenderObservable: Observable<Effect>;
  88906. private _onAfterRenderObserver;
  88907. /**
  88908. * A function that is added to the onAfterRenderObservable
  88909. */
  88910. set onAfterRender(callback: (efect: Effect) => void);
  88911. /**
  88912. * 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
  88913. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  88914. */
  88915. get inputTexture(): InternalTexture;
  88916. set inputTexture(value: InternalTexture);
  88917. /**
  88918. * Gets the camera which post process is applied to.
  88919. * @returns The camera the post process is applied to.
  88920. */
  88921. getCamera(): Camera;
  88922. /**
  88923. * Gets the texel size of the postprocess.
  88924. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  88925. */
  88926. get texelSize(): Vector2;
  88927. /**
  88928. * Creates a new instance PostProcess
  88929. * @param name The name of the PostProcess.
  88930. * @param fragmentUrl The url of the fragment shader to be used.
  88931. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  88932. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  88933. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88934. * @param camera The camera to apply the render pass to.
  88935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88936. * @param engine The engine which the post process will be applied. (default: current engine)
  88937. * @param reusable If the post process can be reused on the same frame. (default: false)
  88938. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  88939. * @param textureType Type of textures used when performing the post process. (default: 0)
  88940. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  88941. * @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
  88942. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  88943. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  88944. */
  88945. constructor(
  88946. /** Name of the PostProcess. */
  88947. 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);
  88948. /**
  88949. * Gets a string idenfifying the name of the class
  88950. * @returns "PostProcess" string
  88951. */
  88952. getClassName(): string;
  88953. /**
  88954. * Gets the engine which this post process belongs to.
  88955. * @returns The engine the post process was enabled with.
  88956. */
  88957. getEngine(): Engine;
  88958. /**
  88959. * The effect that is created when initializing the post process.
  88960. * @returns The created effect corresponding the the postprocess.
  88961. */
  88962. getEffect(): Effect;
  88963. /**
  88964. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  88965. * @param postProcess The post process to share the output with.
  88966. * @returns This post process.
  88967. */
  88968. shareOutputWith(postProcess: PostProcess): PostProcess;
  88969. /**
  88970. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  88971. * This should be called if the post process that shares output with this post process is disabled/disposed.
  88972. */
  88973. useOwnOutput(): void;
  88974. /**
  88975. * Updates the effect with the current post process compile time values and recompiles the shader.
  88976. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88977. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88978. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88979. * @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
  88980. * @param onCompiled Called when the shader has been compiled.
  88981. * @param onError Called if there is an error when compiling a shader.
  88982. */
  88983. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88984. /**
  88985. * The post process is reusable if it can be used multiple times within one frame.
  88986. * @returns If the post process is reusable
  88987. */
  88988. isReusable(): boolean;
  88989. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  88990. markTextureDirty(): void;
  88991. /**
  88992. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  88993. * 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.
  88994. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  88995. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  88996. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  88997. * @returns The target texture that was bound to be written to.
  88998. */
  88999. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  89000. /**
  89001. * If the post process is supported.
  89002. */
  89003. get isSupported(): boolean;
  89004. /**
  89005. * The aspect ratio of the output texture.
  89006. */
  89007. get aspectRatio(): number;
  89008. /**
  89009. * Get a value indicating if the post-process is ready to be used
  89010. * @returns true if the post-process is ready (shader is compiled)
  89011. */
  89012. isReady(): boolean;
  89013. /**
  89014. * Binds all textures and uniforms to the shader, this will be run on every pass.
  89015. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  89016. */
  89017. apply(): Nullable<Effect>;
  89018. private _disposeTextures;
  89019. /**
  89020. * Disposes the post process.
  89021. * @param camera The camera to dispose the post process on.
  89022. */
  89023. dispose(camera?: Camera): void;
  89024. }
  89025. }
  89026. declare module BABYLON {
  89027. /** @hidden */
  89028. export var kernelBlurVaryingDeclaration: {
  89029. name: string;
  89030. shader: string;
  89031. };
  89032. }
  89033. declare module BABYLON {
  89034. /** @hidden */
  89035. export var kernelBlurFragment: {
  89036. name: string;
  89037. shader: string;
  89038. };
  89039. }
  89040. declare module BABYLON {
  89041. /** @hidden */
  89042. export var kernelBlurFragment2: {
  89043. name: string;
  89044. shader: string;
  89045. };
  89046. }
  89047. declare module BABYLON {
  89048. /** @hidden */
  89049. export var kernelBlurPixelShader: {
  89050. name: string;
  89051. shader: string;
  89052. };
  89053. }
  89054. declare module BABYLON {
  89055. /** @hidden */
  89056. export var kernelBlurVertex: {
  89057. name: string;
  89058. shader: string;
  89059. };
  89060. }
  89061. declare module BABYLON {
  89062. /** @hidden */
  89063. export var kernelBlurVertexShader: {
  89064. name: string;
  89065. shader: string;
  89066. };
  89067. }
  89068. declare module BABYLON {
  89069. /**
  89070. * The Blur Post Process which blurs an image based on a kernel and direction.
  89071. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  89072. */
  89073. export class BlurPostProcess extends PostProcess {
  89074. /** The direction in which to blur the image. */
  89075. direction: Vector2;
  89076. private blockCompilation;
  89077. protected _kernel: number;
  89078. protected _idealKernel: number;
  89079. protected _packedFloat: boolean;
  89080. private _staticDefines;
  89081. /**
  89082. * Sets the length in pixels of the blur sample region
  89083. */
  89084. set kernel(v: number);
  89085. /**
  89086. * Gets the length in pixels of the blur sample region
  89087. */
  89088. get kernel(): number;
  89089. /**
  89090. * Sets wether or not the blur needs to unpack/repack floats
  89091. */
  89092. set packedFloat(v: boolean);
  89093. /**
  89094. * Gets wether or not the blur is unpacking/repacking floats
  89095. */
  89096. get packedFloat(): boolean;
  89097. /**
  89098. * Creates a new instance BlurPostProcess
  89099. * @param name The name of the effect.
  89100. * @param direction The direction in which to blur the image.
  89101. * @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.
  89102. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  89103. * @param camera The camera to apply the render pass to.
  89104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  89105. * @param engine The engine which the post process will be applied. (default: current engine)
  89106. * @param reusable If the post process can be reused on the same frame. (default: false)
  89107. * @param textureType Type of textures used when performing the post process. (default: 0)
  89108. * @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)
  89109. */
  89110. constructor(name: string,
  89111. /** The direction in which to blur the image. */
  89112. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  89113. /**
  89114. * Updates the effect with the current post process compile time values and recompiles the shader.
  89115. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  89116. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  89117. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  89118. * @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
  89119. * @param onCompiled Called when the shader has been compiled.
  89120. * @param onError Called if there is an error when compiling a shader.
  89121. */
  89122. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  89123. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  89124. /**
  89125. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  89126. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  89127. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  89128. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  89129. * The gaps between physical kernels are compensated for in the weighting of the samples
  89130. * @param idealKernel Ideal blur kernel.
  89131. * @return Nearest best kernel.
  89132. */
  89133. protected _nearestBestKernel(idealKernel: number): number;
  89134. /**
  89135. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  89136. * @param x The point on the Gaussian distribution to sample.
  89137. * @return the value of the Gaussian function at x.
  89138. */
  89139. protected _gaussianWeight(x: number): number;
  89140. /**
  89141. * Generates a string that can be used as a floating point number in GLSL.
  89142. * @param x Value to print.
  89143. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  89144. * @return GLSL float string.
  89145. */
  89146. protected _glslFloat(x: number, decimalFigures?: number): string;
  89147. }
  89148. }
  89149. declare module BABYLON {
  89150. /**
  89151. * Mirror texture can be used to simulate the view from a mirror in a scene.
  89152. * It will dynamically be rendered every frame to adapt to the camera point of view.
  89153. * You can then easily use it as a reflectionTexture on a flat surface.
  89154. * In case the surface is not a plane, please consider relying on reflection probes.
  89155. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  89156. */
  89157. export class MirrorTexture extends RenderTargetTexture {
  89158. private scene;
  89159. /**
  89160. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  89161. * 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.
  89162. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  89163. */
  89164. mirrorPlane: Plane;
  89165. /**
  89166. * Define the blur ratio used to blur the reflection if needed.
  89167. */
  89168. set blurRatio(value: number);
  89169. get blurRatio(): number;
  89170. /**
  89171. * Define the adaptive blur kernel used to blur the reflection if needed.
  89172. * This will autocompute the closest best match for the `blurKernel`
  89173. */
  89174. set adaptiveBlurKernel(value: number);
  89175. /**
  89176. * Define the blur kernel used to blur the reflection if needed.
  89177. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  89178. */
  89179. set blurKernel(value: number);
  89180. /**
  89181. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  89182. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  89183. */
  89184. set blurKernelX(value: number);
  89185. get blurKernelX(): number;
  89186. /**
  89187. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  89188. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  89189. */
  89190. set blurKernelY(value: number);
  89191. get blurKernelY(): number;
  89192. private _autoComputeBlurKernel;
  89193. protected _onRatioRescale(): void;
  89194. private _updateGammaSpace;
  89195. private _imageProcessingConfigChangeObserver;
  89196. private _transformMatrix;
  89197. private _mirrorMatrix;
  89198. private _savedViewMatrix;
  89199. private _blurX;
  89200. private _blurY;
  89201. private _adaptiveBlurKernel;
  89202. private _blurKernelX;
  89203. private _blurKernelY;
  89204. private _blurRatio;
  89205. /**
  89206. * Instantiates a Mirror Texture.
  89207. * Mirror texture can be used to simulate the view from a mirror in a scene.
  89208. * It will dynamically be rendered every frame to adapt to the camera point of view.
  89209. * You can then easily use it as a reflectionTexture on a flat surface.
  89210. * In case the surface is not a plane, please consider relying on reflection probes.
  89211. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  89212. * @param name
  89213. * @param size
  89214. * @param scene
  89215. * @param generateMipMaps
  89216. * @param type
  89217. * @param samplingMode
  89218. * @param generateDepthBuffer
  89219. */
  89220. constructor(name: string, size: number | {
  89221. width: number;
  89222. height: number;
  89223. } | {
  89224. ratio: number;
  89225. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  89226. private _preparePostProcesses;
  89227. /**
  89228. * Clone the mirror texture.
  89229. * @returns the cloned texture
  89230. */
  89231. clone(): MirrorTexture;
  89232. /**
  89233. * Serialize the texture to a JSON representation you could use in Parse later on
  89234. * @returns the serialized JSON representation
  89235. */
  89236. serialize(): any;
  89237. /**
  89238. * Dispose the texture and release its associated resources.
  89239. */
  89240. dispose(): void;
  89241. }
  89242. }
  89243. declare module BABYLON {
  89244. /**
  89245. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  89246. * @see http://doc.babylonjs.com/babylon101/materials#texture
  89247. */
  89248. export class Texture extends BaseTexture {
  89249. /**
  89250. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  89251. */
  89252. static SerializeBuffers: boolean;
  89253. /** @hidden */
  89254. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  89255. /** @hidden */
  89256. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  89257. /** @hidden */
  89258. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  89259. /** nearest is mag = nearest and min = nearest and mip = linear */
  89260. static readonly NEAREST_SAMPLINGMODE: number;
  89261. /** nearest is mag = nearest and min = nearest and mip = linear */
  89262. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  89263. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89264. static readonly BILINEAR_SAMPLINGMODE: number;
  89265. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89266. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  89267. /** Trilinear is mag = linear and min = linear and mip = linear */
  89268. static readonly TRILINEAR_SAMPLINGMODE: number;
  89269. /** Trilinear is mag = linear and min = linear and mip = linear */
  89270. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  89271. /** mag = nearest and min = nearest and mip = nearest */
  89272. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  89273. /** mag = nearest and min = linear and mip = nearest */
  89274. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  89275. /** mag = nearest and min = linear and mip = linear */
  89276. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  89277. /** mag = nearest and min = linear and mip = none */
  89278. static readonly NEAREST_LINEAR: number;
  89279. /** mag = nearest and min = nearest and mip = none */
  89280. static readonly NEAREST_NEAREST: number;
  89281. /** mag = linear and min = nearest and mip = nearest */
  89282. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  89283. /** mag = linear and min = nearest and mip = linear */
  89284. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  89285. /** mag = linear and min = linear and mip = none */
  89286. static readonly LINEAR_LINEAR: number;
  89287. /** mag = linear and min = nearest and mip = none */
  89288. static readonly LINEAR_NEAREST: number;
  89289. /** Explicit coordinates mode */
  89290. static readonly EXPLICIT_MODE: number;
  89291. /** Spherical coordinates mode */
  89292. static readonly SPHERICAL_MODE: number;
  89293. /** Planar coordinates mode */
  89294. static readonly PLANAR_MODE: number;
  89295. /** Cubic coordinates mode */
  89296. static readonly CUBIC_MODE: number;
  89297. /** Projection coordinates mode */
  89298. static readonly PROJECTION_MODE: number;
  89299. /** Inverse Cubic coordinates mode */
  89300. static readonly SKYBOX_MODE: number;
  89301. /** Inverse Cubic coordinates mode */
  89302. static readonly INVCUBIC_MODE: number;
  89303. /** Equirectangular coordinates mode */
  89304. static readonly EQUIRECTANGULAR_MODE: number;
  89305. /** Equirectangular Fixed coordinates mode */
  89306. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  89307. /** Equirectangular Fixed Mirrored coordinates mode */
  89308. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  89309. /** Texture is not repeating outside of 0..1 UVs */
  89310. static readonly CLAMP_ADDRESSMODE: number;
  89311. /** Texture is repeating outside of 0..1 UVs */
  89312. static readonly WRAP_ADDRESSMODE: number;
  89313. /** Texture is repeating and mirrored */
  89314. static readonly MIRROR_ADDRESSMODE: number;
  89315. /**
  89316. * 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
  89317. */
  89318. static UseSerializedUrlIfAny: boolean;
  89319. /**
  89320. * Define the url of the texture.
  89321. */
  89322. url: Nullable<string>;
  89323. /**
  89324. * Define an offset on the texture to offset the u coordinates of the UVs
  89325. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  89326. */
  89327. uOffset: number;
  89328. /**
  89329. * Define an offset on the texture to offset the v coordinates of the UVs
  89330. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  89331. */
  89332. vOffset: number;
  89333. /**
  89334. * Define an offset on the texture to scale the u coordinates of the UVs
  89335. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  89336. */
  89337. uScale: number;
  89338. /**
  89339. * Define an offset on the texture to scale the v coordinates of the UVs
  89340. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  89341. */
  89342. vScale: number;
  89343. /**
  89344. * Define an offset on the texture to rotate around the u coordinates of the UVs
  89345. * @see http://doc.babylonjs.com/how_to/more_materials
  89346. */
  89347. uAng: number;
  89348. /**
  89349. * Define an offset on the texture to rotate around the v coordinates of the UVs
  89350. * @see http://doc.babylonjs.com/how_to/more_materials
  89351. */
  89352. vAng: number;
  89353. /**
  89354. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  89355. * @see http://doc.babylonjs.com/how_to/more_materials
  89356. */
  89357. wAng: number;
  89358. /**
  89359. * Defines the center of rotation (U)
  89360. */
  89361. uRotationCenter: number;
  89362. /**
  89363. * Defines the center of rotation (V)
  89364. */
  89365. vRotationCenter: number;
  89366. /**
  89367. * Defines the center of rotation (W)
  89368. */
  89369. wRotationCenter: number;
  89370. /**
  89371. * Are mip maps generated for this texture or not.
  89372. */
  89373. get noMipmap(): boolean;
  89374. /**
  89375. * List of inspectable custom properties (used by the Inspector)
  89376. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89377. */
  89378. inspectableCustomProperties: Nullable<IInspectable[]>;
  89379. private _noMipmap;
  89380. /** @hidden */
  89381. _invertY: boolean;
  89382. private _rowGenerationMatrix;
  89383. private _cachedTextureMatrix;
  89384. private _projectionModeMatrix;
  89385. private _t0;
  89386. private _t1;
  89387. private _t2;
  89388. private _cachedUOffset;
  89389. private _cachedVOffset;
  89390. private _cachedUScale;
  89391. private _cachedVScale;
  89392. private _cachedUAng;
  89393. private _cachedVAng;
  89394. private _cachedWAng;
  89395. private _cachedProjectionMatrixId;
  89396. private _cachedCoordinatesMode;
  89397. /** @hidden */
  89398. protected _initialSamplingMode: number;
  89399. /** @hidden */
  89400. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  89401. private _deleteBuffer;
  89402. protected _format: Nullable<number>;
  89403. private _delayedOnLoad;
  89404. private _delayedOnError;
  89405. private _mimeType?;
  89406. /**
  89407. * Observable triggered once the texture has been loaded.
  89408. */
  89409. onLoadObservable: Observable<Texture>;
  89410. protected _isBlocking: boolean;
  89411. /**
  89412. * Is the texture preventing material to render while loading.
  89413. * If false, a default texture will be used instead of the loading one during the preparation step.
  89414. */
  89415. set isBlocking(value: boolean);
  89416. get isBlocking(): boolean;
  89417. /**
  89418. * Get the current sampling mode associated with the texture.
  89419. */
  89420. get samplingMode(): number;
  89421. /**
  89422. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  89423. */
  89424. get invertY(): boolean;
  89425. /**
  89426. * Instantiates a new texture.
  89427. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  89428. * @see http://doc.babylonjs.com/babylon101/materials#texture
  89429. * @param url defines the url of the picture to load as a texture
  89430. * @param scene defines the scene or engine the texture will belong to
  89431. * @param noMipmap defines if the texture will require mip maps or not
  89432. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  89433. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89434. * @param onLoad defines a callback triggered when the texture has been loaded
  89435. * @param onError defines a callback triggered when an error occurred during the loading session
  89436. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  89437. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  89438. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89439. * @param mimeType defines an optional mime type information
  89440. */
  89441. 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);
  89442. /**
  89443. * Update the url (and optional buffer) of this texture if url was null during construction.
  89444. * @param url the url of the texture
  89445. * @param buffer the buffer of the texture (defaults to null)
  89446. * @param onLoad callback called when the texture is loaded (defaults to null)
  89447. */
  89448. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  89449. /**
  89450. * Finish the loading sequence of a texture flagged as delayed load.
  89451. * @hidden
  89452. */
  89453. delayLoad(): void;
  89454. private _prepareRowForTextureGeneration;
  89455. /**
  89456. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  89457. * @returns the transform matrix of the texture.
  89458. */
  89459. getTextureMatrix(uBase?: number): Matrix;
  89460. /**
  89461. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  89462. * @returns The reflection texture transform
  89463. */
  89464. getReflectionTextureMatrix(): Matrix;
  89465. /**
  89466. * Clones the texture.
  89467. * @returns the cloned texture
  89468. */
  89469. clone(): Texture;
  89470. /**
  89471. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89472. * @returns The JSON representation of the texture
  89473. */
  89474. serialize(): any;
  89475. /**
  89476. * Get the current class name of the texture useful for serialization or dynamic coding.
  89477. * @returns "Texture"
  89478. */
  89479. getClassName(): string;
  89480. /**
  89481. * Dispose the texture and release its associated resources.
  89482. */
  89483. dispose(): void;
  89484. /**
  89485. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  89486. * @param parsedTexture Define the JSON representation of the texture
  89487. * @param scene Define the scene the parsed texture should be instantiated in
  89488. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  89489. * @returns The parsed texture if successful
  89490. */
  89491. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  89492. /**
  89493. * Creates a texture from its base 64 representation.
  89494. * @param data Define the base64 payload without the data: prefix
  89495. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  89496. * @param scene Define the scene the texture should belong to
  89497. * @param noMipmap Forces the texture to not create mip map information if true
  89498. * @param invertY define if the texture needs to be inverted on the y axis during loading
  89499. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89500. * @param onLoad define a callback triggered when the texture has been loaded
  89501. * @param onError define a callback triggered when an error occurred during the loading session
  89502. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89503. * @returns the created texture
  89504. */
  89505. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  89506. /**
  89507. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  89508. * @param data Define the base64 payload without the data: prefix
  89509. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  89510. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  89511. * @param scene Define the scene the texture should belong to
  89512. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  89513. * @param noMipmap Forces the texture to not create mip map information if true
  89514. * @param invertY define if the texture needs to be inverted on the y axis during loading
  89515. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89516. * @param onLoad define a callback triggered when the texture has been loaded
  89517. * @param onError define a callback triggered when an error occurred during the loading session
  89518. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89519. * @returns the created texture
  89520. */
  89521. 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;
  89522. }
  89523. }
  89524. declare module BABYLON {
  89525. /**
  89526. * PostProcessManager is used to manage one or more post processes or post process pipelines
  89527. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  89528. */
  89529. export class PostProcessManager {
  89530. private _scene;
  89531. private _indexBuffer;
  89532. private _vertexBuffers;
  89533. /**
  89534. * Creates a new instance PostProcess
  89535. * @param scene The scene that the post process is associated with.
  89536. */
  89537. constructor(scene: Scene);
  89538. private _prepareBuffers;
  89539. private _buildIndexBuffer;
  89540. /**
  89541. * Rebuilds the vertex buffers of the manager.
  89542. * @hidden
  89543. */
  89544. _rebuild(): void;
  89545. /**
  89546. * Prepares a frame to be run through a post process.
  89547. * @param sourceTexture The input texture to the post procesess. (default: null)
  89548. * @param postProcesses An array of post processes to be run. (default: null)
  89549. * @returns True if the post processes were able to be run.
  89550. * @hidden
  89551. */
  89552. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  89553. /**
  89554. * Manually render a set of post processes to a texture.
  89555. * @param postProcesses An array of post processes to be run.
  89556. * @param targetTexture The target texture to render to.
  89557. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  89558. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  89559. * @param lodLevel defines which lod of the texture to render to
  89560. */
  89561. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  89562. /**
  89563. * Finalize the result of the output of the postprocesses.
  89564. * @param doNotPresent If true the result will not be displayed to the screen.
  89565. * @param targetTexture The target texture to render to.
  89566. * @param faceIndex The index of the face to bind the target texture to.
  89567. * @param postProcesses The array of post processes to render.
  89568. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  89569. * @hidden
  89570. */
  89571. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  89572. /**
  89573. * Disposes of the post process manager.
  89574. */
  89575. dispose(): void;
  89576. }
  89577. }
  89578. declare module BABYLON {
  89579. /** Interface used by value gradients (color, factor, ...) */
  89580. export interface IValueGradient {
  89581. /**
  89582. * Gets or sets the gradient value (between 0 and 1)
  89583. */
  89584. gradient: number;
  89585. }
  89586. /** Class used to store color4 gradient */
  89587. export class ColorGradient implements IValueGradient {
  89588. /**
  89589. * Gets or sets the gradient value (between 0 and 1)
  89590. */
  89591. gradient: number;
  89592. /**
  89593. * Gets or sets first associated color
  89594. */
  89595. color1: Color4;
  89596. /**
  89597. * Gets or sets second associated color
  89598. */
  89599. color2?: Color4;
  89600. /**
  89601. * Will get a color picked randomly between color1 and color2.
  89602. * If color2 is undefined then color1 will be used
  89603. * @param result defines the target Color4 to store the result in
  89604. */
  89605. getColorToRef(result: Color4): void;
  89606. }
  89607. /** Class used to store color 3 gradient */
  89608. export class Color3Gradient implements IValueGradient {
  89609. /**
  89610. * Gets or sets the gradient value (between 0 and 1)
  89611. */
  89612. gradient: number;
  89613. /**
  89614. * Gets or sets the associated color
  89615. */
  89616. color: Color3;
  89617. }
  89618. /** Class used to store factor gradient */
  89619. export class FactorGradient implements IValueGradient {
  89620. /**
  89621. * Gets or sets the gradient value (between 0 and 1)
  89622. */
  89623. gradient: number;
  89624. /**
  89625. * Gets or sets first associated factor
  89626. */
  89627. factor1: number;
  89628. /**
  89629. * Gets or sets second associated factor
  89630. */
  89631. factor2?: number;
  89632. /**
  89633. * Will get a number picked randomly between factor1 and factor2.
  89634. * If factor2 is undefined then factor1 will be used
  89635. * @returns the picked number
  89636. */
  89637. getFactor(): number;
  89638. }
  89639. /**
  89640. * Helper used to simplify some generic gradient tasks
  89641. */
  89642. export class GradientHelper {
  89643. /**
  89644. * Gets the current gradient from an array of IValueGradient
  89645. * @param ratio defines the current ratio to get
  89646. * @param gradients defines the array of IValueGradient
  89647. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89648. */
  89649. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89650. }
  89651. }
  89652. declare module BABYLON {
  89653. interface ThinEngine {
  89654. /**
  89655. * Creates a dynamic texture
  89656. * @param width defines the width of the texture
  89657. * @param height defines the height of the texture
  89658. * @param generateMipMaps defines if the engine should generate the mip levels
  89659. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89660. * @returns the dynamic texture inside an InternalTexture
  89661. */
  89662. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  89663. /**
  89664. * Update the content of a dynamic texture
  89665. * @param texture defines the texture to update
  89666. * @param canvas defines the canvas containing the source
  89667. * @param invertY defines if data must be stored with Y axis inverted
  89668. * @param premulAlpha defines if alpha is stored as premultiplied
  89669. * @param format defines the format of the data
  89670. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  89671. */
  89672. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  89673. }
  89674. }
  89675. declare module BABYLON {
  89676. /**
  89677. * Helper class used to generate a canvas to manipulate images
  89678. */
  89679. export class CanvasGenerator {
  89680. /**
  89681. * Create a new canvas (or offscreen canvas depending on the context)
  89682. * @param width defines the expected width
  89683. * @param height defines the expected height
  89684. * @return a new canvas or offscreen canvas
  89685. */
  89686. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  89687. }
  89688. }
  89689. declare module BABYLON {
  89690. /**
  89691. * A class extending Texture allowing drawing on a texture
  89692. * @see http://doc.babylonjs.com/how_to/dynamictexture
  89693. */
  89694. export class DynamicTexture extends Texture {
  89695. private _generateMipMaps;
  89696. private _canvas;
  89697. private _context;
  89698. private _engine;
  89699. /**
  89700. * Creates a DynamicTexture
  89701. * @param name defines the name of the texture
  89702. * @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
  89703. * @param scene defines the scene where you want the texture
  89704. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  89705. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  89706. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  89707. */
  89708. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  89709. /**
  89710. * Get the current class name of the texture useful for serialization or dynamic coding.
  89711. * @returns "DynamicTexture"
  89712. */
  89713. getClassName(): string;
  89714. /**
  89715. * Gets the current state of canRescale
  89716. */
  89717. get canRescale(): boolean;
  89718. private _recreate;
  89719. /**
  89720. * Scales the texture
  89721. * @param ratio the scale factor to apply to both width and height
  89722. */
  89723. scale(ratio: number): void;
  89724. /**
  89725. * Resizes the texture
  89726. * @param width the new width
  89727. * @param height the new height
  89728. */
  89729. scaleTo(width: number, height: number): void;
  89730. /**
  89731. * Gets the context of the canvas used by the texture
  89732. * @returns the canvas context of the dynamic texture
  89733. */
  89734. getContext(): CanvasRenderingContext2D;
  89735. /**
  89736. * Clears the texture
  89737. */
  89738. clear(): void;
  89739. /**
  89740. * Updates the texture
  89741. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89742. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  89743. */
  89744. update(invertY?: boolean, premulAlpha?: boolean): void;
  89745. /**
  89746. * Draws text onto the texture
  89747. * @param text defines the text to be drawn
  89748. * @param x defines the placement of the text from the left
  89749. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  89750. * @param font defines the font to be used with font-style, font-size, font-name
  89751. * @param color defines the color used for the text
  89752. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  89753. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89754. * @param update defines whether texture is immediately update (default is true)
  89755. */
  89756. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  89757. /**
  89758. * Clones the texture
  89759. * @returns the clone of the texture.
  89760. */
  89761. clone(): DynamicTexture;
  89762. /**
  89763. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  89764. * @returns a serialized dynamic texture object
  89765. */
  89766. serialize(): any;
  89767. /** @hidden */
  89768. _rebuild(): void;
  89769. }
  89770. }
  89771. declare module BABYLON {
  89772. interface AbstractScene {
  89773. /**
  89774. * The list of procedural textures added to the scene
  89775. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89776. */
  89777. proceduralTextures: Array<ProceduralTexture>;
  89778. }
  89779. /**
  89780. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89781. * in a given scene.
  89782. */
  89783. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89784. /**
  89785. * The component name helpfull to identify the component in the list of scene components.
  89786. */
  89787. readonly name: string;
  89788. /**
  89789. * The scene the component belongs to.
  89790. */
  89791. scene: Scene;
  89792. /**
  89793. * Creates a new instance of the component for the given scene
  89794. * @param scene Defines the scene to register the component in
  89795. */
  89796. constructor(scene: Scene);
  89797. /**
  89798. * Registers the component in a given scene
  89799. */
  89800. register(): void;
  89801. /**
  89802. * Rebuilds the elements related to this component in case of
  89803. * context lost for instance.
  89804. */
  89805. rebuild(): void;
  89806. /**
  89807. * Disposes the component and the associated ressources.
  89808. */
  89809. dispose(): void;
  89810. private _beforeClear;
  89811. }
  89812. }
  89813. declare module BABYLON {
  89814. interface ThinEngine {
  89815. /**
  89816. * Creates a new render target cube texture
  89817. * @param size defines the size of the texture
  89818. * @param options defines the options used to create the texture
  89819. * @returns a new render target cube texture stored in an InternalTexture
  89820. */
  89821. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89822. }
  89823. }
  89824. declare module BABYLON {
  89825. /** @hidden */
  89826. export var proceduralVertexShader: {
  89827. name: string;
  89828. shader: string;
  89829. };
  89830. }
  89831. declare module BABYLON {
  89832. /**
  89833. * 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.
  89834. * This is the base class of any Procedural texture and contains most of the shareable code.
  89835. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89836. */
  89837. export class ProceduralTexture extends Texture {
  89838. isCube: boolean;
  89839. /**
  89840. * Define if the texture is enabled or not (disabled texture will not render)
  89841. */
  89842. isEnabled: boolean;
  89843. /**
  89844. * Define if the texture must be cleared before rendering (default is true)
  89845. */
  89846. autoClear: boolean;
  89847. /**
  89848. * Callback called when the texture is generated
  89849. */
  89850. onGenerated: () => void;
  89851. /**
  89852. * Event raised when the texture is generated
  89853. */
  89854. onGeneratedObservable: Observable<ProceduralTexture>;
  89855. /** @hidden */
  89856. _generateMipMaps: boolean;
  89857. /** @hidden **/
  89858. _effect: Effect;
  89859. /** @hidden */
  89860. _textures: {
  89861. [key: string]: Texture;
  89862. };
  89863. private _size;
  89864. private _currentRefreshId;
  89865. private _frameId;
  89866. private _refreshRate;
  89867. private _vertexBuffers;
  89868. private _indexBuffer;
  89869. private _uniforms;
  89870. private _samplers;
  89871. private _fragment;
  89872. private _floats;
  89873. private _ints;
  89874. private _floatsArrays;
  89875. private _colors3;
  89876. private _colors4;
  89877. private _vectors2;
  89878. private _vectors3;
  89879. private _matrices;
  89880. private _fallbackTexture;
  89881. private _fallbackTextureUsed;
  89882. private _engine;
  89883. private _cachedDefines;
  89884. private _contentUpdateId;
  89885. private _contentData;
  89886. /**
  89887. * Instantiates a new procedural texture.
  89888. * 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.
  89889. * This is the base class of any Procedural texture and contains most of the shareable code.
  89890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89891. * @param name Define the name of the texture
  89892. * @param size Define the size of the texture to create
  89893. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89894. * @param scene Define the scene the texture belongs to
  89895. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89896. * @param generateMipMaps Define if the texture should creates mip maps or not
  89897. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89898. */
  89899. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89900. /**
  89901. * The effect that is created when initializing the post process.
  89902. * @returns The created effect corresponding the the postprocess.
  89903. */
  89904. getEffect(): Effect;
  89905. /**
  89906. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89907. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89908. */
  89909. getContent(): Nullable<ArrayBufferView>;
  89910. private _createIndexBuffer;
  89911. /** @hidden */
  89912. _rebuild(): void;
  89913. /**
  89914. * Resets the texture in order to recreate its associated resources.
  89915. * This can be called in case of context loss
  89916. */
  89917. reset(): void;
  89918. protected _getDefines(): string;
  89919. /**
  89920. * Is the texture ready to be used ? (rendered at least once)
  89921. * @returns true if ready, otherwise, false.
  89922. */
  89923. isReady(): boolean;
  89924. /**
  89925. * Resets the refresh counter of the texture and start bak from scratch.
  89926. * Could be useful to regenerate the texture if it is setup to render only once.
  89927. */
  89928. resetRefreshCounter(): void;
  89929. /**
  89930. * Set the fragment shader to use in order to render the texture.
  89931. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89932. */
  89933. setFragment(fragment: any): void;
  89934. /**
  89935. * Define the refresh rate of the texture or the rendering frequency.
  89936. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89937. */
  89938. get refreshRate(): number;
  89939. set refreshRate(value: number);
  89940. /** @hidden */
  89941. _shouldRender(): boolean;
  89942. /**
  89943. * Get the size the texture is rendering at.
  89944. * @returns the size (texture is always squared)
  89945. */
  89946. getRenderSize(): number;
  89947. /**
  89948. * Resize the texture to new value.
  89949. * @param size Define the new size the texture should have
  89950. * @param generateMipMaps Define whether the new texture should create mip maps
  89951. */
  89952. resize(size: number, generateMipMaps: boolean): void;
  89953. private _checkUniform;
  89954. /**
  89955. * Set a texture in the shader program used to render.
  89956. * @param name Define the name of the uniform samplers as defined in the shader
  89957. * @param texture Define the texture to bind to this sampler
  89958. * @return the texture itself allowing "fluent" like uniform updates
  89959. */
  89960. setTexture(name: string, texture: Texture): ProceduralTexture;
  89961. /**
  89962. * Set a float in the shader.
  89963. * @param name Define the name of the uniform as defined in the shader
  89964. * @param value Define the value to give to the uniform
  89965. * @return the texture itself allowing "fluent" like uniform updates
  89966. */
  89967. setFloat(name: string, value: number): ProceduralTexture;
  89968. /**
  89969. * Set a int in the shader.
  89970. * @param name Define the name of the uniform as defined in the shader
  89971. * @param value Define the value to give to the uniform
  89972. * @return the texture itself allowing "fluent" like uniform updates
  89973. */
  89974. setInt(name: string, value: number): ProceduralTexture;
  89975. /**
  89976. * Set an array of floats in the shader.
  89977. * @param name Define the name of the uniform as defined in the shader
  89978. * @param value Define the value to give to the uniform
  89979. * @return the texture itself allowing "fluent" like uniform updates
  89980. */
  89981. setFloats(name: string, value: number[]): ProceduralTexture;
  89982. /**
  89983. * Set a vec3 in the shader from a Color3.
  89984. * @param name Define the name of the uniform as defined in the shader
  89985. * @param value Define the value to give to the uniform
  89986. * @return the texture itself allowing "fluent" like uniform updates
  89987. */
  89988. setColor3(name: string, value: Color3): ProceduralTexture;
  89989. /**
  89990. * Set a vec4 in the shader from a Color4.
  89991. * @param name Define the name of the uniform as defined in the shader
  89992. * @param value Define the value to give to the uniform
  89993. * @return the texture itself allowing "fluent" like uniform updates
  89994. */
  89995. setColor4(name: string, value: Color4): ProceduralTexture;
  89996. /**
  89997. * Set a vec2 in the shader from a Vector2.
  89998. * @param name Define the name of the uniform as defined in the shader
  89999. * @param value Define the value to give to the uniform
  90000. * @return the texture itself allowing "fluent" like uniform updates
  90001. */
  90002. setVector2(name: string, value: Vector2): ProceduralTexture;
  90003. /**
  90004. * Set a vec3 in the shader from a Vector3.
  90005. * @param name Define the name of the uniform as defined in the shader
  90006. * @param value Define the value to give to the uniform
  90007. * @return the texture itself allowing "fluent" like uniform updates
  90008. */
  90009. setVector3(name: string, value: Vector3): ProceduralTexture;
  90010. /**
  90011. * Set a mat4 in the shader from a MAtrix.
  90012. * @param name Define the name of the uniform as defined in the shader
  90013. * @param value Define the value to give to the uniform
  90014. * @return the texture itself allowing "fluent" like uniform updates
  90015. */
  90016. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90017. /**
  90018. * Render the texture to its associated render target.
  90019. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90020. */
  90021. render(useCameraPostProcess?: boolean): void;
  90022. /**
  90023. * Clone the texture.
  90024. * @returns the cloned texture
  90025. */
  90026. clone(): ProceduralTexture;
  90027. /**
  90028. * Dispose the texture and release its asoociated resources.
  90029. */
  90030. dispose(): void;
  90031. }
  90032. }
  90033. declare module BABYLON {
  90034. /**
  90035. * This represents the base class for particle system in Babylon.
  90036. * 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.
  90037. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90038. * @example https://doc.babylonjs.com/babylon101/particles
  90039. */
  90040. export class BaseParticleSystem {
  90041. /**
  90042. * Source color is added to the destination color without alpha affecting the result
  90043. */
  90044. static BLENDMODE_ONEONE: number;
  90045. /**
  90046. * Blend current color and particle color using particle’s alpha
  90047. */
  90048. static BLENDMODE_STANDARD: number;
  90049. /**
  90050. * Add current color and particle color multiplied by particle’s alpha
  90051. */
  90052. static BLENDMODE_ADD: number;
  90053. /**
  90054. * Multiply current color with particle color
  90055. */
  90056. static BLENDMODE_MULTIPLY: number;
  90057. /**
  90058. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90059. */
  90060. static BLENDMODE_MULTIPLYADD: number;
  90061. /**
  90062. * List of animations used by the particle system.
  90063. */
  90064. animations: Animation[];
  90065. /**
  90066. * The id of the Particle system.
  90067. */
  90068. id: string;
  90069. /**
  90070. * The friendly name of the Particle system.
  90071. */
  90072. name: string;
  90073. /**
  90074. * The rendering group used by the Particle system to chose when to render.
  90075. */
  90076. renderingGroupId: number;
  90077. /**
  90078. * The emitter represents the Mesh or position we are attaching the particle system to.
  90079. */
  90080. emitter: Nullable<AbstractMesh | Vector3>;
  90081. /**
  90082. * The maximum number of particles to emit per frame
  90083. */
  90084. emitRate: number;
  90085. /**
  90086. * If you want to launch only a few particles at once, that can be done, as well.
  90087. */
  90088. manualEmitCount: number;
  90089. /**
  90090. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90091. */
  90092. updateSpeed: number;
  90093. /**
  90094. * The amount of time the particle system is running (depends of the overall update speed).
  90095. */
  90096. targetStopDuration: number;
  90097. /**
  90098. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90099. */
  90100. disposeOnStop: boolean;
  90101. /**
  90102. * Minimum power of emitting particles.
  90103. */
  90104. minEmitPower: number;
  90105. /**
  90106. * Maximum power of emitting particles.
  90107. */
  90108. maxEmitPower: number;
  90109. /**
  90110. * Minimum life time of emitting particles.
  90111. */
  90112. minLifeTime: number;
  90113. /**
  90114. * Maximum life time of emitting particles.
  90115. */
  90116. maxLifeTime: number;
  90117. /**
  90118. * Minimum Size of emitting particles.
  90119. */
  90120. minSize: number;
  90121. /**
  90122. * Maximum Size of emitting particles.
  90123. */
  90124. maxSize: number;
  90125. /**
  90126. * Minimum scale of emitting particles on X axis.
  90127. */
  90128. minScaleX: number;
  90129. /**
  90130. * Maximum scale of emitting particles on X axis.
  90131. */
  90132. maxScaleX: number;
  90133. /**
  90134. * Minimum scale of emitting particles on Y axis.
  90135. */
  90136. minScaleY: number;
  90137. /**
  90138. * Maximum scale of emitting particles on Y axis.
  90139. */
  90140. maxScaleY: number;
  90141. /**
  90142. * Gets or sets the minimal initial rotation in radians.
  90143. */
  90144. minInitialRotation: number;
  90145. /**
  90146. * Gets or sets the maximal initial rotation in radians.
  90147. */
  90148. maxInitialRotation: number;
  90149. /**
  90150. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90151. */
  90152. minAngularSpeed: number;
  90153. /**
  90154. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90155. */
  90156. maxAngularSpeed: number;
  90157. /**
  90158. * The texture used to render each particle. (this can be a spritesheet)
  90159. */
  90160. particleTexture: Nullable<Texture>;
  90161. /**
  90162. * The layer mask we are rendering the particles through.
  90163. */
  90164. layerMask: number;
  90165. /**
  90166. * This can help using your own shader to render the particle system.
  90167. * The according effect will be created
  90168. */
  90169. customShader: any;
  90170. /**
  90171. * By default particle system starts as soon as they are created. This prevents the
  90172. * automatic start to happen and let you decide when to start emitting particles.
  90173. */
  90174. preventAutoStart: boolean;
  90175. private _noiseTexture;
  90176. /**
  90177. * Gets or sets a texture used to add random noise to particle positions
  90178. */
  90179. get noiseTexture(): Nullable<ProceduralTexture>;
  90180. set noiseTexture(value: Nullable<ProceduralTexture>);
  90181. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90182. noiseStrength: Vector3;
  90183. /**
  90184. * Callback triggered when the particle animation is ending.
  90185. */
  90186. onAnimationEnd: Nullable<() => void>;
  90187. /**
  90188. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90189. */
  90190. blendMode: number;
  90191. /**
  90192. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90193. * to override the particles.
  90194. */
  90195. forceDepthWrite: boolean;
  90196. /** 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 */
  90197. preWarmCycles: number;
  90198. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90199. preWarmStepOffset: number;
  90200. /**
  90201. * 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)
  90202. */
  90203. spriteCellChangeSpeed: number;
  90204. /**
  90205. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90206. */
  90207. startSpriteCellID: number;
  90208. /**
  90209. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90210. */
  90211. endSpriteCellID: number;
  90212. /**
  90213. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90214. */
  90215. spriteCellWidth: number;
  90216. /**
  90217. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90218. */
  90219. spriteCellHeight: number;
  90220. /**
  90221. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90222. */
  90223. spriteRandomStartCell: boolean;
  90224. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90225. translationPivot: Vector2;
  90226. /** @hidden */
  90227. protected _isAnimationSheetEnabled: boolean;
  90228. /**
  90229. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90230. */
  90231. beginAnimationOnStart: boolean;
  90232. /**
  90233. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90234. */
  90235. beginAnimationFrom: number;
  90236. /**
  90237. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90238. */
  90239. beginAnimationTo: number;
  90240. /**
  90241. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90242. */
  90243. beginAnimationLoop: boolean;
  90244. /**
  90245. * Gets or sets a world offset applied to all particles
  90246. */
  90247. worldOffset: Vector3;
  90248. /**
  90249. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90250. */
  90251. get isAnimationSheetEnabled(): boolean;
  90252. set isAnimationSheetEnabled(value: boolean);
  90253. /**
  90254. * Get hosting scene
  90255. * @returns the scene
  90256. */
  90257. getScene(): Scene;
  90258. /**
  90259. * You can use gravity if you want to give an orientation to your particles.
  90260. */
  90261. gravity: Vector3;
  90262. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90263. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90264. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90265. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90266. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90267. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90268. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90269. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90270. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90271. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90272. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90273. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90274. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90275. /**
  90276. * Defines the delay in milliseconds before starting the system (0 by default)
  90277. */
  90278. startDelay: number;
  90279. /**
  90280. * Gets the current list of drag gradients.
  90281. * You must use addDragGradient and removeDragGradient to udpate this list
  90282. * @returns the list of drag gradients
  90283. */
  90284. getDragGradients(): Nullable<Array<FactorGradient>>;
  90285. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90286. limitVelocityDamping: number;
  90287. /**
  90288. * Gets the current list of limit velocity gradients.
  90289. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90290. * @returns the list of limit velocity gradients
  90291. */
  90292. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90293. /**
  90294. * Gets the current list of color gradients.
  90295. * You must use addColorGradient and removeColorGradient to udpate this list
  90296. * @returns the list of color gradients
  90297. */
  90298. getColorGradients(): Nullable<Array<ColorGradient>>;
  90299. /**
  90300. * Gets the current list of size gradients.
  90301. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90302. * @returns the list of size gradients
  90303. */
  90304. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90305. /**
  90306. * Gets the current list of color remap gradients.
  90307. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90308. * @returns the list of color remap gradients
  90309. */
  90310. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90311. /**
  90312. * Gets the current list of alpha remap gradients.
  90313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90314. * @returns the list of alpha remap gradients
  90315. */
  90316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90317. /**
  90318. * Gets the current list of life time gradients.
  90319. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90320. * @returns the list of life time gradients
  90321. */
  90322. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90323. /**
  90324. * Gets the current list of angular speed gradients.
  90325. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90326. * @returns the list of angular speed gradients
  90327. */
  90328. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90329. /**
  90330. * Gets the current list of velocity gradients.
  90331. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90332. * @returns the list of velocity gradients
  90333. */
  90334. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90335. /**
  90336. * Gets the current list of start size gradients.
  90337. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90338. * @returns the list of start size gradients
  90339. */
  90340. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90341. /**
  90342. * Gets the current list of emit rate gradients.
  90343. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90344. * @returns the list of emit rate gradients
  90345. */
  90346. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90347. /**
  90348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90350. */
  90351. get direction1(): Vector3;
  90352. set direction1(value: Vector3);
  90353. /**
  90354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90356. */
  90357. get direction2(): Vector3;
  90358. set direction2(value: Vector3);
  90359. /**
  90360. * 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.
  90361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90362. */
  90363. get minEmitBox(): Vector3;
  90364. set minEmitBox(value: Vector3);
  90365. /**
  90366. * 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.
  90367. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90368. */
  90369. get maxEmitBox(): Vector3;
  90370. set maxEmitBox(value: Vector3);
  90371. /**
  90372. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90373. */
  90374. color1: Color4;
  90375. /**
  90376. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90377. */
  90378. color2: Color4;
  90379. /**
  90380. * Color the particle will have at the end of its lifetime
  90381. */
  90382. colorDead: Color4;
  90383. /**
  90384. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90385. */
  90386. textureMask: Color4;
  90387. /**
  90388. * The particle emitter type defines the emitter used by the particle system.
  90389. * It can be for example box, sphere, or cone...
  90390. */
  90391. particleEmitterType: IParticleEmitterType;
  90392. /** @hidden */
  90393. _isSubEmitter: boolean;
  90394. /**
  90395. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90396. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90397. */
  90398. billboardMode: number;
  90399. protected _isBillboardBased: boolean;
  90400. /**
  90401. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90402. */
  90403. get isBillboardBased(): boolean;
  90404. set isBillboardBased(value: boolean);
  90405. /**
  90406. * The scene the particle system belongs to.
  90407. */
  90408. protected _scene: Scene;
  90409. /**
  90410. * Local cache of defines for image processing.
  90411. */
  90412. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90413. /**
  90414. * Default configuration related to image processing available in the standard Material.
  90415. */
  90416. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90417. /**
  90418. * Gets the image processing configuration used either in this material.
  90419. */
  90420. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90421. /**
  90422. * Sets the Default image processing configuration used either in the this material.
  90423. *
  90424. * If sets to null, the scene one is in use.
  90425. */
  90426. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90427. /**
  90428. * Attaches a new image processing configuration to the Standard Material.
  90429. * @param configuration
  90430. */
  90431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90432. /** @hidden */
  90433. protected _reset(): void;
  90434. /** @hidden */
  90435. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90436. /**
  90437. * Instantiates a particle system.
  90438. * 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.
  90439. * @param name The name of the particle system
  90440. */
  90441. constructor(name: string);
  90442. /**
  90443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90446. * @returns the emitter
  90447. */
  90448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90449. /**
  90450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90451. * @param radius The radius of the hemisphere to emit from
  90452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90453. * @returns the emitter
  90454. */
  90455. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90456. /**
  90457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90458. * @param radius The radius of the sphere to emit from
  90459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90460. * @returns the emitter
  90461. */
  90462. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90463. /**
  90464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90465. * @param radius The radius of the sphere to emit from
  90466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90468. * @returns the emitter
  90469. */
  90470. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90471. /**
  90472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90473. * @param radius The radius of the emission cylinder
  90474. * @param height The height of the emission cylinder
  90475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90477. * @returns the emitter
  90478. */
  90479. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90480. /**
  90481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90482. * @param radius The radius of the cylinder to emit from
  90483. * @param height The height of the emission cylinder
  90484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90487. * @returns the emitter
  90488. */
  90489. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90490. /**
  90491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90492. * @param radius The radius of the cone to emit from
  90493. * @param angle The base angle of the cone
  90494. * @returns the emitter
  90495. */
  90496. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90497. /**
  90498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90503. * @returns the emitter
  90504. */
  90505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90506. }
  90507. }
  90508. declare module BABYLON {
  90509. /**
  90510. * Type of sub emitter
  90511. */
  90512. export enum SubEmitterType {
  90513. /**
  90514. * Attached to the particle over it's lifetime
  90515. */
  90516. ATTACHED = 0,
  90517. /**
  90518. * Created when the particle dies
  90519. */
  90520. END = 1
  90521. }
  90522. /**
  90523. * Sub emitter class used to emit particles from an existing particle
  90524. */
  90525. export class SubEmitter {
  90526. /**
  90527. * the particle system to be used by the sub emitter
  90528. */
  90529. particleSystem: ParticleSystem;
  90530. /**
  90531. * Type of the submitter (Default: END)
  90532. */
  90533. type: SubEmitterType;
  90534. /**
  90535. * 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)
  90536. * Note: This only is supported when using an emitter of type Mesh
  90537. */
  90538. inheritDirection: boolean;
  90539. /**
  90540. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90541. */
  90542. inheritedVelocityAmount: number;
  90543. /**
  90544. * Creates a sub emitter
  90545. * @param particleSystem the particle system to be used by the sub emitter
  90546. */
  90547. constructor(
  90548. /**
  90549. * the particle system to be used by the sub emitter
  90550. */
  90551. particleSystem: ParticleSystem);
  90552. /**
  90553. * Clones the sub emitter
  90554. * @returns the cloned sub emitter
  90555. */
  90556. clone(): SubEmitter;
  90557. /**
  90558. * Serialize current object to a JSON object
  90559. * @returns the serialized object
  90560. */
  90561. serialize(): any;
  90562. /** @hidden */
  90563. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90564. /**
  90565. * Creates a new SubEmitter from a serialized JSON version
  90566. * @param serializationObject defines the JSON object to read from
  90567. * @param scene defines the hosting scene
  90568. * @param rootUrl defines the rootUrl for data loading
  90569. * @returns a new SubEmitter
  90570. */
  90571. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90572. /** Release associated resources */
  90573. dispose(): void;
  90574. }
  90575. }
  90576. declare module BABYLON {
  90577. /** @hidden */
  90578. export var imageProcessingDeclaration: {
  90579. name: string;
  90580. shader: string;
  90581. };
  90582. }
  90583. declare module BABYLON {
  90584. /** @hidden */
  90585. export var imageProcessingFunctions: {
  90586. name: string;
  90587. shader: string;
  90588. };
  90589. }
  90590. declare module BABYLON {
  90591. /** @hidden */
  90592. export var particlesPixelShader: {
  90593. name: string;
  90594. shader: string;
  90595. };
  90596. }
  90597. declare module BABYLON {
  90598. /** @hidden */
  90599. export var particlesVertexShader: {
  90600. name: string;
  90601. shader: string;
  90602. };
  90603. }
  90604. declare module BABYLON {
  90605. /**
  90606. * This represents a particle system in Babylon.
  90607. * 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.
  90608. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90609. * @example https://doc.babylonjs.com/babylon101/particles
  90610. */
  90611. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90612. /**
  90613. * Billboard mode will only apply to Y axis
  90614. */
  90615. static readonly BILLBOARDMODE_Y: number;
  90616. /**
  90617. * Billboard mode will apply to all axes
  90618. */
  90619. static readonly BILLBOARDMODE_ALL: number;
  90620. /**
  90621. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90622. */
  90623. static readonly BILLBOARDMODE_STRETCHED: number;
  90624. /**
  90625. * This function can be defined to provide custom update for active particles.
  90626. * This function will be called instead of regular update (age, position, color, etc.).
  90627. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90628. */
  90629. updateFunction: (particles: Particle[]) => void;
  90630. private _emitterWorldMatrix;
  90631. /**
  90632. * This function can be defined to specify initial direction for every new particle.
  90633. * It by default use the emitterType defined function
  90634. */
  90635. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  90636. /**
  90637. * This function can be defined to specify initial position for every new particle.
  90638. * It by default use the emitterType defined function
  90639. */
  90640. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  90641. /**
  90642. * @hidden
  90643. */
  90644. _inheritedVelocityOffset: Vector3;
  90645. /**
  90646. * An event triggered when the system is disposed
  90647. */
  90648. onDisposeObservable: Observable<ParticleSystem>;
  90649. private _onDisposeObserver;
  90650. /**
  90651. * Sets a callback that will be triggered when the system is disposed
  90652. */
  90653. set onDispose(callback: () => void);
  90654. private _particles;
  90655. private _epsilon;
  90656. private _capacity;
  90657. private _stockParticles;
  90658. private _newPartsExcess;
  90659. private _vertexData;
  90660. private _vertexBuffer;
  90661. private _vertexBuffers;
  90662. private _spriteBuffer;
  90663. private _indexBuffer;
  90664. private _effect;
  90665. private _customEffect;
  90666. private _cachedDefines;
  90667. private _scaledColorStep;
  90668. private _colorDiff;
  90669. private _scaledDirection;
  90670. private _scaledGravity;
  90671. private _currentRenderId;
  90672. private _alive;
  90673. private _useInstancing;
  90674. private _started;
  90675. private _stopped;
  90676. private _actualFrame;
  90677. private _scaledUpdateSpeed;
  90678. private _vertexBufferSize;
  90679. /** @hidden */
  90680. _currentEmitRateGradient: Nullable<FactorGradient>;
  90681. /** @hidden */
  90682. _currentEmitRate1: number;
  90683. /** @hidden */
  90684. _currentEmitRate2: number;
  90685. /** @hidden */
  90686. _currentStartSizeGradient: Nullable<FactorGradient>;
  90687. /** @hidden */
  90688. _currentStartSize1: number;
  90689. /** @hidden */
  90690. _currentStartSize2: number;
  90691. private readonly _rawTextureWidth;
  90692. private _rampGradientsTexture;
  90693. private _useRampGradients;
  90694. /** Gets or sets a boolean indicating that ramp gradients must be used
  90695. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90696. */
  90697. get useRampGradients(): boolean;
  90698. set useRampGradients(value: boolean);
  90699. /**
  90700. * 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.
  90701. * 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: [])
  90702. */
  90703. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90704. private _subEmitters;
  90705. /**
  90706. * @hidden
  90707. * If the particle systems emitter should be disposed when the particle system is disposed
  90708. */
  90709. _disposeEmitterOnDispose: boolean;
  90710. /**
  90711. * The current active Sub-systems, this property is used by the root particle system only.
  90712. */
  90713. activeSubSystems: Array<ParticleSystem>;
  90714. private _rootParticleSystem;
  90715. /**
  90716. * Gets the current list of active particles
  90717. */
  90718. get particles(): Particle[];
  90719. /**
  90720. * Returns the string "ParticleSystem"
  90721. * @returns a string containing the class name
  90722. */
  90723. getClassName(): string;
  90724. /**
  90725. * Instantiates a particle system.
  90726. * 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.
  90727. * @param name The name of the particle system
  90728. * @param capacity The max number of particles alive at the same time
  90729. * @param scene The scene the particle system belongs to
  90730. * @param customEffect a custom effect used to change the way particles are rendered by default
  90731. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90732. * @param epsilon Offset used to render the particles
  90733. */
  90734. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90735. private _addFactorGradient;
  90736. private _removeFactorGradient;
  90737. /**
  90738. * Adds a new life time gradient
  90739. * @param gradient defines the gradient to use (between 0 and 1)
  90740. * @param factor defines the life time factor to affect to the specified gradient
  90741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90742. * @returns the current particle system
  90743. */
  90744. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90745. /**
  90746. * Remove a specific life time gradient
  90747. * @param gradient defines the gradient to remove
  90748. * @returns the current particle system
  90749. */
  90750. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90751. /**
  90752. * Adds a new size gradient
  90753. * @param gradient defines the gradient to use (between 0 and 1)
  90754. * @param factor defines the size factor to affect to the specified gradient
  90755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90756. * @returns the current particle system
  90757. */
  90758. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90759. /**
  90760. * Remove a specific size gradient
  90761. * @param gradient defines the gradient to remove
  90762. * @returns the current particle system
  90763. */
  90764. removeSizeGradient(gradient: number): IParticleSystem;
  90765. /**
  90766. * Adds a new color remap gradient
  90767. * @param gradient defines the gradient to use (between 0 and 1)
  90768. * @param min defines the color remap minimal range
  90769. * @param max defines the color remap maximal range
  90770. * @returns the current particle system
  90771. */
  90772. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90773. /**
  90774. * Remove a specific color remap gradient
  90775. * @param gradient defines the gradient to remove
  90776. * @returns the current particle system
  90777. */
  90778. removeColorRemapGradient(gradient: number): IParticleSystem;
  90779. /**
  90780. * Adds a new alpha remap gradient
  90781. * @param gradient defines the gradient to use (between 0 and 1)
  90782. * @param min defines the alpha remap minimal range
  90783. * @param max defines the alpha remap maximal range
  90784. * @returns the current particle system
  90785. */
  90786. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90787. /**
  90788. * Remove a specific alpha remap gradient
  90789. * @param gradient defines the gradient to remove
  90790. * @returns the current particle system
  90791. */
  90792. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90793. /**
  90794. * Adds a new angular speed gradient
  90795. * @param gradient defines the gradient to use (between 0 and 1)
  90796. * @param factor defines the angular speed to affect to the specified gradient
  90797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90798. * @returns the current particle system
  90799. */
  90800. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90801. /**
  90802. * Remove a specific angular speed gradient
  90803. * @param gradient defines the gradient to remove
  90804. * @returns the current particle system
  90805. */
  90806. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90807. /**
  90808. * Adds a new velocity gradient
  90809. * @param gradient defines the gradient to use (between 0 and 1)
  90810. * @param factor defines the velocity to affect to the specified gradient
  90811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90812. * @returns the current particle system
  90813. */
  90814. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90815. /**
  90816. * Remove a specific velocity gradient
  90817. * @param gradient defines the gradient to remove
  90818. * @returns the current particle system
  90819. */
  90820. removeVelocityGradient(gradient: number): IParticleSystem;
  90821. /**
  90822. * Adds a new limit velocity gradient
  90823. * @param gradient defines the gradient to use (between 0 and 1)
  90824. * @param factor defines the limit velocity value to affect to the specified gradient
  90825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90826. * @returns the current particle system
  90827. */
  90828. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90829. /**
  90830. * Remove a specific limit velocity gradient
  90831. * @param gradient defines the gradient to remove
  90832. * @returns the current particle system
  90833. */
  90834. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90835. /**
  90836. * Adds a new drag gradient
  90837. * @param gradient defines the gradient to use (between 0 and 1)
  90838. * @param factor defines the drag value to affect to the specified gradient
  90839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90840. * @returns the current particle system
  90841. */
  90842. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90843. /**
  90844. * Remove a specific drag gradient
  90845. * @param gradient defines the gradient to remove
  90846. * @returns the current particle system
  90847. */
  90848. removeDragGradient(gradient: number): IParticleSystem;
  90849. /**
  90850. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90851. * @param gradient defines the gradient to use (between 0 and 1)
  90852. * @param factor defines the emit rate value to affect to the specified gradient
  90853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90854. * @returns the current particle system
  90855. */
  90856. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90857. /**
  90858. * Remove a specific emit rate gradient
  90859. * @param gradient defines the gradient to remove
  90860. * @returns the current particle system
  90861. */
  90862. removeEmitRateGradient(gradient: number): IParticleSystem;
  90863. /**
  90864. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90865. * @param gradient defines the gradient to use (between 0 and 1)
  90866. * @param factor defines the start size value to affect to the specified gradient
  90867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90868. * @returns the current particle system
  90869. */
  90870. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90871. /**
  90872. * Remove a specific start size gradient
  90873. * @param gradient defines the gradient to remove
  90874. * @returns the current particle system
  90875. */
  90876. removeStartSizeGradient(gradient: number): IParticleSystem;
  90877. private _createRampGradientTexture;
  90878. /**
  90879. * Gets the current list of ramp gradients.
  90880. * You must use addRampGradient and removeRampGradient to udpate this list
  90881. * @returns the list of ramp gradients
  90882. */
  90883. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90884. /**
  90885. * Adds a new ramp gradient used to remap particle colors
  90886. * @param gradient defines the gradient to use (between 0 and 1)
  90887. * @param color defines the color to affect to the specified gradient
  90888. * @returns the current particle system
  90889. */
  90890. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90891. /**
  90892. * Remove a specific ramp gradient
  90893. * @param gradient defines the gradient to remove
  90894. * @returns the current particle system
  90895. */
  90896. removeRampGradient(gradient: number): ParticleSystem;
  90897. /**
  90898. * Adds a new color gradient
  90899. * @param gradient defines the gradient to use (between 0 and 1)
  90900. * @param color1 defines the color to affect to the specified gradient
  90901. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90902. * @returns this particle system
  90903. */
  90904. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90905. /**
  90906. * Remove a specific color gradient
  90907. * @param gradient defines the gradient to remove
  90908. * @returns this particle system
  90909. */
  90910. removeColorGradient(gradient: number): IParticleSystem;
  90911. private _fetchR;
  90912. protected _reset(): void;
  90913. private _resetEffect;
  90914. private _createVertexBuffers;
  90915. private _createIndexBuffer;
  90916. /**
  90917. * Gets the maximum number of particles active at the same time.
  90918. * @returns The max number of active particles.
  90919. */
  90920. getCapacity(): number;
  90921. /**
  90922. * Gets whether there are still active particles in the system.
  90923. * @returns True if it is alive, otherwise false.
  90924. */
  90925. isAlive(): boolean;
  90926. /**
  90927. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90928. * @returns True if it has been started, otherwise false.
  90929. */
  90930. isStarted(): boolean;
  90931. private _prepareSubEmitterInternalArray;
  90932. /**
  90933. * Starts the particle system and begins to emit
  90934. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90935. */
  90936. start(delay?: number): void;
  90937. /**
  90938. * Stops the particle system.
  90939. * @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.
  90940. */
  90941. stop(stopSubEmitters?: boolean): void;
  90942. /**
  90943. * Remove all active particles
  90944. */
  90945. reset(): void;
  90946. /**
  90947. * @hidden (for internal use only)
  90948. */
  90949. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90950. /**
  90951. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90952. * Its lifetime will start back at 0.
  90953. */
  90954. recycleParticle: (particle: Particle) => void;
  90955. private _stopSubEmitters;
  90956. private _createParticle;
  90957. private _removeFromRoot;
  90958. private _emitFromParticle;
  90959. private _update;
  90960. /** @hidden */
  90961. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90962. /** @hidden */
  90963. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90964. /** @hidden */
  90965. private _getEffect;
  90966. /**
  90967. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90968. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90969. */
  90970. animate(preWarmOnly?: boolean): void;
  90971. private _appendParticleVertices;
  90972. /**
  90973. * Rebuilds the particle system.
  90974. */
  90975. rebuild(): void;
  90976. /**
  90977. * Is this system ready to be used/rendered
  90978. * @return true if the system is ready
  90979. */
  90980. isReady(): boolean;
  90981. private _render;
  90982. /**
  90983. * Renders the particle system in its current state.
  90984. * @returns the current number of particles
  90985. */
  90986. render(): number;
  90987. /**
  90988. * Disposes the particle system and free the associated resources
  90989. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90990. */
  90991. dispose(disposeTexture?: boolean): void;
  90992. /**
  90993. * Clones the particle system.
  90994. * @param name The name of the cloned object
  90995. * @param newEmitter The new emitter to use
  90996. * @returns the cloned particle system
  90997. */
  90998. clone(name: string, newEmitter: any): ParticleSystem;
  90999. /**
  91000. * Serializes the particle system to a JSON object.
  91001. * @returns the JSON object
  91002. */
  91003. serialize(): any;
  91004. /** @hidden */
  91005. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  91006. /** @hidden */
  91007. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91008. /**
  91009. * Parses a JSON object to create a particle system.
  91010. * @param parsedParticleSystem The JSON object to parse
  91011. * @param scene The scene to create the particle system in
  91012. * @param rootUrl The root url to use to load external dependencies like texture
  91013. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91014. * @returns the Parsed particle system
  91015. */
  91016. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91017. }
  91018. }
  91019. declare module BABYLON {
  91020. /**
  91021. * A particle represents one of the element emitted by a particle system.
  91022. * This is mainly define by its coordinates, direction, velocity and age.
  91023. */
  91024. export class Particle {
  91025. /**
  91026. * The particle system the particle belongs to.
  91027. */
  91028. particleSystem: ParticleSystem;
  91029. private static _Count;
  91030. /**
  91031. * Unique ID of the particle
  91032. */
  91033. id: number;
  91034. /**
  91035. * The world position of the particle in the scene.
  91036. */
  91037. position: Vector3;
  91038. /**
  91039. * The world direction of the particle in the scene.
  91040. */
  91041. direction: Vector3;
  91042. /**
  91043. * The color of the particle.
  91044. */
  91045. color: Color4;
  91046. /**
  91047. * The color change of the particle per step.
  91048. */
  91049. colorStep: Color4;
  91050. /**
  91051. * Defines how long will the life of the particle be.
  91052. */
  91053. lifeTime: number;
  91054. /**
  91055. * The current age of the particle.
  91056. */
  91057. age: number;
  91058. /**
  91059. * The current size of the particle.
  91060. */
  91061. size: number;
  91062. /**
  91063. * The current scale of the particle.
  91064. */
  91065. scale: Vector2;
  91066. /**
  91067. * The current angle of the particle.
  91068. */
  91069. angle: number;
  91070. /**
  91071. * Defines how fast is the angle changing.
  91072. */
  91073. angularSpeed: number;
  91074. /**
  91075. * Defines the cell index used by the particle to be rendered from a sprite.
  91076. */
  91077. cellIndex: number;
  91078. /**
  91079. * The information required to support color remapping
  91080. */
  91081. remapData: Vector4;
  91082. /** @hidden */
  91083. _randomCellOffset?: number;
  91084. /** @hidden */
  91085. _initialDirection: Nullable<Vector3>;
  91086. /** @hidden */
  91087. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91088. /** @hidden */
  91089. _initialStartSpriteCellID: number;
  91090. /** @hidden */
  91091. _initialEndSpriteCellID: number;
  91092. /** @hidden */
  91093. _currentColorGradient: Nullable<ColorGradient>;
  91094. /** @hidden */
  91095. _currentColor1: Color4;
  91096. /** @hidden */
  91097. _currentColor2: Color4;
  91098. /** @hidden */
  91099. _currentSizeGradient: Nullable<FactorGradient>;
  91100. /** @hidden */
  91101. _currentSize1: number;
  91102. /** @hidden */
  91103. _currentSize2: number;
  91104. /** @hidden */
  91105. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91106. /** @hidden */
  91107. _currentAngularSpeed1: number;
  91108. /** @hidden */
  91109. _currentAngularSpeed2: number;
  91110. /** @hidden */
  91111. _currentVelocityGradient: Nullable<FactorGradient>;
  91112. /** @hidden */
  91113. _currentVelocity1: number;
  91114. /** @hidden */
  91115. _currentVelocity2: number;
  91116. /** @hidden */
  91117. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91118. /** @hidden */
  91119. _currentLimitVelocity1: number;
  91120. /** @hidden */
  91121. _currentLimitVelocity2: number;
  91122. /** @hidden */
  91123. _currentDragGradient: Nullable<FactorGradient>;
  91124. /** @hidden */
  91125. _currentDrag1: number;
  91126. /** @hidden */
  91127. _currentDrag2: number;
  91128. /** @hidden */
  91129. _randomNoiseCoordinates1: Vector3;
  91130. /** @hidden */
  91131. _randomNoiseCoordinates2: Vector3;
  91132. /**
  91133. * Creates a new instance Particle
  91134. * @param particleSystem the particle system the particle belongs to
  91135. */
  91136. constructor(
  91137. /**
  91138. * The particle system the particle belongs to.
  91139. */
  91140. particleSystem: ParticleSystem);
  91141. private updateCellInfoFromSystem;
  91142. /**
  91143. * Defines how the sprite cell index is updated for the particle
  91144. */
  91145. updateCellIndex(): void;
  91146. /** @hidden */
  91147. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91148. /** @hidden */
  91149. _inheritParticleInfoToSubEmitters(): void;
  91150. /** @hidden */
  91151. _reset(): void;
  91152. /**
  91153. * Copy the properties of particle to another one.
  91154. * @param other the particle to copy the information to.
  91155. */
  91156. copyTo(other: Particle): void;
  91157. }
  91158. }
  91159. declare module BABYLON {
  91160. /**
  91161. * Particle emitter represents a volume emitting particles.
  91162. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91163. */
  91164. export interface IParticleEmitterType {
  91165. /**
  91166. * Called by the particle System when the direction is computed for the created particle.
  91167. * @param worldMatrix is the world matrix of the particle system
  91168. * @param directionToUpdate is the direction vector to update with the result
  91169. * @param particle is the particle we are computed the direction for
  91170. */
  91171. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91172. /**
  91173. * Called by the particle System when the position is computed for the created particle.
  91174. * @param worldMatrix is the world matrix of the particle system
  91175. * @param positionToUpdate is the position vector to update with the result
  91176. * @param particle is the particle we are computed the position for
  91177. */
  91178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91179. /**
  91180. * Clones the current emitter and returns a copy of it
  91181. * @returns the new emitter
  91182. */
  91183. clone(): IParticleEmitterType;
  91184. /**
  91185. * Called by the GPUParticleSystem to setup the update shader
  91186. * @param effect defines the update shader
  91187. */
  91188. applyToShader(effect: Effect): void;
  91189. /**
  91190. * Returns a string to use to update the GPU particles update shader
  91191. * @returns the effect defines string
  91192. */
  91193. getEffectDefines(): string;
  91194. /**
  91195. * Returns a string representing the class name
  91196. * @returns a string containing the class name
  91197. */
  91198. getClassName(): string;
  91199. /**
  91200. * Serializes the particle system to a JSON object.
  91201. * @returns the JSON object
  91202. */
  91203. serialize(): any;
  91204. /**
  91205. * Parse properties from a JSON object
  91206. * @param serializationObject defines the JSON object
  91207. * @param scene defines the hosting scene
  91208. */
  91209. parse(serializationObject: any, scene: Scene): void;
  91210. }
  91211. }
  91212. declare module BABYLON {
  91213. /**
  91214. * Particle emitter emitting particles from the inside of a box.
  91215. * It emits the particles randomly between 2 given directions.
  91216. */
  91217. export class BoxParticleEmitter implements IParticleEmitterType {
  91218. /**
  91219. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91220. */
  91221. direction1: Vector3;
  91222. /**
  91223. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91224. */
  91225. direction2: Vector3;
  91226. /**
  91227. * 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.
  91228. */
  91229. minEmitBox: Vector3;
  91230. /**
  91231. * 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.
  91232. */
  91233. maxEmitBox: Vector3;
  91234. /**
  91235. * Creates a new instance BoxParticleEmitter
  91236. */
  91237. constructor();
  91238. /**
  91239. * Called by the particle System when the direction is computed for the created particle.
  91240. * @param worldMatrix is the world matrix of the particle system
  91241. * @param directionToUpdate is the direction vector to update with the result
  91242. * @param particle is the particle we are computed the direction for
  91243. */
  91244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91245. /**
  91246. * Called by the particle System when the position is computed for the created particle.
  91247. * @param worldMatrix is the world matrix of the particle system
  91248. * @param positionToUpdate is the position vector to update with the result
  91249. * @param particle is the particle we are computed the position for
  91250. */
  91251. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91252. /**
  91253. * Clones the current emitter and returns a copy of it
  91254. * @returns the new emitter
  91255. */
  91256. clone(): BoxParticleEmitter;
  91257. /**
  91258. * Called by the GPUParticleSystem to setup the update shader
  91259. * @param effect defines the update shader
  91260. */
  91261. applyToShader(effect: Effect): void;
  91262. /**
  91263. * Returns a string to use to update the GPU particles update shader
  91264. * @returns a string containng the defines string
  91265. */
  91266. getEffectDefines(): string;
  91267. /**
  91268. * Returns the string "BoxParticleEmitter"
  91269. * @returns a string containing the class name
  91270. */
  91271. getClassName(): string;
  91272. /**
  91273. * Serializes the particle system to a JSON object.
  91274. * @returns the JSON object
  91275. */
  91276. serialize(): any;
  91277. /**
  91278. * Parse properties from a JSON object
  91279. * @param serializationObject defines the JSON object
  91280. */
  91281. parse(serializationObject: any): void;
  91282. }
  91283. }
  91284. declare module BABYLON {
  91285. /**
  91286. * Particle emitter emitting particles from the inside of a cone.
  91287. * It emits the particles alongside the cone volume from the base to the particle.
  91288. * The emission direction might be randomized.
  91289. */
  91290. export class ConeParticleEmitter implements IParticleEmitterType {
  91291. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91292. directionRandomizer: number;
  91293. private _radius;
  91294. private _angle;
  91295. private _height;
  91296. /**
  91297. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91298. */
  91299. radiusRange: number;
  91300. /**
  91301. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91302. */
  91303. heightRange: number;
  91304. /**
  91305. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91306. */
  91307. emitFromSpawnPointOnly: boolean;
  91308. /**
  91309. * Gets or sets the radius of the emission cone
  91310. */
  91311. get radius(): number;
  91312. set radius(value: number);
  91313. /**
  91314. * Gets or sets the angle of the emission cone
  91315. */
  91316. get angle(): number;
  91317. set angle(value: number);
  91318. private _buildHeight;
  91319. /**
  91320. * Creates a new instance ConeParticleEmitter
  91321. * @param radius the radius of the emission cone (1 by default)
  91322. * @param angle the cone base angle (PI by default)
  91323. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91324. */
  91325. constructor(radius?: number, angle?: number,
  91326. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91327. directionRandomizer?: number);
  91328. /**
  91329. * Called by the particle System when the direction is computed for the created particle.
  91330. * @param worldMatrix is the world matrix of the particle system
  91331. * @param directionToUpdate is the direction vector to update with the result
  91332. * @param particle is the particle we are computed the direction for
  91333. */
  91334. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91335. /**
  91336. * Called by the particle System when the position is computed for the created particle.
  91337. * @param worldMatrix is the world matrix of the particle system
  91338. * @param positionToUpdate is the position vector to update with the result
  91339. * @param particle is the particle we are computed the position for
  91340. */
  91341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91342. /**
  91343. * Clones the current emitter and returns a copy of it
  91344. * @returns the new emitter
  91345. */
  91346. clone(): ConeParticleEmitter;
  91347. /**
  91348. * Called by the GPUParticleSystem to setup the update shader
  91349. * @param effect defines the update shader
  91350. */
  91351. applyToShader(effect: Effect): void;
  91352. /**
  91353. * Returns a string to use to update the GPU particles update shader
  91354. * @returns a string containng the defines string
  91355. */
  91356. getEffectDefines(): string;
  91357. /**
  91358. * Returns the string "ConeParticleEmitter"
  91359. * @returns a string containing the class name
  91360. */
  91361. getClassName(): string;
  91362. /**
  91363. * Serializes the particle system to a JSON object.
  91364. * @returns the JSON object
  91365. */
  91366. serialize(): any;
  91367. /**
  91368. * Parse properties from a JSON object
  91369. * @param serializationObject defines the JSON object
  91370. */
  91371. parse(serializationObject: any): void;
  91372. }
  91373. }
  91374. declare module BABYLON {
  91375. /**
  91376. * Particle emitter emitting particles from the inside of a cylinder.
  91377. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91378. */
  91379. export class CylinderParticleEmitter implements IParticleEmitterType {
  91380. /**
  91381. * The radius of the emission cylinder.
  91382. */
  91383. radius: number;
  91384. /**
  91385. * The height of the emission cylinder.
  91386. */
  91387. height: number;
  91388. /**
  91389. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91390. */
  91391. radiusRange: number;
  91392. /**
  91393. * How much to randomize the particle direction [0-1].
  91394. */
  91395. directionRandomizer: number;
  91396. /**
  91397. * Creates a new instance CylinderParticleEmitter
  91398. * @param radius the radius of the emission cylinder (1 by default)
  91399. * @param height the height of the emission cylinder (1 by default)
  91400. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91401. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91402. */
  91403. constructor(
  91404. /**
  91405. * The radius of the emission cylinder.
  91406. */
  91407. radius?: number,
  91408. /**
  91409. * The height of the emission cylinder.
  91410. */
  91411. height?: number,
  91412. /**
  91413. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91414. */
  91415. radiusRange?: number,
  91416. /**
  91417. * How much to randomize the particle direction [0-1].
  91418. */
  91419. directionRandomizer?: number);
  91420. /**
  91421. * Called by the particle System when the direction is computed for the created particle.
  91422. * @param worldMatrix is the world matrix of the particle system
  91423. * @param directionToUpdate is the direction vector to update with the result
  91424. * @param particle is the particle we are computed the direction for
  91425. */
  91426. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91427. /**
  91428. * Called by the particle System when the position is computed for the created particle.
  91429. * @param worldMatrix is the world matrix of the particle system
  91430. * @param positionToUpdate is the position vector to update with the result
  91431. * @param particle is the particle we are computed the position for
  91432. */
  91433. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91434. /**
  91435. * Clones the current emitter and returns a copy of it
  91436. * @returns the new emitter
  91437. */
  91438. clone(): CylinderParticleEmitter;
  91439. /**
  91440. * Called by the GPUParticleSystem to setup the update shader
  91441. * @param effect defines the update shader
  91442. */
  91443. applyToShader(effect: Effect): void;
  91444. /**
  91445. * Returns a string to use to update the GPU particles update shader
  91446. * @returns a string containng the defines string
  91447. */
  91448. getEffectDefines(): string;
  91449. /**
  91450. * Returns the string "CylinderParticleEmitter"
  91451. * @returns a string containing the class name
  91452. */
  91453. getClassName(): string;
  91454. /**
  91455. * Serializes the particle system to a JSON object.
  91456. * @returns the JSON object
  91457. */
  91458. serialize(): any;
  91459. /**
  91460. * Parse properties from a JSON object
  91461. * @param serializationObject defines the JSON object
  91462. */
  91463. parse(serializationObject: any): void;
  91464. }
  91465. /**
  91466. * Particle emitter emitting particles from the inside of a cylinder.
  91467. * It emits the particles randomly between two vectors.
  91468. */
  91469. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91470. /**
  91471. * The min limit of the emission direction.
  91472. */
  91473. direction1: Vector3;
  91474. /**
  91475. * The max limit of the emission direction.
  91476. */
  91477. direction2: Vector3;
  91478. /**
  91479. * Creates a new instance CylinderDirectedParticleEmitter
  91480. * @param radius the radius of the emission cylinder (1 by default)
  91481. * @param height the height of the emission cylinder (1 by default)
  91482. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91483. * @param direction1 the min limit of the emission direction (up vector by default)
  91484. * @param direction2 the max limit of the emission direction (up vector by default)
  91485. */
  91486. constructor(radius?: number, height?: number, radiusRange?: number,
  91487. /**
  91488. * The min limit of the emission direction.
  91489. */
  91490. direction1?: Vector3,
  91491. /**
  91492. * The max limit of the emission direction.
  91493. */
  91494. direction2?: Vector3);
  91495. /**
  91496. * Called by the particle System when the direction is computed for the created particle.
  91497. * @param worldMatrix is the world matrix of the particle system
  91498. * @param directionToUpdate is the direction vector to update with the result
  91499. * @param particle is the particle we are computed the direction for
  91500. */
  91501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91502. /**
  91503. * Clones the current emitter and returns a copy of it
  91504. * @returns the new emitter
  91505. */
  91506. clone(): CylinderDirectedParticleEmitter;
  91507. /**
  91508. * Called by the GPUParticleSystem to setup the update shader
  91509. * @param effect defines the update shader
  91510. */
  91511. applyToShader(effect: Effect): void;
  91512. /**
  91513. * Returns a string to use to update the GPU particles update shader
  91514. * @returns a string containng the defines string
  91515. */
  91516. getEffectDefines(): string;
  91517. /**
  91518. * Returns the string "CylinderDirectedParticleEmitter"
  91519. * @returns a string containing the class name
  91520. */
  91521. getClassName(): string;
  91522. /**
  91523. * Serializes the particle system to a JSON object.
  91524. * @returns the JSON object
  91525. */
  91526. serialize(): any;
  91527. /**
  91528. * Parse properties from a JSON object
  91529. * @param serializationObject defines the JSON object
  91530. */
  91531. parse(serializationObject: any): void;
  91532. }
  91533. }
  91534. declare module BABYLON {
  91535. /**
  91536. * Particle emitter emitting particles from the inside of a hemisphere.
  91537. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91538. */
  91539. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91540. /**
  91541. * The radius of the emission hemisphere.
  91542. */
  91543. radius: number;
  91544. /**
  91545. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91546. */
  91547. radiusRange: number;
  91548. /**
  91549. * How much to randomize the particle direction [0-1].
  91550. */
  91551. directionRandomizer: number;
  91552. /**
  91553. * Creates a new instance HemisphericParticleEmitter
  91554. * @param radius the radius of the emission hemisphere (1 by default)
  91555. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91556. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91557. */
  91558. constructor(
  91559. /**
  91560. * The radius of the emission hemisphere.
  91561. */
  91562. radius?: number,
  91563. /**
  91564. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91565. */
  91566. radiusRange?: number,
  91567. /**
  91568. * How much to randomize the particle direction [0-1].
  91569. */
  91570. directionRandomizer?: number);
  91571. /**
  91572. * Called by the particle System when the direction is computed for the created particle.
  91573. * @param worldMatrix is the world matrix of the particle system
  91574. * @param directionToUpdate is the direction vector to update with the result
  91575. * @param particle is the particle we are computed the direction for
  91576. */
  91577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91578. /**
  91579. * Called by the particle System when the position is computed for the created particle.
  91580. * @param worldMatrix is the world matrix of the particle system
  91581. * @param positionToUpdate is the position vector to update with the result
  91582. * @param particle is the particle we are computed the position for
  91583. */
  91584. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91585. /**
  91586. * Clones the current emitter and returns a copy of it
  91587. * @returns the new emitter
  91588. */
  91589. clone(): HemisphericParticleEmitter;
  91590. /**
  91591. * Called by the GPUParticleSystem to setup the update shader
  91592. * @param effect defines the update shader
  91593. */
  91594. applyToShader(effect: Effect): void;
  91595. /**
  91596. * Returns a string to use to update the GPU particles update shader
  91597. * @returns a string containng the defines string
  91598. */
  91599. getEffectDefines(): string;
  91600. /**
  91601. * Returns the string "HemisphericParticleEmitter"
  91602. * @returns a string containing the class name
  91603. */
  91604. getClassName(): string;
  91605. /**
  91606. * Serializes the particle system to a JSON object.
  91607. * @returns the JSON object
  91608. */
  91609. serialize(): any;
  91610. /**
  91611. * Parse properties from a JSON object
  91612. * @param serializationObject defines the JSON object
  91613. */
  91614. parse(serializationObject: any): void;
  91615. }
  91616. }
  91617. declare module BABYLON {
  91618. /**
  91619. * Particle emitter emitting particles from a point.
  91620. * It emits the particles randomly between 2 given directions.
  91621. */
  91622. export class PointParticleEmitter implements IParticleEmitterType {
  91623. /**
  91624. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91625. */
  91626. direction1: Vector3;
  91627. /**
  91628. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91629. */
  91630. direction2: Vector3;
  91631. /**
  91632. * Creates a new instance PointParticleEmitter
  91633. */
  91634. constructor();
  91635. /**
  91636. * Called by the particle System when the direction is computed for the created particle.
  91637. * @param worldMatrix is the world matrix of the particle system
  91638. * @param directionToUpdate is the direction vector to update with the result
  91639. * @param particle is the particle we are computed the direction for
  91640. */
  91641. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91642. /**
  91643. * Called by the particle System when the position is computed for the created particle.
  91644. * @param worldMatrix is the world matrix of the particle system
  91645. * @param positionToUpdate is the position vector to update with the result
  91646. * @param particle is the particle we are computed the position for
  91647. */
  91648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91649. /**
  91650. * Clones the current emitter and returns a copy of it
  91651. * @returns the new emitter
  91652. */
  91653. clone(): PointParticleEmitter;
  91654. /**
  91655. * Called by the GPUParticleSystem to setup the update shader
  91656. * @param effect defines the update shader
  91657. */
  91658. applyToShader(effect: Effect): void;
  91659. /**
  91660. * Returns a string to use to update the GPU particles update shader
  91661. * @returns a string containng the defines string
  91662. */
  91663. getEffectDefines(): string;
  91664. /**
  91665. * Returns the string "PointParticleEmitter"
  91666. * @returns a string containing the class name
  91667. */
  91668. getClassName(): string;
  91669. /**
  91670. * Serializes the particle system to a JSON object.
  91671. * @returns the JSON object
  91672. */
  91673. serialize(): any;
  91674. /**
  91675. * Parse properties from a JSON object
  91676. * @param serializationObject defines the JSON object
  91677. */
  91678. parse(serializationObject: any): void;
  91679. }
  91680. }
  91681. declare module BABYLON {
  91682. /**
  91683. * Particle emitter emitting particles from the inside of a sphere.
  91684. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91685. */
  91686. export class SphereParticleEmitter implements IParticleEmitterType {
  91687. /**
  91688. * The radius of the emission sphere.
  91689. */
  91690. radius: number;
  91691. /**
  91692. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91693. */
  91694. radiusRange: number;
  91695. /**
  91696. * How much to randomize the particle direction [0-1].
  91697. */
  91698. directionRandomizer: number;
  91699. /**
  91700. * Creates a new instance SphereParticleEmitter
  91701. * @param radius the radius of the emission sphere (1 by default)
  91702. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91703. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91704. */
  91705. constructor(
  91706. /**
  91707. * The radius of the emission sphere.
  91708. */
  91709. radius?: number,
  91710. /**
  91711. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91712. */
  91713. radiusRange?: number,
  91714. /**
  91715. * How much to randomize the particle direction [0-1].
  91716. */
  91717. directionRandomizer?: number);
  91718. /**
  91719. * Called by the particle System when the direction is computed for the created particle.
  91720. * @param worldMatrix is the world matrix of the particle system
  91721. * @param directionToUpdate is the direction vector to update with the result
  91722. * @param particle is the particle we are computed the direction for
  91723. */
  91724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91725. /**
  91726. * Called by the particle System when the position is computed for the created particle.
  91727. * @param worldMatrix is the world matrix of the particle system
  91728. * @param positionToUpdate is the position vector to update with the result
  91729. * @param particle is the particle we are computed the position for
  91730. */
  91731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91732. /**
  91733. * Clones the current emitter and returns a copy of it
  91734. * @returns the new emitter
  91735. */
  91736. clone(): SphereParticleEmitter;
  91737. /**
  91738. * Called by the GPUParticleSystem to setup the update shader
  91739. * @param effect defines the update shader
  91740. */
  91741. applyToShader(effect: Effect): void;
  91742. /**
  91743. * Returns a string to use to update the GPU particles update shader
  91744. * @returns a string containng the defines string
  91745. */
  91746. getEffectDefines(): string;
  91747. /**
  91748. * Returns the string "SphereParticleEmitter"
  91749. * @returns a string containing the class name
  91750. */
  91751. getClassName(): string;
  91752. /**
  91753. * Serializes the particle system to a JSON object.
  91754. * @returns the JSON object
  91755. */
  91756. serialize(): any;
  91757. /**
  91758. * Parse properties from a JSON object
  91759. * @param serializationObject defines the JSON object
  91760. */
  91761. parse(serializationObject: any): void;
  91762. }
  91763. /**
  91764. * Particle emitter emitting particles from the inside of a sphere.
  91765. * It emits the particles randomly between two vectors.
  91766. */
  91767. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91768. /**
  91769. * The min limit of the emission direction.
  91770. */
  91771. direction1: Vector3;
  91772. /**
  91773. * The max limit of the emission direction.
  91774. */
  91775. direction2: Vector3;
  91776. /**
  91777. * Creates a new instance SphereDirectedParticleEmitter
  91778. * @param radius the radius of the emission sphere (1 by default)
  91779. * @param direction1 the min limit of the emission direction (up vector by default)
  91780. * @param direction2 the max limit of the emission direction (up vector by default)
  91781. */
  91782. constructor(radius?: number,
  91783. /**
  91784. * The min limit of the emission direction.
  91785. */
  91786. direction1?: Vector3,
  91787. /**
  91788. * The max limit of the emission direction.
  91789. */
  91790. direction2?: Vector3);
  91791. /**
  91792. * Called by the particle System when the direction is computed for the created particle.
  91793. * @param worldMatrix is the world matrix of the particle system
  91794. * @param directionToUpdate is the direction vector to update with the result
  91795. * @param particle is the particle we are computed the direction for
  91796. */
  91797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91798. /**
  91799. * Clones the current emitter and returns a copy of it
  91800. * @returns the new emitter
  91801. */
  91802. clone(): SphereDirectedParticleEmitter;
  91803. /**
  91804. * Called by the GPUParticleSystem to setup the update shader
  91805. * @param effect defines the update shader
  91806. */
  91807. applyToShader(effect: Effect): void;
  91808. /**
  91809. * Returns a string to use to update the GPU particles update shader
  91810. * @returns a string containng the defines string
  91811. */
  91812. getEffectDefines(): string;
  91813. /**
  91814. * Returns the string "SphereDirectedParticleEmitter"
  91815. * @returns a string containing the class name
  91816. */
  91817. getClassName(): string;
  91818. /**
  91819. * Serializes the particle system to a JSON object.
  91820. * @returns the JSON object
  91821. */
  91822. serialize(): any;
  91823. /**
  91824. * Parse properties from a JSON object
  91825. * @param serializationObject defines the JSON object
  91826. */
  91827. parse(serializationObject: any): void;
  91828. }
  91829. }
  91830. declare module BABYLON {
  91831. /**
  91832. * Particle emitter emitting particles from a custom list of positions.
  91833. */
  91834. export class CustomParticleEmitter implements IParticleEmitterType {
  91835. /**
  91836. * Gets or sets the position generator that will create the inital position of each particle.
  91837. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91838. */
  91839. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91840. /**
  91841. * Gets or sets the destination generator that will create the final destination of each particle.
  91842. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91843. */
  91844. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91845. /**
  91846. * Creates a new instance CustomParticleEmitter
  91847. */
  91848. constructor();
  91849. /**
  91850. * Called by the particle System when the direction is computed for the created particle.
  91851. * @param worldMatrix is the world matrix of the particle system
  91852. * @param directionToUpdate is the direction vector to update with the result
  91853. * @param particle is the particle we are computed the direction for
  91854. */
  91855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91856. /**
  91857. * Called by the particle System when the position is computed for the created particle.
  91858. * @param worldMatrix is the world matrix of the particle system
  91859. * @param positionToUpdate is the position vector to update with the result
  91860. * @param particle is the particle we are computed the position for
  91861. */
  91862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91863. /**
  91864. * Clones the current emitter and returns a copy of it
  91865. * @returns the new emitter
  91866. */
  91867. clone(): CustomParticleEmitter;
  91868. /**
  91869. * Called by the GPUParticleSystem to setup the update shader
  91870. * @param effect defines the update shader
  91871. */
  91872. applyToShader(effect: Effect): void;
  91873. /**
  91874. * Returns a string to use to update the GPU particles update shader
  91875. * @returns a string containng the defines string
  91876. */
  91877. getEffectDefines(): string;
  91878. /**
  91879. * Returns the string "PointParticleEmitter"
  91880. * @returns a string containing the class name
  91881. */
  91882. getClassName(): string;
  91883. /**
  91884. * Serializes the particle system to a JSON object.
  91885. * @returns the JSON object
  91886. */
  91887. serialize(): any;
  91888. /**
  91889. * Parse properties from a JSON object
  91890. * @param serializationObject defines the JSON object
  91891. */
  91892. parse(serializationObject: any): void;
  91893. }
  91894. }
  91895. declare module BABYLON {
  91896. /**
  91897. * Particle emitter emitting particles from the inside of a box.
  91898. * It emits the particles randomly between 2 given directions.
  91899. */
  91900. export class MeshParticleEmitter implements IParticleEmitterType {
  91901. /** Defines the mesh to use as source */
  91902. mesh?: AbstractMesh | undefined;
  91903. private _indices;
  91904. private _positions;
  91905. private _normals;
  91906. private _storedNormal;
  91907. /**
  91908. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91909. */
  91910. direction1: Vector3;
  91911. /**
  91912. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91913. */
  91914. direction2: Vector3;
  91915. /**
  91916. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91917. */
  91918. useMeshNormalsForDirection: boolean;
  91919. /**
  91920. * Creates a new instance MeshParticleEmitter
  91921. * @param mesh defines the mesh to use as source
  91922. */
  91923. constructor(
  91924. /** Defines the mesh to use as source */
  91925. mesh?: AbstractMesh | undefined);
  91926. /**
  91927. * Called by the particle System when the direction is computed for the created particle.
  91928. * @param worldMatrix is the world matrix of the particle system
  91929. * @param directionToUpdate is the direction vector to update with the result
  91930. * @param particle is the particle we are computed the direction for
  91931. */
  91932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91933. /**
  91934. * Called by the particle System when the position is computed for the created particle.
  91935. * @param worldMatrix is the world matrix of the particle system
  91936. * @param positionToUpdate is the position vector to update with the result
  91937. * @param particle is the particle we are computed the position for
  91938. */
  91939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91940. /**
  91941. * Clones the current emitter and returns a copy of it
  91942. * @returns the new emitter
  91943. */
  91944. clone(): MeshParticleEmitter;
  91945. /**
  91946. * Called by the GPUParticleSystem to setup the update shader
  91947. * @param effect defines the update shader
  91948. */
  91949. applyToShader(effect: Effect): void;
  91950. /**
  91951. * Returns a string to use to update the GPU particles update shader
  91952. * @returns a string containng the defines string
  91953. */
  91954. getEffectDefines(): string;
  91955. /**
  91956. * Returns the string "BoxParticleEmitter"
  91957. * @returns a string containing the class name
  91958. */
  91959. getClassName(): string;
  91960. /**
  91961. * Serializes the particle system to a JSON object.
  91962. * @returns the JSON object
  91963. */
  91964. serialize(): any;
  91965. /**
  91966. * Parse properties from a JSON object
  91967. * @param serializationObject defines the JSON object
  91968. * @param scene defines the hosting scene
  91969. */
  91970. parse(serializationObject: any, scene: Scene): void;
  91971. }
  91972. }
  91973. declare module BABYLON {
  91974. /**
  91975. * Interface representing a particle system in Babylon.js.
  91976. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91977. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91978. */
  91979. export interface IParticleSystem {
  91980. /**
  91981. * List of animations used by the particle system.
  91982. */
  91983. animations: Animation[];
  91984. /**
  91985. * The id of the Particle system.
  91986. */
  91987. id: string;
  91988. /**
  91989. * The name of the Particle system.
  91990. */
  91991. name: string;
  91992. /**
  91993. * The emitter represents the Mesh or position we are attaching the particle system to.
  91994. */
  91995. emitter: Nullable<AbstractMesh | Vector3>;
  91996. /**
  91997. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91998. */
  91999. isBillboardBased: boolean;
  92000. /**
  92001. * The rendering group used by the Particle system to chose when to render.
  92002. */
  92003. renderingGroupId: number;
  92004. /**
  92005. * The layer mask we are rendering the particles through.
  92006. */
  92007. layerMask: number;
  92008. /**
  92009. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92010. */
  92011. updateSpeed: number;
  92012. /**
  92013. * The amount of time the particle system is running (depends of the overall update speed).
  92014. */
  92015. targetStopDuration: number;
  92016. /**
  92017. * The texture used to render each particle. (this can be a spritesheet)
  92018. */
  92019. particleTexture: Nullable<Texture>;
  92020. /**
  92021. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92022. */
  92023. blendMode: number;
  92024. /**
  92025. * Minimum life time of emitting particles.
  92026. */
  92027. minLifeTime: number;
  92028. /**
  92029. * Maximum life time of emitting particles.
  92030. */
  92031. maxLifeTime: number;
  92032. /**
  92033. * Minimum Size of emitting particles.
  92034. */
  92035. minSize: number;
  92036. /**
  92037. * Maximum Size of emitting particles.
  92038. */
  92039. maxSize: number;
  92040. /**
  92041. * Minimum scale of emitting particles on X axis.
  92042. */
  92043. minScaleX: number;
  92044. /**
  92045. * Maximum scale of emitting particles on X axis.
  92046. */
  92047. maxScaleX: number;
  92048. /**
  92049. * Minimum scale of emitting particles on Y axis.
  92050. */
  92051. minScaleY: number;
  92052. /**
  92053. * Maximum scale of emitting particles on Y axis.
  92054. */
  92055. maxScaleY: number;
  92056. /**
  92057. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92058. */
  92059. color1: Color4;
  92060. /**
  92061. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92062. */
  92063. color2: Color4;
  92064. /**
  92065. * Color the particle will have at the end of its lifetime.
  92066. */
  92067. colorDead: Color4;
  92068. /**
  92069. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92070. */
  92071. emitRate: number;
  92072. /**
  92073. * You can use gravity if you want to give an orientation to your particles.
  92074. */
  92075. gravity: Vector3;
  92076. /**
  92077. * Minimum power of emitting particles.
  92078. */
  92079. minEmitPower: number;
  92080. /**
  92081. * Maximum power of emitting particles.
  92082. */
  92083. maxEmitPower: number;
  92084. /**
  92085. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92086. */
  92087. minAngularSpeed: number;
  92088. /**
  92089. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92090. */
  92091. maxAngularSpeed: number;
  92092. /**
  92093. * Gets or sets the minimal initial rotation in radians.
  92094. */
  92095. minInitialRotation: number;
  92096. /**
  92097. * Gets or sets the maximal initial rotation in radians.
  92098. */
  92099. maxInitialRotation: number;
  92100. /**
  92101. * The particle emitter type defines the emitter used by the particle system.
  92102. * It can be for example box, sphere, or cone...
  92103. */
  92104. particleEmitterType: Nullable<IParticleEmitterType>;
  92105. /**
  92106. * Defines the delay in milliseconds before starting the system (0 by default)
  92107. */
  92108. startDelay: number;
  92109. /**
  92110. * 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
  92111. */
  92112. preWarmCycles: number;
  92113. /**
  92114. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92115. */
  92116. preWarmStepOffset: number;
  92117. /**
  92118. * 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)
  92119. */
  92120. spriteCellChangeSpeed: number;
  92121. /**
  92122. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92123. */
  92124. startSpriteCellID: number;
  92125. /**
  92126. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92127. */
  92128. endSpriteCellID: number;
  92129. /**
  92130. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92131. */
  92132. spriteCellWidth: number;
  92133. /**
  92134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92135. */
  92136. spriteCellHeight: number;
  92137. /**
  92138. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92139. */
  92140. spriteRandomStartCell: boolean;
  92141. /**
  92142. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92143. */
  92144. isAnimationSheetEnabled: boolean;
  92145. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92146. translationPivot: Vector2;
  92147. /**
  92148. * Gets or sets a texture used to add random noise to particle positions
  92149. */
  92150. noiseTexture: Nullable<BaseTexture>;
  92151. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92152. noiseStrength: Vector3;
  92153. /**
  92154. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92155. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92156. */
  92157. billboardMode: number;
  92158. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92159. limitVelocityDamping: number;
  92160. /**
  92161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92162. */
  92163. beginAnimationOnStart: boolean;
  92164. /**
  92165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92166. */
  92167. beginAnimationFrom: number;
  92168. /**
  92169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92170. */
  92171. beginAnimationTo: number;
  92172. /**
  92173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92174. */
  92175. beginAnimationLoop: boolean;
  92176. /**
  92177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92178. */
  92179. disposeOnStop: boolean;
  92180. /**
  92181. * Gets the maximum number of particles active at the same time.
  92182. * @returns The max number of active particles.
  92183. */
  92184. getCapacity(): number;
  92185. /**
  92186. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92187. * @returns True if it has been started, otherwise false.
  92188. */
  92189. isStarted(): boolean;
  92190. /**
  92191. * Animates the particle system for this frame.
  92192. */
  92193. animate(): void;
  92194. /**
  92195. * Renders the particle system in its current state.
  92196. * @returns the current number of particles
  92197. */
  92198. render(): number;
  92199. /**
  92200. * Dispose the particle system and frees its associated resources.
  92201. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92202. */
  92203. dispose(disposeTexture?: boolean): void;
  92204. /**
  92205. * Clones the particle system.
  92206. * @param name The name of the cloned object
  92207. * @param newEmitter The new emitter to use
  92208. * @returns the cloned particle system
  92209. */
  92210. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92211. /**
  92212. * Serializes the particle system to a JSON object.
  92213. * @returns the JSON object
  92214. */
  92215. serialize(): any;
  92216. /**
  92217. * Rebuild the particle system
  92218. */
  92219. rebuild(): void;
  92220. /**
  92221. * Starts the particle system and begins to emit
  92222. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92223. */
  92224. start(delay?: number): void;
  92225. /**
  92226. * Stops the particle system.
  92227. */
  92228. stop(): void;
  92229. /**
  92230. * Remove all active particles
  92231. */
  92232. reset(): void;
  92233. /**
  92234. * Is this system ready to be used/rendered
  92235. * @return true if the system is ready
  92236. */
  92237. isReady(): boolean;
  92238. /**
  92239. * Adds a new color gradient
  92240. * @param gradient defines the gradient to use (between 0 and 1)
  92241. * @param color1 defines the color to affect to the specified gradient
  92242. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92243. * @returns the current particle system
  92244. */
  92245. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92246. /**
  92247. * Remove a specific color gradient
  92248. * @param gradient defines the gradient to remove
  92249. * @returns the current particle system
  92250. */
  92251. removeColorGradient(gradient: number): IParticleSystem;
  92252. /**
  92253. * Adds a new size gradient
  92254. * @param gradient defines the gradient to use (between 0 and 1)
  92255. * @param factor defines the size factor to affect to the specified gradient
  92256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92257. * @returns the current particle system
  92258. */
  92259. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92260. /**
  92261. * Remove a specific size gradient
  92262. * @param gradient defines the gradient to remove
  92263. * @returns the current particle system
  92264. */
  92265. removeSizeGradient(gradient: number): IParticleSystem;
  92266. /**
  92267. * Gets the current list of color gradients.
  92268. * You must use addColorGradient and removeColorGradient to udpate this list
  92269. * @returns the list of color gradients
  92270. */
  92271. getColorGradients(): Nullable<Array<ColorGradient>>;
  92272. /**
  92273. * Gets the current list of size gradients.
  92274. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92275. * @returns the list of size gradients
  92276. */
  92277. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92278. /**
  92279. * Gets the current list of angular speed gradients.
  92280. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92281. * @returns the list of angular speed gradients
  92282. */
  92283. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92284. /**
  92285. * Adds a new angular speed gradient
  92286. * @param gradient defines the gradient to use (between 0 and 1)
  92287. * @param factor defines the angular speed to affect to the specified gradient
  92288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92289. * @returns the current particle system
  92290. */
  92291. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92292. /**
  92293. * Remove a specific angular speed gradient
  92294. * @param gradient defines the gradient to remove
  92295. * @returns the current particle system
  92296. */
  92297. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92298. /**
  92299. * Gets the current list of velocity gradients.
  92300. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92301. * @returns the list of velocity gradients
  92302. */
  92303. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92304. /**
  92305. * Adds a new velocity gradient
  92306. * @param gradient defines the gradient to use (between 0 and 1)
  92307. * @param factor defines the velocity to affect to the specified gradient
  92308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92309. * @returns the current particle system
  92310. */
  92311. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92312. /**
  92313. * Remove a specific velocity gradient
  92314. * @param gradient defines the gradient to remove
  92315. * @returns the current particle system
  92316. */
  92317. removeVelocityGradient(gradient: number): IParticleSystem;
  92318. /**
  92319. * Gets the current list of limit velocity gradients.
  92320. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92321. * @returns the list of limit velocity gradients
  92322. */
  92323. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92324. /**
  92325. * Adds a new limit velocity gradient
  92326. * @param gradient defines the gradient to use (between 0 and 1)
  92327. * @param factor defines the limit velocity to affect to the specified gradient
  92328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92329. * @returns the current particle system
  92330. */
  92331. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92332. /**
  92333. * Remove a specific limit velocity gradient
  92334. * @param gradient defines the gradient to remove
  92335. * @returns the current particle system
  92336. */
  92337. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92338. /**
  92339. * Adds a new drag gradient
  92340. * @param gradient defines the gradient to use (between 0 and 1)
  92341. * @param factor defines the drag to affect to the specified gradient
  92342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92343. * @returns the current particle system
  92344. */
  92345. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92346. /**
  92347. * Remove a specific drag gradient
  92348. * @param gradient defines the gradient to remove
  92349. * @returns the current particle system
  92350. */
  92351. removeDragGradient(gradient: number): IParticleSystem;
  92352. /**
  92353. * Gets the current list of drag gradients.
  92354. * You must use addDragGradient and removeDragGradient to udpate this list
  92355. * @returns the list of drag gradients
  92356. */
  92357. getDragGradients(): Nullable<Array<FactorGradient>>;
  92358. /**
  92359. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92360. * @param gradient defines the gradient to use (between 0 and 1)
  92361. * @param factor defines the emit rate to affect to the specified gradient
  92362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92363. * @returns the current particle system
  92364. */
  92365. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92366. /**
  92367. * Remove a specific emit rate gradient
  92368. * @param gradient defines the gradient to remove
  92369. * @returns the current particle system
  92370. */
  92371. removeEmitRateGradient(gradient: number): IParticleSystem;
  92372. /**
  92373. * Gets the current list of emit rate gradients.
  92374. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92375. * @returns the list of emit rate gradients
  92376. */
  92377. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92378. /**
  92379. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92380. * @param gradient defines the gradient to use (between 0 and 1)
  92381. * @param factor defines the start size to affect to the specified gradient
  92382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92383. * @returns the current particle system
  92384. */
  92385. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92386. /**
  92387. * Remove a specific start size gradient
  92388. * @param gradient defines the gradient to remove
  92389. * @returns the current particle system
  92390. */
  92391. removeStartSizeGradient(gradient: number): IParticleSystem;
  92392. /**
  92393. * Gets the current list of start size gradients.
  92394. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92395. * @returns the list of start size gradients
  92396. */
  92397. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92398. /**
  92399. * Adds a new life time gradient
  92400. * @param gradient defines the gradient to use (between 0 and 1)
  92401. * @param factor defines the life time factor to affect to the specified gradient
  92402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92403. * @returns the current particle system
  92404. */
  92405. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92406. /**
  92407. * Remove a specific life time gradient
  92408. * @param gradient defines the gradient to remove
  92409. * @returns the current particle system
  92410. */
  92411. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92412. /**
  92413. * Gets the current list of life time gradients.
  92414. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92415. * @returns the list of life time gradients
  92416. */
  92417. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92418. /**
  92419. * Gets the current list of color gradients.
  92420. * You must use addColorGradient and removeColorGradient to udpate this list
  92421. * @returns the list of color gradients
  92422. */
  92423. getColorGradients(): Nullable<Array<ColorGradient>>;
  92424. /**
  92425. * Adds a new ramp gradient used to remap particle colors
  92426. * @param gradient defines the gradient to use (between 0 and 1)
  92427. * @param color defines the color to affect to the specified gradient
  92428. * @returns the current particle system
  92429. */
  92430. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92431. /**
  92432. * Gets the current list of ramp gradients.
  92433. * You must use addRampGradient and removeRampGradient to udpate this list
  92434. * @returns the list of ramp gradients
  92435. */
  92436. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92437. /** Gets or sets a boolean indicating that ramp gradients must be used
  92438. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92439. */
  92440. useRampGradients: boolean;
  92441. /**
  92442. * Adds a new color remap gradient
  92443. * @param gradient defines the gradient to use (between 0 and 1)
  92444. * @param min defines the color remap minimal range
  92445. * @param max defines the color remap maximal range
  92446. * @returns the current particle system
  92447. */
  92448. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92449. /**
  92450. * Gets the current list of color remap gradients.
  92451. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92452. * @returns the list of color remap gradients
  92453. */
  92454. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92455. /**
  92456. * Adds a new alpha remap gradient
  92457. * @param gradient defines the gradient to use (between 0 and 1)
  92458. * @param min defines the alpha remap minimal range
  92459. * @param max defines the alpha remap maximal range
  92460. * @returns the current particle system
  92461. */
  92462. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92463. /**
  92464. * Gets the current list of alpha remap gradients.
  92465. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92466. * @returns the list of alpha remap gradients
  92467. */
  92468. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92469. /**
  92470. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92473. * @returns the emitter
  92474. */
  92475. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92476. /**
  92477. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92478. * @param radius The radius of the hemisphere to emit from
  92479. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92480. * @returns the emitter
  92481. */
  92482. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92483. /**
  92484. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92485. * @param radius The radius of the sphere to emit from
  92486. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92487. * @returns the emitter
  92488. */
  92489. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92490. /**
  92491. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92492. * @param radius The radius of the sphere to emit from
  92493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92495. * @returns the emitter
  92496. */
  92497. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92498. /**
  92499. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92500. * @param radius The radius of the emission cylinder
  92501. * @param height The height of the emission cylinder
  92502. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92503. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92504. * @returns the emitter
  92505. */
  92506. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92507. /**
  92508. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92509. * @param radius The radius of the cylinder to emit from
  92510. * @param height The height of the emission cylinder
  92511. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92512. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92513. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92514. * @returns the emitter
  92515. */
  92516. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92517. /**
  92518. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92519. * @param radius The radius of the cone to emit from
  92520. * @param angle The base angle of the cone
  92521. * @returns the emitter
  92522. */
  92523. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92524. /**
  92525. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92528. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92529. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92530. * @returns the emitter
  92531. */
  92532. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92533. /**
  92534. * Get hosting scene
  92535. * @returns the scene
  92536. */
  92537. getScene(): Scene;
  92538. }
  92539. }
  92540. declare module BABYLON {
  92541. /**
  92542. * Creates an instance based on a source mesh.
  92543. */
  92544. export class InstancedMesh extends AbstractMesh {
  92545. private _sourceMesh;
  92546. private _currentLOD;
  92547. /** @hidden */
  92548. _indexInSourceMeshInstanceArray: number;
  92549. constructor(name: string, source: Mesh);
  92550. /**
  92551. * Returns the string "InstancedMesh".
  92552. */
  92553. getClassName(): string;
  92554. /** Gets the list of lights affecting that mesh */
  92555. get lightSources(): Light[];
  92556. _resyncLightSources(): void;
  92557. _resyncLightSource(light: Light): void;
  92558. _removeLightSource(light: Light, dispose: boolean): void;
  92559. /**
  92560. * If the source mesh receives shadows
  92561. */
  92562. get receiveShadows(): boolean;
  92563. /**
  92564. * The material of the source mesh
  92565. */
  92566. get material(): Nullable<Material>;
  92567. /**
  92568. * Visibility of the source mesh
  92569. */
  92570. get visibility(): number;
  92571. /**
  92572. * Skeleton of the source mesh
  92573. */
  92574. get skeleton(): Nullable<Skeleton>;
  92575. /**
  92576. * Rendering ground id of the source mesh
  92577. */
  92578. get renderingGroupId(): number;
  92579. set renderingGroupId(value: number);
  92580. /**
  92581. * Returns the total number of vertices (integer).
  92582. */
  92583. getTotalVertices(): number;
  92584. /**
  92585. * Returns a positive integer : the total number of indices in this mesh geometry.
  92586. * @returns the numner of indices or zero if the mesh has no geometry.
  92587. */
  92588. getTotalIndices(): number;
  92589. /**
  92590. * The source mesh of the instance
  92591. */
  92592. get sourceMesh(): Mesh;
  92593. /**
  92594. * Is this node ready to be used/rendered
  92595. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92596. * @return {boolean} is it ready
  92597. */
  92598. isReady(completeCheck?: boolean): boolean;
  92599. /**
  92600. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92601. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  92602. * @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.
  92603. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  92604. */
  92605. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  92606. /**
  92607. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92608. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92609. * The `data` are either a numeric array either a Float32Array.
  92610. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  92611. * 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).
  92612. * Note that a new underlying VertexBuffer object is created each call.
  92613. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92614. *
  92615. * Possible `kind` values :
  92616. * - VertexBuffer.PositionKind
  92617. * - VertexBuffer.UVKind
  92618. * - VertexBuffer.UV2Kind
  92619. * - VertexBuffer.UV3Kind
  92620. * - VertexBuffer.UV4Kind
  92621. * - VertexBuffer.UV5Kind
  92622. * - VertexBuffer.UV6Kind
  92623. * - VertexBuffer.ColorKind
  92624. * - VertexBuffer.MatricesIndicesKind
  92625. * - VertexBuffer.MatricesIndicesExtraKind
  92626. * - VertexBuffer.MatricesWeightsKind
  92627. * - VertexBuffer.MatricesWeightsExtraKind
  92628. *
  92629. * Returns the Mesh.
  92630. */
  92631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92632. /**
  92633. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92634. * If the mesh has no geometry, it is simply returned as it is.
  92635. * The `data` are either a numeric array either a Float32Array.
  92636. * No new underlying VertexBuffer object is created.
  92637. * 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.
  92638. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  92639. *
  92640. * Possible `kind` values :
  92641. * - VertexBuffer.PositionKind
  92642. * - VertexBuffer.UVKind
  92643. * - VertexBuffer.UV2Kind
  92644. * - VertexBuffer.UV3Kind
  92645. * - VertexBuffer.UV4Kind
  92646. * - VertexBuffer.UV5Kind
  92647. * - VertexBuffer.UV6Kind
  92648. * - VertexBuffer.ColorKind
  92649. * - VertexBuffer.MatricesIndicesKind
  92650. * - VertexBuffer.MatricesIndicesExtraKind
  92651. * - VertexBuffer.MatricesWeightsKind
  92652. * - VertexBuffer.MatricesWeightsExtraKind
  92653. *
  92654. * Returns the Mesh.
  92655. */
  92656. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  92657. /**
  92658. * Sets the mesh indices.
  92659. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  92660. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92661. * This method creates a new index buffer each call.
  92662. * Returns the Mesh.
  92663. */
  92664. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  92665. /**
  92666. * Boolean : True if the mesh owns the requested kind of data.
  92667. */
  92668. isVerticesDataPresent(kind: string): boolean;
  92669. /**
  92670. * Returns an array of indices (IndicesArray).
  92671. */
  92672. getIndices(): Nullable<IndicesArray>;
  92673. get _positions(): Nullable<Vector3[]>;
  92674. /**
  92675. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92676. * This means the mesh underlying bounding box and sphere are recomputed.
  92677. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92678. * @returns the current mesh
  92679. */
  92680. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  92681. /** @hidden */
  92682. _preActivate(): InstancedMesh;
  92683. /** @hidden */
  92684. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92685. /** @hidden */
  92686. _postActivate(): void;
  92687. getWorldMatrix(): Matrix;
  92688. get isAnInstance(): boolean;
  92689. /**
  92690. * Returns the current associated LOD AbstractMesh.
  92691. */
  92692. getLOD(camera: Camera): AbstractMesh;
  92693. /** @hidden */
  92694. _syncSubMeshes(): InstancedMesh;
  92695. /** @hidden */
  92696. _generatePointsArray(): boolean;
  92697. /**
  92698. * Creates a new InstancedMesh from the current mesh.
  92699. * - name (string) : the cloned mesh name
  92700. * - newParent (optional Node) : the optional Node to parent the clone to.
  92701. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  92702. *
  92703. * Returns the clone.
  92704. */
  92705. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  92706. /**
  92707. * Disposes the InstancedMesh.
  92708. * Returns nothing.
  92709. */
  92710. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92711. }
  92712. interface Mesh {
  92713. /**
  92714. * Register a custom buffer that will be instanced
  92715. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92716. * @param kind defines the buffer kind
  92717. * @param stride defines the stride in floats
  92718. */
  92719. registerInstancedBuffer(kind: string, stride: number): void;
  92720. /** @hidden */
  92721. _userInstancedBuffersStorage: {
  92722. data: {
  92723. [key: string]: Float32Array;
  92724. };
  92725. sizes: {
  92726. [key: string]: number;
  92727. };
  92728. vertexBuffers: {
  92729. [key: string]: Nullable<VertexBuffer>;
  92730. };
  92731. strides: {
  92732. [key: string]: number;
  92733. };
  92734. };
  92735. }
  92736. interface AbstractMesh {
  92737. /**
  92738. * Object used to store instanced buffers defined by user
  92739. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92740. */
  92741. instancedBuffers: {
  92742. [key: string]: any;
  92743. };
  92744. }
  92745. }
  92746. declare module BABYLON {
  92747. /**
  92748. * Defines the options associated with the creation of a shader material.
  92749. */
  92750. export interface IShaderMaterialOptions {
  92751. /**
  92752. * Does the material work in alpha blend mode
  92753. */
  92754. needAlphaBlending: boolean;
  92755. /**
  92756. * Does the material work in alpha test mode
  92757. */
  92758. needAlphaTesting: boolean;
  92759. /**
  92760. * The list of attribute names used in the shader
  92761. */
  92762. attributes: string[];
  92763. /**
  92764. * The list of unifrom names used in the shader
  92765. */
  92766. uniforms: string[];
  92767. /**
  92768. * The list of UBO names used in the shader
  92769. */
  92770. uniformBuffers: string[];
  92771. /**
  92772. * The list of sampler names used in the shader
  92773. */
  92774. samplers: string[];
  92775. /**
  92776. * The list of defines used in the shader
  92777. */
  92778. defines: string[];
  92779. }
  92780. /**
  92781. * 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.
  92782. *
  92783. * This returned material effects how the mesh will look based on the code in the shaders.
  92784. *
  92785. * @see http://doc.babylonjs.com/how_to/shader_material
  92786. */
  92787. export class ShaderMaterial extends Material {
  92788. private _shaderPath;
  92789. private _options;
  92790. private _textures;
  92791. private _textureArrays;
  92792. private _floats;
  92793. private _ints;
  92794. private _floatsArrays;
  92795. private _colors3;
  92796. private _colors3Arrays;
  92797. private _colors4;
  92798. private _colors4Arrays;
  92799. private _vectors2;
  92800. private _vectors3;
  92801. private _vectors4;
  92802. private _matrices;
  92803. private _matrixArrays;
  92804. private _matrices3x3;
  92805. private _matrices2x2;
  92806. private _vectors2Arrays;
  92807. private _vectors3Arrays;
  92808. private _vectors4Arrays;
  92809. private _cachedWorldViewMatrix;
  92810. private _cachedWorldViewProjectionMatrix;
  92811. private _renderId;
  92812. private _multiview;
  92813. /**
  92814. * Instantiate a new shader material.
  92815. * 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.
  92816. * This returned material effects how the mesh will look based on the code in the shaders.
  92817. * @see http://doc.babylonjs.com/how_to/shader_material
  92818. * @param name Define the name of the material in the scene
  92819. * @param scene Define the scene the material belongs to
  92820. * @param shaderPath Defines the route to the shader code in one of three ways:
  92821. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  92822. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  92823. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  92824. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  92825. * @param options Define the options used to create the shader
  92826. */
  92827. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  92828. /**
  92829. * Gets the shader path used to define the shader code
  92830. * It can be modified to trigger a new compilation
  92831. */
  92832. get shaderPath(): any;
  92833. /**
  92834. * Sets the shader path used to define the shader code
  92835. * It can be modified to trigger a new compilation
  92836. */
  92837. set shaderPath(shaderPath: any);
  92838. /**
  92839. * Gets the options used to compile the shader.
  92840. * They can be modified to trigger a new compilation
  92841. */
  92842. get options(): IShaderMaterialOptions;
  92843. /**
  92844. * Gets the current class name of the material e.g. "ShaderMaterial"
  92845. * Mainly use in serialization.
  92846. * @returns the class name
  92847. */
  92848. getClassName(): string;
  92849. /**
  92850. * Specifies if the material will require alpha blending
  92851. * @returns a boolean specifying if alpha blending is needed
  92852. */
  92853. needAlphaBlending(): boolean;
  92854. /**
  92855. * Specifies if this material should be rendered in alpha test mode
  92856. * @returns a boolean specifying if an alpha test is needed.
  92857. */
  92858. needAlphaTesting(): boolean;
  92859. private _checkUniform;
  92860. /**
  92861. * Set a texture in the shader.
  92862. * @param name Define the name of the uniform samplers as defined in the shader
  92863. * @param texture Define the texture to bind to this sampler
  92864. * @return the material itself allowing "fluent" like uniform updates
  92865. */
  92866. setTexture(name: string, texture: Texture): ShaderMaterial;
  92867. /**
  92868. * Set a texture array in the shader.
  92869. * @param name Define the name of the uniform sampler array as defined in the shader
  92870. * @param textures Define the list of textures to bind to this sampler
  92871. * @return the material itself allowing "fluent" like uniform updates
  92872. */
  92873. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  92874. /**
  92875. * Set a float in the shader.
  92876. * @param name Define the name of the uniform as defined in the shader
  92877. * @param value Define the value to give to the uniform
  92878. * @return the material itself allowing "fluent" like uniform updates
  92879. */
  92880. setFloat(name: string, value: number): ShaderMaterial;
  92881. /**
  92882. * Set a int in the shader.
  92883. * @param name Define the name of the uniform as defined in the shader
  92884. * @param value Define the value to give to the uniform
  92885. * @return the material itself allowing "fluent" like uniform updates
  92886. */
  92887. setInt(name: string, value: number): ShaderMaterial;
  92888. /**
  92889. * Set an array of floats in the shader.
  92890. * @param name Define the name of the uniform as defined in the shader
  92891. * @param value Define the value to give to the uniform
  92892. * @return the material itself allowing "fluent" like uniform updates
  92893. */
  92894. setFloats(name: string, value: number[]): ShaderMaterial;
  92895. /**
  92896. * Set a vec3 in the shader from a Color3.
  92897. * @param name Define the name of the uniform as defined in the shader
  92898. * @param value Define the value to give to the uniform
  92899. * @return the material itself allowing "fluent" like uniform updates
  92900. */
  92901. setColor3(name: string, value: Color3): ShaderMaterial;
  92902. /**
  92903. * Set a vec3 array in the shader from a Color3 array.
  92904. * @param name Define the name of the uniform as defined in the shader
  92905. * @param value Define the value to give to the uniform
  92906. * @return the material itself allowing "fluent" like uniform updates
  92907. */
  92908. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  92909. /**
  92910. * Set a vec4 in the shader from a Color4.
  92911. * @param name Define the name of the uniform as defined in the shader
  92912. * @param value Define the value to give to the uniform
  92913. * @return the material itself allowing "fluent" like uniform updates
  92914. */
  92915. setColor4(name: string, value: Color4): ShaderMaterial;
  92916. /**
  92917. * Set a vec4 array in the shader from a Color4 array.
  92918. * @param name Define the name of the uniform as defined in the shader
  92919. * @param value Define the value to give to the uniform
  92920. * @return the material itself allowing "fluent" like uniform updates
  92921. */
  92922. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  92923. /**
  92924. * Set a vec2 in the shader from a Vector2.
  92925. * @param name Define the name of the uniform as defined in the shader
  92926. * @param value Define the value to give to the uniform
  92927. * @return the material itself allowing "fluent" like uniform updates
  92928. */
  92929. setVector2(name: string, value: Vector2): ShaderMaterial;
  92930. /**
  92931. * Set a vec3 in the shader from a Vector3.
  92932. * @param name Define the name of the uniform as defined in the shader
  92933. * @param value Define the value to give to the uniform
  92934. * @return the material itself allowing "fluent" like uniform updates
  92935. */
  92936. setVector3(name: string, value: Vector3): ShaderMaterial;
  92937. /**
  92938. * Set a vec4 in the shader from a Vector4.
  92939. * @param name Define the name of the uniform as defined in the shader
  92940. * @param value Define the value to give to the uniform
  92941. * @return the material itself allowing "fluent" like uniform updates
  92942. */
  92943. setVector4(name: string, value: Vector4): ShaderMaterial;
  92944. /**
  92945. * Set a mat4 in the shader from a Matrix.
  92946. * @param name Define the name of the uniform as defined in the shader
  92947. * @param value Define the value to give to the uniform
  92948. * @return the material itself allowing "fluent" like uniform updates
  92949. */
  92950. setMatrix(name: string, value: Matrix): ShaderMaterial;
  92951. /**
  92952. * Set a float32Array in the shader from a matrix array.
  92953. * @param name Define the name of the uniform as defined in the shader
  92954. * @param value Define the value to give to the uniform
  92955. * @return the material itself allowing "fluent" like uniform updates
  92956. */
  92957. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  92958. /**
  92959. * Set a mat3 in the shader from a Float32Array.
  92960. * @param name Define the name of the uniform as defined in the shader
  92961. * @param value Define the value to give to the uniform
  92962. * @return the material itself allowing "fluent" like uniform updates
  92963. */
  92964. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  92965. /**
  92966. * Set a mat2 in the shader from a Float32Array.
  92967. * @param name Define the name of the uniform as defined in the shader
  92968. * @param value Define the value to give to the uniform
  92969. * @return the material itself allowing "fluent" like uniform updates
  92970. */
  92971. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  92972. /**
  92973. * Set a vec2 array in the shader from a number array.
  92974. * @param name Define the name of the uniform as defined in the shader
  92975. * @param value Define the value to give to the uniform
  92976. * @return the material itself allowing "fluent" like uniform updates
  92977. */
  92978. setArray2(name: string, value: number[]): ShaderMaterial;
  92979. /**
  92980. * Set a vec3 array in the shader from a number array.
  92981. * @param name Define the name of the uniform as defined in the shader
  92982. * @param value Define the value to give to the uniform
  92983. * @return the material itself allowing "fluent" like uniform updates
  92984. */
  92985. setArray3(name: string, value: number[]): ShaderMaterial;
  92986. /**
  92987. * Set a vec4 array in the shader from a number array.
  92988. * @param name Define the name of the uniform as defined in the shader
  92989. * @param value Define the value to give to the uniform
  92990. * @return the material itself allowing "fluent" like uniform updates
  92991. */
  92992. setArray4(name: string, value: number[]): ShaderMaterial;
  92993. private _checkCache;
  92994. /**
  92995. * Specifies that the submesh is ready to be used
  92996. * @param mesh defines the mesh to check
  92997. * @param subMesh defines which submesh to check
  92998. * @param useInstances specifies that instances should be used
  92999. * @returns a boolean indicating that the submesh is ready or not
  93000. */
  93001. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93002. /**
  93003. * Checks if the material is ready to render the requested mesh
  93004. * @param mesh Define the mesh to render
  93005. * @param useInstances Define whether or not the material is used with instances
  93006. * @returns true if ready, otherwise false
  93007. */
  93008. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93009. /**
  93010. * Binds the world matrix to the material
  93011. * @param world defines the world transformation matrix
  93012. */
  93013. bindOnlyWorldMatrix(world: Matrix): void;
  93014. /**
  93015. * Binds the material to the mesh
  93016. * @param world defines the world transformation matrix
  93017. * @param mesh defines the mesh to bind the material to
  93018. */
  93019. bind(world: Matrix, mesh?: Mesh): void;
  93020. /**
  93021. * Gets the active textures from the material
  93022. * @returns an array of textures
  93023. */
  93024. getActiveTextures(): BaseTexture[];
  93025. /**
  93026. * Specifies if the material uses a texture
  93027. * @param texture defines the texture to check against the material
  93028. * @returns a boolean specifying if the material uses the texture
  93029. */
  93030. hasTexture(texture: BaseTexture): boolean;
  93031. /**
  93032. * Makes a duplicate of the material, and gives it a new name
  93033. * @param name defines the new name for the duplicated material
  93034. * @returns the cloned material
  93035. */
  93036. clone(name: string): ShaderMaterial;
  93037. /**
  93038. * Disposes the material
  93039. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93040. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93041. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93042. */
  93043. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93044. /**
  93045. * Serializes this material in a JSON representation
  93046. * @returns the serialized material object
  93047. */
  93048. serialize(): any;
  93049. /**
  93050. * Creates a shader material from parsed shader material data
  93051. * @param source defines the JSON represnetation of the material
  93052. * @param scene defines the hosting scene
  93053. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93054. * @returns a new material
  93055. */
  93056. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  93057. }
  93058. }
  93059. declare module BABYLON {
  93060. /** @hidden */
  93061. export var colorPixelShader: {
  93062. name: string;
  93063. shader: string;
  93064. };
  93065. }
  93066. declare module BABYLON {
  93067. /** @hidden */
  93068. export var colorVertexShader: {
  93069. name: string;
  93070. shader: string;
  93071. };
  93072. }
  93073. declare module BABYLON {
  93074. /**
  93075. * Line mesh
  93076. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  93077. */
  93078. export class LinesMesh extends Mesh {
  93079. /**
  93080. * If vertex color should be applied to the mesh
  93081. */
  93082. readonly useVertexColor?: boolean | undefined;
  93083. /**
  93084. * If vertex alpha should be applied to the mesh
  93085. */
  93086. readonly useVertexAlpha?: boolean | undefined;
  93087. /**
  93088. * Color of the line (Default: White)
  93089. */
  93090. color: Color3;
  93091. /**
  93092. * Alpha of the line (Default: 1)
  93093. */
  93094. alpha: number;
  93095. /**
  93096. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93097. * This margin is expressed in world space coordinates, so its value may vary.
  93098. * Default value is 0.1
  93099. */
  93100. intersectionThreshold: number;
  93101. private _colorShader;
  93102. private color4;
  93103. /**
  93104. * Creates a new LinesMesh
  93105. * @param name defines the name
  93106. * @param scene defines the hosting scene
  93107. * @param parent defines the parent mesh if any
  93108. * @param source defines the optional source LinesMesh used to clone data from
  93109. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93110. * When false, achieved by calling a clone(), also passing False.
  93111. * This will make creation of children, recursive.
  93112. * @param useVertexColor defines if this LinesMesh supports vertex color
  93113. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  93114. */
  93115. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  93116. /**
  93117. * If vertex color should be applied to the mesh
  93118. */
  93119. useVertexColor?: boolean | undefined,
  93120. /**
  93121. * If vertex alpha should be applied to the mesh
  93122. */
  93123. useVertexAlpha?: boolean | undefined);
  93124. private _addClipPlaneDefine;
  93125. private _removeClipPlaneDefine;
  93126. isReady(): boolean;
  93127. /**
  93128. * Returns the string "LineMesh"
  93129. */
  93130. getClassName(): string;
  93131. /**
  93132. * @hidden
  93133. */
  93134. get material(): Material;
  93135. /**
  93136. * @hidden
  93137. */
  93138. set material(value: Material);
  93139. /**
  93140. * @hidden
  93141. */
  93142. get checkCollisions(): boolean;
  93143. /** @hidden */
  93144. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93145. /** @hidden */
  93146. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93147. /**
  93148. * Disposes of the line mesh
  93149. * @param doNotRecurse If children should be disposed
  93150. */
  93151. dispose(doNotRecurse?: boolean): void;
  93152. /**
  93153. * Returns a new LineMesh object cloned from the current one.
  93154. */
  93155. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  93156. /**
  93157. * Creates a new InstancedLinesMesh object from the mesh model.
  93158. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93159. * @param name defines the name of the new instance
  93160. * @returns a new InstancedLinesMesh
  93161. */
  93162. createInstance(name: string): InstancedLinesMesh;
  93163. }
  93164. /**
  93165. * Creates an instance based on a source LinesMesh
  93166. */
  93167. export class InstancedLinesMesh extends InstancedMesh {
  93168. /**
  93169. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93170. * This margin is expressed in world space coordinates, so its value may vary.
  93171. * Initilized with the intersectionThreshold value of the source LinesMesh
  93172. */
  93173. intersectionThreshold: number;
  93174. constructor(name: string, source: LinesMesh);
  93175. /**
  93176. * Returns the string "InstancedLinesMesh".
  93177. */
  93178. getClassName(): string;
  93179. }
  93180. }
  93181. declare module BABYLON {
  93182. /** @hidden */
  93183. export var linePixelShader: {
  93184. name: string;
  93185. shader: string;
  93186. };
  93187. }
  93188. declare module BABYLON {
  93189. /** @hidden */
  93190. export var lineVertexShader: {
  93191. name: string;
  93192. shader: string;
  93193. };
  93194. }
  93195. declare module BABYLON {
  93196. interface AbstractMesh {
  93197. /**
  93198. * Gets the edgesRenderer associated with the mesh
  93199. */
  93200. edgesRenderer: Nullable<EdgesRenderer>;
  93201. }
  93202. interface LinesMesh {
  93203. /**
  93204. * Enables the edge rendering mode on the mesh.
  93205. * This mode makes the mesh edges visible
  93206. * @param epsilon defines the maximal distance between two angles to detect a face
  93207. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93208. * @returns the currentAbstractMesh
  93209. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93210. */
  93211. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93212. }
  93213. interface InstancedLinesMesh {
  93214. /**
  93215. * Enables the edge rendering mode on the mesh.
  93216. * This mode makes the mesh edges visible
  93217. * @param epsilon defines the maximal distance between two angles to detect a face
  93218. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93219. * @returns the current InstancedLinesMesh
  93220. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93221. */
  93222. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  93223. }
  93224. /**
  93225. * Defines the minimum contract an Edges renderer should follow.
  93226. */
  93227. export interface IEdgesRenderer extends IDisposable {
  93228. /**
  93229. * Gets or sets a boolean indicating if the edgesRenderer is active
  93230. */
  93231. isEnabled: boolean;
  93232. /**
  93233. * Renders the edges of the attached mesh,
  93234. */
  93235. render(): void;
  93236. /**
  93237. * Checks wether or not the edges renderer is ready to render.
  93238. * @return true if ready, otherwise false.
  93239. */
  93240. isReady(): boolean;
  93241. }
  93242. /**
  93243. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  93244. */
  93245. export class EdgesRenderer implements IEdgesRenderer {
  93246. /**
  93247. * Define the size of the edges with an orthographic camera
  93248. */
  93249. edgesWidthScalerForOrthographic: number;
  93250. /**
  93251. * Define the size of the edges with a perspective camera
  93252. */
  93253. edgesWidthScalerForPerspective: number;
  93254. protected _source: AbstractMesh;
  93255. protected _linesPositions: number[];
  93256. protected _linesNormals: number[];
  93257. protected _linesIndices: number[];
  93258. protected _epsilon: number;
  93259. protected _indicesCount: number;
  93260. protected _lineShader: ShaderMaterial;
  93261. protected _ib: DataBuffer;
  93262. protected _buffers: {
  93263. [key: string]: Nullable<VertexBuffer>;
  93264. };
  93265. protected _checkVerticesInsteadOfIndices: boolean;
  93266. private _meshRebuildObserver;
  93267. private _meshDisposeObserver;
  93268. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  93269. isEnabled: boolean;
  93270. /**
  93271. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  93272. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  93273. * @param source Mesh used to create edges
  93274. * @param epsilon sum of angles in adjacency to check for edge
  93275. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  93276. * @param generateEdgesLines - should generate Lines or only prepare resources.
  93277. */
  93278. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  93279. protected _prepareRessources(): void;
  93280. /** @hidden */
  93281. _rebuild(): void;
  93282. /**
  93283. * Releases the required resources for the edges renderer
  93284. */
  93285. dispose(): void;
  93286. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  93287. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  93288. /**
  93289. * Checks if the pair of p0 and p1 is en edge
  93290. * @param faceIndex
  93291. * @param edge
  93292. * @param faceNormals
  93293. * @param p0
  93294. * @param p1
  93295. * @private
  93296. */
  93297. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  93298. /**
  93299. * push line into the position, normal and index buffer
  93300. * @protected
  93301. */
  93302. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  93303. /**
  93304. * Generates lines edges from adjacencjes
  93305. * @private
  93306. */
  93307. _generateEdgesLines(): void;
  93308. /**
  93309. * Checks wether or not the edges renderer is ready to render.
  93310. * @return true if ready, otherwise false.
  93311. */
  93312. isReady(): boolean;
  93313. /**
  93314. * Renders the edges of the attached mesh,
  93315. */
  93316. render(): void;
  93317. }
  93318. /**
  93319. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  93320. */
  93321. export class LineEdgesRenderer extends EdgesRenderer {
  93322. /**
  93323. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  93324. * @param source LineMesh used to generate edges
  93325. * @param epsilon not important (specified angle for edge detection)
  93326. * @param checkVerticesInsteadOfIndices not important for LineMesh
  93327. */
  93328. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  93329. /**
  93330. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  93331. */
  93332. _generateEdgesLines(): void;
  93333. }
  93334. }
  93335. declare module BABYLON {
  93336. /**
  93337. * This represents the object necessary to create a rendering group.
  93338. * This is exclusively used and created by the rendering manager.
  93339. * To modify the behavior, you use the available helpers in your scene or meshes.
  93340. * @hidden
  93341. */
  93342. export class RenderingGroup {
  93343. index: number;
  93344. private static _zeroVector;
  93345. private _scene;
  93346. private _opaqueSubMeshes;
  93347. private _transparentSubMeshes;
  93348. private _alphaTestSubMeshes;
  93349. private _depthOnlySubMeshes;
  93350. private _particleSystems;
  93351. private _spriteManagers;
  93352. private _opaqueSortCompareFn;
  93353. private _alphaTestSortCompareFn;
  93354. private _transparentSortCompareFn;
  93355. private _renderOpaque;
  93356. private _renderAlphaTest;
  93357. private _renderTransparent;
  93358. /** @hidden */
  93359. _edgesRenderers: SmartArray<IEdgesRenderer>;
  93360. onBeforeTransparentRendering: () => void;
  93361. /**
  93362. * Set the opaque sort comparison function.
  93363. * If null the sub meshes will be render in the order they were created
  93364. */
  93365. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93366. /**
  93367. * Set the alpha test sort comparison function.
  93368. * If null the sub meshes will be render in the order they were created
  93369. */
  93370. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93371. /**
  93372. * Set the transparent sort comparison function.
  93373. * If null the sub meshes will be render in the order they were created
  93374. */
  93375. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93376. /**
  93377. * Creates a new rendering group.
  93378. * @param index The rendering group index
  93379. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  93380. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  93381. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  93382. */
  93383. 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>);
  93384. /**
  93385. * Render all the sub meshes contained in the group.
  93386. * @param customRenderFunction Used to override the default render behaviour of the group.
  93387. * @returns true if rendered some submeshes.
  93388. */
  93389. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  93390. /**
  93391. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  93392. * @param subMeshes The submeshes to render
  93393. */
  93394. private renderOpaqueSorted;
  93395. /**
  93396. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  93397. * @param subMeshes The submeshes to render
  93398. */
  93399. private renderAlphaTestSorted;
  93400. /**
  93401. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  93402. * @param subMeshes The submeshes to render
  93403. */
  93404. private renderTransparentSorted;
  93405. /**
  93406. * Renders the submeshes in a specified order.
  93407. * @param subMeshes The submeshes to sort before render
  93408. * @param sortCompareFn The comparison function use to sort
  93409. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  93410. * @param transparent Specifies to activate blending if true
  93411. */
  93412. private static renderSorted;
  93413. /**
  93414. * Renders the submeshes in the order they were dispatched (no sort applied).
  93415. * @param subMeshes The submeshes to render
  93416. */
  93417. private static renderUnsorted;
  93418. /**
  93419. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93420. * are rendered back to front if in the same alpha index.
  93421. *
  93422. * @param a The first submesh
  93423. * @param b The second submesh
  93424. * @returns The result of the comparison
  93425. */
  93426. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  93427. /**
  93428. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93429. * are rendered back to front.
  93430. *
  93431. * @param a The first submesh
  93432. * @param b The second submesh
  93433. * @returns The result of the comparison
  93434. */
  93435. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  93436. /**
  93437. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93438. * are rendered front to back (prevent overdraw).
  93439. *
  93440. * @param a The first submesh
  93441. * @param b The second submesh
  93442. * @returns The result of the comparison
  93443. */
  93444. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  93445. /**
  93446. * Resets the different lists of submeshes to prepare a new frame.
  93447. */
  93448. prepare(): void;
  93449. dispose(): void;
  93450. /**
  93451. * Inserts the submesh in its correct queue depending on its material.
  93452. * @param subMesh The submesh to dispatch
  93453. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  93454. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  93455. */
  93456. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  93457. dispatchSprites(spriteManager: ISpriteManager): void;
  93458. dispatchParticles(particleSystem: IParticleSystem): void;
  93459. private _renderParticles;
  93460. private _renderSprites;
  93461. }
  93462. }
  93463. declare module BABYLON {
  93464. /**
  93465. * Interface describing the different options available in the rendering manager
  93466. * regarding Auto Clear between groups.
  93467. */
  93468. export interface IRenderingManagerAutoClearSetup {
  93469. /**
  93470. * Defines whether or not autoclear is enable.
  93471. */
  93472. autoClear: boolean;
  93473. /**
  93474. * Defines whether or not to autoclear the depth buffer.
  93475. */
  93476. depth: boolean;
  93477. /**
  93478. * Defines whether or not to autoclear the stencil buffer.
  93479. */
  93480. stencil: boolean;
  93481. }
  93482. /**
  93483. * This class is used by the onRenderingGroupObservable
  93484. */
  93485. export class RenderingGroupInfo {
  93486. /**
  93487. * The Scene that being rendered
  93488. */
  93489. scene: Scene;
  93490. /**
  93491. * The camera currently used for the rendering pass
  93492. */
  93493. camera: Nullable<Camera>;
  93494. /**
  93495. * The ID of the renderingGroup being processed
  93496. */
  93497. renderingGroupId: number;
  93498. }
  93499. /**
  93500. * This is the manager responsible of all the rendering for meshes sprites and particles.
  93501. * It is enable to manage the different groups as well as the different necessary sort functions.
  93502. * This should not be used directly aside of the few static configurations
  93503. */
  93504. export class RenderingManager {
  93505. /**
  93506. * The max id used for rendering groups (not included)
  93507. */
  93508. static MAX_RENDERINGGROUPS: number;
  93509. /**
  93510. * The min id used for rendering groups (included)
  93511. */
  93512. static MIN_RENDERINGGROUPS: number;
  93513. /**
  93514. * Used to globally prevent autoclearing scenes.
  93515. */
  93516. static AUTOCLEAR: boolean;
  93517. /**
  93518. * @hidden
  93519. */
  93520. _useSceneAutoClearSetup: boolean;
  93521. private _scene;
  93522. private _renderingGroups;
  93523. private _depthStencilBufferAlreadyCleaned;
  93524. private _autoClearDepthStencil;
  93525. private _customOpaqueSortCompareFn;
  93526. private _customAlphaTestSortCompareFn;
  93527. private _customTransparentSortCompareFn;
  93528. private _renderingGroupInfo;
  93529. /**
  93530. * Instantiates a new rendering group for a particular scene
  93531. * @param scene Defines the scene the groups belongs to
  93532. */
  93533. constructor(scene: Scene);
  93534. private _clearDepthStencilBuffer;
  93535. /**
  93536. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  93537. * @hidden
  93538. */
  93539. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  93540. /**
  93541. * Resets the different information of the group to prepare a new frame
  93542. * @hidden
  93543. */
  93544. reset(): void;
  93545. /**
  93546. * Dispose and release the group and its associated resources.
  93547. * @hidden
  93548. */
  93549. dispose(): void;
  93550. /**
  93551. * Clear the info related to rendering groups preventing retention points during dispose.
  93552. */
  93553. freeRenderingGroups(): void;
  93554. private _prepareRenderingGroup;
  93555. /**
  93556. * Add a sprite manager to the rendering manager in order to render it this frame.
  93557. * @param spriteManager Define the sprite manager to render
  93558. */
  93559. dispatchSprites(spriteManager: ISpriteManager): void;
  93560. /**
  93561. * Add a particle system to the rendering manager in order to render it this frame.
  93562. * @param particleSystem Define the particle system to render
  93563. */
  93564. dispatchParticles(particleSystem: IParticleSystem): void;
  93565. /**
  93566. * Add a submesh to the manager in order to render it this frame
  93567. * @param subMesh The submesh to dispatch
  93568. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  93569. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  93570. */
  93571. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  93572. /**
  93573. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93574. * This allowed control for front to back rendering or reversly depending of the special needs.
  93575. *
  93576. * @param renderingGroupId The rendering group id corresponding to its index
  93577. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93578. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93579. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93580. */
  93581. 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;
  93582. /**
  93583. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93584. *
  93585. * @param renderingGroupId The rendering group id corresponding to its index
  93586. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93587. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93588. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93589. */
  93590. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93591. /**
  93592. * Gets the current auto clear configuration for one rendering group of the rendering
  93593. * manager.
  93594. * @param index the rendering group index to get the information for
  93595. * @returns The auto clear setup for the requested rendering group
  93596. */
  93597. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93598. }
  93599. }
  93600. declare module BABYLON {
  93601. /**
  93602. * This Helps creating a texture that will be created from a camera in your scene.
  93603. * It is basically a dynamic texture that could be used to create special effects for instance.
  93604. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93605. */
  93606. export class RenderTargetTexture extends Texture {
  93607. isCube: boolean;
  93608. /**
  93609. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93610. */
  93611. static readonly REFRESHRATE_RENDER_ONCE: number;
  93612. /**
  93613. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93614. */
  93615. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93616. /**
  93617. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93618. * the central point of your effect and can save a lot of performances.
  93619. */
  93620. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93621. /**
  93622. * Use this predicate to dynamically define the list of mesh you want to render.
  93623. * If set, the renderList property will be overwritten.
  93624. */
  93625. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93626. private _renderList;
  93627. /**
  93628. * Use this list to define the list of mesh you want to render.
  93629. */
  93630. get renderList(): Nullable<Array<AbstractMesh>>;
  93631. set renderList(value: Nullable<Array<AbstractMesh>>);
  93632. /**
  93633. * Use this function to overload the renderList array at rendering time.
  93634. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93635. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93636. * the cube (if the RTT is a cube, else layerOrFace=0).
  93637. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93638. */
  93639. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93640. private _hookArray;
  93641. /**
  93642. * Define if particles should be rendered in your texture.
  93643. */
  93644. renderParticles: boolean;
  93645. /**
  93646. * Define if sprites should be rendered in your texture.
  93647. */
  93648. renderSprites: boolean;
  93649. /**
  93650. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93651. */
  93652. coordinatesMode: number;
  93653. /**
  93654. * Define the camera used to render the texture.
  93655. */
  93656. activeCamera: Nullable<Camera>;
  93657. /**
  93658. * Override the render function of the texture with your own one.
  93659. */
  93660. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93661. /**
  93662. * Define if camera post processes should be use while rendering the texture.
  93663. */
  93664. useCameraPostProcesses: boolean;
  93665. /**
  93666. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93667. */
  93668. ignoreCameraViewport: boolean;
  93669. private _postProcessManager;
  93670. private _postProcesses;
  93671. private _resizeObserver;
  93672. /**
  93673. * An event triggered when the texture is unbind.
  93674. */
  93675. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93676. /**
  93677. * An event triggered when the texture is unbind.
  93678. */
  93679. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93680. private _onAfterUnbindObserver;
  93681. /**
  93682. * Set a after unbind callback in the texture.
  93683. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93684. */
  93685. set onAfterUnbind(callback: () => void);
  93686. /**
  93687. * An event triggered before rendering the texture
  93688. */
  93689. onBeforeRenderObservable: Observable<number>;
  93690. private _onBeforeRenderObserver;
  93691. /**
  93692. * Set a before render callback in the texture.
  93693. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93694. */
  93695. set onBeforeRender(callback: (faceIndex: number) => void);
  93696. /**
  93697. * An event triggered after rendering the texture
  93698. */
  93699. onAfterRenderObservable: Observable<number>;
  93700. private _onAfterRenderObserver;
  93701. /**
  93702. * Set a after render callback in the texture.
  93703. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93704. */
  93705. set onAfterRender(callback: (faceIndex: number) => void);
  93706. /**
  93707. * An event triggered after the texture clear
  93708. */
  93709. onClearObservable: Observable<Engine>;
  93710. private _onClearObserver;
  93711. /**
  93712. * Set a clear callback in the texture.
  93713. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93714. */
  93715. set onClear(callback: (Engine: Engine) => void);
  93716. /**
  93717. * An event triggered when the texture is resized.
  93718. */
  93719. onResizeObservable: Observable<RenderTargetTexture>;
  93720. /**
  93721. * Define the clear color of the Render Target if it should be different from the scene.
  93722. */
  93723. clearColor: Color4;
  93724. protected _size: number | {
  93725. width: number;
  93726. height: number;
  93727. layers?: number;
  93728. };
  93729. protected _initialSizeParameter: number | {
  93730. width: number;
  93731. height: number;
  93732. } | {
  93733. ratio: number;
  93734. };
  93735. protected _sizeRatio: Nullable<number>;
  93736. /** @hidden */
  93737. _generateMipMaps: boolean;
  93738. protected _renderingManager: RenderingManager;
  93739. /** @hidden */
  93740. _waitingRenderList: string[];
  93741. protected _doNotChangeAspectRatio: boolean;
  93742. protected _currentRefreshId: number;
  93743. protected _refreshRate: number;
  93744. protected _textureMatrix: Matrix;
  93745. protected _samples: number;
  93746. protected _renderTargetOptions: RenderTargetCreationOptions;
  93747. /**
  93748. * Gets render target creation options that were used.
  93749. */
  93750. get renderTargetOptions(): RenderTargetCreationOptions;
  93751. protected _engine: Engine;
  93752. protected _onRatioRescale(): void;
  93753. /**
  93754. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93755. * It must define where the camera used to render the texture is set
  93756. */
  93757. boundingBoxPosition: Vector3;
  93758. private _boundingBoxSize;
  93759. /**
  93760. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93761. * When defined, the cubemap will switch to local mode
  93762. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93763. * @example https://www.babylonjs-playground.com/#RNASML
  93764. */
  93765. set boundingBoxSize(value: Vector3);
  93766. get boundingBoxSize(): Vector3;
  93767. /**
  93768. * In case the RTT has been created with a depth texture, get the associated
  93769. * depth texture.
  93770. * Otherwise, return null.
  93771. */
  93772. get depthStencilTexture(): Nullable<InternalTexture>;
  93773. /**
  93774. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93775. * or used a shadow, depth texture...
  93776. * @param name The friendly name of the texture
  93777. * @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)
  93778. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93779. * @param generateMipMaps True if mip maps need to be generated after render.
  93780. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93781. * @param type The type of the buffer in the RTT (int, half float, float...)
  93782. * @param isCube True if a cube texture needs to be created
  93783. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93784. * @param generateDepthBuffer True to generate a depth buffer
  93785. * @param generateStencilBuffer True to generate a stencil buffer
  93786. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93787. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93788. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93789. */
  93790. constructor(name: string, size: number | {
  93791. width: number;
  93792. height: number;
  93793. layers?: number;
  93794. } | {
  93795. ratio: number;
  93796. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93797. /**
  93798. * Creates a depth stencil texture.
  93799. * This is only available in WebGL 2 or with the depth texture extension available.
  93800. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93801. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93802. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93803. */
  93804. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93805. private _processSizeParameter;
  93806. /**
  93807. * Define the number of samples to use in case of MSAA.
  93808. * It defaults to one meaning no MSAA has been enabled.
  93809. */
  93810. get samples(): number;
  93811. set samples(value: number);
  93812. /**
  93813. * Resets the refresh counter of the texture and start bak from scratch.
  93814. * Could be useful to regenerate the texture if it is setup to render only once.
  93815. */
  93816. resetRefreshCounter(): void;
  93817. /**
  93818. * Define the refresh rate of the texture or the rendering frequency.
  93819. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93820. */
  93821. get refreshRate(): number;
  93822. set refreshRate(value: number);
  93823. /**
  93824. * Adds a post process to the render target rendering passes.
  93825. * @param postProcess define the post process to add
  93826. */
  93827. addPostProcess(postProcess: PostProcess): void;
  93828. /**
  93829. * Clear all the post processes attached to the render target
  93830. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93831. */
  93832. clearPostProcesses(dispose?: boolean): void;
  93833. /**
  93834. * Remove one of the post process from the list of attached post processes to the texture
  93835. * @param postProcess define the post process to remove from the list
  93836. */
  93837. removePostProcess(postProcess: PostProcess): void;
  93838. /** @hidden */
  93839. _shouldRender(): boolean;
  93840. /**
  93841. * Gets the actual render size of the texture.
  93842. * @returns the width of the render size
  93843. */
  93844. getRenderSize(): number;
  93845. /**
  93846. * Gets the actual render width of the texture.
  93847. * @returns the width of the render size
  93848. */
  93849. getRenderWidth(): number;
  93850. /**
  93851. * Gets the actual render height of the texture.
  93852. * @returns the height of the render size
  93853. */
  93854. getRenderHeight(): number;
  93855. /**
  93856. * Gets the actual number of layers of the texture.
  93857. * @returns the number of layers
  93858. */
  93859. getRenderLayers(): number;
  93860. /**
  93861. * Get if the texture can be rescaled or not.
  93862. */
  93863. get canRescale(): boolean;
  93864. /**
  93865. * Resize the texture using a ratio.
  93866. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93867. */
  93868. scale(ratio: number): void;
  93869. /**
  93870. * Get the texture reflection matrix used to rotate/transform the reflection.
  93871. * @returns the reflection matrix
  93872. */
  93873. getReflectionTextureMatrix(): Matrix;
  93874. /**
  93875. * Resize the texture to a new desired size.
  93876. * Be carrefull as it will recreate all the data in the new texture.
  93877. * @param size Define the new size. It can be:
  93878. * - a number for squared texture,
  93879. * - an object containing { width: number, height: number }
  93880. * - or an object containing a ratio { ratio: number }
  93881. */
  93882. resize(size: number | {
  93883. width: number;
  93884. height: number;
  93885. } | {
  93886. ratio: number;
  93887. }): void;
  93888. private _defaultRenderListPrepared;
  93889. /**
  93890. * Renders all the objects from the render list into the texture.
  93891. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93892. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93893. */
  93894. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93895. private _bestReflectionRenderTargetDimension;
  93896. private _prepareRenderingManager;
  93897. /**
  93898. * @hidden
  93899. * @param faceIndex face index to bind to if this is a cubetexture
  93900. * @param layer defines the index of the texture to bind in the array
  93901. */
  93902. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93903. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93904. private renderToTarget;
  93905. /**
  93906. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93907. * This allowed control for front to back rendering or reversly depending of the special needs.
  93908. *
  93909. * @param renderingGroupId The rendering group id corresponding to its index
  93910. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93911. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93912. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93913. */
  93914. 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;
  93915. /**
  93916. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93917. *
  93918. * @param renderingGroupId The rendering group id corresponding to its index
  93919. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93920. */
  93921. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93922. /**
  93923. * Clones the texture.
  93924. * @returns the cloned texture
  93925. */
  93926. clone(): RenderTargetTexture;
  93927. /**
  93928. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93929. * @returns The JSON representation of the texture
  93930. */
  93931. serialize(): any;
  93932. /**
  93933. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93934. */
  93935. disposeFramebufferObjects(): void;
  93936. /**
  93937. * Dispose the texture and release its associated resources.
  93938. */
  93939. dispose(): void;
  93940. /** @hidden */
  93941. _rebuild(): void;
  93942. /**
  93943. * Clear the info related to rendering groups preventing retention point in material dispose.
  93944. */
  93945. freeRenderingGroups(): void;
  93946. /**
  93947. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93948. * @returns the view count
  93949. */
  93950. getViewCount(): number;
  93951. }
  93952. }
  93953. declare module BABYLON {
  93954. /**
  93955. * Options for compiling materials.
  93956. */
  93957. export interface IMaterialCompilationOptions {
  93958. /**
  93959. * Defines whether clip planes are enabled.
  93960. */
  93961. clipPlane: boolean;
  93962. /**
  93963. * Defines whether instances are enabled.
  93964. */
  93965. useInstances: boolean;
  93966. }
  93967. /**
  93968. * Base class for the main features of a material in Babylon.js
  93969. */
  93970. export class Material implements IAnimatable {
  93971. /**
  93972. * Returns the triangle fill mode
  93973. */
  93974. static readonly TriangleFillMode: number;
  93975. /**
  93976. * Returns the wireframe mode
  93977. */
  93978. static readonly WireFrameFillMode: number;
  93979. /**
  93980. * Returns the point fill mode
  93981. */
  93982. static readonly PointFillMode: number;
  93983. /**
  93984. * Returns the point list draw mode
  93985. */
  93986. static readonly PointListDrawMode: number;
  93987. /**
  93988. * Returns the line list draw mode
  93989. */
  93990. static readonly LineListDrawMode: number;
  93991. /**
  93992. * Returns the line loop draw mode
  93993. */
  93994. static readonly LineLoopDrawMode: number;
  93995. /**
  93996. * Returns the line strip draw mode
  93997. */
  93998. static readonly LineStripDrawMode: number;
  93999. /**
  94000. * Returns the triangle strip draw mode
  94001. */
  94002. static readonly TriangleStripDrawMode: number;
  94003. /**
  94004. * Returns the triangle fan draw mode
  94005. */
  94006. static readonly TriangleFanDrawMode: number;
  94007. /**
  94008. * Stores the clock-wise side orientation
  94009. */
  94010. static readonly ClockWiseSideOrientation: number;
  94011. /**
  94012. * Stores the counter clock-wise side orientation
  94013. */
  94014. static readonly CounterClockWiseSideOrientation: number;
  94015. /**
  94016. * The dirty texture flag value
  94017. */
  94018. static readonly TextureDirtyFlag: number;
  94019. /**
  94020. * The dirty light flag value
  94021. */
  94022. static readonly LightDirtyFlag: number;
  94023. /**
  94024. * The dirty fresnel flag value
  94025. */
  94026. static readonly FresnelDirtyFlag: number;
  94027. /**
  94028. * The dirty attribute flag value
  94029. */
  94030. static readonly AttributesDirtyFlag: number;
  94031. /**
  94032. * The dirty misc flag value
  94033. */
  94034. static readonly MiscDirtyFlag: number;
  94035. /**
  94036. * The all dirty flag value
  94037. */
  94038. static readonly AllDirtyFlag: number;
  94039. /**
  94040. * The ID of the material
  94041. */
  94042. id: string;
  94043. /**
  94044. * Gets or sets the unique id of the material
  94045. */
  94046. uniqueId: number;
  94047. /**
  94048. * The name of the material
  94049. */
  94050. name: string;
  94051. /**
  94052. * Gets or sets user defined metadata
  94053. */
  94054. metadata: any;
  94055. /**
  94056. * For internal use only. Please do not use.
  94057. */
  94058. reservedDataStore: any;
  94059. /**
  94060. * Specifies if the ready state should be checked on each call
  94061. */
  94062. checkReadyOnEveryCall: boolean;
  94063. /**
  94064. * Specifies if the ready state should be checked once
  94065. */
  94066. checkReadyOnlyOnce: boolean;
  94067. /**
  94068. * The state of the material
  94069. */
  94070. state: string;
  94071. /**
  94072. * The alpha value of the material
  94073. */
  94074. protected _alpha: number;
  94075. /**
  94076. * List of inspectable custom properties (used by the Inspector)
  94077. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94078. */
  94079. inspectableCustomProperties: IInspectable[];
  94080. /**
  94081. * Sets the alpha value of the material
  94082. */
  94083. set alpha(value: number);
  94084. /**
  94085. * Gets the alpha value of the material
  94086. */
  94087. get alpha(): number;
  94088. /**
  94089. * Specifies if back face culling is enabled
  94090. */
  94091. protected _backFaceCulling: boolean;
  94092. /**
  94093. * Sets the back-face culling state
  94094. */
  94095. set backFaceCulling(value: boolean);
  94096. /**
  94097. * Gets the back-face culling state
  94098. */
  94099. get backFaceCulling(): boolean;
  94100. /**
  94101. * Stores the value for side orientation
  94102. */
  94103. sideOrientation: number;
  94104. /**
  94105. * Callback triggered when the material is compiled
  94106. */
  94107. onCompiled: Nullable<(effect: Effect) => void>;
  94108. /**
  94109. * Callback triggered when an error occurs
  94110. */
  94111. onError: Nullable<(effect: Effect, errors: string) => void>;
  94112. /**
  94113. * Callback triggered to get the render target textures
  94114. */
  94115. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94116. /**
  94117. * Gets a boolean indicating that current material needs to register RTT
  94118. */
  94119. get hasRenderTargetTextures(): boolean;
  94120. /**
  94121. * Specifies if the material should be serialized
  94122. */
  94123. doNotSerialize: boolean;
  94124. /**
  94125. * @hidden
  94126. */
  94127. _storeEffectOnSubMeshes: boolean;
  94128. /**
  94129. * Stores the animations for the material
  94130. */
  94131. animations: Nullable<Array<Animation>>;
  94132. /**
  94133. * An event triggered when the material is disposed
  94134. */
  94135. onDisposeObservable: Observable<Material>;
  94136. /**
  94137. * An observer which watches for dispose events
  94138. */
  94139. private _onDisposeObserver;
  94140. private _onUnBindObservable;
  94141. /**
  94142. * Called during a dispose event
  94143. */
  94144. set onDispose(callback: () => void);
  94145. private _onBindObservable;
  94146. /**
  94147. * An event triggered when the material is bound
  94148. */
  94149. get onBindObservable(): Observable<AbstractMesh>;
  94150. /**
  94151. * An observer which watches for bind events
  94152. */
  94153. private _onBindObserver;
  94154. /**
  94155. * Called during a bind event
  94156. */
  94157. set onBind(callback: (Mesh: AbstractMesh) => void);
  94158. /**
  94159. * An event triggered when the material is unbound
  94160. */
  94161. get onUnBindObservable(): Observable<Material>;
  94162. /**
  94163. * Stores the value of the alpha mode
  94164. */
  94165. private _alphaMode;
  94166. /**
  94167. * Sets the value of the alpha mode.
  94168. *
  94169. * | Value | Type | Description |
  94170. * | --- | --- | --- |
  94171. * | 0 | ALPHA_DISABLE | |
  94172. * | 1 | ALPHA_ADD | |
  94173. * | 2 | ALPHA_COMBINE | |
  94174. * | 3 | ALPHA_SUBTRACT | |
  94175. * | 4 | ALPHA_MULTIPLY | |
  94176. * | 5 | ALPHA_MAXIMIZED | |
  94177. * | 6 | ALPHA_ONEONE | |
  94178. * | 7 | ALPHA_PREMULTIPLIED | |
  94179. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94180. * | 9 | ALPHA_INTERPOLATE | |
  94181. * | 10 | ALPHA_SCREENMODE | |
  94182. *
  94183. */
  94184. set alphaMode(value: number);
  94185. /**
  94186. * Gets the value of the alpha mode
  94187. */
  94188. get alphaMode(): number;
  94189. /**
  94190. * Stores the state of the need depth pre-pass value
  94191. */
  94192. private _needDepthPrePass;
  94193. /**
  94194. * Sets the need depth pre-pass value
  94195. */
  94196. set needDepthPrePass(value: boolean);
  94197. /**
  94198. * Gets the depth pre-pass value
  94199. */
  94200. get needDepthPrePass(): boolean;
  94201. /**
  94202. * Specifies if depth writing should be disabled
  94203. */
  94204. disableDepthWrite: boolean;
  94205. /**
  94206. * Specifies if depth writing should be forced
  94207. */
  94208. forceDepthWrite: boolean;
  94209. /**
  94210. * Specifies the depth function that should be used. 0 means the default engine function
  94211. */
  94212. depthFunction: number;
  94213. /**
  94214. * Specifies if there should be a separate pass for culling
  94215. */
  94216. separateCullingPass: boolean;
  94217. /**
  94218. * Stores the state specifing if fog should be enabled
  94219. */
  94220. private _fogEnabled;
  94221. /**
  94222. * Sets the state for enabling fog
  94223. */
  94224. set fogEnabled(value: boolean);
  94225. /**
  94226. * Gets the value of the fog enabled state
  94227. */
  94228. get fogEnabled(): boolean;
  94229. /**
  94230. * Stores the size of points
  94231. */
  94232. pointSize: number;
  94233. /**
  94234. * Stores the z offset value
  94235. */
  94236. zOffset: number;
  94237. /**
  94238. * Gets a value specifying if wireframe mode is enabled
  94239. */
  94240. get wireframe(): boolean;
  94241. /**
  94242. * Sets the state of wireframe mode
  94243. */
  94244. set wireframe(value: boolean);
  94245. /**
  94246. * Gets the value specifying if point clouds are enabled
  94247. */
  94248. get pointsCloud(): boolean;
  94249. /**
  94250. * Sets the state of point cloud mode
  94251. */
  94252. set pointsCloud(value: boolean);
  94253. /**
  94254. * Gets the material fill mode
  94255. */
  94256. get fillMode(): number;
  94257. /**
  94258. * Sets the material fill mode
  94259. */
  94260. set fillMode(value: number);
  94261. /**
  94262. * @hidden
  94263. * Stores the effects for the material
  94264. */
  94265. _effect: Nullable<Effect>;
  94266. /**
  94267. * Specifies if uniform buffers should be used
  94268. */
  94269. private _useUBO;
  94270. /**
  94271. * Stores a reference to the scene
  94272. */
  94273. private _scene;
  94274. /**
  94275. * Stores the fill mode state
  94276. */
  94277. private _fillMode;
  94278. /**
  94279. * Specifies if the depth write state should be cached
  94280. */
  94281. private _cachedDepthWriteState;
  94282. /**
  94283. * Specifies if the depth function state should be cached
  94284. */
  94285. private _cachedDepthFunctionState;
  94286. /**
  94287. * Stores the uniform buffer
  94288. */
  94289. protected _uniformBuffer: UniformBuffer;
  94290. /** @hidden */
  94291. _indexInSceneMaterialArray: number;
  94292. /** @hidden */
  94293. meshMap: Nullable<{
  94294. [id: string]: AbstractMesh | undefined;
  94295. }>;
  94296. /**
  94297. * Creates a material instance
  94298. * @param name defines the name of the material
  94299. * @param scene defines the scene to reference
  94300. * @param doNotAdd specifies if the material should be added to the scene
  94301. */
  94302. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94303. /**
  94304. * Returns a string representation of the current material
  94305. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94306. * @returns a string with material information
  94307. */
  94308. toString(fullDetails?: boolean): string;
  94309. /**
  94310. * Gets the class name of the material
  94311. * @returns a string with the class name of the material
  94312. */
  94313. getClassName(): string;
  94314. /**
  94315. * Specifies if updates for the material been locked
  94316. */
  94317. get isFrozen(): boolean;
  94318. /**
  94319. * Locks updates for the material
  94320. */
  94321. freeze(): void;
  94322. /**
  94323. * Unlocks updates for the material
  94324. */
  94325. unfreeze(): void;
  94326. /**
  94327. * Specifies if the material is ready to be used
  94328. * @param mesh defines the mesh to check
  94329. * @param useInstances specifies if instances should be used
  94330. * @returns a boolean indicating if the material is ready to be used
  94331. */
  94332. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94333. /**
  94334. * Specifies that the submesh is ready to be used
  94335. * @param mesh defines the mesh to check
  94336. * @param subMesh defines which submesh to check
  94337. * @param useInstances specifies that instances should be used
  94338. * @returns a boolean indicating that the submesh is ready or not
  94339. */
  94340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94341. /**
  94342. * Returns the material effect
  94343. * @returns the effect associated with the material
  94344. */
  94345. getEffect(): Nullable<Effect>;
  94346. /**
  94347. * Returns the current scene
  94348. * @returns a Scene
  94349. */
  94350. getScene(): Scene;
  94351. /**
  94352. * Specifies if the material will require alpha blending
  94353. * @returns a boolean specifying if alpha blending is needed
  94354. */
  94355. needAlphaBlending(): boolean;
  94356. /**
  94357. * Specifies if the mesh will require alpha blending
  94358. * @param mesh defines the mesh to check
  94359. * @returns a boolean specifying if alpha blending is needed for the mesh
  94360. */
  94361. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94362. /**
  94363. * Specifies if this material should be rendered in alpha test mode
  94364. * @returns a boolean specifying if an alpha test is needed.
  94365. */
  94366. needAlphaTesting(): boolean;
  94367. /**
  94368. * Gets the texture used for the alpha test
  94369. * @returns the texture to use for alpha testing
  94370. */
  94371. getAlphaTestTexture(): Nullable<BaseTexture>;
  94372. /**
  94373. * Marks the material to indicate that it needs to be re-calculated
  94374. */
  94375. markDirty(): void;
  94376. /** @hidden */
  94377. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94378. /**
  94379. * Binds the material to the mesh
  94380. * @param world defines the world transformation matrix
  94381. * @param mesh defines the mesh to bind the material to
  94382. */
  94383. bind(world: Matrix, mesh?: Mesh): void;
  94384. /**
  94385. * Binds the submesh to the material
  94386. * @param world defines the world transformation matrix
  94387. * @param mesh defines the mesh containing the submesh
  94388. * @param subMesh defines the submesh to bind the material to
  94389. */
  94390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94391. /**
  94392. * Binds the world matrix to the material
  94393. * @param world defines the world transformation matrix
  94394. */
  94395. bindOnlyWorldMatrix(world: Matrix): void;
  94396. /**
  94397. * Binds the scene's uniform buffer to the effect.
  94398. * @param effect defines the effect to bind to the scene uniform buffer
  94399. * @param sceneUbo defines the uniform buffer storing scene data
  94400. */
  94401. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94402. /**
  94403. * Binds the view matrix to the effect
  94404. * @param effect defines the effect to bind the view matrix to
  94405. */
  94406. bindView(effect: Effect): void;
  94407. /**
  94408. * Binds the view projection matrix to the effect
  94409. * @param effect defines the effect to bind the view projection matrix to
  94410. */
  94411. bindViewProjection(effect: Effect): void;
  94412. /**
  94413. * Specifies if material alpha testing should be turned on for the mesh
  94414. * @param mesh defines the mesh to check
  94415. */
  94416. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94417. /**
  94418. * Processes to execute after binding the material to a mesh
  94419. * @param mesh defines the rendered mesh
  94420. */
  94421. protected _afterBind(mesh?: Mesh): void;
  94422. /**
  94423. * Unbinds the material from the mesh
  94424. */
  94425. unbind(): void;
  94426. /**
  94427. * Gets the active textures from the material
  94428. * @returns an array of textures
  94429. */
  94430. getActiveTextures(): BaseTexture[];
  94431. /**
  94432. * Specifies if the material uses a texture
  94433. * @param texture defines the texture to check against the material
  94434. * @returns a boolean specifying if the material uses the texture
  94435. */
  94436. hasTexture(texture: BaseTexture): boolean;
  94437. /**
  94438. * Makes a duplicate of the material, and gives it a new name
  94439. * @param name defines the new name for the duplicated material
  94440. * @returns the cloned material
  94441. */
  94442. clone(name: string): Nullable<Material>;
  94443. /**
  94444. * Gets the meshes bound to the material
  94445. * @returns an array of meshes bound to the material
  94446. */
  94447. getBindedMeshes(): AbstractMesh[];
  94448. /**
  94449. * Force shader compilation
  94450. * @param mesh defines the mesh associated with this material
  94451. * @param onCompiled defines a function to execute once the material is compiled
  94452. * @param options defines the options to configure the compilation
  94453. * @param onError defines a function to execute if the material fails compiling
  94454. */
  94455. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94456. /**
  94457. * Force shader compilation
  94458. * @param mesh defines the mesh that will use this material
  94459. * @param options defines additional options for compiling the shaders
  94460. * @returns a promise that resolves when the compilation completes
  94461. */
  94462. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94463. private static readonly _AllDirtyCallBack;
  94464. private static readonly _ImageProcessingDirtyCallBack;
  94465. private static readonly _TextureDirtyCallBack;
  94466. private static readonly _FresnelDirtyCallBack;
  94467. private static readonly _MiscDirtyCallBack;
  94468. private static readonly _LightsDirtyCallBack;
  94469. private static readonly _AttributeDirtyCallBack;
  94470. private static _FresnelAndMiscDirtyCallBack;
  94471. private static _TextureAndMiscDirtyCallBack;
  94472. private static readonly _DirtyCallbackArray;
  94473. private static readonly _RunDirtyCallBacks;
  94474. /**
  94475. * Marks a define in the material to indicate that it needs to be re-computed
  94476. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94477. */
  94478. markAsDirty(flag: number): void;
  94479. /**
  94480. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94481. * @param func defines a function which checks material defines against the submeshes
  94482. */
  94483. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94484. /**
  94485. * Indicates that we need to re-calculated for all submeshes
  94486. */
  94487. protected _markAllSubMeshesAsAllDirty(): void;
  94488. /**
  94489. * Indicates that image processing needs to be re-calculated for all submeshes
  94490. */
  94491. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94492. /**
  94493. * Indicates that textures need to be re-calculated for all submeshes
  94494. */
  94495. protected _markAllSubMeshesAsTexturesDirty(): void;
  94496. /**
  94497. * Indicates that fresnel needs to be re-calculated for all submeshes
  94498. */
  94499. protected _markAllSubMeshesAsFresnelDirty(): void;
  94500. /**
  94501. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94502. */
  94503. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94504. /**
  94505. * Indicates that lights need to be re-calculated for all submeshes
  94506. */
  94507. protected _markAllSubMeshesAsLightsDirty(): void;
  94508. /**
  94509. * Indicates that attributes need to be re-calculated for all submeshes
  94510. */
  94511. protected _markAllSubMeshesAsAttributesDirty(): void;
  94512. /**
  94513. * Indicates that misc needs to be re-calculated for all submeshes
  94514. */
  94515. protected _markAllSubMeshesAsMiscDirty(): void;
  94516. /**
  94517. * Indicates that textures and misc need to be re-calculated for all submeshes
  94518. */
  94519. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94520. /**
  94521. * Disposes the material
  94522. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94523. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94524. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94525. */
  94526. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94527. /** @hidden */
  94528. private releaseVertexArrayObject;
  94529. /**
  94530. * Serializes this material
  94531. * @returns the serialized material object
  94532. */
  94533. serialize(): any;
  94534. /**
  94535. * Creates a material from parsed material data
  94536. * @param parsedMaterial defines parsed material data
  94537. * @param scene defines the hosting scene
  94538. * @param rootUrl defines the root URL to use to load textures
  94539. * @returns a new material
  94540. */
  94541. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94542. }
  94543. }
  94544. declare module BABYLON {
  94545. /**
  94546. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94547. * separate meshes. This can be use to improve performances.
  94548. * @see http://doc.babylonjs.com/how_to/multi_materials
  94549. */
  94550. export class MultiMaterial extends Material {
  94551. private _subMaterials;
  94552. /**
  94553. * Gets or Sets the list of Materials used within the multi material.
  94554. * They need to be ordered according to the submeshes order in the associated mesh
  94555. */
  94556. get subMaterials(): Nullable<Material>[];
  94557. set subMaterials(value: Nullable<Material>[]);
  94558. /**
  94559. * Function used to align with Node.getChildren()
  94560. * @returns the list of Materials used within the multi material
  94561. */
  94562. getChildren(): Nullable<Material>[];
  94563. /**
  94564. * Instantiates a new Multi Material
  94565. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94566. * separate meshes. This can be use to improve performances.
  94567. * @see http://doc.babylonjs.com/how_to/multi_materials
  94568. * @param name Define the name in the scene
  94569. * @param scene Define the scene the material belongs to
  94570. */
  94571. constructor(name: string, scene: Scene);
  94572. private _hookArray;
  94573. /**
  94574. * Get one of the submaterial by its index in the submaterials array
  94575. * @param index The index to look the sub material at
  94576. * @returns The Material if the index has been defined
  94577. */
  94578. getSubMaterial(index: number): Nullable<Material>;
  94579. /**
  94580. * Get the list of active textures for the whole sub materials list.
  94581. * @returns All the textures that will be used during the rendering
  94582. */
  94583. getActiveTextures(): BaseTexture[];
  94584. /**
  94585. * Gets the current class name of the material e.g. "MultiMaterial"
  94586. * Mainly use in serialization.
  94587. * @returns the class name
  94588. */
  94589. getClassName(): string;
  94590. /**
  94591. * Checks if the material is ready to render the requested sub mesh
  94592. * @param mesh Define the mesh the submesh belongs to
  94593. * @param subMesh Define the sub mesh to look readyness for
  94594. * @param useInstances Define whether or not the material is used with instances
  94595. * @returns true if ready, otherwise false
  94596. */
  94597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94598. /**
  94599. * Clones the current material and its related sub materials
  94600. * @param name Define the name of the newly cloned material
  94601. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94602. * @returns the cloned material
  94603. */
  94604. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94605. /**
  94606. * Serializes the materials into a JSON representation.
  94607. * @returns the JSON representation
  94608. */
  94609. serialize(): any;
  94610. /**
  94611. * Dispose the material and release its associated resources
  94612. * @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)
  94613. * @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)
  94614. * @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)
  94615. */
  94616. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94617. /**
  94618. * Creates a MultiMaterial from parsed MultiMaterial data.
  94619. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94620. * @param scene defines the hosting scene
  94621. * @returns a new MultiMaterial
  94622. */
  94623. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94624. }
  94625. }
  94626. declare module BABYLON {
  94627. /**
  94628. * Base class for submeshes
  94629. */
  94630. export class BaseSubMesh {
  94631. /** @hidden */
  94632. _materialDefines: Nullable<MaterialDefines>;
  94633. /** @hidden */
  94634. _materialEffect: Nullable<Effect>;
  94635. /**
  94636. * Gets material defines used by the effect associated to the sub mesh
  94637. */
  94638. get materialDefines(): Nullable<MaterialDefines>;
  94639. /**
  94640. * Sets material defines used by the effect associated to the sub mesh
  94641. */
  94642. set materialDefines(defines: Nullable<MaterialDefines>);
  94643. /**
  94644. * Gets associated effect
  94645. */
  94646. get effect(): Nullable<Effect>;
  94647. /**
  94648. * Sets associated effect (effect used to render this submesh)
  94649. * @param effect defines the effect to associate with
  94650. * @param defines defines the set of defines used to compile this effect
  94651. */
  94652. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94653. }
  94654. /**
  94655. * Defines a subdivision inside a mesh
  94656. */
  94657. export class SubMesh extends BaseSubMesh implements ICullable {
  94658. /** the material index to use */
  94659. materialIndex: number;
  94660. /** vertex index start */
  94661. verticesStart: number;
  94662. /** vertices count */
  94663. verticesCount: number;
  94664. /** index start */
  94665. indexStart: number;
  94666. /** indices count */
  94667. indexCount: number;
  94668. /** @hidden */
  94669. _linesIndexCount: number;
  94670. private _mesh;
  94671. private _renderingMesh;
  94672. private _boundingInfo;
  94673. private _linesIndexBuffer;
  94674. /** @hidden */
  94675. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94676. /** @hidden */
  94677. _trianglePlanes: Plane[];
  94678. /** @hidden */
  94679. _lastColliderTransformMatrix: Nullable<Matrix>;
  94680. /** @hidden */
  94681. _renderId: number;
  94682. /** @hidden */
  94683. _alphaIndex: number;
  94684. /** @hidden */
  94685. _distanceToCamera: number;
  94686. /** @hidden */
  94687. _id: number;
  94688. private _currentMaterial;
  94689. /**
  94690. * Add a new submesh to a mesh
  94691. * @param materialIndex defines the material index to use
  94692. * @param verticesStart defines vertex index start
  94693. * @param verticesCount defines vertices count
  94694. * @param indexStart defines index start
  94695. * @param indexCount defines indices count
  94696. * @param mesh defines the parent mesh
  94697. * @param renderingMesh defines an optional rendering mesh
  94698. * @param createBoundingBox defines if bounding box should be created for this submesh
  94699. * @returns the new submesh
  94700. */
  94701. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94702. /**
  94703. * Creates a new submesh
  94704. * @param materialIndex defines the material index to use
  94705. * @param verticesStart defines vertex index start
  94706. * @param verticesCount defines vertices count
  94707. * @param indexStart defines index start
  94708. * @param indexCount defines indices count
  94709. * @param mesh defines the parent mesh
  94710. * @param renderingMesh defines an optional rendering mesh
  94711. * @param createBoundingBox defines if bounding box should be created for this submesh
  94712. */
  94713. constructor(
  94714. /** the material index to use */
  94715. materialIndex: number,
  94716. /** vertex index start */
  94717. verticesStart: number,
  94718. /** vertices count */
  94719. verticesCount: number,
  94720. /** index start */
  94721. indexStart: number,
  94722. /** indices count */
  94723. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94724. /**
  94725. * Returns true if this submesh covers the entire parent mesh
  94726. * @ignorenaming
  94727. */
  94728. get IsGlobal(): boolean;
  94729. /**
  94730. * Returns the submesh BoudingInfo object
  94731. * @returns current bounding info (or mesh's one if the submesh is global)
  94732. */
  94733. getBoundingInfo(): BoundingInfo;
  94734. /**
  94735. * Sets the submesh BoundingInfo
  94736. * @param boundingInfo defines the new bounding info to use
  94737. * @returns the SubMesh
  94738. */
  94739. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94740. /**
  94741. * Returns the mesh of the current submesh
  94742. * @return the parent mesh
  94743. */
  94744. getMesh(): AbstractMesh;
  94745. /**
  94746. * Returns the rendering mesh of the submesh
  94747. * @returns the rendering mesh (could be different from parent mesh)
  94748. */
  94749. getRenderingMesh(): Mesh;
  94750. /**
  94751. * Returns the submesh material
  94752. * @returns null or the current material
  94753. */
  94754. getMaterial(): Nullable<Material>;
  94755. /**
  94756. * Sets a new updated BoundingInfo object to the submesh
  94757. * @param data defines an optional position array to use to determine the bounding info
  94758. * @returns the SubMesh
  94759. */
  94760. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94761. /** @hidden */
  94762. _checkCollision(collider: Collider): boolean;
  94763. /**
  94764. * Updates the submesh BoundingInfo
  94765. * @param world defines the world matrix to use to update the bounding info
  94766. * @returns the submesh
  94767. */
  94768. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94769. /**
  94770. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94771. * @param frustumPlanes defines the frustum planes
  94772. * @returns true if the submesh is intersecting with the frustum
  94773. */
  94774. isInFrustum(frustumPlanes: Plane[]): boolean;
  94775. /**
  94776. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94777. * @param frustumPlanes defines the frustum planes
  94778. * @returns true if the submesh is inside the frustum
  94779. */
  94780. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94781. /**
  94782. * Renders the submesh
  94783. * @param enableAlphaMode defines if alpha needs to be used
  94784. * @returns the submesh
  94785. */
  94786. render(enableAlphaMode: boolean): SubMesh;
  94787. /**
  94788. * @hidden
  94789. */
  94790. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94791. /**
  94792. * Checks if the submesh intersects with a ray
  94793. * @param ray defines the ray to test
  94794. * @returns true is the passed ray intersects the submesh bounding box
  94795. */
  94796. canIntersects(ray: Ray): boolean;
  94797. /**
  94798. * Intersects current submesh with a ray
  94799. * @param ray defines the ray to test
  94800. * @param positions defines mesh's positions array
  94801. * @param indices defines mesh's indices array
  94802. * @param fastCheck defines if only bounding info should be used
  94803. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94804. * @returns intersection info or null if no intersection
  94805. */
  94806. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94807. /** @hidden */
  94808. private _intersectLines;
  94809. /** @hidden */
  94810. private _intersectUnIndexedLines;
  94811. /** @hidden */
  94812. private _intersectTriangles;
  94813. /** @hidden */
  94814. private _intersectUnIndexedTriangles;
  94815. /** @hidden */
  94816. _rebuild(): void;
  94817. /**
  94818. * Creates a new submesh from the passed mesh
  94819. * @param newMesh defines the new hosting mesh
  94820. * @param newRenderingMesh defines an optional rendering mesh
  94821. * @returns the new submesh
  94822. */
  94823. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94824. /**
  94825. * Release associated resources
  94826. */
  94827. dispose(): void;
  94828. /**
  94829. * Gets the class name
  94830. * @returns the string "SubMesh".
  94831. */
  94832. getClassName(): string;
  94833. /**
  94834. * Creates a new submesh from indices data
  94835. * @param materialIndex the index of the main mesh material
  94836. * @param startIndex the index where to start the copy in the mesh indices array
  94837. * @param indexCount the number of indices to copy then from the startIndex
  94838. * @param mesh the main mesh to create the submesh from
  94839. * @param renderingMesh the optional rendering mesh
  94840. * @returns a new submesh
  94841. */
  94842. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94843. }
  94844. }
  94845. declare module BABYLON {
  94846. /**
  94847. * Class used to represent data loading progression
  94848. */
  94849. export class SceneLoaderFlags {
  94850. private static _ForceFullSceneLoadingForIncremental;
  94851. private static _ShowLoadingScreen;
  94852. private static _CleanBoneMatrixWeights;
  94853. private static _loggingLevel;
  94854. /**
  94855. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94856. */
  94857. static get ForceFullSceneLoadingForIncremental(): boolean;
  94858. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94859. /**
  94860. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94861. */
  94862. static get ShowLoadingScreen(): boolean;
  94863. static set ShowLoadingScreen(value: boolean);
  94864. /**
  94865. * Defines the current logging level (while loading the scene)
  94866. * @ignorenaming
  94867. */
  94868. static get loggingLevel(): number;
  94869. static set loggingLevel(value: number);
  94870. /**
  94871. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94872. */
  94873. static get CleanBoneMatrixWeights(): boolean;
  94874. static set CleanBoneMatrixWeights(value: boolean);
  94875. }
  94876. }
  94877. declare module BABYLON {
  94878. /**
  94879. * Class used to store geometry data (vertex buffers + index buffer)
  94880. */
  94881. export class Geometry implements IGetSetVerticesData {
  94882. /**
  94883. * Gets or sets the ID of the geometry
  94884. */
  94885. id: string;
  94886. /**
  94887. * Gets or sets the unique ID of the geometry
  94888. */
  94889. uniqueId: number;
  94890. /**
  94891. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94892. */
  94893. delayLoadState: number;
  94894. /**
  94895. * Gets the file containing the data to load when running in delay load state
  94896. */
  94897. delayLoadingFile: Nullable<string>;
  94898. /**
  94899. * Callback called when the geometry is updated
  94900. */
  94901. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94902. private _scene;
  94903. private _engine;
  94904. private _meshes;
  94905. private _totalVertices;
  94906. /** @hidden */
  94907. _indices: IndicesArray;
  94908. /** @hidden */
  94909. _vertexBuffers: {
  94910. [key: string]: VertexBuffer;
  94911. };
  94912. private _isDisposed;
  94913. private _extend;
  94914. private _boundingBias;
  94915. /** @hidden */
  94916. _delayInfo: Array<string>;
  94917. private _indexBuffer;
  94918. private _indexBufferIsUpdatable;
  94919. /** @hidden */
  94920. _boundingInfo: Nullable<BoundingInfo>;
  94921. /** @hidden */
  94922. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94923. /** @hidden */
  94924. _softwareSkinningFrameId: number;
  94925. private _vertexArrayObjects;
  94926. private _updatable;
  94927. /** @hidden */
  94928. _positions: Nullable<Vector3[]>;
  94929. /**
  94930. * 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
  94931. */
  94932. get boundingBias(): Vector2;
  94933. /**
  94934. * 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
  94935. */
  94936. set boundingBias(value: Vector2);
  94937. /**
  94938. * Static function used to attach a new empty geometry to a mesh
  94939. * @param mesh defines the mesh to attach the geometry to
  94940. * @returns the new Geometry
  94941. */
  94942. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94943. /**
  94944. * Creates a new geometry
  94945. * @param id defines the unique ID
  94946. * @param scene defines the hosting scene
  94947. * @param vertexData defines the VertexData used to get geometry data
  94948. * @param updatable defines if geometry must be updatable (false by default)
  94949. * @param mesh defines the mesh that will be associated with the geometry
  94950. */
  94951. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94952. /**
  94953. * Gets the current extend of the geometry
  94954. */
  94955. get extend(): {
  94956. minimum: Vector3;
  94957. maximum: Vector3;
  94958. };
  94959. /**
  94960. * Gets the hosting scene
  94961. * @returns the hosting Scene
  94962. */
  94963. getScene(): Scene;
  94964. /**
  94965. * Gets the hosting engine
  94966. * @returns the hosting Engine
  94967. */
  94968. getEngine(): Engine;
  94969. /**
  94970. * Defines if the geometry is ready to use
  94971. * @returns true if the geometry is ready to be used
  94972. */
  94973. isReady(): boolean;
  94974. /**
  94975. * Gets a value indicating that the geometry should not be serialized
  94976. */
  94977. get doNotSerialize(): boolean;
  94978. /** @hidden */
  94979. _rebuild(): void;
  94980. /**
  94981. * Affects all geometry data in one call
  94982. * @param vertexData defines the geometry data
  94983. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94984. */
  94985. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94986. /**
  94987. * Set specific vertex data
  94988. * @param kind defines the data kind (Position, normal, etc...)
  94989. * @param data defines the vertex data to use
  94990. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94991. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94992. */
  94993. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94994. /**
  94995. * Removes a specific vertex data
  94996. * @param kind defines the data kind (Position, normal, etc...)
  94997. */
  94998. removeVerticesData(kind: string): void;
  94999. /**
  95000. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95001. * @param buffer defines the vertex buffer to use
  95002. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95003. */
  95004. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95005. /**
  95006. * Update a specific vertex buffer
  95007. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95008. * It will do nothing if the buffer is not updatable
  95009. * @param kind defines the data kind (Position, normal, etc...)
  95010. * @param data defines the data to use
  95011. * @param offset defines the offset in the target buffer where to store the data
  95012. * @param useBytes set to true if the offset is in bytes
  95013. */
  95014. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95015. /**
  95016. * Update a specific vertex buffer
  95017. * This function will create a new buffer if the current one is not updatable
  95018. * @param kind defines the data kind (Position, normal, etc...)
  95019. * @param data defines the data to use
  95020. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95021. */
  95022. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95023. private _updateBoundingInfo;
  95024. /** @hidden */
  95025. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95026. /**
  95027. * Gets total number of vertices
  95028. * @returns the total number of vertices
  95029. */
  95030. getTotalVertices(): number;
  95031. /**
  95032. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95033. * @param kind defines the data kind (Position, normal, etc...)
  95034. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95035. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95036. * @returns a float array containing vertex data
  95037. */
  95038. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95039. /**
  95040. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95041. * @param kind defines the data kind (Position, normal, etc...)
  95042. * @returns true if the vertex buffer with the specified kind is updatable
  95043. */
  95044. isVertexBufferUpdatable(kind: string): boolean;
  95045. /**
  95046. * Gets a specific vertex buffer
  95047. * @param kind defines the data kind (Position, normal, etc...)
  95048. * @returns a VertexBuffer
  95049. */
  95050. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95051. /**
  95052. * Returns all vertex buffers
  95053. * @return an object holding all vertex buffers indexed by kind
  95054. */
  95055. getVertexBuffers(): Nullable<{
  95056. [key: string]: VertexBuffer;
  95057. }>;
  95058. /**
  95059. * Gets a boolean indicating if specific vertex buffer is present
  95060. * @param kind defines the data kind (Position, normal, etc...)
  95061. * @returns true if data is present
  95062. */
  95063. isVerticesDataPresent(kind: string): boolean;
  95064. /**
  95065. * Gets a list of all attached data kinds (Position, normal, etc...)
  95066. * @returns a list of string containing all kinds
  95067. */
  95068. getVerticesDataKinds(): string[];
  95069. /**
  95070. * Update index buffer
  95071. * @param indices defines the indices to store in the index buffer
  95072. * @param offset defines the offset in the target buffer where to store the data
  95073. * @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)
  95074. */
  95075. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95076. /**
  95077. * Creates a new index buffer
  95078. * @param indices defines the indices to store in the index buffer
  95079. * @param totalVertices defines the total number of vertices (could be null)
  95080. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95081. */
  95082. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95083. /**
  95084. * Return the total number of indices
  95085. * @returns the total number of indices
  95086. */
  95087. getTotalIndices(): number;
  95088. /**
  95089. * Gets the index buffer array
  95090. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95091. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95092. * @returns the index buffer array
  95093. */
  95094. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95095. /**
  95096. * Gets the index buffer
  95097. * @return the index buffer
  95098. */
  95099. getIndexBuffer(): Nullable<DataBuffer>;
  95100. /** @hidden */
  95101. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95102. /**
  95103. * Release the associated resources for a specific mesh
  95104. * @param mesh defines the source mesh
  95105. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95106. */
  95107. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95108. /**
  95109. * Apply current geometry to a given mesh
  95110. * @param mesh defines the mesh to apply geometry to
  95111. */
  95112. applyToMesh(mesh: Mesh): void;
  95113. private _updateExtend;
  95114. private _applyToMesh;
  95115. private notifyUpdate;
  95116. /**
  95117. * Load the geometry if it was flagged as delay loaded
  95118. * @param scene defines the hosting scene
  95119. * @param onLoaded defines a callback called when the geometry is loaded
  95120. */
  95121. load(scene: Scene, onLoaded?: () => void): void;
  95122. private _queueLoad;
  95123. /**
  95124. * Invert the geometry to move from a right handed system to a left handed one.
  95125. */
  95126. toLeftHanded(): void;
  95127. /** @hidden */
  95128. _resetPointsArrayCache(): void;
  95129. /** @hidden */
  95130. _generatePointsArray(): boolean;
  95131. /**
  95132. * Gets a value indicating if the geometry is disposed
  95133. * @returns true if the geometry was disposed
  95134. */
  95135. isDisposed(): boolean;
  95136. private _disposeVertexArrayObjects;
  95137. /**
  95138. * Free all associated resources
  95139. */
  95140. dispose(): void;
  95141. /**
  95142. * Clone the current geometry into a new geometry
  95143. * @param id defines the unique ID of the new geometry
  95144. * @returns a new geometry object
  95145. */
  95146. copy(id: string): Geometry;
  95147. /**
  95148. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95149. * @return a JSON representation of the current geometry data (without the vertices data)
  95150. */
  95151. serialize(): any;
  95152. private toNumberArray;
  95153. /**
  95154. * Serialize all vertices data into a JSON oject
  95155. * @returns a JSON representation of the current geometry data
  95156. */
  95157. serializeVerticeData(): any;
  95158. /**
  95159. * Extracts a clone of a mesh geometry
  95160. * @param mesh defines the source mesh
  95161. * @param id defines the unique ID of the new geometry object
  95162. * @returns the new geometry object
  95163. */
  95164. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95165. /**
  95166. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95167. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95168. * Be aware Math.random() could cause collisions, but:
  95169. * "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"
  95170. * @returns a string containing a new GUID
  95171. */
  95172. static RandomId(): string;
  95173. /** @hidden */
  95174. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95175. private static _CleanMatricesWeights;
  95176. /**
  95177. * Create a new geometry from persisted data (Using .babylon file format)
  95178. * @param parsedVertexData defines the persisted data
  95179. * @param scene defines the hosting scene
  95180. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95181. * @returns the new geometry object
  95182. */
  95183. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95184. }
  95185. }
  95186. declare module BABYLON {
  95187. /**
  95188. * Define an interface for all classes that will get and set the data on vertices
  95189. */
  95190. export interface IGetSetVerticesData {
  95191. /**
  95192. * Gets a boolean indicating if specific vertex data is present
  95193. * @param kind defines the vertex data kind to use
  95194. * @returns true is data kind is present
  95195. */
  95196. isVerticesDataPresent(kind: string): boolean;
  95197. /**
  95198. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95199. * @param kind defines the data kind (Position, normal, etc...)
  95200. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95201. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95202. * @returns a float array containing vertex data
  95203. */
  95204. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95205. /**
  95206. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95207. * @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.
  95208. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95209. * @returns the indices array or an empty array if the mesh has no geometry
  95210. */
  95211. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95212. /**
  95213. * Set specific vertex data
  95214. * @param kind defines the data kind (Position, normal, etc...)
  95215. * @param data defines the vertex data to use
  95216. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95217. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95218. */
  95219. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95220. /**
  95221. * Update a specific associated vertex buffer
  95222. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95223. * - VertexBuffer.PositionKind
  95224. * - VertexBuffer.UVKind
  95225. * - VertexBuffer.UV2Kind
  95226. * - VertexBuffer.UV3Kind
  95227. * - VertexBuffer.UV4Kind
  95228. * - VertexBuffer.UV5Kind
  95229. * - VertexBuffer.UV6Kind
  95230. * - VertexBuffer.ColorKind
  95231. * - VertexBuffer.MatricesIndicesKind
  95232. * - VertexBuffer.MatricesIndicesExtraKind
  95233. * - VertexBuffer.MatricesWeightsKind
  95234. * - VertexBuffer.MatricesWeightsExtraKind
  95235. * @param data defines the data source
  95236. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95237. * @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)
  95238. */
  95239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95240. /**
  95241. * Creates a new index buffer
  95242. * @param indices defines the indices to store in the index buffer
  95243. * @param totalVertices defines the total number of vertices (could be null)
  95244. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95245. */
  95246. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95247. }
  95248. /**
  95249. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95250. */
  95251. export class VertexData {
  95252. /**
  95253. * Mesh side orientation : usually the external or front surface
  95254. */
  95255. static readonly FRONTSIDE: number;
  95256. /**
  95257. * Mesh side orientation : usually the internal or back surface
  95258. */
  95259. static readonly BACKSIDE: number;
  95260. /**
  95261. * Mesh side orientation : both internal and external or front and back surfaces
  95262. */
  95263. static readonly DOUBLESIDE: number;
  95264. /**
  95265. * Mesh side orientation : by default, `FRONTSIDE`
  95266. */
  95267. static readonly DEFAULTSIDE: number;
  95268. /**
  95269. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95270. */
  95271. positions: Nullable<FloatArray>;
  95272. /**
  95273. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95274. */
  95275. normals: Nullable<FloatArray>;
  95276. /**
  95277. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95278. */
  95279. tangents: Nullable<FloatArray>;
  95280. /**
  95281. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95282. */
  95283. uvs: Nullable<FloatArray>;
  95284. /**
  95285. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95286. */
  95287. uvs2: Nullable<FloatArray>;
  95288. /**
  95289. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95290. */
  95291. uvs3: Nullable<FloatArray>;
  95292. /**
  95293. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95294. */
  95295. uvs4: Nullable<FloatArray>;
  95296. /**
  95297. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95298. */
  95299. uvs5: Nullable<FloatArray>;
  95300. /**
  95301. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95302. */
  95303. uvs6: Nullable<FloatArray>;
  95304. /**
  95305. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95306. */
  95307. colors: Nullable<FloatArray>;
  95308. /**
  95309. * 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).
  95310. */
  95311. matricesIndices: Nullable<FloatArray>;
  95312. /**
  95313. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95314. */
  95315. matricesWeights: Nullable<FloatArray>;
  95316. /**
  95317. * An array extending the number of possible indices
  95318. */
  95319. matricesIndicesExtra: Nullable<FloatArray>;
  95320. /**
  95321. * An array extending the number of possible weights when the number of indices is extended
  95322. */
  95323. matricesWeightsExtra: Nullable<FloatArray>;
  95324. /**
  95325. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95326. */
  95327. indices: Nullable<IndicesArray>;
  95328. /**
  95329. * Uses the passed data array to set the set the values for the specified kind of data
  95330. * @param data a linear array of floating numbers
  95331. * @param kind the type of data that is being set, eg positions, colors etc
  95332. */
  95333. set(data: FloatArray, kind: string): void;
  95334. /**
  95335. * Associates the vertexData to the passed Mesh.
  95336. * Sets it as updatable or not (default `false`)
  95337. * @param mesh the mesh the vertexData is applied to
  95338. * @param updatable when used and having the value true allows new data to update the vertexData
  95339. * @returns the VertexData
  95340. */
  95341. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95342. /**
  95343. * Associates the vertexData to the passed Geometry.
  95344. * Sets it as updatable or not (default `false`)
  95345. * @param geometry the geometry the vertexData is applied to
  95346. * @param updatable when used and having the value true allows new data to update the vertexData
  95347. * @returns VertexData
  95348. */
  95349. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95350. /**
  95351. * Updates the associated mesh
  95352. * @param mesh the mesh to be updated
  95353. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95354. * @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
  95355. * @returns VertexData
  95356. */
  95357. updateMesh(mesh: Mesh): VertexData;
  95358. /**
  95359. * Updates the associated geometry
  95360. * @param geometry the geometry to be updated
  95361. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95362. * @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
  95363. * @returns VertexData.
  95364. */
  95365. updateGeometry(geometry: Geometry): VertexData;
  95366. private _applyTo;
  95367. private _update;
  95368. /**
  95369. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95370. * @param matrix the transforming matrix
  95371. * @returns the VertexData
  95372. */
  95373. transform(matrix: Matrix): VertexData;
  95374. /**
  95375. * Merges the passed VertexData into the current one
  95376. * @param other the VertexData to be merged into the current one
  95377. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95378. * @returns the modified VertexData
  95379. */
  95380. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95381. private _mergeElement;
  95382. private _validate;
  95383. /**
  95384. * Serializes the VertexData
  95385. * @returns a serialized object
  95386. */
  95387. serialize(): any;
  95388. /**
  95389. * Extracts the vertexData from a mesh
  95390. * @param mesh the mesh from which to extract the VertexData
  95391. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95392. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95393. * @returns the object VertexData associated to the passed mesh
  95394. */
  95395. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95396. /**
  95397. * Extracts the vertexData from the geometry
  95398. * @param geometry the geometry from which to extract the VertexData
  95399. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95400. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95401. * @returns the object VertexData associated to the passed mesh
  95402. */
  95403. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95404. private static _ExtractFrom;
  95405. /**
  95406. * Creates the VertexData for a Ribbon
  95407. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95408. * * pathArray array of paths, each of which an array of successive Vector3
  95409. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95410. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95411. * * 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
  95412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95413. * * 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)
  95414. * * 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)
  95415. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95416. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95417. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95418. * @returns the VertexData of the ribbon
  95419. */
  95420. static CreateRibbon(options: {
  95421. pathArray: Vector3[][];
  95422. closeArray?: boolean;
  95423. closePath?: boolean;
  95424. offset?: number;
  95425. sideOrientation?: number;
  95426. frontUVs?: Vector4;
  95427. backUVs?: Vector4;
  95428. invertUV?: boolean;
  95429. uvs?: Vector2[];
  95430. colors?: Color4[];
  95431. }): VertexData;
  95432. /**
  95433. * Creates the VertexData for a box
  95434. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95435. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95436. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95437. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95438. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95439. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95440. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95442. * * 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)
  95443. * * 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)
  95444. * @returns the VertexData of the box
  95445. */
  95446. static CreateBox(options: {
  95447. size?: number;
  95448. width?: number;
  95449. height?: number;
  95450. depth?: number;
  95451. faceUV?: Vector4[];
  95452. faceColors?: Color4[];
  95453. sideOrientation?: number;
  95454. frontUVs?: Vector4;
  95455. backUVs?: Vector4;
  95456. }): VertexData;
  95457. /**
  95458. * Creates the VertexData for a tiled box
  95459. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95460. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95461. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95462. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95464. * @returns the VertexData of the box
  95465. */
  95466. static CreateTiledBox(options: {
  95467. pattern?: number;
  95468. width?: number;
  95469. height?: number;
  95470. depth?: number;
  95471. tileSize?: number;
  95472. tileWidth?: number;
  95473. tileHeight?: number;
  95474. alignHorizontal?: number;
  95475. alignVertical?: number;
  95476. faceUV?: Vector4[];
  95477. faceColors?: Color4[];
  95478. sideOrientation?: number;
  95479. }): VertexData;
  95480. /**
  95481. * Creates the VertexData for a tiled plane
  95482. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95483. * * pattern a limited pattern arrangement depending on the number
  95484. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95485. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95486. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95488. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  95489. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  95490. * @returns the VertexData of the tiled plane
  95491. */
  95492. static CreateTiledPlane(options: {
  95493. pattern?: number;
  95494. tileSize?: number;
  95495. tileWidth?: number;
  95496. tileHeight?: number;
  95497. size?: number;
  95498. width?: number;
  95499. height?: number;
  95500. alignHorizontal?: number;
  95501. alignVertical?: number;
  95502. sideOrientation?: number;
  95503. frontUVs?: Vector4;
  95504. backUVs?: Vector4;
  95505. }): VertexData;
  95506. /**
  95507. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95508. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95509. * * segments sets the number of horizontal strips optional, default 32
  95510. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95511. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95512. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95513. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95514. * * 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
  95515. * * 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
  95516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95517. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  95518. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  95519. * @returns the VertexData of the ellipsoid
  95520. */
  95521. static CreateSphere(options: {
  95522. segments?: number;
  95523. diameter?: number;
  95524. diameterX?: number;
  95525. diameterY?: number;
  95526. diameterZ?: number;
  95527. arc?: number;
  95528. slice?: number;
  95529. sideOrientation?: number;
  95530. frontUVs?: Vector4;
  95531. backUVs?: Vector4;
  95532. }): VertexData;
  95533. /**
  95534. * Creates the VertexData for a cylinder, cone or prism
  95535. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95536. * * height sets the height (y direction) of the cylinder, optional, default 2
  95537. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95538. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95539. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95540. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95541. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95542. * * 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
  95543. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95544. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95545. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95546. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95548. * * 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)
  95549. * * 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)
  95550. * @returns the VertexData of the cylinder, cone or prism
  95551. */
  95552. static CreateCylinder(options: {
  95553. height?: number;
  95554. diameterTop?: number;
  95555. diameterBottom?: number;
  95556. diameter?: number;
  95557. tessellation?: number;
  95558. subdivisions?: number;
  95559. arc?: number;
  95560. faceColors?: Color4[];
  95561. faceUV?: Vector4[];
  95562. hasRings?: boolean;
  95563. enclose?: boolean;
  95564. sideOrientation?: number;
  95565. frontUVs?: Vector4;
  95566. backUVs?: Vector4;
  95567. }): VertexData;
  95568. /**
  95569. * Creates the VertexData for a torus
  95570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95571. * * diameter the diameter of the torus, optional default 1
  95572. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95573. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95574. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95575. * * 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)
  95576. * * 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)
  95577. * @returns the VertexData of the torus
  95578. */
  95579. static CreateTorus(options: {
  95580. diameter?: number;
  95581. thickness?: number;
  95582. tessellation?: number;
  95583. sideOrientation?: number;
  95584. frontUVs?: Vector4;
  95585. backUVs?: Vector4;
  95586. }): VertexData;
  95587. /**
  95588. * Creates the VertexData of the LineSystem
  95589. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95590. * - lines an array of lines, each line being an array of successive Vector3
  95591. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95592. * @returns the VertexData of the LineSystem
  95593. */
  95594. static CreateLineSystem(options: {
  95595. lines: Vector3[][];
  95596. colors?: Nullable<Color4[][]>;
  95597. }): VertexData;
  95598. /**
  95599. * Create the VertexData for a DashedLines
  95600. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95601. * - points an array successive Vector3
  95602. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95603. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95604. * - dashNb the intended total number of dashes, optional, default 200
  95605. * @returns the VertexData for the DashedLines
  95606. */
  95607. static CreateDashedLines(options: {
  95608. points: Vector3[];
  95609. dashSize?: number;
  95610. gapSize?: number;
  95611. dashNb?: number;
  95612. }): VertexData;
  95613. /**
  95614. * Creates the VertexData for a Ground
  95615. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95616. * - width the width (x direction) of the ground, optional, default 1
  95617. * - height the height (z direction) of the ground, optional, default 1
  95618. * - subdivisions the number of subdivisions per side, optional, default 1
  95619. * @returns the VertexData of the Ground
  95620. */
  95621. static CreateGround(options: {
  95622. width?: number;
  95623. height?: number;
  95624. subdivisions?: number;
  95625. subdivisionsX?: number;
  95626. subdivisionsY?: number;
  95627. }): VertexData;
  95628. /**
  95629. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95630. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95631. * * xmin the ground minimum X coordinate, optional, default -1
  95632. * * zmin the ground minimum Z coordinate, optional, default -1
  95633. * * xmax the ground maximum X coordinate, optional, default 1
  95634. * * zmax the ground maximum Z coordinate, optional, default 1
  95635. * * 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}
  95636. * * 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}
  95637. * @returns the VertexData of the TiledGround
  95638. */
  95639. static CreateTiledGround(options: {
  95640. xmin: number;
  95641. zmin: number;
  95642. xmax: number;
  95643. zmax: number;
  95644. subdivisions?: {
  95645. w: number;
  95646. h: number;
  95647. };
  95648. precision?: {
  95649. w: number;
  95650. h: number;
  95651. };
  95652. }): VertexData;
  95653. /**
  95654. * Creates the VertexData of the Ground designed from a heightmap
  95655. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95656. * * width the width (x direction) of the ground
  95657. * * height the height (z direction) of the ground
  95658. * * subdivisions the number of subdivisions per side
  95659. * * minHeight the minimum altitude on the ground, optional, default 0
  95660. * * maxHeight the maximum altitude on the ground, optional default 1
  95661. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95662. * * buffer the array holding the image color data
  95663. * * bufferWidth the width of image
  95664. * * bufferHeight the height of image
  95665. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95666. * @returns the VertexData of the Ground designed from a heightmap
  95667. */
  95668. static CreateGroundFromHeightMap(options: {
  95669. width: number;
  95670. height: number;
  95671. subdivisions: number;
  95672. minHeight: number;
  95673. maxHeight: number;
  95674. colorFilter: Color3;
  95675. buffer: Uint8Array;
  95676. bufferWidth: number;
  95677. bufferHeight: number;
  95678. alphaFilter: number;
  95679. }): VertexData;
  95680. /**
  95681. * Creates the VertexData for a Plane
  95682. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95683. * * size sets the width and height of the plane to the value of size, optional default 1
  95684. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95685. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95687. * * 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)
  95688. * * 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)
  95689. * @returns the VertexData of the box
  95690. */
  95691. static CreatePlane(options: {
  95692. size?: number;
  95693. width?: number;
  95694. height?: number;
  95695. sideOrientation?: number;
  95696. frontUVs?: Vector4;
  95697. backUVs?: Vector4;
  95698. }): VertexData;
  95699. /**
  95700. * Creates the VertexData of the Disc or regular Polygon
  95701. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95702. * * radius the radius of the disc, optional default 0.5
  95703. * * tessellation the number of polygon sides, optional, default 64
  95704. * * 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
  95705. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95706. * * 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)
  95707. * * 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)
  95708. * @returns the VertexData of the box
  95709. */
  95710. static CreateDisc(options: {
  95711. radius?: number;
  95712. tessellation?: number;
  95713. arc?: number;
  95714. sideOrientation?: number;
  95715. frontUVs?: Vector4;
  95716. backUVs?: Vector4;
  95717. }): VertexData;
  95718. /**
  95719. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95720. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95721. * @param polygon a mesh built from polygonTriangulation.build()
  95722. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95723. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95724. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95725. * @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)
  95726. * @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)
  95727. * @returns the VertexData of the Polygon
  95728. */
  95729. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95730. /**
  95731. * Creates the VertexData of the IcoSphere
  95732. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95733. * * radius the radius of the IcoSphere, optional default 1
  95734. * * radiusX allows stretching in the x direction, optional, default radius
  95735. * * radiusY allows stretching in the y direction, optional, default radius
  95736. * * radiusZ allows stretching in the z direction, optional, default radius
  95737. * * flat when true creates a flat shaded mesh, optional, default true
  95738. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95740. * * 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)
  95741. * * 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)
  95742. * @returns the VertexData of the IcoSphere
  95743. */
  95744. static CreateIcoSphere(options: {
  95745. radius?: number;
  95746. radiusX?: number;
  95747. radiusY?: number;
  95748. radiusZ?: number;
  95749. flat?: boolean;
  95750. subdivisions?: number;
  95751. sideOrientation?: number;
  95752. frontUVs?: Vector4;
  95753. backUVs?: Vector4;
  95754. }): VertexData;
  95755. /**
  95756. * Creates the VertexData for a Polyhedron
  95757. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95758. * * type provided types are:
  95759. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95760. * * 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)
  95761. * * size the size of the IcoSphere, optional default 1
  95762. * * sizeX allows stretching in the x direction, optional, default size
  95763. * * sizeY allows stretching in the y direction, optional, default size
  95764. * * sizeZ allows stretching in the z direction, optional, default size
  95765. * * 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
  95766. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95767. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95768. * * flat when true creates a flat shaded mesh, optional, default true
  95769. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95770. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95771. * * 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)
  95772. * * 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)
  95773. * @returns the VertexData of the Polyhedron
  95774. */
  95775. static CreatePolyhedron(options: {
  95776. type?: number;
  95777. size?: number;
  95778. sizeX?: number;
  95779. sizeY?: number;
  95780. sizeZ?: number;
  95781. custom?: any;
  95782. faceUV?: Vector4[];
  95783. faceColors?: Color4[];
  95784. flat?: boolean;
  95785. sideOrientation?: number;
  95786. frontUVs?: Vector4;
  95787. backUVs?: Vector4;
  95788. }): VertexData;
  95789. /**
  95790. * Creates the VertexData for a TorusKnot
  95791. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95792. * * radius the radius of the torus knot, optional, default 2
  95793. * * tube the thickness of the tube, optional, default 0.5
  95794. * * radialSegments the number of sides on each tube segments, optional, default 32
  95795. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95796. * * p the number of windings around the z axis, optional, default 2
  95797. * * q the number of windings around the x axis, optional, default 3
  95798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95799. * * 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)
  95800. * * 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)
  95801. * @returns the VertexData of the Torus Knot
  95802. */
  95803. static CreateTorusKnot(options: {
  95804. radius?: number;
  95805. tube?: number;
  95806. radialSegments?: number;
  95807. tubularSegments?: number;
  95808. p?: number;
  95809. q?: number;
  95810. sideOrientation?: number;
  95811. frontUVs?: Vector4;
  95812. backUVs?: Vector4;
  95813. }): VertexData;
  95814. /**
  95815. * Compute normals for given positions and indices
  95816. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95817. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95818. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95819. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95820. * * facetNormals : optional array of facet normals (vector3)
  95821. * * facetPositions : optional array of facet positions (vector3)
  95822. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95823. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95824. * * bInfo : optional bounding info, required for facetPartitioning computation
  95825. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95826. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95827. * * useRightHandedSystem: optional boolean to for right handed system computation
  95828. * * depthSort : optional boolean to enable the facet depth sort computation
  95829. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95830. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95831. */
  95832. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95833. facetNormals?: any;
  95834. facetPositions?: any;
  95835. facetPartitioning?: any;
  95836. ratio?: number;
  95837. bInfo?: any;
  95838. bbSize?: Vector3;
  95839. subDiv?: any;
  95840. useRightHandedSystem?: boolean;
  95841. depthSort?: boolean;
  95842. distanceTo?: Vector3;
  95843. depthSortedFacets?: any;
  95844. }): void;
  95845. /** @hidden */
  95846. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95847. /**
  95848. * Applies VertexData created from the imported parameters to the geometry
  95849. * @param parsedVertexData the parsed data from an imported file
  95850. * @param geometry the geometry to apply the VertexData to
  95851. */
  95852. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95853. }
  95854. }
  95855. declare module BABYLON {
  95856. /**
  95857. * Defines a target to use with MorphTargetManager
  95858. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95859. */
  95860. export class MorphTarget implements IAnimatable {
  95861. /** defines the name of the target */
  95862. name: string;
  95863. /**
  95864. * Gets or sets the list of animations
  95865. */
  95866. animations: Animation[];
  95867. private _scene;
  95868. private _positions;
  95869. private _normals;
  95870. private _tangents;
  95871. private _uvs;
  95872. private _influence;
  95873. private _uniqueId;
  95874. /**
  95875. * Observable raised when the influence changes
  95876. */
  95877. onInfluenceChanged: Observable<boolean>;
  95878. /** @hidden */
  95879. _onDataLayoutChanged: Observable<void>;
  95880. /**
  95881. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95882. */
  95883. get influence(): number;
  95884. set influence(influence: number);
  95885. /**
  95886. * Gets or sets the id of the morph Target
  95887. */
  95888. id: string;
  95889. private _animationPropertiesOverride;
  95890. /**
  95891. * Gets or sets the animation properties override
  95892. */
  95893. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95894. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95895. /**
  95896. * Creates a new MorphTarget
  95897. * @param name defines the name of the target
  95898. * @param influence defines the influence to use
  95899. * @param scene defines the scene the morphtarget belongs to
  95900. */
  95901. constructor(
  95902. /** defines the name of the target */
  95903. name: string, influence?: number, scene?: Nullable<Scene>);
  95904. /**
  95905. * Gets the unique ID of this manager
  95906. */
  95907. get uniqueId(): number;
  95908. /**
  95909. * Gets a boolean defining if the target contains position data
  95910. */
  95911. get hasPositions(): boolean;
  95912. /**
  95913. * Gets a boolean defining if the target contains normal data
  95914. */
  95915. get hasNormals(): boolean;
  95916. /**
  95917. * Gets a boolean defining if the target contains tangent data
  95918. */
  95919. get hasTangents(): boolean;
  95920. /**
  95921. * Gets a boolean defining if the target contains texture coordinates data
  95922. */
  95923. get hasUVs(): boolean;
  95924. /**
  95925. * Affects position data to this target
  95926. * @param data defines the position data to use
  95927. */
  95928. setPositions(data: Nullable<FloatArray>): void;
  95929. /**
  95930. * Gets the position data stored in this target
  95931. * @returns a FloatArray containing the position data (or null if not present)
  95932. */
  95933. getPositions(): Nullable<FloatArray>;
  95934. /**
  95935. * Affects normal data to this target
  95936. * @param data defines the normal data to use
  95937. */
  95938. setNormals(data: Nullable<FloatArray>): void;
  95939. /**
  95940. * Gets the normal data stored in this target
  95941. * @returns a FloatArray containing the normal data (or null if not present)
  95942. */
  95943. getNormals(): Nullable<FloatArray>;
  95944. /**
  95945. * Affects tangent data to this target
  95946. * @param data defines the tangent data to use
  95947. */
  95948. setTangents(data: Nullable<FloatArray>): void;
  95949. /**
  95950. * Gets the tangent data stored in this target
  95951. * @returns a FloatArray containing the tangent data (or null if not present)
  95952. */
  95953. getTangents(): Nullable<FloatArray>;
  95954. /**
  95955. * Affects texture coordinates data to this target
  95956. * @param data defines the texture coordinates data to use
  95957. */
  95958. setUVs(data: Nullable<FloatArray>): void;
  95959. /**
  95960. * Gets the texture coordinates data stored in this target
  95961. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95962. */
  95963. getUVs(): Nullable<FloatArray>;
  95964. /**
  95965. * Clone the current target
  95966. * @returns a new MorphTarget
  95967. */
  95968. clone(): MorphTarget;
  95969. /**
  95970. * Serializes the current target into a Serialization object
  95971. * @returns the serialized object
  95972. */
  95973. serialize(): any;
  95974. /**
  95975. * Returns the string "MorphTarget"
  95976. * @returns "MorphTarget"
  95977. */
  95978. getClassName(): string;
  95979. /**
  95980. * Creates a new target from serialized data
  95981. * @param serializationObject defines the serialized data to use
  95982. * @returns a new MorphTarget
  95983. */
  95984. static Parse(serializationObject: any): MorphTarget;
  95985. /**
  95986. * Creates a MorphTarget from mesh data
  95987. * @param mesh defines the source mesh
  95988. * @param name defines the name to use for the new target
  95989. * @param influence defines the influence to attach to the target
  95990. * @returns a new MorphTarget
  95991. */
  95992. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95993. }
  95994. }
  95995. declare module BABYLON {
  95996. /**
  95997. * This class is used to deform meshes using morphing between different targets
  95998. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95999. */
  96000. export class MorphTargetManager {
  96001. private _targets;
  96002. private _targetInfluenceChangedObservers;
  96003. private _targetDataLayoutChangedObservers;
  96004. private _activeTargets;
  96005. private _scene;
  96006. private _influences;
  96007. private _supportsNormals;
  96008. private _supportsTangents;
  96009. private _supportsUVs;
  96010. private _vertexCount;
  96011. private _uniqueId;
  96012. private _tempInfluences;
  96013. /**
  96014. * Gets or sets a boolean indicating if normals must be morphed
  96015. */
  96016. enableNormalMorphing: boolean;
  96017. /**
  96018. * Gets or sets a boolean indicating if tangents must be morphed
  96019. */
  96020. enableTangentMorphing: boolean;
  96021. /**
  96022. * Gets or sets a boolean indicating if UV must be morphed
  96023. */
  96024. enableUVMorphing: boolean;
  96025. /**
  96026. * Creates a new MorphTargetManager
  96027. * @param scene defines the current scene
  96028. */
  96029. constructor(scene?: Nullable<Scene>);
  96030. /**
  96031. * Gets the unique ID of this manager
  96032. */
  96033. get uniqueId(): number;
  96034. /**
  96035. * Gets the number of vertices handled by this manager
  96036. */
  96037. get vertexCount(): number;
  96038. /**
  96039. * Gets a boolean indicating if this manager supports morphing of normals
  96040. */
  96041. get supportsNormals(): boolean;
  96042. /**
  96043. * Gets a boolean indicating if this manager supports morphing of tangents
  96044. */
  96045. get supportsTangents(): boolean;
  96046. /**
  96047. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96048. */
  96049. get supportsUVs(): boolean;
  96050. /**
  96051. * Gets the number of targets stored in this manager
  96052. */
  96053. get numTargets(): number;
  96054. /**
  96055. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96056. */
  96057. get numInfluencers(): number;
  96058. /**
  96059. * Gets the list of influences (one per target)
  96060. */
  96061. get influences(): Float32Array;
  96062. /**
  96063. * Gets the active target at specified index. An active target is a target with an influence > 0
  96064. * @param index defines the index to check
  96065. * @returns the requested target
  96066. */
  96067. getActiveTarget(index: number): MorphTarget;
  96068. /**
  96069. * Gets the target at specified index
  96070. * @param index defines the index to check
  96071. * @returns the requested target
  96072. */
  96073. getTarget(index: number): MorphTarget;
  96074. /**
  96075. * Add a new target to this manager
  96076. * @param target defines the target to add
  96077. */
  96078. addTarget(target: MorphTarget): void;
  96079. /**
  96080. * Removes a target from the manager
  96081. * @param target defines the target to remove
  96082. */
  96083. removeTarget(target: MorphTarget): void;
  96084. /**
  96085. * Clone the current manager
  96086. * @returns a new MorphTargetManager
  96087. */
  96088. clone(): MorphTargetManager;
  96089. /**
  96090. * Serializes the current manager into a Serialization object
  96091. * @returns the serialized object
  96092. */
  96093. serialize(): any;
  96094. private _syncActiveTargets;
  96095. /**
  96096. * Syncrhonize the targets with all the meshes using this morph target manager
  96097. */
  96098. synchronize(): void;
  96099. /**
  96100. * Creates a new MorphTargetManager from serialized data
  96101. * @param serializationObject defines the serialized data
  96102. * @param scene defines the hosting scene
  96103. * @returns the new MorphTargetManager
  96104. */
  96105. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96106. }
  96107. }
  96108. declare module BABYLON {
  96109. /**
  96110. * Class used to represent a specific level of detail of a mesh
  96111. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96112. */
  96113. export class MeshLODLevel {
  96114. /** Defines the distance where this level should start being displayed */
  96115. distance: number;
  96116. /** Defines the mesh to use to render this level */
  96117. mesh: Nullable<Mesh>;
  96118. /**
  96119. * Creates a new LOD level
  96120. * @param distance defines the distance where this level should star being displayed
  96121. * @param mesh defines the mesh to use to render this level
  96122. */
  96123. constructor(
  96124. /** Defines the distance where this level should start being displayed */
  96125. distance: number,
  96126. /** Defines the mesh to use to render this level */
  96127. mesh: Nullable<Mesh>);
  96128. }
  96129. }
  96130. declare module BABYLON {
  96131. /**
  96132. * Mesh representing the gorund
  96133. */
  96134. export class GroundMesh extends Mesh {
  96135. /** If octree should be generated */
  96136. generateOctree: boolean;
  96137. private _heightQuads;
  96138. /** @hidden */
  96139. _subdivisionsX: number;
  96140. /** @hidden */
  96141. _subdivisionsY: number;
  96142. /** @hidden */
  96143. _width: number;
  96144. /** @hidden */
  96145. _height: number;
  96146. /** @hidden */
  96147. _minX: number;
  96148. /** @hidden */
  96149. _maxX: number;
  96150. /** @hidden */
  96151. _minZ: number;
  96152. /** @hidden */
  96153. _maxZ: number;
  96154. constructor(name: string, scene: Scene);
  96155. /**
  96156. * "GroundMesh"
  96157. * @returns "GroundMesh"
  96158. */
  96159. getClassName(): string;
  96160. /**
  96161. * The minimum of x and y subdivisions
  96162. */
  96163. get subdivisions(): number;
  96164. /**
  96165. * X subdivisions
  96166. */
  96167. get subdivisionsX(): number;
  96168. /**
  96169. * Y subdivisions
  96170. */
  96171. get subdivisionsY(): number;
  96172. /**
  96173. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96174. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96175. * @param chunksCount the number of subdivisions for x and y
  96176. * @param octreeBlocksSize (Default: 32)
  96177. */
  96178. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96179. /**
  96180. * Returns a height (y) value in the Worl system :
  96181. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96182. * @param x x coordinate
  96183. * @param z z coordinate
  96184. * @returns the ground y position if (x, z) are outside the ground surface.
  96185. */
  96186. getHeightAtCoordinates(x: number, z: number): number;
  96187. /**
  96188. * Returns a normalized vector (Vector3) orthogonal to the ground
  96189. * at the ground coordinates (x, z) expressed in the World system.
  96190. * @param x x coordinate
  96191. * @param z z coordinate
  96192. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96193. */
  96194. getNormalAtCoordinates(x: number, z: number): Vector3;
  96195. /**
  96196. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96197. * at the ground coordinates (x, z) expressed in the World system.
  96198. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96199. * @param x x coordinate
  96200. * @param z z coordinate
  96201. * @param ref vector to store the result
  96202. * @returns the GroundMesh.
  96203. */
  96204. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96205. /**
  96206. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96207. * if the ground has been updated.
  96208. * This can be used in the render loop.
  96209. * @returns the GroundMesh.
  96210. */
  96211. updateCoordinateHeights(): GroundMesh;
  96212. private _getFacetAt;
  96213. private _initHeightQuads;
  96214. private _computeHeightQuads;
  96215. /**
  96216. * Serializes this ground mesh
  96217. * @param serializationObject object to write serialization to
  96218. */
  96219. serialize(serializationObject: any): void;
  96220. /**
  96221. * Parses a serialized ground mesh
  96222. * @param parsedMesh the serialized mesh
  96223. * @param scene the scene to create the ground mesh in
  96224. * @returns the created ground mesh
  96225. */
  96226. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96227. }
  96228. }
  96229. declare module BABYLON {
  96230. /**
  96231. * Interface for Physics-Joint data
  96232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96233. */
  96234. export interface PhysicsJointData {
  96235. /**
  96236. * The main pivot of the joint
  96237. */
  96238. mainPivot?: Vector3;
  96239. /**
  96240. * The connected pivot of the joint
  96241. */
  96242. connectedPivot?: Vector3;
  96243. /**
  96244. * The main axis of the joint
  96245. */
  96246. mainAxis?: Vector3;
  96247. /**
  96248. * The connected axis of the joint
  96249. */
  96250. connectedAxis?: Vector3;
  96251. /**
  96252. * The collision of the joint
  96253. */
  96254. collision?: boolean;
  96255. /**
  96256. * Native Oimo/Cannon/Energy data
  96257. */
  96258. nativeParams?: any;
  96259. }
  96260. /**
  96261. * This is a holder class for the physics joint created by the physics plugin
  96262. * It holds a set of functions to control the underlying joint
  96263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96264. */
  96265. export class PhysicsJoint {
  96266. /**
  96267. * The type of the physics joint
  96268. */
  96269. type: number;
  96270. /**
  96271. * The data for the physics joint
  96272. */
  96273. jointData: PhysicsJointData;
  96274. private _physicsJoint;
  96275. protected _physicsPlugin: IPhysicsEnginePlugin;
  96276. /**
  96277. * Initializes the physics joint
  96278. * @param type The type of the physics joint
  96279. * @param jointData The data for the physics joint
  96280. */
  96281. constructor(
  96282. /**
  96283. * The type of the physics joint
  96284. */
  96285. type: number,
  96286. /**
  96287. * The data for the physics joint
  96288. */
  96289. jointData: PhysicsJointData);
  96290. /**
  96291. * Gets the physics joint
  96292. */
  96293. get physicsJoint(): any;
  96294. /**
  96295. * Sets the physics joint
  96296. */
  96297. set physicsJoint(newJoint: any);
  96298. /**
  96299. * Sets the physics plugin
  96300. */
  96301. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96302. /**
  96303. * Execute a function that is physics-plugin specific.
  96304. * @param {Function} func the function that will be executed.
  96305. * It accepts two parameters: the physics world and the physics joint
  96306. */
  96307. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96308. /**
  96309. * Distance-Joint type
  96310. */
  96311. static DistanceJoint: number;
  96312. /**
  96313. * Hinge-Joint type
  96314. */
  96315. static HingeJoint: number;
  96316. /**
  96317. * Ball-and-Socket joint type
  96318. */
  96319. static BallAndSocketJoint: number;
  96320. /**
  96321. * Wheel-Joint type
  96322. */
  96323. static WheelJoint: number;
  96324. /**
  96325. * Slider-Joint type
  96326. */
  96327. static SliderJoint: number;
  96328. /**
  96329. * Prismatic-Joint type
  96330. */
  96331. static PrismaticJoint: number;
  96332. /**
  96333. * Universal-Joint type
  96334. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96335. */
  96336. static UniversalJoint: number;
  96337. /**
  96338. * Hinge-Joint 2 type
  96339. */
  96340. static Hinge2Joint: number;
  96341. /**
  96342. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96343. */
  96344. static PointToPointJoint: number;
  96345. /**
  96346. * Spring-Joint type
  96347. */
  96348. static SpringJoint: number;
  96349. /**
  96350. * Lock-Joint type
  96351. */
  96352. static LockJoint: number;
  96353. }
  96354. /**
  96355. * A class representing a physics distance joint
  96356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96357. */
  96358. export class DistanceJoint extends PhysicsJoint {
  96359. /**
  96360. *
  96361. * @param jointData The data for the Distance-Joint
  96362. */
  96363. constructor(jointData: DistanceJointData);
  96364. /**
  96365. * Update the predefined distance.
  96366. * @param maxDistance The maximum preferred distance
  96367. * @param minDistance The minimum preferred distance
  96368. */
  96369. updateDistance(maxDistance: number, minDistance?: number): void;
  96370. }
  96371. /**
  96372. * Represents a Motor-Enabled Joint
  96373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96374. */
  96375. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96376. /**
  96377. * Initializes the Motor-Enabled Joint
  96378. * @param type The type of the joint
  96379. * @param jointData The physica joint data for the joint
  96380. */
  96381. constructor(type: number, jointData: PhysicsJointData);
  96382. /**
  96383. * Set the motor values.
  96384. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96385. * @param force the force to apply
  96386. * @param maxForce max force for this motor.
  96387. */
  96388. setMotor(force?: number, maxForce?: number): void;
  96389. /**
  96390. * Set the motor's limits.
  96391. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96392. * @param upperLimit The upper limit of the motor
  96393. * @param lowerLimit The lower limit of the motor
  96394. */
  96395. setLimit(upperLimit: number, lowerLimit?: number): void;
  96396. }
  96397. /**
  96398. * This class represents a single physics Hinge-Joint
  96399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96400. */
  96401. export class HingeJoint extends MotorEnabledJoint {
  96402. /**
  96403. * Initializes the Hinge-Joint
  96404. * @param jointData The joint data for the Hinge-Joint
  96405. */
  96406. constructor(jointData: PhysicsJointData);
  96407. /**
  96408. * Set the motor values.
  96409. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96410. * @param {number} force the force to apply
  96411. * @param {number} maxForce max force for this motor.
  96412. */
  96413. setMotor(force?: number, maxForce?: number): void;
  96414. /**
  96415. * Set the motor's limits.
  96416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96417. * @param upperLimit The upper limit of the motor
  96418. * @param lowerLimit The lower limit of the motor
  96419. */
  96420. setLimit(upperLimit: number, lowerLimit?: number): void;
  96421. }
  96422. /**
  96423. * This class represents a dual hinge physics joint (same as wheel joint)
  96424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96425. */
  96426. export class Hinge2Joint extends MotorEnabledJoint {
  96427. /**
  96428. * Initializes the Hinge2-Joint
  96429. * @param jointData The joint data for the Hinge2-Joint
  96430. */
  96431. constructor(jointData: PhysicsJointData);
  96432. /**
  96433. * Set the motor values.
  96434. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96435. * @param {number} targetSpeed the speed the motor is to reach
  96436. * @param {number} maxForce max force for this motor.
  96437. * @param {motorIndex} the motor's index, 0 or 1.
  96438. */
  96439. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96440. /**
  96441. * Set the motor limits.
  96442. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96443. * @param {number} upperLimit the upper limit
  96444. * @param {number} lowerLimit lower limit
  96445. * @param {motorIndex} the motor's index, 0 or 1.
  96446. */
  96447. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96448. }
  96449. /**
  96450. * Interface for a motor enabled joint
  96451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96452. */
  96453. export interface IMotorEnabledJoint {
  96454. /**
  96455. * Physics joint
  96456. */
  96457. physicsJoint: any;
  96458. /**
  96459. * Sets the motor of the motor-enabled joint
  96460. * @param force The force of the motor
  96461. * @param maxForce The maximum force of the motor
  96462. * @param motorIndex The index of the motor
  96463. */
  96464. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96465. /**
  96466. * Sets the limit of the motor
  96467. * @param upperLimit The upper limit of the motor
  96468. * @param lowerLimit The lower limit of the motor
  96469. * @param motorIndex The index of the motor
  96470. */
  96471. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96472. }
  96473. /**
  96474. * Joint data for a Distance-Joint
  96475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96476. */
  96477. export interface DistanceJointData extends PhysicsJointData {
  96478. /**
  96479. * Max distance the 2 joint objects can be apart
  96480. */
  96481. maxDistance: number;
  96482. }
  96483. /**
  96484. * Joint data from a spring joint
  96485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96486. */
  96487. export interface SpringJointData extends PhysicsJointData {
  96488. /**
  96489. * Length of the spring
  96490. */
  96491. length: number;
  96492. /**
  96493. * Stiffness of the spring
  96494. */
  96495. stiffness: number;
  96496. /**
  96497. * Damping of the spring
  96498. */
  96499. damping: number;
  96500. /** this callback will be called when applying the force to the impostors. */
  96501. forceApplicationCallback: () => void;
  96502. }
  96503. }
  96504. declare module BABYLON {
  96505. /**
  96506. * Holds the data for the raycast result
  96507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96508. */
  96509. export class PhysicsRaycastResult {
  96510. private _hasHit;
  96511. private _hitDistance;
  96512. private _hitNormalWorld;
  96513. private _hitPointWorld;
  96514. private _rayFromWorld;
  96515. private _rayToWorld;
  96516. /**
  96517. * Gets if there was a hit
  96518. */
  96519. get hasHit(): boolean;
  96520. /**
  96521. * Gets the distance from the hit
  96522. */
  96523. get hitDistance(): number;
  96524. /**
  96525. * Gets the hit normal/direction in the world
  96526. */
  96527. get hitNormalWorld(): Vector3;
  96528. /**
  96529. * Gets the hit point in the world
  96530. */
  96531. get hitPointWorld(): Vector3;
  96532. /**
  96533. * Gets the ray "start point" of the ray in the world
  96534. */
  96535. get rayFromWorld(): Vector3;
  96536. /**
  96537. * Gets the ray "end point" of the ray in the world
  96538. */
  96539. get rayToWorld(): Vector3;
  96540. /**
  96541. * Sets the hit data (normal & point in world space)
  96542. * @param hitNormalWorld defines the normal in world space
  96543. * @param hitPointWorld defines the point in world space
  96544. */
  96545. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96546. /**
  96547. * Sets the distance from the start point to the hit point
  96548. * @param distance
  96549. */
  96550. setHitDistance(distance: number): void;
  96551. /**
  96552. * Calculates the distance manually
  96553. */
  96554. calculateHitDistance(): void;
  96555. /**
  96556. * Resets all the values to default
  96557. * @param from The from point on world space
  96558. * @param to The to point on world space
  96559. */
  96560. reset(from?: Vector3, to?: Vector3): void;
  96561. }
  96562. /**
  96563. * Interface for the size containing width and height
  96564. */
  96565. interface IXYZ {
  96566. /**
  96567. * X
  96568. */
  96569. x: number;
  96570. /**
  96571. * Y
  96572. */
  96573. y: number;
  96574. /**
  96575. * Z
  96576. */
  96577. z: number;
  96578. }
  96579. }
  96580. declare module BABYLON {
  96581. /**
  96582. * Interface used to describe a physics joint
  96583. */
  96584. export interface PhysicsImpostorJoint {
  96585. /** Defines the main impostor to which the joint is linked */
  96586. mainImpostor: PhysicsImpostor;
  96587. /** Defines the impostor that is connected to the main impostor using this joint */
  96588. connectedImpostor: PhysicsImpostor;
  96589. /** Defines the joint itself */
  96590. joint: PhysicsJoint;
  96591. }
  96592. /** @hidden */
  96593. export interface IPhysicsEnginePlugin {
  96594. world: any;
  96595. name: string;
  96596. setGravity(gravity: Vector3): void;
  96597. setTimeStep(timeStep: number): void;
  96598. getTimeStep(): number;
  96599. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96600. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96601. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96602. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96603. removePhysicsBody(impostor: PhysicsImpostor): void;
  96604. generateJoint(joint: PhysicsImpostorJoint): void;
  96605. removeJoint(joint: PhysicsImpostorJoint): void;
  96606. isSupported(): boolean;
  96607. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96608. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96609. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96610. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96611. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96612. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96613. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96614. getBodyMass(impostor: PhysicsImpostor): number;
  96615. getBodyFriction(impostor: PhysicsImpostor): number;
  96616. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96617. getBodyRestitution(impostor: PhysicsImpostor): number;
  96618. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96619. getBodyPressure?(impostor: PhysicsImpostor): number;
  96620. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96621. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96622. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96623. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96624. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96625. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96626. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96627. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96628. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96629. sleepBody(impostor: PhysicsImpostor): void;
  96630. wakeUpBody(impostor: PhysicsImpostor): void;
  96631. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96633. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96635. getRadius(impostor: PhysicsImpostor): number;
  96636. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96637. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96638. dispose(): void;
  96639. }
  96640. /**
  96641. * Interface used to define a physics engine
  96642. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96643. */
  96644. export interface IPhysicsEngine {
  96645. /**
  96646. * Gets the gravity vector used by the simulation
  96647. */
  96648. gravity: Vector3;
  96649. /**
  96650. * Sets the gravity vector used by the simulation
  96651. * @param gravity defines the gravity vector to use
  96652. */
  96653. setGravity(gravity: Vector3): void;
  96654. /**
  96655. * Set the time step of the physics engine.
  96656. * Default is 1/60.
  96657. * To slow it down, enter 1/600 for example.
  96658. * To speed it up, 1/30
  96659. * @param newTimeStep the new timestep to apply to this world.
  96660. */
  96661. setTimeStep(newTimeStep: number): void;
  96662. /**
  96663. * Get the time step of the physics engine.
  96664. * @returns the current time step
  96665. */
  96666. getTimeStep(): number;
  96667. /**
  96668. * Set the sub time step of the physics engine.
  96669. * Default is 0 meaning there is no sub steps
  96670. * To increase physics resolution precision, set a small value (like 1 ms)
  96671. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96672. */
  96673. setSubTimeStep(subTimeStep: number): void;
  96674. /**
  96675. * Get the sub time step of the physics engine.
  96676. * @returns the current sub time step
  96677. */
  96678. getSubTimeStep(): number;
  96679. /**
  96680. * Release all resources
  96681. */
  96682. dispose(): void;
  96683. /**
  96684. * Gets the name of the current physics plugin
  96685. * @returns the name of the plugin
  96686. */
  96687. getPhysicsPluginName(): string;
  96688. /**
  96689. * Adding a new impostor for the impostor tracking.
  96690. * This will be done by the impostor itself.
  96691. * @param impostor the impostor to add
  96692. */
  96693. addImpostor(impostor: PhysicsImpostor): void;
  96694. /**
  96695. * Remove an impostor from the engine.
  96696. * This impostor and its mesh will not longer be updated by the physics engine.
  96697. * @param impostor the impostor to remove
  96698. */
  96699. removeImpostor(impostor: PhysicsImpostor): void;
  96700. /**
  96701. * Add a joint to the physics engine
  96702. * @param mainImpostor defines the main impostor to which the joint is added.
  96703. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96704. * @param joint defines the joint that will connect both impostors.
  96705. */
  96706. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96707. /**
  96708. * Removes a joint from the simulation
  96709. * @param mainImpostor defines the impostor used with the joint
  96710. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96711. * @param joint defines the joint to remove
  96712. */
  96713. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96714. /**
  96715. * Gets the current plugin used to run the simulation
  96716. * @returns current plugin
  96717. */
  96718. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96719. /**
  96720. * Gets the list of physic impostors
  96721. * @returns an array of PhysicsImpostor
  96722. */
  96723. getImpostors(): Array<PhysicsImpostor>;
  96724. /**
  96725. * Gets the impostor for a physics enabled object
  96726. * @param object defines the object impersonated by the impostor
  96727. * @returns the PhysicsImpostor or null if not found
  96728. */
  96729. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96730. /**
  96731. * Gets the impostor for a physics body object
  96732. * @param body defines physics body used by the impostor
  96733. * @returns the PhysicsImpostor or null if not found
  96734. */
  96735. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96736. /**
  96737. * Does a raycast in the physics world
  96738. * @param from when should the ray start?
  96739. * @param to when should the ray end?
  96740. * @returns PhysicsRaycastResult
  96741. */
  96742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96743. /**
  96744. * Called by the scene. No need to call it.
  96745. * @param delta defines the timespam between frames
  96746. */
  96747. _step(delta: number): void;
  96748. }
  96749. }
  96750. declare module BABYLON {
  96751. /**
  96752. * The interface for the physics imposter parameters
  96753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96754. */
  96755. export interface PhysicsImpostorParameters {
  96756. /**
  96757. * The mass of the physics imposter
  96758. */
  96759. mass: number;
  96760. /**
  96761. * The friction of the physics imposter
  96762. */
  96763. friction?: number;
  96764. /**
  96765. * The coefficient of restitution of the physics imposter
  96766. */
  96767. restitution?: number;
  96768. /**
  96769. * The native options of the physics imposter
  96770. */
  96771. nativeOptions?: any;
  96772. /**
  96773. * Specifies if the parent should be ignored
  96774. */
  96775. ignoreParent?: boolean;
  96776. /**
  96777. * Specifies if bi-directional transformations should be disabled
  96778. */
  96779. disableBidirectionalTransformation?: boolean;
  96780. /**
  96781. * The pressure inside the physics imposter, soft object only
  96782. */
  96783. pressure?: number;
  96784. /**
  96785. * The stiffness the physics imposter, soft object only
  96786. */
  96787. stiffness?: number;
  96788. /**
  96789. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96790. */
  96791. velocityIterations?: number;
  96792. /**
  96793. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96794. */
  96795. positionIterations?: number;
  96796. /**
  96797. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96798. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96799. * Add to fix multiple points
  96800. */
  96801. fixedPoints?: number;
  96802. /**
  96803. * The collision margin around a soft object
  96804. */
  96805. margin?: number;
  96806. /**
  96807. * The collision margin around a soft object
  96808. */
  96809. damping?: number;
  96810. /**
  96811. * The path for a rope based on an extrusion
  96812. */
  96813. path?: any;
  96814. /**
  96815. * The shape of an extrusion used for a rope based on an extrusion
  96816. */
  96817. shape?: any;
  96818. }
  96819. /**
  96820. * Interface for a physics-enabled object
  96821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96822. */
  96823. export interface IPhysicsEnabledObject {
  96824. /**
  96825. * The position of the physics-enabled object
  96826. */
  96827. position: Vector3;
  96828. /**
  96829. * The rotation of the physics-enabled object
  96830. */
  96831. rotationQuaternion: Nullable<Quaternion>;
  96832. /**
  96833. * The scale of the physics-enabled object
  96834. */
  96835. scaling: Vector3;
  96836. /**
  96837. * The rotation of the physics-enabled object
  96838. */
  96839. rotation?: Vector3;
  96840. /**
  96841. * The parent of the physics-enabled object
  96842. */
  96843. parent?: any;
  96844. /**
  96845. * The bounding info of the physics-enabled object
  96846. * @returns The bounding info of the physics-enabled object
  96847. */
  96848. getBoundingInfo(): BoundingInfo;
  96849. /**
  96850. * Computes the world matrix
  96851. * @param force Specifies if the world matrix should be computed by force
  96852. * @returns A world matrix
  96853. */
  96854. computeWorldMatrix(force: boolean): Matrix;
  96855. /**
  96856. * Gets the world matrix
  96857. * @returns A world matrix
  96858. */
  96859. getWorldMatrix?(): Matrix;
  96860. /**
  96861. * Gets the child meshes
  96862. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96863. * @returns An array of abstract meshes
  96864. */
  96865. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96866. /**
  96867. * Gets the vertex data
  96868. * @param kind The type of vertex data
  96869. * @returns A nullable array of numbers, or a float32 array
  96870. */
  96871. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96872. /**
  96873. * Gets the indices from the mesh
  96874. * @returns A nullable array of index arrays
  96875. */
  96876. getIndices?(): Nullable<IndicesArray>;
  96877. /**
  96878. * Gets the scene from the mesh
  96879. * @returns the indices array or null
  96880. */
  96881. getScene?(): Scene;
  96882. /**
  96883. * Gets the absolute position from the mesh
  96884. * @returns the absolute position
  96885. */
  96886. getAbsolutePosition(): Vector3;
  96887. /**
  96888. * Gets the absolute pivot point from the mesh
  96889. * @returns the absolute pivot point
  96890. */
  96891. getAbsolutePivotPoint(): Vector3;
  96892. /**
  96893. * Rotates the mesh
  96894. * @param axis The axis of rotation
  96895. * @param amount The amount of rotation
  96896. * @param space The space of the rotation
  96897. * @returns The rotation transform node
  96898. */
  96899. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96900. /**
  96901. * Translates the mesh
  96902. * @param axis The axis of translation
  96903. * @param distance The distance of translation
  96904. * @param space The space of the translation
  96905. * @returns The transform node
  96906. */
  96907. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96908. /**
  96909. * Sets the absolute position of the mesh
  96910. * @param absolutePosition The absolute position of the mesh
  96911. * @returns The transform node
  96912. */
  96913. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96914. /**
  96915. * Gets the class name of the mesh
  96916. * @returns The class name
  96917. */
  96918. getClassName(): string;
  96919. }
  96920. /**
  96921. * Represents a physics imposter
  96922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96923. */
  96924. export class PhysicsImpostor {
  96925. /**
  96926. * The physics-enabled object used as the physics imposter
  96927. */
  96928. object: IPhysicsEnabledObject;
  96929. /**
  96930. * The type of the physics imposter
  96931. */
  96932. type: number;
  96933. private _options;
  96934. private _scene?;
  96935. /**
  96936. * The default object size of the imposter
  96937. */
  96938. static DEFAULT_OBJECT_SIZE: Vector3;
  96939. /**
  96940. * The identity quaternion of the imposter
  96941. */
  96942. static IDENTITY_QUATERNION: Quaternion;
  96943. /** @hidden */
  96944. _pluginData: any;
  96945. private _physicsEngine;
  96946. private _physicsBody;
  96947. private _bodyUpdateRequired;
  96948. private _onBeforePhysicsStepCallbacks;
  96949. private _onAfterPhysicsStepCallbacks;
  96950. /** @hidden */
  96951. _onPhysicsCollideCallbacks: Array<{
  96952. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96953. otherImpostors: Array<PhysicsImpostor>;
  96954. }>;
  96955. private _deltaPosition;
  96956. private _deltaRotation;
  96957. private _deltaRotationConjugated;
  96958. /** @hidden */
  96959. _isFromLine: boolean;
  96960. private _parent;
  96961. private _isDisposed;
  96962. private static _tmpVecs;
  96963. private static _tmpQuat;
  96964. /**
  96965. * Specifies if the physics imposter is disposed
  96966. */
  96967. get isDisposed(): boolean;
  96968. /**
  96969. * Gets the mass of the physics imposter
  96970. */
  96971. get mass(): number;
  96972. set mass(value: number);
  96973. /**
  96974. * Gets the coefficient of friction
  96975. */
  96976. get friction(): number;
  96977. /**
  96978. * Sets the coefficient of friction
  96979. */
  96980. set friction(value: number);
  96981. /**
  96982. * Gets the coefficient of restitution
  96983. */
  96984. get restitution(): number;
  96985. /**
  96986. * Sets the coefficient of restitution
  96987. */
  96988. set restitution(value: number);
  96989. /**
  96990. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96991. */
  96992. get pressure(): number;
  96993. /**
  96994. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96995. */
  96996. set pressure(value: number);
  96997. /**
  96998. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96999. */
  97000. get stiffness(): number;
  97001. /**
  97002. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97003. */
  97004. set stiffness(value: number);
  97005. /**
  97006. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97007. */
  97008. get velocityIterations(): number;
  97009. /**
  97010. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97011. */
  97012. set velocityIterations(value: number);
  97013. /**
  97014. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97015. */
  97016. get positionIterations(): number;
  97017. /**
  97018. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97019. */
  97020. set positionIterations(value: number);
  97021. /**
  97022. * The unique id of the physics imposter
  97023. * set by the physics engine when adding this impostor to the array
  97024. */
  97025. uniqueId: number;
  97026. /**
  97027. * @hidden
  97028. */
  97029. soft: boolean;
  97030. /**
  97031. * @hidden
  97032. */
  97033. segments: number;
  97034. private _joints;
  97035. /**
  97036. * Initializes the physics imposter
  97037. * @param object The physics-enabled object used as the physics imposter
  97038. * @param type The type of the physics imposter
  97039. * @param _options The options for the physics imposter
  97040. * @param _scene The Babylon scene
  97041. */
  97042. constructor(
  97043. /**
  97044. * The physics-enabled object used as the physics imposter
  97045. */
  97046. object: IPhysicsEnabledObject,
  97047. /**
  97048. * The type of the physics imposter
  97049. */
  97050. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97051. /**
  97052. * This function will completly initialize this impostor.
  97053. * It will create a new body - but only if this mesh has no parent.
  97054. * If it has, this impostor will not be used other than to define the impostor
  97055. * of the child mesh.
  97056. * @hidden
  97057. */
  97058. _init(): void;
  97059. private _getPhysicsParent;
  97060. /**
  97061. * Should a new body be generated.
  97062. * @returns boolean specifying if body initialization is required
  97063. */
  97064. isBodyInitRequired(): boolean;
  97065. /**
  97066. * Sets the updated scaling
  97067. * @param updated Specifies if the scaling is updated
  97068. */
  97069. setScalingUpdated(): void;
  97070. /**
  97071. * Force a regeneration of this or the parent's impostor's body.
  97072. * Use under cautious - This will remove all joints already implemented.
  97073. */
  97074. forceUpdate(): void;
  97075. /**
  97076. * Gets the body that holds this impostor. Either its own, or its parent.
  97077. */
  97078. get physicsBody(): any;
  97079. /**
  97080. * Get the parent of the physics imposter
  97081. * @returns Physics imposter or null
  97082. */
  97083. get parent(): Nullable<PhysicsImpostor>;
  97084. /**
  97085. * Sets the parent of the physics imposter
  97086. */
  97087. set parent(value: Nullable<PhysicsImpostor>);
  97088. /**
  97089. * Set the physics body. Used mainly by the physics engine/plugin
  97090. */
  97091. set physicsBody(physicsBody: any);
  97092. /**
  97093. * Resets the update flags
  97094. */
  97095. resetUpdateFlags(): void;
  97096. /**
  97097. * Gets the object extend size
  97098. * @returns the object extend size
  97099. */
  97100. getObjectExtendSize(): Vector3;
  97101. /**
  97102. * Gets the object center
  97103. * @returns The object center
  97104. */
  97105. getObjectCenter(): Vector3;
  97106. /**
  97107. * Get a specific parameter from the options parameters
  97108. * @param paramName The object parameter name
  97109. * @returns The object parameter
  97110. */
  97111. getParam(paramName: string): any;
  97112. /**
  97113. * Sets a specific parameter in the options given to the physics plugin
  97114. * @param paramName The parameter name
  97115. * @param value The value of the parameter
  97116. */
  97117. setParam(paramName: string, value: number): void;
  97118. /**
  97119. * Specifically change the body's mass option. Won't recreate the physics body object
  97120. * @param mass The mass of the physics imposter
  97121. */
  97122. setMass(mass: number): void;
  97123. /**
  97124. * Gets the linear velocity
  97125. * @returns linear velocity or null
  97126. */
  97127. getLinearVelocity(): Nullable<Vector3>;
  97128. /**
  97129. * Sets the linear velocity
  97130. * @param velocity linear velocity or null
  97131. */
  97132. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97133. /**
  97134. * Gets the angular velocity
  97135. * @returns angular velocity or null
  97136. */
  97137. getAngularVelocity(): Nullable<Vector3>;
  97138. /**
  97139. * Sets the angular velocity
  97140. * @param velocity The velocity or null
  97141. */
  97142. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97143. /**
  97144. * Execute a function with the physics plugin native code
  97145. * Provide a function the will have two variables - the world object and the physics body object
  97146. * @param func The function to execute with the physics plugin native code
  97147. */
  97148. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97149. /**
  97150. * Register a function that will be executed before the physics world is stepping forward
  97151. * @param func The function to execute before the physics world is stepped forward
  97152. */
  97153. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97154. /**
  97155. * Unregister a function that will be executed before the physics world is stepping forward
  97156. * @param func The function to execute before the physics world is stepped forward
  97157. */
  97158. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97159. /**
  97160. * Register a function that will be executed after the physics step
  97161. * @param func The function to execute after physics step
  97162. */
  97163. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97164. /**
  97165. * Unregisters a function that will be executed after the physics step
  97166. * @param func The function to execute after physics step
  97167. */
  97168. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97169. /**
  97170. * register a function that will be executed when this impostor collides against a different body
  97171. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97172. * @param func Callback that is executed on collision
  97173. */
  97174. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97175. /**
  97176. * Unregisters the physics imposter on contact
  97177. * @param collideAgainst The physics object to collide against
  97178. * @param func Callback to execute on collision
  97179. */
  97180. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97181. private _tmpQuat;
  97182. private _tmpQuat2;
  97183. /**
  97184. * Get the parent rotation
  97185. * @returns The parent rotation
  97186. */
  97187. getParentsRotation(): Quaternion;
  97188. /**
  97189. * this function is executed by the physics engine.
  97190. */
  97191. beforeStep: () => void;
  97192. /**
  97193. * this function is executed by the physics engine
  97194. */
  97195. afterStep: () => void;
  97196. /**
  97197. * Legacy collision detection event support
  97198. */
  97199. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97200. /**
  97201. * event and body object due to cannon's event-based architecture.
  97202. */
  97203. onCollide: (e: {
  97204. body: any;
  97205. }) => void;
  97206. /**
  97207. * Apply a force
  97208. * @param force The force to apply
  97209. * @param contactPoint The contact point for the force
  97210. * @returns The physics imposter
  97211. */
  97212. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97213. /**
  97214. * Apply an impulse
  97215. * @param force The impulse force
  97216. * @param contactPoint The contact point for the impulse force
  97217. * @returns The physics imposter
  97218. */
  97219. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97220. /**
  97221. * A help function to create a joint
  97222. * @param otherImpostor A physics imposter used to create a joint
  97223. * @param jointType The type of joint
  97224. * @param jointData The data for the joint
  97225. * @returns The physics imposter
  97226. */
  97227. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97228. /**
  97229. * Add a joint to this impostor with a different impostor
  97230. * @param otherImpostor A physics imposter used to add a joint
  97231. * @param joint The joint to add
  97232. * @returns The physics imposter
  97233. */
  97234. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97235. /**
  97236. * Add an anchor to a cloth impostor
  97237. * @param otherImpostor rigid impostor to anchor to
  97238. * @param width ratio across width from 0 to 1
  97239. * @param height ratio up height from 0 to 1
  97240. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97241. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97242. * @returns impostor the soft imposter
  97243. */
  97244. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97245. /**
  97246. * Add a hook to a rope impostor
  97247. * @param otherImpostor rigid impostor to anchor to
  97248. * @param length ratio across rope from 0 to 1
  97249. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97250. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97251. * @returns impostor the rope imposter
  97252. */
  97253. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97254. /**
  97255. * Will keep this body still, in a sleep mode.
  97256. * @returns the physics imposter
  97257. */
  97258. sleep(): PhysicsImpostor;
  97259. /**
  97260. * Wake the body up.
  97261. * @returns The physics imposter
  97262. */
  97263. wakeUp(): PhysicsImpostor;
  97264. /**
  97265. * Clones the physics imposter
  97266. * @param newObject The physics imposter clones to this physics-enabled object
  97267. * @returns A nullable physics imposter
  97268. */
  97269. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97270. /**
  97271. * Disposes the physics imposter
  97272. */
  97273. dispose(): void;
  97274. /**
  97275. * Sets the delta position
  97276. * @param position The delta position amount
  97277. */
  97278. setDeltaPosition(position: Vector3): void;
  97279. /**
  97280. * Sets the delta rotation
  97281. * @param rotation The delta rotation amount
  97282. */
  97283. setDeltaRotation(rotation: Quaternion): void;
  97284. /**
  97285. * Gets the box size of the physics imposter and stores the result in the input parameter
  97286. * @param result Stores the box size
  97287. * @returns The physics imposter
  97288. */
  97289. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97290. /**
  97291. * Gets the radius of the physics imposter
  97292. * @returns Radius of the physics imposter
  97293. */
  97294. getRadius(): number;
  97295. /**
  97296. * Sync a bone with this impostor
  97297. * @param bone The bone to sync to the impostor.
  97298. * @param boneMesh The mesh that the bone is influencing.
  97299. * @param jointPivot The pivot of the joint / bone in local space.
  97300. * @param distToJoint Optional distance from the impostor to the joint.
  97301. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97302. */
  97303. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97304. /**
  97305. * Sync impostor to a bone
  97306. * @param bone The bone that the impostor will be synced to.
  97307. * @param boneMesh The mesh that the bone is influencing.
  97308. * @param jointPivot The pivot of the joint / bone in local space.
  97309. * @param distToJoint Optional distance from the impostor to the joint.
  97310. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97311. * @param boneAxis Optional vector3 axis the bone is aligned with
  97312. */
  97313. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97314. /**
  97315. * No-Imposter type
  97316. */
  97317. static NoImpostor: number;
  97318. /**
  97319. * Sphere-Imposter type
  97320. */
  97321. static SphereImpostor: number;
  97322. /**
  97323. * Box-Imposter type
  97324. */
  97325. static BoxImpostor: number;
  97326. /**
  97327. * Plane-Imposter type
  97328. */
  97329. static PlaneImpostor: number;
  97330. /**
  97331. * Mesh-imposter type
  97332. */
  97333. static MeshImpostor: number;
  97334. /**
  97335. * Capsule-Impostor type (Ammo.js plugin only)
  97336. */
  97337. static CapsuleImpostor: number;
  97338. /**
  97339. * Cylinder-Imposter type
  97340. */
  97341. static CylinderImpostor: number;
  97342. /**
  97343. * Particle-Imposter type
  97344. */
  97345. static ParticleImpostor: number;
  97346. /**
  97347. * Heightmap-Imposter type
  97348. */
  97349. static HeightmapImpostor: number;
  97350. /**
  97351. * ConvexHull-Impostor type (Ammo.js plugin only)
  97352. */
  97353. static ConvexHullImpostor: number;
  97354. /**
  97355. * Custom-Imposter type (Ammo.js plugin only)
  97356. */
  97357. static CustomImpostor: number;
  97358. /**
  97359. * Rope-Imposter type
  97360. */
  97361. static RopeImpostor: number;
  97362. /**
  97363. * Cloth-Imposter type
  97364. */
  97365. static ClothImpostor: number;
  97366. /**
  97367. * Softbody-Imposter type
  97368. */
  97369. static SoftbodyImpostor: number;
  97370. }
  97371. }
  97372. declare module BABYLON {
  97373. /**
  97374. * @hidden
  97375. **/
  97376. export class _CreationDataStorage {
  97377. closePath?: boolean;
  97378. closeArray?: boolean;
  97379. idx: number[];
  97380. dashSize: number;
  97381. gapSize: number;
  97382. path3D: Path3D;
  97383. pathArray: Vector3[][];
  97384. arc: number;
  97385. radius: number;
  97386. cap: number;
  97387. tessellation: number;
  97388. }
  97389. /**
  97390. * @hidden
  97391. **/
  97392. class _InstanceDataStorage {
  97393. visibleInstances: any;
  97394. batchCache: _InstancesBatch;
  97395. instancesBufferSize: number;
  97396. instancesBuffer: Nullable<Buffer>;
  97397. instancesData: Float32Array;
  97398. overridenInstanceCount: number;
  97399. isFrozen: boolean;
  97400. previousBatch: Nullable<_InstancesBatch>;
  97401. hardwareInstancedRendering: boolean;
  97402. sideOrientation: number;
  97403. manualUpdate: boolean;
  97404. }
  97405. /**
  97406. * @hidden
  97407. **/
  97408. export class _InstancesBatch {
  97409. mustReturn: boolean;
  97410. visibleInstances: Nullable<InstancedMesh[]>[];
  97411. renderSelf: boolean[];
  97412. hardwareInstancedRendering: boolean[];
  97413. }
  97414. /**
  97415. * Class used to represent renderable models
  97416. */
  97417. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97418. /**
  97419. * Mesh side orientation : usually the external or front surface
  97420. */
  97421. static readonly FRONTSIDE: number;
  97422. /**
  97423. * Mesh side orientation : usually the internal or back surface
  97424. */
  97425. static readonly BACKSIDE: number;
  97426. /**
  97427. * Mesh side orientation : both internal and external or front and back surfaces
  97428. */
  97429. static readonly DOUBLESIDE: number;
  97430. /**
  97431. * Mesh side orientation : by default, `FRONTSIDE`
  97432. */
  97433. static readonly DEFAULTSIDE: number;
  97434. /**
  97435. * Mesh cap setting : no cap
  97436. */
  97437. static readonly NO_CAP: number;
  97438. /**
  97439. * Mesh cap setting : one cap at the beginning of the mesh
  97440. */
  97441. static readonly CAP_START: number;
  97442. /**
  97443. * Mesh cap setting : one cap at the end of the mesh
  97444. */
  97445. static readonly CAP_END: number;
  97446. /**
  97447. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97448. */
  97449. static readonly CAP_ALL: number;
  97450. /**
  97451. * Mesh pattern setting : no flip or rotate
  97452. */
  97453. static readonly NO_FLIP: number;
  97454. /**
  97455. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97456. */
  97457. static readonly FLIP_TILE: number;
  97458. /**
  97459. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97460. */
  97461. static readonly ROTATE_TILE: number;
  97462. /**
  97463. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97464. */
  97465. static readonly FLIP_ROW: number;
  97466. /**
  97467. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97468. */
  97469. static readonly ROTATE_ROW: number;
  97470. /**
  97471. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97472. */
  97473. static readonly FLIP_N_ROTATE_TILE: number;
  97474. /**
  97475. * Mesh pattern setting : rotate pattern and rotate
  97476. */
  97477. static readonly FLIP_N_ROTATE_ROW: number;
  97478. /**
  97479. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97480. */
  97481. static readonly CENTER: number;
  97482. /**
  97483. * Mesh tile positioning : part tiles on left
  97484. */
  97485. static readonly LEFT: number;
  97486. /**
  97487. * Mesh tile positioning : part tiles on right
  97488. */
  97489. static readonly RIGHT: number;
  97490. /**
  97491. * Mesh tile positioning : part tiles on top
  97492. */
  97493. static readonly TOP: number;
  97494. /**
  97495. * Mesh tile positioning : part tiles on bottom
  97496. */
  97497. static readonly BOTTOM: number;
  97498. /**
  97499. * Gets the default side orientation.
  97500. * @param orientation the orientation to value to attempt to get
  97501. * @returns the default orientation
  97502. * @hidden
  97503. */
  97504. static _GetDefaultSideOrientation(orientation?: number): number;
  97505. private _internalMeshDataInfo;
  97506. /**
  97507. * An event triggered before rendering the mesh
  97508. */
  97509. get onBeforeRenderObservable(): Observable<Mesh>;
  97510. /**
  97511. * An event triggered before binding the mesh
  97512. */
  97513. get onBeforeBindObservable(): Observable<Mesh>;
  97514. /**
  97515. * An event triggered after rendering the mesh
  97516. */
  97517. get onAfterRenderObservable(): Observable<Mesh>;
  97518. /**
  97519. * An event triggered before drawing the mesh
  97520. */
  97521. get onBeforeDrawObservable(): Observable<Mesh>;
  97522. private _onBeforeDrawObserver;
  97523. /**
  97524. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97525. */
  97526. set onBeforeDraw(callback: () => void);
  97527. get hasInstances(): boolean;
  97528. /**
  97529. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97530. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97531. */
  97532. delayLoadState: number;
  97533. /**
  97534. * Gets the list of instances created from this mesh
  97535. * it is not supposed to be modified manually.
  97536. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97537. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97538. */
  97539. instances: InstancedMesh[];
  97540. /**
  97541. * Gets the file containing delay loading data for this mesh
  97542. */
  97543. delayLoadingFile: string;
  97544. /** @hidden */
  97545. _binaryInfo: any;
  97546. /**
  97547. * User defined function used to change how LOD level selection is done
  97548. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97549. */
  97550. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97551. /**
  97552. * Gets or sets the morph target manager
  97553. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97554. */
  97555. get morphTargetManager(): Nullable<MorphTargetManager>;
  97556. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97557. /** @hidden */
  97558. _creationDataStorage: Nullable<_CreationDataStorage>;
  97559. /** @hidden */
  97560. _geometry: Nullable<Geometry>;
  97561. /** @hidden */
  97562. _delayInfo: Array<string>;
  97563. /** @hidden */
  97564. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97565. /** @hidden */
  97566. _instanceDataStorage: _InstanceDataStorage;
  97567. private _effectiveMaterial;
  97568. /** @hidden */
  97569. _shouldGenerateFlatShading: boolean;
  97570. /** @hidden */
  97571. _originalBuilderSideOrientation: number;
  97572. /**
  97573. * Use this property to change the original side orientation defined at construction time
  97574. */
  97575. overrideMaterialSideOrientation: Nullable<number>;
  97576. /**
  97577. * Gets the source mesh (the one used to clone this one from)
  97578. */
  97579. get source(): Nullable<Mesh>;
  97580. /**
  97581. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97582. */
  97583. get isUnIndexed(): boolean;
  97584. set isUnIndexed(value: boolean);
  97585. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97586. get worldMatrixInstancedBuffer(): Float32Array;
  97587. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97588. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97589. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97590. /**
  97591. * @constructor
  97592. * @param name The value used by scene.getMeshByName() to do a lookup.
  97593. * @param scene The scene to add this mesh to.
  97594. * @param parent The parent of this mesh, if it has one
  97595. * @param source An optional Mesh from which geometry is shared, cloned.
  97596. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97597. * When false, achieved by calling a clone(), also passing False.
  97598. * This will make creation of children, recursive.
  97599. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97600. */
  97601. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97602. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97603. doNotInstantiate: boolean;
  97604. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97605. /**
  97606. * Gets the class name
  97607. * @returns the string "Mesh".
  97608. */
  97609. getClassName(): string;
  97610. /** @hidden */
  97611. get _isMesh(): boolean;
  97612. /**
  97613. * Returns a description of this mesh
  97614. * @param fullDetails define if full details about this mesh must be used
  97615. * @returns a descriptive string representing this mesh
  97616. */
  97617. toString(fullDetails?: boolean): string;
  97618. /** @hidden */
  97619. _unBindEffect(): void;
  97620. /**
  97621. * Gets a boolean indicating if this mesh has LOD
  97622. */
  97623. get hasLODLevels(): boolean;
  97624. /**
  97625. * Gets the list of MeshLODLevel associated with the current mesh
  97626. * @returns an array of MeshLODLevel
  97627. */
  97628. getLODLevels(): MeshLODLevel[];
  97629. private _sortLODLevels;
  97630. /**
  97631. * Add a mesh as LOD level triggered at the given distance.
  97632. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97633. * @param distance The distance from the center of the object to show this level
  97634. * @param mesh The mesh to be added as LOD level (can be null)
  97635. * @return This mesh (for chaining)
  97636. */
  97637. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97638. /**
  97639. * Returns the LOD level mesh at the passed distance or null if not found.
  97640. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97641. * @param distance The distance from the center of the object to show this level
  97642. * @returns a Mesh or `null`
  97643. */
  97644. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97645. /**
  97646. * Remove a mesh from the LOD array
  97647. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97648. * @param mesh defines the mesh to be removed
  97649. * @return This mesh (for chaining)
  97650. */
  97651. removeLODLevel(mesh: Mesh): Mesh;
  97652. /**
  97653. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97654. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97655. * @param camera defines the camera to use to compute distance
  97656. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97657. * @return This mesh (for chaining)
  97658. */
  97659. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97660. /**
  97661. * Gets the mesh internal Geometry object
  97662. */
  97663. get geometry(): Nullable<Geometry>;
  97664. /**
  97665. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97666. * @returns the total number of vertices
  97667. */
  97668. getTotalVertices(): number;
  97669. /**
  97670. * Returns the content of an associated vertex buffer
  97671. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97672. * - VertexBuffer.PositionKind
  97673. * - VertexBuffer.UVKind
  97674. * - VertexBuffer.UV2Kind
  97675. * - VertexBuffer.UV3Kind
  97676. * - VertexBuffer.UV4Kind
  97677. * - VertexBuffer.UV5Kind
  97678. * - VertexBuffer.UV6Kind
  97679. * - VertexBuffer.ColorKind
  97680. * - VertexBuffer.MatricesIndicesKind
  97681. * - VertexBuffer.MatricesIndicesExtraKind
  97682. * - VertexBuffer.MatricesWeightsKind
  97683. * - VertexBuffer.MatricesWeightsExtraKind
  97684. * @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
  97685. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97686. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97687. */
  97688. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97689. /**
  97690. * Returns the mesh VertexBuffer object from the requested `kind`
  97691. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97692. * - VertexBuffer.PositionKind
  97693. * - VertexBuffer.NormalKind
  97694. * - VertexBuffer.UVKind
  97695. * - VertexBuffer.UV2Kind
  97696. * - VertexBuffer.UV3Kind
  97697. * - VertexBuffer.UV4Kind
  97698. * - VertexBuffer.UV5Kind
  97699. * - VertexBuffer.UV6Kind
  97700. * - VertexBuffer.ColorKind
  97701. * - VertexBuffer.MatricesIndicesKind
  97702. * - VertexBuffer.MatricesIndicesExtraKind
  97703. * - VertexBuffer.MatricesWeightsKind
  97704. * - VertexBuffer.MatricesWeightsExtraKind
  97705. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97706. */
  97707. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97708. /**
  97709. * Tests if a specific vertex buffer is associated with this mesh
  97710. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97711. * - VertexBuffer.PositionKind
  97712. * - VertexBuffer.NormalKind
  97713. * - VertexBuffer.UVKind
  97714. * - VertexBuffer.UV2Kind
  97715. * - VertexBuffer.UV3Kind
  97716. * - VertexBuffer.UV4Kind
  97717. * - VertexBuffer.UV5Kind
  97718. * - VertexBuffer.UV6Kind
  97719. * - VertexBuffer.ColorKind
  97720. * - VertexBuffer.MatricesIndicesKind
  97721. * - VertexBuffer.MatricesIndicesExtraKind
  97722. * - VertexBuffer.MatricesWeightsKind
  97723. * - VertexBuffer.MatricesWeightsExtraKind
  97724. * @returns a boolean
  97725. */
  97726. isVerticesDataPresent(kind: string): boolean;
  97727. /**
  97728. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97729. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97730. * - VertexBuffer.PositionKind
  97731. * - VertexBuffer.UVKind
  97732. * - VertexBuffer.UV2Kind
  97733. * - VertexBuffer.UV3Kind
  97734. * - VertexBuffer.UV4Kind
  97735. * - VertexBuffer.UV5Kind
  97736. * - VertexBuffer.UV6Kind
  97737. * - VertexBuffer.ColorKind
  97738. * - VertexBuffer.MatricesIndicesKind
  97739. * - VertexBuffer.MatricesIndicesExtraKind
  97740. * - VertexBuffer.MatricesWeightsKind
  97741. * - VertexBuffer.MatricesWeightsExtraKind
  97742. * @returns a boolean
  97743. */
  97744. isVertexBufferUpdatable(kind: string): boolean;
  97745. /**
  97746. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97747. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97748. * - VertexBuffer.PositionKind
  97749. * - VertexBuffer.NormalKind
  97750. * - VertexBuffer.UVKind
  97751. * - VertexBuffer.UV2Kind
  97752. * - VertexBuffer.UV3Kind
  97753. * - VertexBuffer.UV4Kind
  97754. * - VertexBuffer.UV5Kind
  97755. * - VertexBuffer.UV6Kind
  97756. * - VertexBuffer.ColorKind
  97757. * - VertexBuffer.MatricesIndicesKind
  97758. * - VertexBuffer.MatricesIndicesExtraKind
  97759. * - VertexBuffer.MatricesWeightsKind
  97760. * - VertexBuffer.MatricesWeightsExtraKind
  97761. * @returns an array of strings
  97762. */
  97763. getVerticesDataKinds(): string[];
  97764. /**
  97765. * Returns a positive integer : the total number of indices in this mesh geometry.
  97766. * @returns the numner of indices or zero if the mesh has no geometry.
  97767. */
  97768. getTotalIndices(): number;
  97769. /**
  97770. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97771. * @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.
  97772. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97773. * @returns the indices array or an empty array if the mesh has no geometry
  97774. */
  97775. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97776. get isBlocked(): boolean;
  97777. /**
  97778. * Determine if the current mesh is ready to be rendered
  97779. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97780. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97781. * @returns true if all associated assets are ready (material, textures, shaders)
  97782. */
  97783. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97784. /**
  97785. * 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.
  97786. */
  97787. get areNormalsFrozen(): boolean;
  97788. /**
  97789. * 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.
  97790. * @returns the current mesh
  97791. */
  97792. freezeNormals(): Mesh;
  97793. /**
  97794. * 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
  97795. * @returns the current mesh
  97796. */
  97797. unfreezeNormals(): Mesh;
  97798. /**
  97799. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97800. */
  97801. set overridenInstanceCount(count: number);
  97802. /** @hidden */
  97803. _preActivate(): Mesh;
  97804. /** @hidden */
  97805. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97806. /** @hidden */
  97807. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97808. /**
  97809. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97810. * This means the mesh underlying bounding box and sphere are recomputed.
  97811. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97812. * @returns the current mesh
  97813. */
  97814. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97815. /** @hidden */
  97816. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97817. /**
  97818. * This function will subdivide the mesh into multiple submeshes
  97819. * @param count defines the expected number of submeshes
  97820. */
  97821. subdivide(count: number): void;
  97822. /**
  97823. * Copy a FloatArray into a specific associated vertex buffer
  97824. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97825. * - VertexBuffer.PositionKind
  97826. * - VertexBuffer.UVKind
  97827. * - VertexBuffer.UV2Kind
  97828. * - VertexBuffer.UV3Kind
  97829. * - VertexBuffer.UV4Kind
  97830. * - VertexBuffer.UV5Kind
  97831. * - VertexBuffer.UV6Kind
  97832. * - VertexBuffer.ColorKind
  97833. * - VertexBuffer.MatricesIndicesKind
  97834. * - VertexBuffer.MatricesIndicesExtraKind
  97835. * - VertexBuffer.MatricesWeightsKind
  97836. * - VertexBuffer.MatricesWeightsExtraKind
  97837. * @param data defines the data source
  97838. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97839. * @param stride defines the data stride size (can be null)
  97840. * @returns the current mesh
  97841. */
  97842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97843. /**
  97844. * Delete a vertex buffer associated with this mesh
  97845. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97846. * - VertexBuffer.PositionKind
  97847. * - VertexBuffer.UVKind
  97848. * - VertexBuffer.UV2Kind
  97849. * - VertexBuffer.UV3Kind
  97850. * - VertexBuffer.UV4Kind
  97851. * - VertexBuffer.UV5Kind
  97852. * - VertexBuffer.UV6Kind
  97853. * - VertexBuffer.ColorKind
  97854. * - VertexBuffer.MatricesIndicesKind
  97855. * - VertexBuffer.MatricesIndicesExtraKind
  97856. * - VertexBuffer.MatricesWeightsKind
  97857. * - VertexBuffer.MatricesWeightsExtraKind
  97858. */
  97859. removeVerticesData(kind: string): void;
  97860. /**
  97861. * Flags an associated vertex buffer as updatable
  97862. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97863. * - VertexBuffer.PositionKind
  97864. * - VertexBuffer.UVKind
  97865. * - VertexBuffer.UV2Kind
  97866. * - VertexBuffer.UV3Kind
  97867. * - VertexBuffer.UV4Kind
  97868. * - VertexBuffer.UV5Kind
  97869. * - VertexBuffer.UV6Kind
  97870. * - VertexBuffer.ColorKind
  97871. * - VertexBuffer.MatricesIndicesKind
  97872. * - VertexBuffer.MatricesIndicesExtraKind
  97873. * - VertexBuffer.MatricesWeightsKind
  97874. * - VertexBuffer.MatricesWeightsExtraKind
  97875. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97876. */
  97877. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97878. /**
  97879. * Sets the mesh global Vertex Buffer
  97880. * @param buffer defines the buffer to use
  97881. * @returns the current mesh
  97882. */
  97883. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97884. /**
  97885. * Update a specific associated vertex buffer
  97886. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97887. * - VertexBuffer.PositionKind
  97888. * - VertexBuffer.UVKind
  97889. * - VertexBuffer.UV2Kind
  97890. * - VertexBuffer.UV3Kind
  97891. * - VertexBuffer.UV4Kind
  97892. * - VertexBuffer.UV5Kind
  97893. * - VertexBuffer.UV6Kind
  97894. * - VertexBuffer.ColorKind
  97895. * - VertexBuffer.MatricesIndicesKind
  97896. * - VertexBuffer.MatricesIndicesExtraKind
  97897. * - VertexBuffer.MatricesWeightsKind
  97898. * - VertexBuffer.MatricesWeightsExtraKind
  97899. * @param data defines the data source
  97900. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97901. * @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)
  97902. * @returns the current mesh
  97903. */
  97904. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97905. /**
  97906. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97907. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97908. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97909. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97910. * @returns the current mesh
  97911. */
  97912. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97913. /**
  97914. * Creates a un-shared specific occurence of the geometry for the mesh.
  97915. * @returns the current mesh
  97916. */
  97917. makeGeometryUnique(): Mesh;
  97918. /**
  97919. * Set the index buffer of this mesh
  97920. * @param indices defines the source data
  97921. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97922. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97923. * @returns the current mesh
  97924. */
  97925. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97926. /**
  97927. * Update the current index buffer
  97928. * @param indices defines the source data
  97929. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97930. * @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)
  97931. * @returns the current mesh
  97932. */
  97933. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97934. /**
  97935. * Invert the geometry to move from a right handed system to a left handed one.
  97936. * @returns the current mesh
  97937. */
  97938. toLeftHanded(): Mesh;
  97939. /** @hidden */
  97940. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97941. /** @hidden */
  97942. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97943. /**
  97944. * Registers for this mesh a javascript function called just before the rendering process
  97945. * @param func defines the function to call before rendering this mesh
  97946. * @returns the current mesh
  97947. */
  97948. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97949. /**
  97950. * Disposes a previously registered javascript function called before the rendering
  97951. * @param func defines the function to remove
  97952. * @returns the current mesh
  97953. */
  97954. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97955. /**
  97956. * Registers for this mesh a javascript function called just after the rendering is complete
  97957. * @param func defines the function to call after rendering this mesh
  97958. * @returns the current mesh
  97959. */
  97960. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97961. /**
  97962. * Disposes a previously registered javascript function called after the rendering.
  97963. * @param func defines the function to remove
  97964. * @returns the current mesh
  97965. */
  97966. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97967. /** @hidden */
  97968. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97969. /** @hidden */
  97970. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97971. /** @hidden */
  97972. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97973. /** @hidden */
  97974. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97975. /** @hidden */
  97976. _rebuild(): void;
  97977. /** @hidden */
  97978. _freeze(): void;
  97979. /** @hidden */
  97980. _unFreeze(): void;
  97981. /**
  97982. * 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
  97983. * @param subMesh defines the subMesh to render
  97984. * @param enableAlphaMode defines if alpha mode can be changed
  97985. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97986. * @returns the current mesh
  97987. */
  97988. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97989. private _onBeforeDraw;
  97990. /**
  97991. * Renormalize the mesh and patch it up if there are no weights
  97992. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97993. * However in the case of zero weights then we set just a single influence to 1.
  97994. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97995. */
  97996. cleanMatrixWeights(): void;
  97997. private normalizeSkinFourWeights;
  97998. private normalizeSkinWeightsAndExtra;
  97999. /**
  98000. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98001. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98002. * the user know there was an issue with importing the mesh
  98003. * @returns a validation object with skinned, valid and report string
  98004. */
  98005. validateSkinning(): {
  98006. skinned: boolean;
  98007. valid: boolean;
  98008. report: string;
  98009. };
  98010. /** @hidden */
  98011. _checkDelayState(): Mesh;
  98012. private _queueLoad;
  98013. /**
  98014. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98015. * A mesh is in the frustum if its bounding box intersects the frustum
  98016. * @param frustumPlanes defines the frustum to test
  98017. * @returns true if the mesh is in the frustum planes
  98018. */
  98019. isInFrustum(frustumPlanes: Plane[]): boolean;
  98020. /**
  98021. * Sets the mesh material by the material or multiMaterial `id` property
  98022. * @param id is a string identifying the material or the multiMaterial
  98023. * @returns the current mesh
  98024. */
  98025. setMaterialByID(id: string): Mesh;
  98026. /**
  98027. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98028. * @returns an array of IAnimatable
  98029. */
  98030. getAnimatables(): IAnimatable[];
  98031. /**
  98032. * Modifies the mesh geometry according to the passed transformation matrix.
  98033. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98034. * The mesh normals are modified using the same transformation.
  98035. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98036. * @param transform defines the transform matrix to use
  98037. * @see http://doc.babylonjs.com/resources/baking_transformations
  98038. * @returns the current mesh
  98039. */
  98040. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98041. /**
  98042. * Modifies the mesh geometry according to its own current World Matrix.
  98043. * The mesh World Matrix is then reset.
  98044. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98045. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98046. * @see http://doc.babylonjs.com/resources/baking_transformations
  98047. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98048. * @returns the current mesh
  98049. */
  98050. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98051. /** @hidden */
  98052. get _positions(): Nullable<Vector3[]>;
  98053. /** @hidden */
  98054. _resetPointsArrayCache(): Mesh;
  98055. /** @hidden */
  98056. _generatePointsArray(): boolean;
  98057. /**
  98058. * Returns a new Mesh object generated from the current mesh properties.
  98059. * This method must not get confused with createInstance()
  98060. * @param name is a string, the name given to the new mesh
  98061. * @param newParent can be any Node object (default `null`)
  98062. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98063. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98064. * @returns a new mesh
  98065. */
  98066. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98067. /**
  98068. * Releases resources associated with this mesh.
  98069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98071. */
  98072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98073. /** @hidden */
  98074. _disposeInstanceSpecificData(): void;
  98075. /**
  98076. * Modifies the mesh geometry according to a displacement map.
  98077. * 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.
  98078. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98079. * @param url is a string, the URL from the image file is to be downloaded.
  98080. * @param minHeight is the lower limit of the displacement.
  98081. * @param maxHeight is the upper limit of the displacement.
  98082. * @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.
  98083. * @param uvOffset is an optional vector2 used to offset UV.
  98084. * @param uvScale is an optional vector2 used to scale UV.
  98085. * @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.
  98086. * @returns the Mesh.
  98087. */
  98088. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98089. /**
  98090. * Modifies the mesh geometry according to a displacementMap buffer.
  98091. * 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.
  98092. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98093. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98094. * @param heightMapWidth is the width of the buffer image.
  98095. * @param heightMapHeight is the height of the buffer image.
  98096. * @param minHeight is the lower limit of the displacement.
  98097. * @param maxHeight is the upper limit of the displacement.
  98098. * @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.
  98099. * @param uvOffset is an optional vector2 used to offset UV.
  98100. * @param uvScale is an optional vector2 used to scale UV.
  98101. * @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.
  98102. * @returns the Mesh.
  98103. */
  98104. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98105. /**
  98106. * Modify the mesh to get a flat shading rendering.
  98107. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98108. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98109. * @returns current mesh
  98110. */
  98111. convertToFlatShadedMesh(): Mesh;
  98112. /**
  98113. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98114. * In other words, more vertices, no more indices and a single bigger VBO.
  98115. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98116. * @returns current mesh
  98117. */
  98118. convertToUnIndexedMesh(): Mesh;
  98119. /**
  98120. * Inverses facet orientations.
  98121. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98122. * @param flipNormals will also inverts the normals
  98123. * @returns current mesh
  98124. */
  98125. flipFaces(flipNormals?: boolean): Mesh;
  98126. /**
  98127. * Increase the number of facets and hence vertices in a mesh
  98128. * Vertex normals are interpolated from existing vertex normals
  98129. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98130. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98131. */
  98132. increaseVertices(numberPerEdge: number): void;
  98133. /**
  98134. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98135. * This will undo any application of covertToFlatShadedMesh
  98136. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98137. */
  98138. forceSharedVertices(): void;
  98139. /** @hidden */
  98140. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98141. /** @hidden */
  98142. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98143. /**
  98144. * Creates a new InstancedMesh object from the mesh model.
  98145. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98146. * @param name defines the name of the new instance
  98147. * @returns a new InstancedMesh
  98148. */
  98149. createInstance(name: string): InstancedMesh;
  98150. /**
  98151. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98152. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98153. * @returns the current mesh
  98154. */
  98155. synchronizeInstances(): Mesh;
  98156. /**
  98157. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98158. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98159. * This should be used together with the simplification to avoid disappearing triangles.
  98160. * @param successCallback an optional success callback to be called after the optimization finished.
  98161. * @returns the current mesh
  98162. */
  98163. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98164. /**
  98165. * Serialize current mesh
  98166. * @param serializationObject defines the object which will receive the serialization data
  98167. */
  98168. serialize(serializationObject: any): void;
  98169. /** @hidden */
  98170. _syncGeometryWithMorphTargetManager(): void;
  98171. /** @hidden */
  98172. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98173. /**
  98174. * Returns a new Mesh object parsed from the source provided.
  98175. * @param parsedMesh is the source
  98176. * @param scene defines the hosting scene
  98177. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98178. * @returns a new Mesh
  98179. */
  98180. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98181. /**
  98182. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98183. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98184. * @param name defines the name of the mesh to create
  98185. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98186. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98187. * @param closePath creates a seam between the first and the last points of each path of the path array
  98188. * @param offset is taken in account only if the `pathArray` is containing a single path
  98189. * @param scene defines the hosting scene
  98190. * @param updatable defines if the mesh must be flagged as updatable
  98191. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98192. * @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)
  98193. * @returns a new Mesh
  98194. */
  98195. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98196. /**
  98197. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98198. * @param name defines the name of the mesh to create
  98199. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98200. * @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
  98201. * @param scene defines the hosting scene
  98202. * @param updatable defines if the mesh must be flagged as updatable
  98203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98204. * @returns a new Mesh
  98205. */
  98206. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98207. /**
  98208. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98209. * @param name defines the name of the mesh to create
  98210. * @param size sets the size (float) of each box side (default 1)
  98211. * @param scene defines the hosting scene
  98212. * @param updatable defines if the mesh must be flagged as updatable
  98213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98214. * @returns a new Mesh
  98215. */
  98216. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98217. /**
  98218. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98219. * @param name defines the name of the mesh to create
  98220. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98221. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98222. * @param scene defines the hosting scene
  98223. * @param updatable defines if the mesh must be flagged as updatable
  98224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98225. * @returns a new Mesh
  98226. */
  98227. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98228. /**
  98229. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98230. * @param name defines the name of the mesh to create
  98231. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98232. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98233. * @param scene defines the hosting scene
  98234. * @returns a new Mesh
  98235. */
  98236. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98237. /**
  98238. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98239. * @param name defines the name of the mesh to create
  98240. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98241. * @param diameterTop set the top cap diameter (floats, default 1)
  98242. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98243. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98244. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98245. * @param scene defines the hosting scene
  98246. * @param updatable defines if the mesh must be flagged as updatable
  98247. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98248. * @returns a new Mesh
  98249. */
  98250. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98251. /**
  98252. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98253. * @param name defines the name of the mesh to create
  98254. * @param diameter sets the diameter size (float) of the torus (default 1)
  98255. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98256. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98257. * @param scene defines the hosting scene
  98258. * @param updatable defines if the mesh must be flagged as updatable
  98259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98260. * @returns a new Mesh
  98261. */
  98262. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98263. /**
  98264. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98265. * @param name defines the name of the mesh to create
  98266. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98267. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98268. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98269. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98270. * @param p the number of windings on X axis (positive integers, default 2)
  98271. * @param q the number of windings on Y axis (positive integers, default 3)
  98272. * @param scene defines the hosting scene
  98273. * @param updatable defines if the mesh must be flagged as updatable
  98274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98275. * @returns a new Mesh
  98276. */
  98277. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98278. /**
  98279. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98280. * @param name defines the name of the mesh to create
  98281. * @param points is an array successive Vector3
  98282. * @param scene defines the hosting scene
  98283. * @param updatable defines if the mesh must be flagged as updatable
  98284. * @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).
  98285. * @returns a new Mesh
  98286. */
  98287. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98288. /**
  98289. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98290. * @param name defines the name of the mesh to create
  98291. * @param points is an array successive Vector3
  98292. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98293. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98294. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98295. * @param scene defines the hosting scene
  98296. * @param updatable defines if the mesh must be flagged as updatable
  98297. * @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)
  98298. * @returns a new Mesh
  98299. */
  98300. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98301. /**
  98302. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98303. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98304. * 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.
  98305. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98306. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98307. * Remember you can only change the shape positions, not their number when updating a polygon.
  98308. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98309. * @param name defines the name of the mesh to create
  98310. * @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
  98311. * @param scene defines the hosting scene
  98312. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98313. * @param updatable defines if the mesh must be flagged as updatable
  98314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98315. * @param earcutInjection can be used to inject your own earcut reference
  98316. * @returns a new Mesh
  98317. */
  98318. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98319. /**
  98320. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98321. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98322. * @param name defines the name of the mesh to create
  98323. * @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
  98324. * @param depth defines the height of extrusion
  98325. * @param scene defines the hosting scene
  98326. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98327. * @param updatable defines if the mesh must be flagged as updatable
  98328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98329. * @param earcutInjection can be used to inject your own earcut reference
  98330. * @returns a new Mesh
  98331. */
  98332. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98333. /**
  98334. * Creates an extruded shape mesh.
  98335. * 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
  98336. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98337. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98338. * @param name defines the name of the mesh to create
  98339. * @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
  98340. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98341. * @param scale is the value to scale the shape
  98342. * @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
  98343. * @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
  98344. * @param scene defines the hosting scene
  98345. * @param updatable defines if the mesh must be flagged as updatable
  98346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98347. * @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)
  98348. * @returns a new Mesh
  98349. */
  98350. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98351. /**
  98352. * Creates an custom extruded shape mesh.
  98353. * The custom extrusion is a parametric shape.
  98354. * It has no predefined shape. Its final shape will depend on the input parameters.
  98355. * Please consider using the same method from the MeshBuilder class instead
  98356. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98357. * @param name defines the name of the mesh to create
  98358. * @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
  98359. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98360. * @param scaleFunction is a custom Javascript function called on each path point
  98361. * @param rotationFunction is a custom Javascript function called on each path point
  98362. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98363. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98364. * @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
  98365. * @param scene defines the hosting scene
  98366. * @param updatable defines if the mesh must be flagged as updatable
  98367. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98368. * @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)
  98369. * @returns a new Mesh
  98370. */
  98371. 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;
  98372. /**
  98373. * Creates lathe mesh.
  98374. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98375. * Please consider using the same method from the MeshBuilder class instead
  98376. * @param name defines the name of the mesh to create
  98377. * @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
  98378. * @param radius is the radius value of the lathe
  98379. * @param tessellation is the side number of the lathe.
  98380. * @param scene defines the hosting scene
  98381. * @param updatable defines if the mesh must be flagged as updatable
  98382. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98383. * @returns a new Mesh
  98384. */
  98385. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98386. /**
  98387. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98388. * @param name defines the name of the mesh to create
  98389. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98390. * @param scene defines the hosting scene
  98391. * @param updatable defines if the mesh must be flagged as updatable
  98392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98393. * @returns a new Mesh
  98394. */
  98395. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98396. /**
  98397. * Creates a ground mesh.
  98398. * Please consider using the same method from the MeshBuilder class instead
  98399. * @param name defines the name of the mesh to create
  98400. * @param width set the width of the ground
  98401. * @param height set the height of the ground
  98402. * @param subdivisions sets the number of subdivisions per side
  98403. * @param scene defines the hosting scene
  98404. * @param updatable defines if the mesh must be flagged as updatable
  98405. * @returns a new Mesh
  98406. */
  98407. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98408. /**
  98409. * Creates a tiled ground mesh.
  98410. * Please consider using the same method from the MeshBuilder class instead
  98411. * @param name defines the name of the mesh to create
  98412. * @param xmin set the ground minimum X coordinate
  98413. * @param zmin set the ground minimum Y coordinate
  98414. * @param xmax set the ground maximum X coordinate
  98415. * @param zmax set the ground maximum Z coordinate
  98416. * @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
  98417. * @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
  98418. * @param scene defines the hosting scene
  98419. * @param updatable defines if the mesh must be flagged as updatable
  98420. * @returns a new Mesh
  98421. */
  98422. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98423. w: number;
  98424. h: number;
  98425. }, precision: {
  98426. w: number;
  98427. h: number;
  98428. }, scene: Scene, updatable?: boolean): Mesh;
  98429. /**
  98430. * Creates a ground mesh from a height map.
  98431. * Please consider using the same method from the MeshBuilder class instead
  98432. * @see http://doc.babylonjs.com/babylon101/height_map
  98433. * @param name defines the name of the mesh to create
  98434. * @param url sets the URL of the height map image resource
  98435. * @param width set the ground width size
  98436. * @param height set the ground height size
  98437. * @param subdivisions sets the number of subdivision per side
  98438. * @param minHeight is the minimum altitude on the ground
  98439. * @param maxHeight is the maximum altitude on the ground
  98440. * @param scene defines the hosting scene
  98441. * @param updatable defines if the mesh must be flagged as updatable
  98442. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98443. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98444. * @returns a new Mesh
  98445. */
  98446. 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;
  98447. /**
  98448. * Creates a tube mesh.
  98449. * The tube is a parametric shape.
  98450. * It has no predefined shape. Its final shape will depend on the input parameters.
  98451. * Please consider using the same method from the MeshBuilder class instead
  98452. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98453. * @param name defines the name of the mesh to create
  98454. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98455. * @param radius sets the tube radius size
  98456. * @param tessellation is the number of sides on the tubular surface
  98457. * @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
  98458. * @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
  98459. * @param scene defines the hosting scene
  98460. * @param updatable defines if the mesh must be flagged as updatable
  98461. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98462. * @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)
  98463. * @returns a new Mesh
  98464. */
  98465. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98466. (i: number, distance: number): number;
  98467. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98468. /**
  98469. * Creates a polyhedron mesh.
  98470. * Please consider using the same method from the MeshBuilder class instead.
  98471. * * 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
  98472. * * The parameter `size` (positive float, default 1) sets the polygon size
  98473. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98474. * * 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`
  98475. * * 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
  98476. * * 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)`)
  98477. * * 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
  98478. * * 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
  98479. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98480. * * If you create a double-sided mesh, you can choose what parts of 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
  98481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98482. * @param name defines the name of the mesh to create
  98483. * @param options defines the options used to create the mesh
  98484. * @param scene defines the hosting scene
  98485. * @returns a new Mesh
  98486. */
  98487. static CreatePolyhedron(name: string, options: {
  98488. type?: number;
  98489. size?: number;
  98490. sizeX?: number;
  98491. sizeY?: number;
  98492. sizeZ?: number;
  98493. custom?: any;
  98494. faceUV?: Vector4[];
  98495. faceColors?: Color4[];
  98496. updatable?: boolean;
  98497. sideOrientation?: number;
  98498. }, scene: Scene): Mesh;
  98499. /**
  98500. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98501. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98502. * * 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`)
  98503. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98504. * * 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
  98505. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98506. * * If you create a double-sided mesh, you can choose what parts of 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
  98507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98508. * @param name defines the name of the mesh
  98509. * @param options defines the options used to create the mesh
  98510. * @param scene defines the hosting scene
  98511. * @returns a new Mesh
  98512. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98513. */
  98514. static CreateIcoSphere(name: string, options: {
  98515. radius?: number;
  98516. flat?: boolean;
  98517. subdivisions?: number;
  98518. sideOrientation?: number;
  98519. updatable?: boolean;
  98520. }, scene: Scene): Mesh;
  98521. /**
  98522. * Creates a decal mesh.
  98523. * Please consider using the same method from the MeshBuilder class instead.
  98524. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98525. * @param name defines the name of the mesh
  98526. * @param sourceMesh defines the mesh receiving the decal
  98527. * @param position sets the position of the decal in world coordinates
  98528. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98529. * @param size sets the decal scaling
  98530. * @param angle sets the angle to rotate the decal
  98531. * @returns a new Mesh
  98532. */
  98533. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98534. /**
  98535. * Prepare internal position array for software CPU skinning
  98536. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98537. */
  98538. setPositionsForCPUSkinning(): Float32Array;
  98539. /**
  98540. * Prepare internal normal array for software CPU skinning
  98541. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98542. */
  98543. setNormalsForCPUSkinning(): Float32Array;
  98544. /**
  98545. * Updates the vertex buffer by applying transformation from the bones
  98546. * @param skeleton defines the skeleton to apply to current mesh
  98547. * @returns the current mesh
  98548. */
  98549. applySkeleton(skeleton: Skeleton): Mesh;
  98550. /**
  98551. * 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
  98552. * @param meshes defines the list of meshes to scan
  98553. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98554. */
  98555. static MinMax(meshes: AbstractMesh[]): {
  98556. min: Vector3;
  98557. max: Vector3;
  98558. };
  98559. /**
  98560. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98561. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98562. * @returns a vector3
  98563. */
  98564. static Center(meshesOrMinMaxVector: {
  98565. min: Vector3;
  98566. max: Vector3;
  98567. } | AbstractMesh[]): Vector3;
  98568. /**
  98569. * Merge the array of meshes into a single mesh for performance reasons.
  98570. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98571. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98572. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98573. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98574. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98575. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98576. * @returns a new mesh
  98577. */
  98578. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98579. /** @hidden */
  98580. addInstance(instance: InstancedMesh): void;
  98581. /** @hidden */
  98582. removeInstance(instance: InstancedMesh): void;
  98583. }
  98584. }
  98585. declare module BABYLON {
  98586. /**
  98587. * This is the base class of all the camera used in the application.
  98588. * @see http://doc.babylonjs.com/features/cameras
  98589. */
  98590. export class Camera extends Node {
  98591. /** @hidden */
  98592. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98593. /**
  98594. * This is the default projection mode used by the cameras.
  98595. * It helps recreating a feeling of perspective and better appreciate depth.
  98596. * This is the best way to simulate real life cameras.
  98597. */
  98598. static readonly PERSPECTIVE_CAMERA: number;
  98599. /**
  98600. * This helps creating camera with an orthographic mode.
  98601. * 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.
  98602. */
  98603. static readonly ORTHOGRAPHIC_CAMERA: number;
  98604. /**
  98605. * This is the default FOV mode for perspective cameras.
  98606. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98607. */
  98608. static readonly FOVMODE_VERTICAL_FIXED: number;
  98609. /**
  98610. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98611. */
  98612. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98613. /**
  98614. * This specifies ther is no need for a camera rig.
  98615. * Basically only one eye is rendered corresponding to the camera.
  98616. */
  98617. static readonly RIG_MODE_NONE: number;
  98618. /**
  98619. * Simulates a camera Rig with one blue eye and one red eye.
  98620. * This can be use with 3d blue and red glasses.
  98621. */
  98622. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98623. /**
  98624. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98625. */
  98626. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98627. /**
  98628. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98629. */
  98630. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98631. /**
  98632. * Defines that both eyes of the camera will be rendered over under each other.
  98633. */
  98634. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98635. /**
  98636. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98637. */
  98638. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98639. /**
  98640. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98641. */
  98642. static readonly RIG_MODE_VR: number;
  98643. /**
  98644. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98645. */
  98646. static readonly RIG_MODE_WEBVR: number;
  98647. /**
  98648. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98649. */
  98650. static readonly RIG_MODE_CUSTOM: number;
  98651. /**
  98652. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98653. */
  98654. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98655. /**
  98656. * Define the input manager associated with the camera.
  98657. */
  98658. inputs: CameraInputsManager<Camera>;
  98659. /** @hidden */
  98660. _position: Vector3;
  98661. /**
  98662. * Define the current local position of the camera in the scene
  98663. */
  98664. get position(): Vector3;
  98665. set position(newPosition: Vector3);
  98666. /**
  98667. * The vector the camera should consider as up.
  98668. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98669. */
  98670. upVector: Vector3;
  98671. /**
  98672. * Define the current limit on the left side for an orthographic camera
  98673. * In scene unit
  98674. */
  98675. orthoLeft: Nullable<number>;
  98676. /**
  98677. * Define the current limit on the right side for an orthographic camera
  98678. * In scene unit
  98679. */
  98680. orthoRight: Nullable<number>;
  98681. /**
  98682. * Define the current limit on the bottom side for an orthographic camera
  98683. * In scene unit
  98684. */
  98685. orthoBottom: Nullable<number>;
  98686. /**
  98687. * Define the current limit on the top side for an orthographic camera
  98688. * In scene unit
  98689. */
  98690. orthoTop: Nullable<number>;
  98691. /**
  98692. * Field Of View is set in Radians. (default is 0.8)
  98693. */
  98694. fov: number;
  98695. /**
  98696. * Define the minimum distance the camera can see from.
  98697. * This is important to note that the depth buffer are not infinite and the closer it starts
  98698. * the more your scene might encounter depth fighting issue.
  98699. */
  98700. minZ: number;
  98701. /**
  98702. * Define the maximum distance the camera can see to.
  98703. * This is important to note that the depth buffer are not infinite and the further it end
  98704. * the more your scene might encounter depth fighting issue.
  98705. */
  98706. maxZ: number;
  98707. /**
  98708. * Define the default inertia of the camera.
  98709. * This helps giving a smooth feeling to the camera movement.
  98710. */
  98711. inertia: number;
  98712. /**
  98713. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98714. */
  98715. mode: number;
  98716. /**
  98717. * Define whether the camera is intermediate.
  98718. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98719. */
  98720. isIntermediate: boolean;
  98721. /**
  98722. * Define the viewport of the camera.
  98723. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98724. */
  98725. viewport: Viewport;
  98726. /**
  98727. * Restricts the camera to viewing objects with the same layerMask.
  98728. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98729. */
  98730. layerMask: number;
  98731. /**
  98732. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98733. */
  98734. fovMode: number;
  98735. /**
  98736. * Rig mode of the camera.
  98737. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98738. * This is normally controlled byt the camera themselves as internal use.
  98739. */
  98740. cameraRigMode: number;
  98741. /**
  98742. * Defines the distance between both "eyes" in case of a RIG
  98743. */
  98744. interaxialDistance: number;
  98745. /**
  98746. * Defines if stereoscopic rendering is done side by side or over under.
  98747. */
  98748. isStereoscopicSideBySide: boolean;
  98749. /**
  98750. * 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
  98751. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98752. * else in the scene. (Eg. security camera)
  98753. *
  98754. * 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)
  98755. */
  98756. customRenderTargets: RenderTargetTexture[];
  98757. /**
  98758. * When set, the camera will render to this render target instead of the default canvas
  98759. *
  98760. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98761. */
  98762. outputRenderTarget: Nullable<RenderTargetTexture>;
  98763. /**
  98764. * Observable triggered when the camera view matrix has changed.
  98765. */
  98766. onViewMatrixChangedObservable: Observable<Camera>;
  98767. /**
  98768. * Observable triggered when the camera Projection matrix has changed.
  98769. */
  98770. onProjectionMatrixChangedObservable: Observable<Camera>;
  98771. /**
  98772. * Observable triggered when the inputs have been processed.
  98773. */
  98774. onAfterCheckInputsObservable: Observable<Camera>;
  98775. /**
  98776. * Observable triggered when reset has been called and applied to the camera.
  98777. */
  98778. onRestoreStateObservable: Observable<Camera>;
  98779. /**
  98780. * Is this camera a part of a rig system?
  98781. */
  98782. isRigCamera: boolean;
  98783. /**
  98784. * If isRigCamera set to true this will be set with the parent camera.
  98785. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98786. */
  98787. rigParent?: Camera;
  98788. /** @hidden */
  98789. _cameraRigParams: any;
  98790. /** @hidden */
  98791. _rigCameras: Camera[];
  98792. /** @hidden */
  98793. _rigPostProcess: Nullable<PostProcess>;
  98794. protected _webvrViewMatrix: Matrix;
  98795. /** @hidden */
  98796. _skipRendering: boolean;
  98797. /** @hidden */
  98798. _projectionMatrix: Matrix;
  98799. /** @hidden */
  98800. _postProcesses: Nullable<PostProcess>[];
  98801. /** @hidden */
  98802. _activeMeshes: SmartArray<AbstractMesh>;
  98803. protected _globalPosition: Vector3;
  98804. /** @hidden */
  98805. _computedViewMatrix: Matrix;
  98806. private _doNotComputeProjectionMatrix;
  98807. private _transformMatrix;
  98808. private _frustumPlanes;
  98809. private _refreshFrustumPlanes;
  98810. private _storedFov;
  98811. private _stateStored;
  98812. /**
  98813. * Instantiates a new camera object.
  98814. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98815. * @see http://doc.babylonjs.com/features/cameras
  98816. * @param name Defines the name of the camera in the scene
  98817. * @param position Defines the position of the camera
  98818. * @param scene Defines the scene the camera belongs too
  98819. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98820. */
  98821. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98822. /**
  98823. * Store current camera state (fov, position, etc..)
  98824. * @returns the camera
  98825. */
  98826. storeState(): Camera;
  98827. /**
  98828. * Restores the camera state values if it has been stored. You must call storeState() first
  98829. */
  98830. protected _restoreStateValues(): boolean;
  98831. /**
  98832. * Restored camera state. You must call storeState() first.
  98833. * @returns true if restored and false otherwise
  98834. */
  98835. restoreState(): boolean;
  98836. /**
  98837. * Gets the class name of the camera.
  98838. * @returns the class name
  98839. */
  98840. getClassName(): string;
  98841. /** @hidden */
  98842. readonly _isCamera: boolean;
  98843. /**
  98844. * Gets a string representation of the camera useful for debug purpose.
  98845. * @param fullDetails Defines that a more verboe level of logging is required
  98846. * @returns the string representation
  98847. */
  98848. toString(fullDetails?: boolean): string;
  98849. /**
  98850. * Gets the current world space position of the camera.
  98851. */
  98852. get globalPosition(): Vector3;
  98853. /**
  98854. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98855. * @returns the active meshe list
  98856. */
  98857. getActiveMeshes(): SmartArray<AbstractMesh>;
  98858. /**
  98859. * Check whether a mesh is part of the current active mesh list of the camera
  98860. * @param mesh Defines the mesh to check
  98861. * @returns true if active, false otherwise
  98862. */
  98863. isActiveMesh(mesh: Mesh): boolean;
  98864. /**
  98865. * Is this camera ready to be used/rendered
  98866. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98867. * @return true if the camera is ready
  98868. */
  98869. isReady(completeCheck?: boolean): boolean;
  98870. /** @hidden */
  98871. _initCache(): void;
  98872. /** @hidden */
  98873. _updateCache(ignoreParentClass?: boolean): void;
  98874. /** @hidden */
  98875. _isSynchronized(): boolean;
  98876. /** @hidden */
  98877. _isSynchronizedViewMatrix(): boolean;
  98878. /** @hidden */
  98879. _isSynchronizedProjectionMatrix(): boolean;
  98880. /**
  98881. * Attach the input controls to a specific dom element to get the input from.
  98882. * @param element Defines the element the controls should be listened from
  98883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98884. */
  98885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98886. /**
  98887. * Detach the current controls from the specified dom element.
  98888. * @param element Defines the element to stop listening the inputs from
  98889. */
  98890. detachControl(element: HTMLElement): void;
  98891. /**
  98892. * Update the camera state according to the different inputs gathered during the frame.
  98893. */
  98894. update(): void;
  98895. /** @hidden */
  98896. _checkInputs(): void;
  98897. /** @hidden */
  98898. get rigCameras(): Camera[];
  98899. /**
  98900. * Gets the post process used by the rig cameras
  98901. */
  98902. get rigPostProcess(): Nullable<PostProcess>;
  98903. /**
  98904. * Internal, gets the first post proces.
  98905. * @returns the first post process to be run on this camera.
  98906. */
  98907. _getFirstPostProcess(): Nullable<PostProcess>;
  98908. private _cascadePostProcessesToRigCams;
  98909. /**
  98910. * Attach a post process to the camera.
  98911. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98912. * @param postProcess The post process to attach to the camera
  98913. * @param insertAt The position of the post process in case several of them are in use in the scene
  98914. * @returns the position the post process has been inserted at
  98915. */
  98916. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98917. /**
  98918. * Detach a post process to the camera.
  98919. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98920. * @param postProcess The post process to detach from the camera
  98921. */
  98922. detachPostProcess(postProcess: PostProcess): void;
  98923. /**
  98924. * Gets the current world matrix of the camera
  98925. */
  98926. getWorldMatrix(): Matrix;
  98927. /** @hidden */
  98928. _getViewMatrix(): Matrix;
  98929. /**
  98930. * Gets the current view matrix of the camera.
  98931. * @param force forces the camera to recompute the matrix without looking at the cached state
  98932. * @returns the view matrix
  98933. */
  98934. getViewMatrix(force?: boolean): Matrix;
  98935. /**
  98936. * Freeze the projection matrix.
  98937. * It will prevent the cache check of the camera projection compute and can speed up perf
  98938. * if no parameter of the camera are meant to change
  98939. * @param projection Defines manually a projection if necessary
  98940. */
  98941. freezeProjectionMatrix(projection?: Matrix): void;
  98942. /**
  98943. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98944. */
  98945. unfreezeProjectionMatrix(): void;
  98946. /**
  98947. * Gets the current projection matrix of the camera.
  98948. * @param force forces the camera to recompute the matrix without looking at the cached state
  98949. * @returns the projection matrix
  98950. */
  98951. getProjectionMatrix(force?: boolean): Matrix;
  98952. /**
  98953. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98954. * @returns a Matrix
  98955. */
  98956. getTransformationMatrix(): Matrix;
  98957. private _updateFrustumPlanes;
  98958. /**
  98959. * Checks if a cullable object (mesh...) is in the camera frustum
  98960. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98961. * @param target The object to check
  98962. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98963. * @returns true if the object is in frustum otherwise false
  98964. */
  98965. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98966. /**
  98967. * Checks if a cullable object (mesh...) is in the camera frustum
  98968. * Unlike isInFrustum this cheks the full bounding box
  98969. * @param target The object to check
  98970. * @returns true if the object is in frustum otherwise false
  98971. */
  98972. isCompletelyInFrustum(target: ICullable): boolean;
  98973. /**
  98974. * Gets a ray in the forward direction from the camera.
  98975. * @param length Defines the length of the ray to create
  98976. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98977. * @param origin Defines the start point of the ray which defaults to the camera position
  98978. * @returns the forward ray
  98979. */
  98980. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98981. /**
  98982. * Releases resources associated with this node.
  98983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98985. */
  98986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98987. /** @hidden */
  98988. _isLeftCamera: boolean;
  98989. /**
  98990. * Gets the left camera of a rig setup in case of Rigged Camera
  98991. */
  98992. get isLeftCamera(): boolean;
  98993. /** @hidden */
  98994. _isRightCamera: boolean;
  98995. /**
  98996. * Gets the right camera of a rig setup in case of Rigged Camera
  98997. */
  98998. get isRightCamera(): boolean;
  98999. /**
  99000. * Gets the left camera of a rig setup in case of Rigged Camera
  99001. */
  99002. get leftCamera(): Nullable<FreeCamera>;
  99003. /**
  99004. * Gets the right camera of a rig setup in case of Rigged Camera
  99005. */
  99006. get rightCamera(): Nullable<FreeCamera>;
  99007. /**
  99008. * Gets the left camera target of a rig setup in case of Rigged Camera
  99009. * @returns the target position
  99010. */
  99011. getLeftTarget(): Nullable<Vector3>;
  99012. /**
  99013. * Gets the right camera target of a rig setup in case of Rigged Camera
  99014. * @returns the target position
  99015. */
  99016. getRightTarget(): Nullable<Vector3>;
  99017. /**
  99018. * @hidden
  99019. */
  99020. setCameraRigMode(mode: number, rigParams: any): void;
  99021. /** @hidden */
  99022. static _setStereoscopicRigMode(camera: Camera): void;
  99023. /** @hidden */
  99024. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99025. /** @hidden */
  99026. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99027. /** @hidden */
  99028. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99029. /** @hidden */
  99030. _getVRProjectionMatrix(): Matrix;
  99031. protected _updateCameraRotationMatrix(): void;
  99032. protected _updateWebVRCameraRotationMatrix(): void;
  99033. /**
  99034. * This function MUST be overwritten by the different WebVR cameras available.
  99035. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99036. * @hidden
  99037. */
  99038. _getWebVRProjectionMatrix(): Matrix;
  99039. /**
  99040. * This function MUST be overwritten by the different WebVR cameras available.
  99041. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99042. * @hidden
  99043. */
  99044. _getWebVRViewMatrix(): Matrix;
  99045. /** @hidden */
  99046. setCameraRigParameter(name: string, value: any): void;
  99047. /**
  99048. * needs to be overridden by children so sub has required properties to be copied
  99049. * @hidden
  99050. */
  99051. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99052. /**
  99053. * May need to be overridden by children
  99054. * @hidden
  99055. */
  99056. _updateRigCameras(): void;
  99057. /** @hidden */
  99058. _setupInputs(): void;
  99059. /**
  99060. * Serialiaze the camera setup to a json represention
  99061. * @returns the JSON representation
  99062. */
  99063. serialize(): any;
  99064. /**
  99065. * Clones the current camera.
  99066. * @param name The cloned camera name
  99067. * @returns the cloned camera
  99068. */
  99069. clone(name: string): Camera;
  99070. /**
  99071. * Gets the direction of the camera relative to a given local axis.
  99072. * @param localAxis Defines the reference axis to provide a relative direction.
  99073. * @return the direction
  99074. */
  99075. getDirection(localAxis: Vector3): Vector3;
  99076. /**
  99077. * Returns the current camera absolute rotation
  99078. */
  99079. get absoluteRotation(): Quaternion;
  99080. /**
  99081. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99082. * @param localAxis Defines the reference axis to provide a relative direction.
  99083. * @param result Defines the vector to store the result in
  99084. */
  99085. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99086. /**
  99087. * Gets a camera constructor for a given camera type
  99088. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99089. * @param name The name of the camera the result will be able to instantiate
  99090. * @param scene The scene the result will construct the camera in
  99091. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99092. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99093. * @returns a factory method to construc the camera
  99094. */
  99095. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99096. /**
  99097. * Compute the world matrix of the camera.
  99098. * @returns the camera world matrix
  99099. */
  99100. computeWorldMatrix(): Matrix;
  99101. /**
  99102. * Parse a JSON and creates the camera from the parsed information
  99103. * @param parsedCamera The JSON to parse
  99104. * @param scene The scene to instantiate the camera in
  99105. * @returns the newly constructed camera
  99106. */
  99107. static Parse(parsedCamera: any, scene: Scene): Camera;
  99108. }
  99109. }
  99110. declare module BABYLON {
  99111. /**
  99112. * Class containing static functions to help procedurally build meshes
  99113. */
  99114. export class DiscBuilder {
  99115. /**
  99116. * Creates a plane polygonal mesh. By default, this is a disc
  99117. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99118. * * 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
  99119. * * 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
  99120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99123. * @param name defines the name of the mesh
  99124. * @param options defines the options used to create the mesh
  99125. * @param scene defines the hosting scene
  99126. * @returns the plane polygonal mesh
  99127. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99128. */
  99129. static CreateDisc(name: string, options: {
  99130. radius?: number;
  99131. tessellation?: number;
  99132. arc?: number;
  99133. updatable?: boolean;
  99134. sideOrientation?: number;
  99135. frontUVs?: Vector4;
  99136. backUVs?: Vector4;
  99137. }, scene?: Nullable<Scene>): Mesh;
  99138. }
  99139. }
  99140. declare module BABYLON {
  99141. /**
  99142. * This represents all the required information to add a fresnel effect on a material:
  99143. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99144. */
  99145. export class FresnelParameters {
  99146. private _isEnabled;
  99147. /**
  99148. * Define if the fresnel effect is enable or not.
  99149. */
  99150. get isEnabled(): boolean;
  99151. set isEnabled(value: boolean);
  99152. /**
  99153. * Define the color used on edges (grazing angle)
  99154. */
  99155. leftColor: Color3;
  99156. /**
  99157. * Define the color used on center
  99158. */
  99159. rightColor: Color3;
  99160. /**
  99161. * Define bias applied to computed fresnel term
  99162. */
  99163. bias: number;
  99164. /**
  99165. * Defined the power exponent applied to fresnel term
  99166. */
  99167. power: number;
  99168. /**
  99169. * Clones the current fresnel and its valuues
  99170. * @returns a clone fresnel configuration
  99171. */
  99172. clone(): FresnelParameters;
  99173. /**
  99174. * Serializes the current fresnel parameters to a JSON representation.
  99175. * @return the JSON serialization
  99176. */
  99177. serialize(): any;
  99178. /**
  99179. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99180. * @param parsedFresnelParameters Define the JSON representation
  99181. * @returns the parsed parameters
  99182. */
  99183. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99184. }
  99185. }
  99186. declare module BABYLON {
  99187. /**
  99188. * Base class of materials working in push mode in babylon JS
  99189. * @hidden
  99190. */
  99191. export class PushMaterial extends Material {
  99192. protected _activeEffect: Effect;
  99193. protected _normalMatrix: Matrix;
  99194. /**
  99195. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99196. * This means that the material can keep using a previous shader while a new one is being compiled.
  99197. * This is mostly used when shader parallel compilation is supported (true by default)
  99198. */
  99199. allowShaderHotSwapping: boolean;
  99200. constructor(name: string, scene: Scene);
  99201. getEffect(): Effect;
  99202. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99203. /**
  99204. * Binds the given world matrix to the active effect
  99205. *
  99206. * @param world the matrix to bind
  99207. */
  99208. bindOnlyWorldMatrix(world: Matrix): void;
  99209. /**
  99210. * Binds the given normal matrix to the active effect
  99211. *
  99212. * @param normalMatrix the matrix to bind
  99213. */
  99214. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99215. bind(world: Matrix, mesh?: Mesh): void;
  99216. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99217. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99218. }
  99219. }
  99220. declare module BABYLON {
  99221. /**
  99222. * This groups all the flags used to control the materials channel.
  99223. */
  99224. export class MaterialFlags {
  99225. private static _DiffuseTextureEnabled;
  99226. /**
  99227. * Are diffuse textures enabled in the application.
  99228. */
  99229. static get DiffuseTextureEnabled(): boolean;
  99230. static set DiffuseTextureEnabled(value: boolean);
  99231. private static _AmbientTextureEnabled;
  99232. /**
  99233. * Are ambient textures enabled in the application.
  99234. */
  99235. static get AmbientTextureEnabled(): boolean;
  99236. static set AmbientTextureEnabled(value: boolean);
  99237. private static _OpacityTextureEnabled;
  99238. /**
  99239. * Are opacity textures enabled in the application.
  99240. */
  99241. static get OpacityTextureEnabled(): boolean;
  99242. static set OpacityTextureEnabled(value: boolean);
  99243. private static _ReflectionTextureEnabled;
  99244. /**
  99245. * Are reflection textures enabled in the application.
  99246. */
  99247. static get ReflectionTextureEnabled(): boolean;
  99248. static set ReflectionTextureEnabled(value: boolean);
  99249. private static _EmissiveTextureEnabled;
  99250. /**
  99251. * Are emissive textures enabled in the application.
  99252. */
  99253. static get EmissiveTextureEnabled(): boolean;
  99254. static set EmissiveTextureEnabled(value: boolean);
  99255. private static _SpecularTextureEnabled;
  99256. /**
  99257. * Are specular textures enabled in the application.
  99258. */
  99259. static get SpecularTextureEnabled(): boolean;
  99260. static set SpecularTextureEnabled(value: boolean);
  99261. private static _BumpTextureEnabled;
  99262. /**
  99263. * Are bump textures enabled in the application.
  99264. */
  99265. static get BumpTextureEnabled(): boolean;
  99266. static set BumpTextureEnabled(value: boolean);
  99267. private static _LightmapTextureEnabled;
  99268. /**
  99269. * Are lightmap textures enabled in the application.
  99270. */
  99271. static get LightmapTextureEnabled(): boolean;
  99272. static set LightmapTextureEnabled(value: boolean);
  99273. private static _RefractionTextureEnabled;
  99274. /**
  99275. * Are refraction textures enabled in the application.
  99276. */
  99277. static get RefractionTextureEnabled(): boolean;
  99278. static set RefractionTextureEnabled(value: boolean);
  99279. private static _ColorGradingTextureEnabled;
  99280. /**
  99281. * Are color grading textures enabled in the application.
  99282. */
  99283. static get ColorGradingTextureEnabled(): boolean;
  99284. static set ColorGradingTextureEnabled(value: boolean);
  99285. private static _FresnelEnabled;
  99286. /**
  99287. * Are fresnels enabled in the application.
  99288. */
  99289. static get FresnelEnabled(): boolean;
  99290. static set FresnelEnabled(value: boolean);
  99291. private static _ClearCoatTextureEnabled;
  99292. /**
  99293. * Are clear coat textures enabled in the application.
  99294. */
  99295. static get ClearCoatTextureEnabled(): boolean;
  99296. static set ClearCoatTextureEnabled(value: boolean);
  99297. private static _ClearCoatBumpTextureEnabled;
  99298. /**
  99299. * Are clear coat bump textures enabled in the application.
  99300. */
  99301. static get ClearCoatBumpTextureEnabled(): boolean;
  99302. static set ClearCoatBumpTextureEnabled(value: boolean);
  99303. private static _ClearCoatTintTextureEnabled;
  99304. /**
  99305. * Are clear coat tint textures enabled in the application.
  99306. */
  99307. static get ClearCoatTintTextureEnabled(): boolean;
  99308. static set ClearCoatTintTextureEnabled(value: boolean);
  99309. private static _SheenTextureEnabled;
  99310. /**
  99311. * Are sheen textures enabled in the application.
  99312. */
  99313. static get SheenTextureEnabled(): boolean;
  99314. static set SheenTextureEnabled(value: boolean);
  99315. private static _AnisotropicTextureEnabled;
  99316. /**
  99317. * Are anisotropic textures enabled in the application.
  99318. */
  99319. static get AnisotropicTextureEnabled(): boolean;
  99320. static set AnisotropicTextureEnabled(value: boolean);
  99321. private static _ThicknessTextureEnabled;
  99322. /**
  99323. * Are thickness textures enabled in the application.
  99324. */
  99325. static get ThicknessTextureEnabled(): boolean;
  99326. static set ThicknessTextureEnabled(value: boolean);
  99327. }
  99328. }
  99329. declare module BABYLON {
  99330. /** @hidden */
  99331. export var defaultFragmentDeclaration: {
  99332. name: string;
  99333. shader: string;
  99334. };
  99335. }
  99336. declare module BABYLON {
  99337. /** @hidden */
  99338. export var defaultUboDeclaration: {
  99339. name: string;
  99340. shader: string;
  99341. };
  99342. }
  99343. declare module BABYLON {
  99344. /** @hidden */
  99345. export var lightFragmentDeclaration: {
  99346. name: string;
  99347. shader: string;
  99348. };
  99349. }
  99350. declare module BABYLON {
  99351. /** @hidden */
  99352. export var lightUboDeclaration: {
  99353. name: string;
  99354. shader: string;
  99355. };
  99356. }
  99357. declare module BABYLON {
  99358. /** @hidden */
  99359. export var lightsFragmentFunctions: {
  99360. name: string;
  99361. shader: string;
  99362. };
  99363. }
  99364. declare module BABYLON {
  99365. /** @hidden */
  99366. export var shadowsFragmentFunctions: {
  99367. name: string;
  99368. shader: string;
  99369. };
  99370. }
  99371. declare module BABYLON {
  99372. /** @hidden */
  99373. export var fresnelFunction: {
  99374. name: string;
  99375. shader: string;
  99376. };
  99377. }
  99378. declare module BABYLON {
  99379. /** @hidden */
  99380. export var reflectionFunction: {
  99381. name: string;
  99382. shader: string;
  99383. };
  99384. }
  99385. declare module BABYLON {
  99386. /** @hidden */
  99387. export var bumpFragmentFunctions: {
  99388. name: string;
  99389. shader: string;
  99390. };
  99391. }
  99392. declare module BABYLON {
  99393. /** @hidden */
  99394. export var logDepthDeclaration: {
  99395. name: string;
  99396. shader: string;
  99397. };
  99398. }
  99399. declare module BABYLON {
  99400. /** @hidden */
  99401. export var bumpFragment: {
  99402. name: string;
  99403. shader: string;
  99404. };
  99405. }
  99406. declare module BABYLON {
  99407. /** @hidden */
  99408. export var depthPrePass: {
  99409. name: string;
  99410. shader: string;
  99411. };
  99412. }
  99413. declare module BABYLON {
  99414. /** @hidden */
  99415. export var lightFragment: {
  99416. name: string;
  99417. shader: string;
  99418. };
  99419. }
  99420. declare module BABYLON {
  99421. /** @hidden */
  99422. export var logDepthFragment: {
  99423. name: string;
  99424. shader: string;
  99425. };
  99426. }
  99427. declare module BABYLON {
  99428. /** @hidden */
  99429. export var defaultPixelShader: {
  99430. name: string;
  99431. shader: string;
  99432. };
  99433. }
  99434. declare module BABYLON {
  99435. /** @hidden */
  99436. export var defaultVertexDeclaration: {
  99437. name: string;
  99438. shader: string;
  99439. };
  99440. }
  99441. declare module BABYLON {
  99442. /** @hidden */
  99443. export var bumpVertexDeclaration: {
  99444. name: string;
  99445. shader: string;
  99446. };
  99447. }
  99448. declare module BABYLON {
  99449. /** @hidden */
  99450. export var bumpVertex: {
  99451. name: string;
  99452. shader: string;
  99453. };
  99454. }
  99455. declare module BABYLON {
  99456. /** @hidden */
  99457. export var fogVertex: {
  99458. name: string;
  99459. shader: string;
  99460. };
  99461. }
  99462. declare module BABYLON {
  99463. /** @hidden */
  99464. export var shadowsVertex: {
  99465. name: string;
  99466. shader: string;
  99467. };
  99468. }
  99469. declare module BABYLON {
  99470. /** @hidden */
  99471. export var pointCloudVertex: {
  99472. name: string;
  99473. shader: string;
  99474. };
  99475. }
  99476. declare module BABYLON {
  99477. /** @hidden */
  99478. export var logDepthVertex: {
  99479. name: string;
  99480. shader: string;
  99481. };
  99482. }
  99483. declare module BABYLON {
  99484. /** @hidden */
  99485. export var defaultVertexShader: {
  99486. name: string;
  99487. shader: string;
  99488. };
  99489. }
  99490. declare module BABYLON {
  99491. /** @hidden */
  99492. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99493. MAINUV1: boolean;
  99494. MAINUV2: boolean;
  99495. DIFFUSE: boolean;
  99496. DIFFUSEDIRECTUV: number;
  99497. AMBIENT: boolean;
  99498. AMBIENTDIRECTUV: number;
  99499. OPACITY: boolean;
  99500. OPACITYDIRECTUV: number;
  99501. OPACITYRGB: boolean;
  99502. REFLECTION: boolean;
  99503. EMISSIVE: boolean;
  99504. EMISSIVEDIRECTUV: number;
  99505. SPECULAR: boolean;
  99506. SPECULARDIRECTUV: number;
  99507. BUMP: boolean;
  99508. BUMPDIRECTUV: number;
  99509. PARALLAX: boolean;
  99510. PARALLAXOCCLUSION: boolean;
  99511. SPECULAROVERALPHA: boolean;
  99512. CLIPPLANE: boolean;
  99513. CLIPPLANE2: boolean;
  99514. CLIPPLANE3: boolean;
  99515. CLIPPLANE4: boolean;
  99516. CLIPPLANE5: boolean;
  99517. CLIPPLANE6: boolean;
  99518. ALPHATEST: boolean;
  99519. DEPTHPREPASS: boolean;
  99520. ALPHAFROMDIFFUSE: boolean;
  99521. POINTSIZE: boolean;
  99522. FOG: boolean;
  99523. SPECULARTERM: boolean;
  99524. DIFFUSEFRESNEL: boolean;
  99525. OPACITYFRESNEL: boolean;
  99526. REFLECTIONFRESNEL: boolean;
  99527. REFRACTIONFRESNEL: boolean;
  99528. EMISSIVEFRESNEL: boolean;
  99529. FRESNEL: boolean;
  99530. NORMAL: boolean;
  99531. UV1: boolean;
  99532. UV2: boolean;
  99533. VERTEXCOLOR: boolean;
  99534. VERTEXALPHA: boolean;
  99535. NUM_BONE_INFLUENCERS: number;
  99536. BonesPerMesh: number;
  99537. BONETEXTURE: boolean;
  99538. INSTANCES: boolean;
  99539. GLOSSINESS: boolean;
  99540. ROUGHNESS: boolean;
  99541. EMISSIVEASILLUMINATION: boolean;
  99542. LINKEMISSIVEWITHDIFFUSE: boolean;
  99543. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99544. LIGHTMAP: boolean;
  99545. LIGHTMAPDIRECTUV: number;
  99546. OBJECTSPACE_NORMALMAP: boolean;
  99547. USELIGHTMAPASSHADOWMAP: boolean;
  99548. REFLECTIONMAP_3D: boolean;
  99549. REFLECTIONMAP_SPHERICAL: boolean;
  99550. REFLECTIONMAP_PLANAR: boolean;
  99551. REFLECTIONMAP_CUBIC: boolean;
  99552. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99553. REFLECTIONMAP_PROJECTION: boolean;
  99554. REFLECTIONMAP_SKYBOX: boolean;
  99555. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  99556. REFLECTIONMAP_EXPLICIT: boolean;
  99557. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99558. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99559. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99560. INVERTCUBICMAP: boolean;
  99561. LOGARITHMICDEPTH: boolean;
  99562. REFRACTION: boolean;
  99563. REFRACTIONMAP_3D: boolean;
  99564. REFLECTIONOVERALPHA: boolean;
  99565. TWOSIDEDLIGHTING: boolean;
  99566. SHADOWFLOAT: boolean;
  99567. MORPHTARGETS: boolean;
  99568. MORPHTARGETS_NORMAL: boolean;
  99569. MORPHTARGETS_TANGENT: boolean;
  99570. MORPHTARGETS_UV: boolean;
  99571. NUM_MORPH_INFLUENCERS: number;
  99572. NONUNIFORMSCALING: boolean;
  99573. PREMULTIPLYALPHA: boolean;
  99574. IMAGEPROCESSING: boolean;
  99575. VIGNETTE: boolean;
  99576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99577. VIGNETTEBLENDMODEOPAQUE: boolean;
  99578. TONEMAPPING: boolean;
  99579. TONEMAPPING_ACES: boolean;
  99580. CONTRAST: boolean;
  99581. COLORCURVES: boolean;
  99582. COLORGRADING: boolean;
  99583. COLORGRADING3D: boolean;
  99584. SAMPLER3DGREENDEPTH: boolean;
  99585. SAMPLER3DBGRMAP: boolean;
  99586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99587. MULTIVIEW: boolean;
  99588. /**
  99589. * If the reflection texture on this material is in linear color space
  99590. * @hidden
  99591. */
  99592. IS_REFLECTION_LINEAR: boolean;
  99593. /**
  99594. * If the refraction texture on this material is in linear color space
  99595. * @hidden
  99596. */
  99597. IS_REFRACTION_LINEAR: boolean;
  99598. EXPOSURE: boolean;
  99599. constructor();
  99600. setReflectionMode(modeToEnable: string): void;
  99601. }
  99602. /**
  99603. * This is the default material used in Babylon. It is the best trade off between quality
  99604. * and performances.
  99605. * @see http://doc.babylonjs.com/babylon101/materials
  99606. */
  99607. export class StandardMaterial extends PushMaterial {
  99608. private _diffuseTexture;
  99609. /**
  99610. * The basic texture of the material as viewed under a light.
  99611. */
  99612. diffuseTexture: Nullable<BaseTexture>;
  99613. private _ambientTexture;
  99614. /**
  99615. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99616. */
  99617. ambientTexture: Nullable<BaseTexture>;
  99618. private _opacityTexture;
  99619. /**
  99620. * Define the transparency of the material from a texture.
  99621. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99622. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99623. */
  99624. opacityTexture: Nullable<BaseTexture>;
  99625. private _reflectionTexture;
  99626. /**
  99627. * Define the texture used to display the reflection.
  99628. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99629. */
  99630. reflectionTexture: Nullable<BaseTexture>;
  99631. private _emissiveTexture;
  99632. /**
  99633. * Define texture of the material as if self lit.
  99634. * This will be mixed in the final result even in the absence of light.
  99635. */
  99636. emissiveTexture: Nullable<BaseTexture>;
  99637. private _specularTexture;
  99638. /**
  99639. * Define how the color and intensity of the highlight given by the light in the material.
  99640. */
  99641. specularTexture: Nullable<BaseTexture>;
  99642. private _bumpTexture;
  99643. /**
  99644. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99645. * 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.
  99646. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99647. */
  99648. bumpTexture: Nullable<BaseTexture>;
  99649. private _lightmapTexture;
  99650. /**
  99651. * Complex lighting can be computationally expensive to compute at runtime.
  99652. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99653. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99654. */
  99655. lightmapTexture: Nullable<BaseTexture>;
  99656. private _refractionTexture;
  99657. /**
  99658. * Define the texture used to display the refraction.
  99659. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99660. */
  99661. refractionTexture: Nullable<BaseTexture>;
  99662. /**
  99663. * The color of the material lit by the environmental background lighting.
  99664. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99665. */
  99666. ambientColor: Color3;
  99667. /**
  99668. * The basic color of the material as viewed under a light.
  99669. */
  99670. diffuseColor: Color3;
  99671. /**
  99672. * Define how the color and intensity of the highlight given by the light in the material.
  99673. */
  99674. specularColor: Color3;
  99675. /**
  99676. * Define the color of the material as if self lit.
  99677. * This will be mixed in the final result even in the absence of light.
  99678. */
  99679. emissiveColor: Color3;
  99680. /**
  99681. * Defines how sharp are the highlights in the material.
  99682. * The bigger the value the sharper giving a more glossy feeling to the result.
  99683. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99684. */
  99685. specularPower: number;
  99686. private _useAlphaFromDiffuseTexture;
  99687. /**
  99688. * Does the transparency come from the diffuse texture alpha channel.
  99689. */
  99690. useAlphaFromDiffuseTexture: boolean;
  99691. private _useEmissiveAsIllumination;
  99692. /**
  99693. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99694. */
  99695. useEmissiveAsIllumination: boolean;
  99696. private _linkEmissiveWithDiffuse;
  99697. /**
  99698. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99699. * the emissive level when the final color is close to one.
  99700. */
  99701. linkEmissiveWithDiffuse: boolean;
  99702. private _useSpecularOverAlpha;
  99703. /**
  99704. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99705. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99706. */
  99707. useSpecularOverAlpha: boolean;
  99708. private _useReflectionOverAlpha;
  99709. /**
  99710. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99711. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99712. */
  99713. useReflectionOverAlpha: boolean;
  99714. private _disableLighting;
  99715. /**
  99716. * Does lights from the scene impacts this material.
  99717. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99718. */
  99719. disableLighting: boolean;
  99720. private _useObjectSpaceNormalMap;
  99721. /**
  99722. * Allows using an object space normal map (instead of tangent space).
  99723. */
  99724. useObjectSpaceNormalMap: boolean;
  99725. private _useParallax;
  99726. /**
  99727. * Is parallax enabled or not.
  99728. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99729. */
  99730. useParallax: boolean;
  99731. private _useParallaxOcclusion;
  99732. /**
  99733. * Is parallax occlusion enabled or not.
  99734. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99735. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99736. */
  99737. useParallaxOcclusion: boolean;
  99738. /**
  99739. * 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.
  99740. */
  99741. parallaxScaleBias: number;
  99742. private _roughness;
  99743. /**
  99744. * Helps to define how blurry the reflections should appears in the material.
  99745. */
  99746. roughness: number;
  99747. /**
  99748. * In case of refraction, define the value of the index of refraction.
  99749. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99750. */
  99751. indexOfRefraction: number;
  99752. /**
  99753. * Invert the refraction texture alongside the y axis.
  99754. * It can be useful with procedural textures or probe for instance.
  99755. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99756. */
  99757. invertRefractionY: boolean;
  99758. /**
  99759. * Defines the alpha limits in alpha test mode.
  99760. */
  99761. alphaCutOff: number;
  99762. private _useLightmapAsShadowmap;
  99763. /**
  99764. * In case of light mapping, define whether the map contains light or shadow informations.
  99765. */
  99766. useLightmapAsShadowmap: boolean;
  99767. private _diffuseFresnelParameters;
  99768. /**
  99769. * Define the diffuse fresnel parameters of the material.
  99770. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99771. */
  99772. diffuseFresnelParameters: FresnelParameters;
  99773. private _opacityFresnelParameters;
  99774. /**
  99775. * Define the opacity fresnel parameters of the material.
  99776. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99777. */
  99778. opacityFresnelParameters: FresnelParameters;
  99779. private _reflectionFresnelParameters;
  99780. /**
  99781. * Define the reflection fresnel parameters of the material.
  99782. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99783. */
  99784. reflectionFresnelParameters: FresnelParameters;
  99785. private _refractionFresnelParameters;
  99786. /**
  99787. * Define the refraction fresnel parameters of the material.
  99788. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99789. */
  99790. refractionFresnelParameters: FresnelParameters;
  99791. private _emissiveFresnelParameters;
  99792. /**
  99793. * Define the emissive fresnel parameters of the material.
  99794. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99795. */
  99796. emissiveFresnelParameters: FresnelParameters;
  99797. private _useReflectionFresnelFromSpecular;
  99798. /**
  99799. * If true automatically deducts the fresnels values from the material specularity.
  99800. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99801. */
  99802. useReflectionFresnelFromSpecular: boolean;
  99803. private _useGlossinessFromSpecularMapAlpha;
  99804. /**
  99805. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99806. */
  99807. useGlossinessFromSpecularMapAlpha: boolean;
  99808. private _maxSimultaneousLights;
  99809. /**
  99810. * Defines the maximum number of lights that can be used in the material
  99811. */
  99812. maxSimultaneousLights: number;
  99813. private _invertNormalMapX;
  99814. /**
  99815. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99816. */
  99817. invertNormalMapX: boolean;
  99818. private _invertNormalMapY;
  99819. /**
  99820. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99821. */
  99822. invertNormalMapY: boolean;
  99823. private _twoSidedLighting;
  99824. /**
  99825. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99826. */
  99827. twoSidedLighting: boolean;
  99828. /**
  99829. * Default configuration related to image processing available in the standard Material.
  99830. */
  99831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99832. /**
  99833. * Gets the image processing configuration used either in this material.
  99834. */
  99835. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99836. /**
  99837. * Sets the Default image processing configuration used either in the this material.
  99838. *
  99839. * If sets to null, the scene one is in use.
  99840. */
  99841. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99842. /**
  99843. * Keep track of the image processing observer to allow dispose and replace.
  99844. */
  99845. private _imageProcessingObserver;
  99846. /**
  99847. * Attaches a new image processing configuration to the Standard Material.
  99848. * @param configuration
  99849. */
  99850. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99851. /**
  99852. * Gets wether the color curves effect is enabled.
  99853. */
  99854. get cameraColorCurvesEnabled(): boolean;
  99855. /**
  99856. * Sets wether the color curves effect is enabled.
  99857. */
  99858. set cameraColorCurvesEnabled(value: boolean);
  99859. /**
  99860. * Gets wether the color grading effect is enabled.
  99861. */
  99862. get cameraColorGradingEnabled(): boolean;
  99863. /**
  99864. * Gets wether the color grading effect is enabled.
  99865. */
  99866. set cameraColorGradingEnabled(value: boolean);
  99867. /**
  99868. * Gets wether tonemapping is enabled or not.
  99869. */
  99870. get cameraToneMappingEnabled(): boolean;
  99871. /**
  99872. * Sets wether tonemapping is enabled or not
  99873. */
  99874. set cameraToneMappingEnabled(value: boolean);
  99875. /**
  99876. * The camera exposure used on this material.
  99877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99878. * This corresponds to a photographic exposure.
  99879. */
  99880. get cameraExposure(): number;
  99881. /**
  99882. * The camera exposure used on this material.
  99883. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99884. * This corresponds to a photographic exposure.
  99885. */
  99886. set cameraExposure(value: number);
  99887. /**
  99888. * Gets The camera contrast used on this material.
  99889. */
  99890. get cameraContrast(): number;
  99891. /**
  99892. * Sets The camera contrast used on this material.
  99893. */
  99894. set cameraContrast(value: number);
  99895. /**
  99896. * Gets the Color Grading 2D Lookup Texture.
  99897. */
  99898. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99899. /**
  99900. * Sets the Color Grading 2D Lookup Texture.
  99901. */
  99902. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99903. /**
  99904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99906. * 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;
  99907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99908. */
  99909. get cameraColorCurves(): Nullable<ColorCurves>;
  99910. /**
  99911. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99912. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99913. * 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;
  99914. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99915. */
  99916. set cameraColorCurves(value: Nullable<ColorCurves>);
  99917. /**
  99918. * Custom callback helping to override the default shader used in the material.
  99919. */
  99920. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99921. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99922. protected _worldViewProjectionMatrix: Matrix;
  99923. protected _globalAmbientColor: Color3;
  99924. protected _useLogarithmicDepth: boolean;
  99925. protected _rebuildInParallel: boolean;
  99926. /**
  99927. * Instantiates a new standard material.
  99928. * This is the default material used in Babylon. It is the best trade off between quality
  99929. * and performances.
  99930. * @see http://doc.babylonjs.com/babylon101/materials
  99931. * @param name Define the name of the material in the scene
  99932. * @param scene Define the scene the material belong to
  99933. */
  99934. constructor(name: string, scene: Scene);
  99935. /**
  99936. * Gets a boolean indicating that current material needs to register RTT
  99937. */
  99938. get hasRenderTargetTextures(): boolean;
  99939. /**
  99940. * Gets the current class name of the material e.g. "StandardMaterial"
  99941. * Mainly use in serialization.
  99942. * @returns the class name
  99943. */
  99944. getClassName(): string;
  99945. /**
  99946. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99947. * You can try switching to logarithmic depth.
  99948. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99949. */
  99950. get useLogarithmicDepth(): boolean;
  99951. set useLogarithmicDepth(value: boolean);
  99952. /**
  99953. * Specifies if the material will require alpha blending
  99954. * @returns a boolean specifying if alpha blending is needed
  99955. */
  99956. needAlphaBlending(): boolean;
  99957. /**
  99958. * Specifies if this material should be rendered in alpha test mode
  99959. * @returns a boolean specifying if an alpha test is needed.
  99960. */
  99961. needAlphaTesting(): boolean;
  99962. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99963. /**
  99964. * Get the texture used for alpha test purpose.
  99965. * @returns the diffuse texture in case of the standard material.
  99966. */
  99967. getAlphaTestTexture(): Nullable<BaseTexture>;
  99968. /**
  99969. * Get if the submesh is ready to be used and all its information available.
  99970. * Child classes can use it to update shaders
  99971. * @param mesh defines the mesh to check
  99972. * @param subMesh defines which submesh to check
  99973. * @param useInstances specifies that instances should be used
  99974. * @returns a boolean indicating that the submesh is ready or not
  99975. */
  99976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99977. /**
  99978. * Builds the material UBO layouts.
  99979. * Used internally during the effect preparation.
  99980. */
  99981. buildUniformLayout(): void;
  99982. /**
  99983. * Unbinds the material from the mesh
  99984. */
  99985. unbind(): void;
  99986. /**
  99987. * Binds the submesh to this material by preparing the effect and shader to draw
  99988. * @param world defines the world transformation matrix
  99989. * @param mesh defines the mesh containing the submesh
  99990. * @param subMesh defines the submesh to bind the material to
  99991. */
  99992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99993. /**
  99994. * Get the list of animatables in the material.
  99995. * @returns the list of animatables object used in the material
  99996. */
  99997. getAnimatables(): IAnimatable[];
  99998. /**
  99999. * Gets the active textures from the material
  100000. * @returns an array of textures
  100001. */
  100002. getActiveTextures(): BaseTexture[];
  100003. /**
  100004. * Specifies if the material uses a texture
  100005. * @param texture defines the texture to check against the material
  100006. * @returns a boolean specifying if the material uses the texture
  100007. */
  100008. hasTexture(texture: BaseTexture): boolean;
  100009. /**
  100010. * Disposes the material
  100011. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100012. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100013. */
  100014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100015. /**
  100016. * Makes a duplicate of the material, and gives it a new name
  100017. * @param name defines the new name for the duplicated material
  100018. * @returns the cloned material
  100019. */
  100020. clone(name: string): StandardMaterial;
  100021. /**
  100022. * Serializes this material in a JSON representation
  100023. * @returns the serialized material object
  100024. */
  100025. serialize(): any;
  100026. /**
  100027. * Creates a standard material from parsed material data
  100028. * @param source defines the JSON representation of the material
  100029. * @param scene defines the hosting scene
  100030. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100031. * @returns a new standard material
  100032. */
  100033. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100034. /**
  100035. * Are diffuse textures enabled in the application.
  100036. */
  100037. static get DiffuseTextureEnabled(): boolean;
  100038. static set DiffuseTextureEnabled(value: boolean);
  100039. /**
  100040. * Are ambient textures enabled in the application.
  100041. */
  100042. static get AmbientTextureEnabled(): boolean;
  100043. static set AmbientTextureEnabled(value: boolean);
  100044. /**
  100045. * Are opacity textures enabled in the application.
  100046. */
  100047. static get OpacityTextureEnabled(): boolean;
  100048. static set OpacityTextureEnabled(value: boolean);
  100049. /**
  100050. * Are reflection textures enabled in the application.
  100051. */
  100052. static get ReflectionTextureEnabled(): boolean;
  100053. static set ReflectionTextureEnabled(value: boolean);
  100054. /**
  100055. * Are emissive textures enabled in the application.
  100056. */
  100057. static get EmissiveTextureEnabled(): boolean;
  100058. static set EmissiveTextureEnabled(value: boolean);
  100059. /**
  100060. * Are specular textures enabled in the application.
  100061. */
  100062. static get SpecularTextureEnabled(): boolean;
  100063. static set SpecularTextureEnabled(value: boolean);
  100064. /**
  100065. * Are bump textures enabled in the application.
  100066. */
  100067. static get BumpTextureEnabled(): boolean;
  100068. static set BumpTextureEnabled(value: boolean);
  100069. /**
  100070. * Are lightmap textures enabled in the application.
  100071. */
  100072. static get LightmapTextureEnabled(): boolean;
  100073. static set LightmapTextureEnabled(value: boolean);
  100074. /**
  100075. * Are refraction textures enabled in the application.
  100076. */
  100077. static get RefractionTextureEnabled(): boolean;
  100078. static set RefractionTextureEnabled(value: boolean);
  100079. /**
  100080. * Are color grading textures enabled in the application.
  100081. */
  100082. static get ColorGradingTextureEnabled(): boolean;
  100083. static set ColorGradingTextureEnabled(value: boolean);
  100084. /**
  100085. * Are fresnels enabled in the application.
  100086. */
  100087. static get FresnelEnabled(): boolean;
  100088. static set FresnelEnabled(value: boolean);
  100089. }
  100090. }
  100091. declare module BABYLON {
  100092. /**
  100093. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100094. *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.
  100095. * The SPS is also a particle system. It provides some methods to manage the particles.
  100096. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100097. *
  100098. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100099. */
  100100. export class SolidParticleSystem implements IDisposable {
  100101. /**
  100102. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100103. * Example : var p = SPS.particles[i];
  100104. */
  100105. particles: SolidParticle[];
  100106. /**
  100107. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100108. */
  100109. nbParticles: number;
  100110. /**
  100111. * If the particles must ever face the camera (default false). Useful for planar particles.
  100112. */
  100113. billboard: boolean;
  100114. /**
  100115. * Recompute normals when adding a shape
  100116. */
  100117. recomputeNormals: boolean;
  100118. /**
  100119. * This a counter ofr your own usage. It's not set by any SPS functions.
  100120. */
  100121. counter: number;
  100122. /**
  100123. * The SPS name. This name is also given to the underlying mesh.
  100124. */
  100125. name: string;
  100126. /**
  100127. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100128. */
  100129. mesh: Mesh;
  100130. /**
  100131. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100132. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100133. */
  100134. vars: any;
  100135. /**
  100136. * This array is populated when the SPS is set as 'pickable'.
  100137. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100138. * Each element of this array is an object `{idx: int, faceId: int}`.
  100139. * `idx` is the picked particle index in the `SPS.particles` array
  100140. * `faceId` is the picked face index counted within this particle.
  100141. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100142. */
  100143. pickedParticles: {
  100144. idx: number;
  100145. faceId: number;
  100146. }[];
  100147. /**
  100148. * This array is populated when `enableDepthSort` is set to true.
  100149. * Each element of this array is an instance of the class DepthSortedParticle.
  100150. */
  100151. depthSortedParticles: DepthSortedParticle[];
  100152. /**
  100153. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100154. * @hidden
  100155. */
  100156. _bSphereOnly: boolean;
  100157. /**
  100158. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100159. * @hidden
  100160. */
  100161. _bSphereRadiusFactor: number;
  100162. private _scene;
  100163. private _positions;
  100164. private _indices;
  100165. private _normals;
  100166. private _colors;
  100167. private _uvs;
  100168. private _indices32;
  100169. private _positions32;
  100170. private _normals32;
  100171. private _fixedNormal32;
  100172. private _colors32;
  100173. private _uvs32;
  100174. private _index;
  100175. private _updatable;
  100176. private _pickable;
  100177. private _isVisibilityBoxLocked;
  100178. private _alwaysVisible;
  100179. private _depthSort;
  100180. private _expandable;
  100181. private _shapeCounter;
  100182. private _copy;
  100183. private _color;
  100184. private _computeParticleColor;
  100185. private _computeParticleTexture;
  100186. private _computeParticleRotation;
  100187. private _computeParticleVertex;
  100188. private _computeBoundingBox;
  100189. private _depthSortParticles;
  100190. private _camera;
  100191. private _mustUnrotateFixedNormals;
  100192. private _particlesIntersect;
  100193. private _needs32Bits;
  100194. private _isNotBuilt;
  100195. private _lastParticleId;
  100196. private _idxOfId;
  100197. private _multimaterialEnabled;
  100198. private _useModelMaterial;
  100199. private _indicesByMaterial;
  100200. private _materialIndexes;
  100201. private _depthSortFunction;
  100202. private _materialSortFunction;
  100203. private _materials;
  100204. private _multimaterial;
  100205. private _materialIndexesById;
  100206. private _defaultMaterial;
  100207. private _autoUpdateSubMeshes;
  100208. /**
  100209. * Creates a SPS (Solid Particle System) object.
  100210. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100211. * @param scene (Scene) is the scene in which the SPS is added.
  100212. * @param options defines the options of the sps e.g.
  100213. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100214. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100215. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100216. * * 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.
  100217. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100218. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100219. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100220. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100221. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100222. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100223. */
  100224. constructor(name: string, scene: Scene, options?: {
  100225. updatable?: boolean;
  100226. isPickable?: boolean;
  100227. enableDepthSort?: boolean;
  100228. particleIntersection?: boolean;
  100229. boundingSphereOnly?: boolean;
  100230. bSphereRadiusFactor?: number;
  100231. expandable?: boolean;
  100232. useModelMaterial?: boolean;
  100233. enableMultiMaterial?: boolean;
  100234. });
  100235. /**
  100236. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100237. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100238. * @returns the created mesh
  100239. */
  100240. buildMesh(): Mesh;
  100241. /**
  100242. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100243. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100244. * Thus the particles generated from `digest()` have their property `position` set yet.
  100245. * @param mesh ( Mesh ) is the mesh to be digested
  100246. * @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
  100247. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100248. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100249. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100250. * @returns the current SPS
  100251. */
  100252. digest(mesh: Mesh, options?: {
  100253. facetNb?: number;
  100254. number?: number;
  100255. delta?: number;
  100256. storage?: [];
  100257. }): SolidParticleSystem;
  100258. /**
  100259. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100260. * @hidden
  100261. */
  100262. private _unrotateFixedNormals;
  100263. /**
  100264. * Resets the temporary working copy particle
  100265. * @hidden
  100266. */
  100267. private _resetCopy;
  100268. /**
  100269. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100270. * @param p the current index in the positions array to be updated
  100271. * @param ind the current index in the indices array
  100272. * @param shape a Vector3 array, the shape geometry
  100273. * @param positions the positions array to be updated
  100274. * @param meshInd the shape indices array
  100275. * @param indices the indices array to be updated
  100276. * @param meshUV the shape uv array
  100277. * @param uvs the uv array to be updated
  100278. * @param meshCol the shape color array
  100279. * @param colors the color array to be updated
  100280. * @param meshNor the shape normals array
  100281. * @param normals the normals array to be updated
  100282. * @param idx the particle index
  100283. * @param idxInShape the particle index in its shape
  100284. * @param options the addShape() method passed options
  100285. * @model the particle model
  100286. * @hidden
  100287. */
  100288. private _meshBuilder;
  100289. /**
  100290. * Returns a shape Vector3 array from positions float array
  100291. * @param positions float array
  100292. * @returns a vector3 array
  100293. * @hidden
  100294. */
  100295. private _posToShape;
  100296. /**
  100297. * Returns a shapeUV array from a float uvs (array deep copy)
  100298. * @param uvs as a float array
  100299. * @returns a shapeUV array
  100300. * @hidden
  100301. */
  100302. private _uvsToShapeUV;
  100303. /**
  100304. * Adds a new particle object in the particles array
  100305. * @param idx particle index in particles array
  100306. * @param id particle id
  100307. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100308. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100309. * @param model particle ModelShape object
  100310. * @param shapeId model shape identifier
  100311. * @param idxInShape index of the particle in the current model
  100312. * @param bInfo model bounding info object
  100313. * @param storage target storage array, if any
  100314. * @hidden
  100315. */
  100316. private _addParticle;
  100317. /**
  100318. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100319. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100320. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100321. * @param nb (positive integer) the number of particles to be created from this model
  100322. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100323. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100324. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100325. * @returns the number of shapes in the system
  100326. */
  100327. addShape(mesh: Mesh, nb: number, options?: {
  100328. positionFunction?: any;
  100329. vertexFunction?: any;
  100330. storage?: [];
  100331. }): number;
  100332. /**
  100333. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100334. * @hidden
  100335. */
  100336. private _rebuildParticle;
  100337. /**
  100338. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100339. * @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.
  100340. * @returns the SPS.
  100341. */
  100342. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100343. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100344. * Returns an array with the removed particles.
  100345. * 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.
  100346. * The SPS can't be empty so at least one particle needs to remain in place.
  100347. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100348. * @param start index of the first particle to remove
  100349. * @param end index of the last particle to remove (included)
  100350. * @returns an array populated with the removed particles
  100351. */
  100352. removeParticles(start: number, end: number): SolidParticle[];
  100353. /**
  100354. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100355. * @param solidParticleArray an array populated with Solid Particles objects
  100356. * @returns the SPS
  100357. */
  100358. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100359. /**
  100360. * Creates a new particle and modifies the SPS mesh geometry :
  100361. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100362. * - calls _addParticle() to populate the particle array
  100363. * factorized code from addShape() and insertParticlesFromArray()
  100364. * @param idx particle index in the particles array
  100365. * @param i particle index in its shape
  100366. * @param modelShape particle ModelShape object
  100367. * @param shape shape vertex array
  100368. * @param meshInd shape indices array
  100369. * @param meshUV shape uv array
  100370. * @param meshCol shape color array
  100371. * @param meshNor shape normals array
  100372. * @param bbInfo shape bounding info
  100373. * @param storage target particle storage
  100374. * @options addShape() passed options
  100375. * @hidden
  100376. */
  100377. private _insertNewParticle;
  100378. /**
  100379. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100380. * This method calls `updateParticle()` for each particle of the SPS.
  100381. * For an animated SPS, it is usually called within the render loop.
  100382. * 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.
  100383. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100384. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100385. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100386. * @returns the SPS.
  100387. */
  100388. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100389. /**
  100390. * Disposes the SPS.
  100391. */
  100392. dispose(): void;
  100393. /**
  100394. * Returns a SolidParticle object from its identifier : particle.id
  100395. * @param id (integer) the particle Id
  100396. * @returns the searched particle or null if not found in the SPS.
  100397. */
  100398. getParticleById(id: number): Nullable<SolidParticle>;
  100399. /**
  100400. * Returns a new array populated with the particles having the passed shapeId.
  100401. * @param shapeId (integer) the shape identifier
  100402. * @returns a new solid particle array
  100403. */
  100404. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100405. /**
  100406. * Populates the passed array "ref" with the particles having the passed shapeId.
  100407. * @param shapeId the shape identifier
  100408. * @returns the SPS
  100409. * @param ref
  100410. */
  100411. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100412. /**
  100413. * Computes the required SubMeshes according the materials assigned to the particles.
  100414. * @returns the solid particle system.
  100415. * Does nothing if called before the SPS mesh is built.
  100416. */
  100417. computeSubMeshes(): SolidParticleSystem;
  100418. /**
  100419. * Sorts the solid particles by material when MultiMaterial is enabled.
  100420. * Updates the indices32 array.
  100421. * Updates the indicesByMaterial array.
  100422. * Updates the mesh indices array.
  100423. * @returns the SPS
  100424. * @hidden
  100425. */
  100426. private _sortParticlesByMaterial;
  100427. /**
  100428. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100429. * @hidden
  100430. */
  100431. private _setMaterialIndexesById;
  100432. /**
  100433. * Returns an array with unique values of Materials from the passed array
  100434. * @param array the material array to be checked and filtered
  100435. * @hidden
  100436. */
  100437. private _filterUniqueMaterialId;
  100438. /**
  100439. * Sets a new Standard Material as _defaultMaterial if not already set.
  100440. * @hidden
  100441. */
  100442. private _setDefaultMaterial;
  100443. /**
  100444. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100445. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100446. * @returns the SPS.
  100447. */
  100448. refreshVisibleSize(): SolidParticleSystem;
  100449. /**
  100450. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100451. * @param size the size (float) of the visibility box
  100452. * note : this doesn't lock the SPS mesh bounding box.
  100453. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100454. */
  100455. setVisibilityBox(size: number): void;
  100456. /**
  100457. * Gets whether the SPS as always visible or not
  100458. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100459. */
  100460. get isAlwaysVisible(): boolean;
  100461. /**
  100462. * Sets the SPS as always visible or not
  100463. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100464. */
  100465. set isAlwaysVisible(val: boolean);
  100466. /**
  100467. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100468. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100469. */
  100470. set isVisibilityBoxLocked(val: boolean);
  100471. /**
  100472. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100473. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100474. */
  100475. get isVisibilityBoxLocked(): boolean;
  100476. /**
  100477. * Tells to `setParticles()` to compute the particle rotations or not.
  100478. * Default value : true. The SPS is faster when it's set to false.
  100479. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100480. */
  100481. set computeParticleRotation(val: boolean);
  100482. /**
  100483. * Tells to `setParticles()` to compute the particle colors or not.
  100484. * Default value : true. The SPS is faster when it's set to false.
  100485. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100486. */
  100487. set computeParticleColor(val: boolean);
  100488. set computeParticleTexture(val: boolean);
  100489. /**
  100490. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100491. * Default value : false. The SPS is faster when it's set to false.
  100492. * Note : the particle custom vertex positions aren't stored values.
  100493. */
  100494. set computeParticleVertex(val: boolean);
  100495. /**
  100496. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100497. */
  100498. set computeBoundingBox(val: boolean);
  100499. /**
  100500. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100501. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100502. * Default : `true`
  100503. */
  100504. set depthSortParticles(val: boolean);
  100505. /**
  100506. * Gets if `setParticles()` computes the particle rotations or not.
  100507. * Default value : true. The SPS is faster when it's set to false.
  100508. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100509. */
  100510. get computeParticleRotation(): boolean;
  100511. /**
  100512. * Gets if `setParticles()` computes the particle colors or not.
  100513. * Default value : true. The SPS is faster when it's set to false.
  100514. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100515. */
  100516. get computeParticleColor(): boolean;
  100517. /**
  100518. * Gets if `setParticles()` computes the particle textures or not.
  100519. * Default value : true. The SPS is faster when it's set to false.
  100520. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100521. */
  100522. get computeParticleTexture(): boolean;
  100523. /**
  100524. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100525. * Default value : false. The SPS is faster when it's set to false.
  100526. * Note : the particle custom vertex positions aren't stored values.
  100527. */
  100528. get computeParticleVertex(): boolean;
  100529. /**
  100530. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100531. */
  100532. get computeBoundingBox(): boolean;
  100533. /**
  100534. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100535. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100536. * Default : `true`
  100537. */
  100538. get depthSortParticles(): boolean;
  100539. /**
  100540. * Gets if the SPS is created as expandable at construction time.
  100541. * Default : `false`
  100542. */
  100543. get expandable(): boolean;
  100544. /**
  100545. * Gets if the SPS supports the Multi Materials
  100546. */
  100547. get multimaterialEnabled(): boolean;
  100548. /**
  100549. * Gets if the SPS uses the model materials for its own multimaterial.
  100550. */
  100551. get useModelMaterial(): boolean;
  100552. /**
  100553. * The SPS used material array.
  100554. */
  100555. get materials(): Material[];
  100556. /**
  100557. * Sets the SPS MultiMaterial from the passed materials.
  100558. * Note : the passed array is internally copied and not used then by reference.
  100559. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100560. */
  100561. setMultiMaterial(materials: Material[]): void;
  100562. /**
  100563. * The SPS computed multimaterial object
  100564. */
  100565. get multimaterial(): MultiMaterial;
  100566. set multimaterial(mm: MultiMaterial);
  100567. /**
  100568. * If the subMeshes must be updated on the next call to setParticles()
  100569. */
  100570. get autoUpdateSubMeshes(): boolean;
  100571. set autoUpdateSubMeshes(val: boolean);
  100572. /**
  100573. * This function does nothing. It may be overwritten to set all the particle first values.
  100574. * The SPS doesn't call this function, you may have to call it by your own.
  100575. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100576. */
  100577. initParticles(): void;
  100578. /**
  100579. * This function does nothing. It may be overwritten to recycle a particle.
  100580. * The SPS doesn't call this function, you may have to call it by your own.
  100581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100582. * @param particle The particle to recycle
  100583. * @returns the recycled particle
  100584. */
  100585. recycleParticle(particle: SolidParticle): SolidParticle;
  100586. /**
  100587. * Updates a particle : this function should be overwritten by the user.
  100588. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100589. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100590. * @example : just set a particle position or velocity and recycle conditions
  100591. * @param particle The particle to update
  100592. * @returns the updated particle
  100593. */
  100594. updateParticle(particle: SolidParticle): SolidParticle;
  100595. /**
  100596. * Updates a vertex of a particle : it can be overwritten by the user.
  100597. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100598. * @param particle the current particle
  100599. * @param vertex the current index of the current particle
  100600. * @param pt the index of the current vertex in the particle shape
  100601. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100602. * @example : just set a vertex particle position
  100603. * @returns the updated vertex
  100604. */
  100605. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100606. /**
  100607. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100608. * This does nothing and may be overwritten by the user.
  100609. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100610. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100611. * @param update the boolean update value actually passed to setParticles()
  100612. */
  100613. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100614. /**
  100615. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100616. * This will be passed three parameters.
  100617. * This does nothing and may be overwritten by the user.
  100618. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100619. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100620. * @param update the boolean update value actually passed to setParticles()
  100621. */
  100622. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100623. }
  100624. }
  100625. declare module BABYLON {
  100626. /**
  100627. * Represents one particle of a solid particle system.
  100628. */
  100629. export class SolidParticle {
  100630. /**
  100631. * particle global index
  100632. */
  100633. idx: number;
  100634. /**
  100635. * particle identifier
  100636. */
  100637. id: number;
  100638. /**
  100639. * The color of the particle
  100640. */
  100641. color: Nullable<Color4>;
  100642. /**
  100643. * The world space position of the particle.
  100644. */
  100645. position: Vector3;
  100646. /**
  100647. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100648. */
  100649. rotation: Vector3;
  100650. /**
  100651. * The world space rotation quaternion of the particle.
  100652. */
  100653. rotationQuaternion: Nullable<Quaternion>;
  100654. /**
  100655. * The scaling of the particle.
  100656. */
  100657. scaling: Vector3;
  100658. /**
  100659. * The uvs of the particle.
  100660. */
  100661. uvs: Vector4;
  100662. /**
  100663. * The current speed of the particle.
  100664. */
  100665. velocity: Vector3;
  100666. /**
  100667. * The pivot point in the particle local space.
  100668. */
  100669. pivot: Vector3;
  100670. /**
  100671. * Must the particle be translated from its pivot point in its local space ?
  100672. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100673. * Default : false
  100674. */
  100675. translateFromPivot: boolean;
  100676. /**
  100677. * Is the particle active or not ?
  100678. */
  100679. alive: boolean;
  100680. /**
  100681. * Is the particle visible or not ?
  100682. */
  100683. isVisible: boolean;
  100684. /**
  100685. * Index of this particle in the global "positions" array (Internal use)
  100686. * @hidden
  100687. */
  100688. _pos: number;
  100689. /**
  100690. * @hidden Index of this particle in the global "indices" array (Internal use)
  100691. */
  100692. _ind: number;
  100693. /**
  100694. * @hidden ModelShape of this particle (Internal use)
  100695. */
  100696. _model: ModelShape;
  100697. /**
  100698. * ModelShape id of this particle
  100699. */
  100700. shapeId: number;
  100701. /**
  100702. * Index of the particle in its shape id
  100703. */
  100704. idxInShape: number;
  100705. /**
  100706. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100707. */
  100708. _modelBoundingInfo: BoundingInfo;
  100709. /**
  100710. * @hidden Particle BoundingInfo object (Internal use)
  100711. */
  100712. _boundingInfo: BoundingInfo;
  100713. /**
  100714. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100715. */
  100716. _sps: SolidParticleSystem;
  100717. /**
  100718. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100719. */
  100720. _stillInvisible: boolean;
  100721. /**
  100722. * @hidden Last computed particle rotation matrix
  100723. */
  100724. _rotationMatrix: number[];
  100725. /**
  100726. * Parent particle Id, if any.
  100727. * Default null.
  100728. */
  100729. parentId: Nullable<number>;
  100730. /**
  100731. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100732. */
  100733. materialIndex: Nullable<number>;
  100734. /**
  100735. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100736. * The possible values are :
  100737. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100738. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100739. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100740. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100741. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100742. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100743. * */
  100744. cullingStrategy: number;
  100745. /**
  100746. * @hidden Internal global position in the SPS.
  100747. */
  100748. _globalPosition: Vector3;
  100749. /**
  100750. * Creates a Solid Particle object.
  100751. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100752. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100753. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100754. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100755. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100756. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100757. * @param shapeId (integer) is the model shape identifier in the SPS.
  100758. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100759. * @param sps defines the sps it is associated to
  100760. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100761. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100762. */
  100763. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100764. /**
  100765. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100766. * @param target the particle target
  100767. * @returns the current particle
  100768. */
  100769. copyToRef(target: SolidParticle): SolidParticle;
  100770. /**
  100771. * Legacy support, changed scale to scaling
  100772. */
  100773. get scale(): Vector3;
  100774. /**
  100775. * Legacy support, changed scale to scaling
  100776. */
  100777. set scale(scale: Vector3);
  100778. /**
  100779. * Legacy support, changed quaternion to rotationQuaternion
  100780. */
  100781. get quaternion(): Nullable<Quaternion>;
  100782. /**
  100783. * Legacy support, changed quaternion to rotationQuaternion
  100784. */
  100785. set quaternion(q: Nullable<Quaternion>);
  100786. /**
  100787. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100788. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100789. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100790. * @returns true if it intersects
  100791. */
  100792. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100793. /**
  100794. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100795. * A particle is in the frustum if its bounding box intersects the frustum
  100796. * @param frustumPlanes defines the frustum to test
  100797. * @returns true if the particle is in the frustum planes
  100798. */
  100799. isInFrustum(frustumPlanes: Plane[]): boolean;
  100800. /**
  100801. * get the rotation matrix of the particle
  100802. * @hidden
  100803. */
  100804. getRotationMatrix(m: Matrix): void;
  100805. }
  100806. /**
  100807. * Represents the shape of the model used by one particle of a solid particle system.
  100808. * SPS internal tool, don't use it manually.
  100809. */
  100810. export class ModelShape {
  100811. /**
  100812. * The shape id
  100813. * @hidden
  100814. */
  100815. shapeID: number;
  100816. /**
  100817. * flat array of model positions (internal use)
  100818. * @hidden
  100819. */
  100820. _shape: Vector3[];
  100821. /**
  100822. * flat array of model UVs (internal use)
  100823. * @hidden
  100824. */
  100825. _shapeUV: number[];
  100826. /**
  100827. * color array of the model
  100828. * @hidden
  100829. */
  100830. _shapeColors: number[];
  100831. /**
  100832. * indices array of the model
  100833. * @hidden
  100834. */
  100835. _indices: number[];
  100836. /**
  100837. * normals array of the model
  100838. * @hidden
  100839. */
  100840. _normals: number[];
  100841. /**
  100842. * length of the shape in the model indices array (internal use)
  100843. * @hidden
  100844. */
  100845. _indicesLength: number;
  100846. /**
  100847. * Custom position function (internal use)
  100848. * @hidden
  100849. */
  100850. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100851. /**
  100852. * Custom vertex function (internal use)
  100853. * @hidden
  100854. */
  100855. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100856. /**
  100857. * Model material (internal use)
  100858. * @hidden
  100859. */
  100860. _material: Nullable<Material>;
  100861. /**
  100862. * 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.
  100863. * SPS internal tool, don't use it manually.
  100864. * @hidden
  100865. */
  100866. 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>);
  100867. }
  100868. /**
  100869. * Represents a Depth Sorted Particle in the solid particle system.
  100870. * @hidden
  100871. */
  100872. export class DepthSortedParticle {
  100873. /**
  100874. * Index of the particle in the "indices" array
  100875. */
  100876. ind: number;
  100877. /**
  100878. * Length of the particle shape in the "indices" array
  100879. */
  100880. indicesLength: number;
  100881. /**
  100882. * Squared distance from the particle to the camera
  100883. */
  100884. sqDistance: number;
  100885. /**
  100886. * Material index when used with MultiMaterials
  100887. */
  100888. materialIndex: number;
  100889. /**
  100890. * Creates a new sorted particle
  100891. * @param materialIndex
  100892. */
  100893. constructor(ind: number, indLength: number, materialIndex: number);
  100894. }
  100895. }
  100896. declare module BABYLON {
  100897. /**
  100898. * @hidden
  100899. */
  100900. export class _MeshCollisionData {
  100901. _checkCollisions: boolean;
  100902. _collisionMask: number;
  100903. _collisionGroup: number;
  100904. _collider: Nullable<Collider>;
  100905. _oldPositionForCollisions: Vector3;
  100906. _diffPositionForCollisions: Vector3;
  100907. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100908. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100909. }
  100910. }
  100911. declare module BABYLON {
  100912. /** @hidden */
  100913. class _FacetDataStorage {
  100914. facetPositions: Vector3[];
  100915. facetNormals: Vector3[];
  100916. facetPartitioning: number[][];
  100917. facetNb: number;
  100918. partitioningSubdivisions: number;
  100919. partitioningBBoxRatio: number;
  100920. facetDataEnabled: boolean;
  100921. facetParameters: any;
  100922. bbSize: Vector3;
  100923. subDiv: {
  100924. max: number;
  100925. X: number;
  100926. Y: number;
  100927. Z: number;
  100928. };
  100929. facetDepthSort: boolean;
  100930. facetDepthSortEnabled: boolean;
  100931. depthSortedIndices: IndicesArray;
  100932. depthSortedFacets: {
  100933. ind: number;
  100934. sqDistance: number;
  100935. }[];
  100936. facetDepthSortFunction: (f1: {
  100937. ind: number;
  100938. sqDistance: number;
  100939. }, f2: {
  100940. ind: number;
  100941. sqDistance: number;
  100942. }) => number;
  100943. facetDepthSortFrom: Vector3;
  100944. facetDepthSortOrigin: Vector3;
  100945. invertedMatrix: Matrix;
  100946. }
  100947. /**
  100948. * @hidden
  100949. **/
  100950. class _InternalAbstractMeshDataInfo {
  100951. _hasVertexAlpha: boolean;
  100952. _useVertexColors: boolean;
  100953. _numBoneInfluencers: number;
  100954. _applyFog: boolean;
  100955. _receiveShadows: boolean;
  100956. _facetData: _FacetDataStorage;
  100957. _visibility: number;
  100958. _skeleton: Nullable<Skeleton>;
  100959. _layerMask: number;
  100960. _computeBonesUsingShaders: boolean;
  100961. _isActive: boolean;
  100962. _onlyForInstances: boolean;
  100963. _isActiveIntermediate: boolean;
  100964. _onlyForInstancesIntermediate: boolean;
  100965. _actAsRegularMesh: boolean;
  100966. }
  100967. /**
  100968. * Class used to store all common mesh properties
  100969. */
  100970. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100971. /** No occlusion */
  100972. static OCCLUSION_TYPE_NONE: number;
  100973. /** Occlusion set to optimisitic */
  100974. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100975. /** Occlusion set to strict */
  100976. static OCCLUSION_TYPE_STRICT: number;
  100977. /** Use an accurante occlusion algorithm */
  100978. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100979. /** Use a conservative occlusion algorithm */
  100980. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100981. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100982. * Test order :
  100983. * Is the bounding sphere outside the frustum ?
  100984. * If not, are the bounding box vertices outside the frustum ?
  100985. * It not, then the cullable object is in the frustum.
  100986. */
  100987. static readonly CULLINGSTRATEGY_STANDARD: number;
  100988. /** Culling strategy : Bounding Sphere Only.
  100989. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100990. * It's also less accurate than the standard because some not visible objects can still be selected.
  100991. * Test : is the bounding sphere outside the frustum ?
  100992. * If not, then the cullable object is in the frustum.
  100993. */
  100994. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100995. /** Culling strategy : Optimistic Inclusion.
  100996. * This in an inclusion test first, then the standard exclusion test.
  100997. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  100998. * 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.
  100999. * Anyway, it's as accurate as the standard strategy.
  101000. * Test :
  101001. * Is the cullable object bounding sphere center in the frustum ?
  101002. * If not, apply the default culling strategy.
  101003. */
  101004. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101005. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101006. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101007. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101008. * 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.
  101009. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101010. * Test :
  101011. * Is the cullable object bounding sphere center in the frustum ?
  101012. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101013. */
  101014. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101015. /**
  101016. * No billboard
  101017. */
  101018. static get BILLBOARDMODE_NONE(): number;
  101019. /** Billboard on X axis */
  101020. static get BILLBOARDMODE_X(): number;
  101021. /** Billboard on Y axis */
  101022. static get BILLBOARDMODE_Y(): number;
  101023. /** Billboard on Z axis */
  101024. static get BILLBOARDMODE_Z(): number;
  101025. /** Billboard on all axes */
  101026. static get BILLBOARDMODE_ALL(): number;
  101027. /** Billboard on using position instead of orientation */
  101028. static get BILLBOARDMODE_USE_POSITION(): number;
  101029. /** @hidden */
  101030. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101031. /**
  101032. * The culling strategy to use to check whether the mesh must be rendered or not.
  101033. * This value can be changed at any time and will be used on the next render mesh selection.
  101034. * The possible values are :
  101035. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101036. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101037. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101038. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101039. * Please read each static variable documentation to get details about the culling process.
  101040. * */
  101041. cullingStrategy: number;
  101042. /**
  101043. * Gets the number of facets in the mesh
  101044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101045. */
  101046. get facetNb(): number;
  101047. /**
  101048. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101050. */
  101051. get partitioningSubdivisions(): number;
  101052. set partitioningSubdivisions(nb: number);
  101053. /**
  101054. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101055. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101057. */
  101058. get partitioningBBoxRatio(): number;
  101059. set partitioningBBoxRatio(ratio: number);
  101060. /**
  101061. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101062. * Works only for updatable meshes.
  101063. * Doesn't work with multi-materials
  101064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101065. */
  101066. get mustDepthSortFacets(): boolean;
  101067. set mustDepthSortFacets(sort: boolean);
  101068. /**
  101069. * The location (Vector3) where the facet depth sort must be computed from.
  101070. * By default, the active camera position.
  101071. * Used only when facet depth sort is enabled
  101072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101073. */
  101074. get facetDepthSortFrom(): Vector3;
  101075. set facetDepthSortFrom(location: Vector3);
  101076. /**
  101077. * gets a boolean indicating if facetData is enabled
  101078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101079. */
  101080. get isFacetDataEnabled(): boolean;
  101081. /** @hidden */
  101082. _updateNonUniformScalingState(value: boolean): boolean;
  101083. /**
  101084. * An event triggered when this mesh collides with another one
  101085. */
  101086. onCollideObservable: Observable<AbstractMesh>;
  101087. /** Set a function to call when this mesh collides with another one */
  101088. set onCollide(callback: () => void);
  101089. /**
  101090. * An event triggered when the collision's position changes
  101091. */
  101092. onCollisionPositionChangeObservable: Observable<Vector3>;
  101093. /** Set a function to call when the collision's position changes */
  101094. set onCollisionPositionChange(callback: () => void);
  101095. /**
  101096. * An event triggered when material is changed
  101097. */
  101098. onMaterialChangedObservable: Observable<AbstractMesh>;
  101099. /**
  101100. * Gets or sets the orientation for POV movement & rotation
  101101. */
  101102. definedFacingForward: boolean;
  101103. /** @hidden */
  101104. _occlusionQuery: Nullable<WebGLQuery>;
  101105. /** @hidden */
  101106. _renderingGroup: Nullable<RenderingGroup>;
  101107. /**
  101108. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101109. */
  101110. get visibility(): number;
  101111. /**
  101112. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101113. */
  101114. set visibility(value: number);
  101115. /** Gets or sets the alpha index used to sort transparent meshes
  101116. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101117. */
  101118. alphaIndex: number;
  101119. /**
  101120. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101121. */
  101122. isVisible: boolean;
  101123. /**
  101124. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101125. */
  101126. isPickable: boolean;
  101127. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101128. showSubMeshesBoundingBox: boolean;
  101129. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101131. */
  101132. isBlocker: boolean;
  101133. /**
  101134. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101135. */
  101136. enablePointerMoveEvents: boolean;
  101137. /**
  101138. * Specifies the rendering group id for this mesh (0 by default)
  101139. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101140. */
  101141. renderingGroupId: number;
  101142. private _material;
  101143. /** Gets or sets current material */
  101144. get material(): Nullable<Material>;
  101145. set material(value: Nullable<Material>);
  101146. /**
  101147. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101148. * @see http://doc.babylonjs.com/babylon101/shadows
  101149. */
  101150. get receiveShadows(): boolean;
  101151. set receiveShadows(value: boolean);
  101152. /** Defines color to use when rendering outline */
  101153. outlineColor: Color3;
  101154. /** Define width to use when rendering outline */
  101155. outlineWidth: number;
  101156. /** Defines color to use when rendering overlay */
  101157. overlayColor: Color3;
  101158. /** Defines alpha to use when rendering overlay */
  101159. overlayAlpha: number;
  101160. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101161. get hasVertexAlpha(): boolean;
  101162. set hasVertexAlpha(value: boolean);
  101163. /** 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) */
  101164. get useVertexColors(): boolean;
  101165. set useVertexColors(value: boolean);
  101166. /**
  101167. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101168. */
  101169. get computeBonesUsingShaders(): boolean;
  101170. set computeBonesUsingShaders(value: boolean);
  101171. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101172. get numBoneInfluencers(): number;
  101173. set numBoneInfluencers(value: number);
  101174. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101175. get applyFog(): boolean;
  101176. set applyFog(value: boolean);
  101177. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101178. useOctreeForRenderingSelection: boolean;
  101179. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101180. useOctreeForPicking: boolean;
  101181. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101182. useOctreeForCollisions: boolean;
  101183. /**
  101184. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101185. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101186. */
  101187. get layerMask(): number;
  101188. set layerMask(value: number);
  101189. /**
  101190. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101191. */
  101192. alwaysSelectAsActiveMesh: boolean;
  101193. /**
  101194. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101195. */
  101196. doNotSyncBoundingInfo: boolean;
  101197. /**
  101198. * Gets or sets the current action manager
  101199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101200. */
  101201. actionManager: Nullable<AbstractActionManager>;
  101202. private _meshCollisionData;
  101203. /**
  101204. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101206. */
  101207. ellipsoid: Vector3;
  101208. /**
  101209. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101210. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101211. */
  101212. ellipsoidOffset: Vector3;
  101213. /**
  101214. * Gets or sets a collision mask used to mask collisions (default is -1).
  101215. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101216. */
  101217. get collisionMask(): number;
  101218. set collisionMask(mask: number);
  101219. /**
  101220. * Gets or sets the current collision group mask (-1 by default).
  101221. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101222. */
  101223. get collisionGroup(): number;
  101224. set collisionGroup(mask: number);
  101225. /**
  101226. * Defines edge width used when edgesRenderer is enabled
  101227. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101228. */
  101229. edgesWidth: number;
  101230. /**
  101231. * Defines edge color used when edgesRenderer is enabled
  101232. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101233. */
  101234. edgesColor: Color4;
  101235. /** @hidden */
  101236. _edgesRenderer: Nullable<IEdgesRenderer>;
  101237. /** @hidden */
  101238. _masterMesh: Nullable<AbstractMesh>;
  101239. /** @hidden */
  101240. _boundingInfo: Nullable<BoundingInfo>;
  101241. /** @hidden */
  101242. _renderId: number;
  101243. /**
  101244. * Gets or sets the list of subMeshes
  101245. * @see http://doc.babylonjs.com/how_to/multi_materials
  101246. */
  101247. subMeshes: SubMesh[];
  101248. /** @hidden */
  101249. _intersectionsInProgress: AbstractMesh[];
  101250. /** @hidden */
  101251. _unIndexed: boolean;
  101252. /** @hidden */
  101253. _lightSources: Light[];
  101254. /** Gets the list of lights affecting that mesh */
  101255. get lightSources(): Light[];
  101256. /** @hidden */
  101257. get _positions(): Nullable<Vector3[]>;
  101258. /** @hidden */
  101259. _waitingData: {
  101260. lods: Nullable<any>;
  101261. actions: Nullable<any>;
  101262. freezeWorldMatrix: Nullable<boolean>;
  101263. };
  101264. /** @hidden */
  101265. _bonesTransformMatrices: Nullable<Float32Array>;
  101266. /** @hidden */
  101267. _transformMatrixTexture: Nullable<RawTexture>;
  101268. /**
  101269. * Gets or sets a skeleton to apply skining transformations
  101270. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101271. */
  101272. set skeleton(value: Nullable<Skeleton>);
  101273. get skeleton(): Nullable<Skeleton>;
  101274. /**
  101275. * An event triggered when the mesh is rebuilt.
  101276. */
  101277. onRebuildObservable: Observable<AbstractMesh>;
  101278. /**
  101279. * Creates a new AbstractMesh
  101280. * @param name defines the name of the mesh
  101281. * @param scene defines the hosting scene
  101282. */
  101283. constructor(name: string, scene?: Nullable<Scene>);
  101284. /**
  101285. * Returns the string "AbstractMesh"
  101286. * @returns "AbstractMesh"
  101287. */
  101288. getClassName(): string;
  101289. /**
  101290. * Gets a string representation of the current mesh
  101291. * @param fullDetails defines a boolean indicating if full details must be included
  101292. * @returns a string representation of the current mesh
  101293. */
  101294. toString(fullDetails?: boolean): string;
  101295. /**
  101296. * @hidden
  101297. */
  101298. protected _getEffectiveParent(): Nullable<Node>;
  101299. /** @hidden */
  101300. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101301. /** @hidden */
  101302. _rebuild(): void;
  101303. /** @hidden */
  101304. _resyncLightSources(): void;
  101305. /** @hidden */
  101306. _resyncLightSource(light: Light): void;
  101307. /** @hidden */
  101308. _unBindEffect(): void;
  101309. /** @hidden */
  101310. _removeLightSource(light: Light, dispose: boolean): void;
  101311. private _markSubMeshesAsDirty;
  101312. /** @hidden */
  101313. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101314. /** @hidden */
  101315. _markSubMeshesAsAttributesDirty(): void;
  101316. /** @hidden */
  101317. _markSubMeshesAsMiscDirty(): void;
  101318. /**
  101319. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101320. */
  101321. get scaling(): Vector3;
  101322. set scaling(newScaling: Vector3);
  101323. /**
  101324. * Returns true if the mesh is blocked. Implemented by child classes
  101325. */
  101326. get isBlocked(): boolean;
  101327. /**
  101328. * Returns the mesh itself by default. Implemented by child classes
  101329. * @param camera defines the camera to use to pick the right LOD level
  101330. * @returns the currentAbstractMesh
  101331. */
  101332. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101333. /**
  101334. * Returns 0 by default. Implemented by child classes
  101335. * @returns an integer
  101336. */
  101337. getTotalVertices(): number;
  101338. /**
  101339. * Returns a positive integer : the total number of indices in this mesh geometry.
  101340. * @returns the numner of indices or zero if the mesh has no geometry.
  101341. */
  101342. getTotalIndices(): number;
  101343. /**
  101344. * Returns null by default. Implemented by child classes
  101345. * @returns null
  101346. */
  101347. getIndices(): Nullable<IndicesArray>;
  101348. /**
  101349. * Returns the array of the requested vertex data kind. Implemented by child classes
  101350. * @param kind defines the vertex data kind to use
  101351. * @returns null
  101352. */
  101353. getVerticesData(kind: string): Nullable<FloatArray>;
  101354. /**
  101355. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101356. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101357. * Note that a new underlying VertexBuffer object is created each call.
  101358. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101359. * @param kind defines vertex data kind:
  101360. * * VertexBuffer.PositionKind
  101361. * * VertexBuffer.UVKind
  101362. * * VertexBuffer.UV2Kind
  101363. * * VertexBuffer.UV3Kind
  101364. * * VertexBuffer.UV4Kind
  101365. * * VertexBuffer.UV5Kind
  101366. * * VertexBuffer.UV6Kind
  101367. * * VertexBuffer.ColorKind
  101368. * * VertexBuffer.MatricesIndicesKind
  101369. * * VertexBuffer.MatricesIndicesExtraKind
  101370. * * VertexBuffer.MatricesWeightsKind
  101371. * * VertexBuffer.MatricesWeightsExtraKind
  101372. * @param data defines the data source
  101373. * @param updatable defines if the data must be flagged as updatable (or static)
  101374. * @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
  101375. * @returns the current mesh
  101376. */
  101377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101378. /**
  101379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101380. * If the mesh has no geometry, it is simply returned as it is.
  101381. * @param kind defines vertex data kind:
  101382. * * VertexBuffer.PositionKind
  101383. * * VertexBuffer.UVKind
  101384. * * VertexBuffer.UV2Kind
  101385. * * VertexBuffer.UV3Kind
  101386. * * VertexBuffer.UV4Kind
  101387. * * VertexBuffer.UV5Kind
  101388. * * VertexBuffer.UV6Kind
  101389. * * VertexBuffer.ColorKind
  101390. * * VertexBuffer.MatricesIndicesKind
  101391. * * VertexBuffer.MatricesIndicesExtraKind
  101392. * * VertexBuffer.MatricesWeightsKind
  101393. * * VertexBuffer.MatricesWeightsExtraKind
  101394. * @param data defines the data source
  101395. * @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
  101396. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101397. * @returns the current mesh
  101398. */
  101399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101400. /**
  101401. * Sets the mesh indices,
  101402. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101403. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101404. * @param totalVertices Defines the total number of vertices
  101405. * @returns the current mesh
  101406. */
  101407. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101408. /**
  101409. * Gets a boolean indicating if specific vertex data is present
  101410. * @param kind defines the vertex data kind to use
  101411. * @returns true is data kind is present
  101412. */
  101413. isVerticesDataPresent(kind: string): boolean;
  101414. /**
  101415. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101416. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101417. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101418. * @returns a BoundingInfo
  101419. */
  101420. getBoundingInfo(): BoundingInfo;
  101421. /**
  101422. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101423. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101424. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101425. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101426. * @returns the current mesh
  101427. */
  101428. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101429. /**
  101430. * Overwrite the current bounding info
  101431. * @param boundingInfo defines the new bounding info
  101432. * @returns the current mesh
  101433. */
  101434. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101435. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101436. get useBones(): boolean;
  101437. /** @hidden */
  101438. _preActivate(): void;
  101439. /** @hidden */
  101440. _preActivateForIntermediateRendering(renderId: number): void;
  101441. /** @hidden */
  101442. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101443. /** @hidden */
  101444. _postActivate(): void;
  101445. /** @hidden */
  101446. _freeze(): void;
  101447. /** @hidden */
  101448. _unFreeze(): void;
  101449. /**
  101450. * Gets the current world matrix
  101451. * @returns a Matrix
  101452. */
  101453. getWorldMatrix(): Matrix;
  101454. /** @hidden */
  101455. _getWorldMatrixDeterminant(): number;
  101456. /**
  101457. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101458. */
  101459. get isAnInstance(): boolean;
  101460. /**
  101461. * Gets a boolean indicating if this mesh has instances
  101462. */
  101463. get hasInstances(): boolean;
  101464. /**
  101465. * Perform relative position change from the point of view of behind the front of the mesh.
  101466. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101467. * Supports definition of mesh facing forward or backward
  101468. * @param amountRight defines the distance on the right axis
  101469. * @param amountUp defines the distance on the up axis
  101470. * @param amountForward defines the distance on the forward axis
  101471. * @returns the current mesh
  101472. */
  101473. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101474. /**
  101475. * Calculate relative position change from the point of view of behind the front of the mesh.
  101476. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101477. * Supports definition of mesh facing forward or backward
  101478. * @param amountRight defines the distance on the right axis
  101479. * @param amountUp defines the distance on the up axis
  101480. * @param amountForward defines the distance on the forward axis
  101481. * @returns the new displacement vector
  101482. */
  101483. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101484. /**
  101485. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101486. * Supports definition of mesh facing forward or backward
  101487. * @param flipBack defines the flip
  101488. * @param twirlClockwise defines the twirl
  101489. * @param tiltRight defines the tilt
  101490. * @returns the current mesh
  101491. */
  101492. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101493. /**
  101494. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101495. * Supports definition of mesh facing forward or backward.
  101496. * @param flipBack defines the flip
  101497. * @param twirlClockwise defines the twirl
  101498. * @param tiltRight defines the tilt
  101499. * @returns the new rotation vector
  101500. */
  101501. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101502. /**
  101503. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101504. * This means the mesh underlying bounding box and sphere are recomputed.
  101505. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101506. * @returns the current mesh
  101507. */
  101508. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101509. /** @hidden */
  101510. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101511. /** @hidden */
  101512. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101513. /** @hidden */
  101514. _updateBoundingInfo(): AbstractMesh;
  101515. /** @hidden */
  101516. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101517. /** @hidden */
  101518. protected _afterComputeWorldMatrix(): void;
  101519. /** @hidden */
  101520. get _effectiveMesh(): AbstractMesh;
  101521. /**
  101522. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101523. * A mesh is in the frustum if its bounding box intersects the frustum
  101524. * @param frustumPlanes defines the frustum to test
  101525. * @returns true if the mesh is in the frustum planes
  101526. */
  101527. isInFrustum(frustumPlanes: Plane[]): boolean;
  101528. /**
  101529. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101530. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101531. * @param frustumPlanes defines the frustum to test
  101532. * @returns true if the mesh is completely in the frustum planes
  101533. */
  101534. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101535. /**
  101536. * True if the mesh intersects another mesh or a SolidParticle object
  101537. * @param mesh defines a target mesh or SolidParticle to test
  101538. * @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)
  101539. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101540. * @returns true if there is an intersection
  101541. */
  101542. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101543. /**
  101544. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101545. * @param point defines the point to test
  101546. * @returns true if there is an intersection
  101547. */
  101548. intersectsPoint(point: Vector3): boolean;
  101549. /**
  101550. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101551. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101552. */
  101553. get checkCollisions(): boolean;
  101554. set checkCollisions(collisionEnabled: boolean);
  101555. /**
  101556. * Gets Collider object used to compute collisions (not physics)
  101557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101558. */
  101559. get collider(): Nullable<Collider>;
  101560. /**
  101561. * Move the mesh using collision engine
  101562. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101563. * @param displacement defines the requested displacement vector
  101564. * @returns the current mesh
  101565. */
  101566. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101567. private _onCollisionPositionChange;
  101568. /** @hidden */
  101569. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101570. /** @hidden */
  101571. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101572. /** @hidden */
  101573. _checkCollision(collider: Collider): AbstractMesh;
  101574. /** @hidden */
  101575. _generatePointsArray(): boolean;
  101576. /**
  101577. * Checks if the passed Ray intersects with the mesh
  101578. * @param ray defines the ray to use
  101579. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101580. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101581. * @returns the picking info
  101582. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101583. */
  101584. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101585. /**
  101586. * Clones the current mesh
  101587. * @param name defines the mesh name
  101588. * @param newParent defines the new mesh parent
  101589. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101590. * @returns the new mesh
  101591. */
  101592. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101593. /**
  101594. * Disposes all the submeshes of the current meshnp
  101595. * @returns the current mesh
  101596. */
  101597. releaseSubMeshes(): AbstractMesh;
  101598. /**
  101599. * Releases resources associated with this abstract mesh.
  101600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101602. */
  101603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101604. /**
  101605. * Adds the passed mesh as a child to the current mesh
  101606. * @param mesh defines the child mesh
  101607. * @returns the current mesh
  101608. */
  101609. addChild(mesh: AbstractMesh): AbstractMesh;
  101610. /**
  101611. * Removes the passed mesh from the current mesh children list
  101612. * @param mesh defines the child mesh
  101613. * @returns the current mesh
  101614. */
  101615. removeChild(mesh: AbstractMesh): AbstractMesh;
  101616. /** @hidden */
  101617. private _initFacetData;
  101618. /**
  101619. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101620. * This method can be called within the render loop.
  101621. * 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
  101622. * @returns the current mesh
  101623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101624. */
  101625. updateFacetData(): AbstractMesh;
  101626. /**
  101627. * Returns the facetLocalNormals array.
  101628. * The normals are expressed in the mesh local spac
  101629. * @returns an array of Vector3
  101630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101631. */
  101632. getFacetLocalNormals(): Vector3[];
  101633. /**
  101634. * Returns the facetLocalPositions array.
  101635. * The facet positions are expressed in the mesh local space
  101636. * @returns an array of Vector3
  101637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101638. */
  101639. getFacetLocalPositions(): Vector3[];
  101640. /**
  101641. * Returns the facetLocalPartioning array
  101642. * @returns an array of array of numbers
  101643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101644. */
  101645. getFacetLocalPartitioning(): number[][];
  101646. /**
  101647. * Returns the i-th facet position in the world system.
  101648. * This method allocates a new Vector3 per call
  101649. * @param i defines the facet index
  101650. * @returns a new Vector3
  101651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101652. */
  101653. getFacetPosition(i: number): Vector3;
  101654. /**
  101655. * Sets the reference Vector3 with the i-th facet position in the world system
  101656. * @param i defines the facet index
  101657. * @param ref defines the target vector
  101658. * @returns the current mesh
  101659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101660. */
  101661. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101662. /**
  101663. * Returns the i-th facet normal in the world system.
  101664. * This method allocates a new Vector3 per call
  101665. * @param i defines the facet index
  101666. * @returns a new Vector3
  101667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101668. */
  101669. getFacetNormal(i: number): Vector3;
  101670. /**
  101671. * Sets the reference Vector3 with the i-th facet normal in the world system
  101672. * @param i defines the facet index
  101673. * @param ref defines the target vector
  101674. * @returns the current mesh
  101675. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101676. */
  101677. getFacetNormalToRef(i: number, ref: Vector3): this;
  101678. /**
  101679. * 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)
  101680. * @param x defines x coordinate
  101681. * @param y defines y coordinate
  101682. * @param z defines z coordinate
  101683. * @returns the array of facet indexes
  101684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101685. */
  101686. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101687. /**
  101688. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101689. * @param projected sets as the (x,y,z) world projection on the facet
  101690. * @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
  101691. * @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
  101692. * @param x defines x coordinate
  101693. * @param y defines y coordinate
  101694. * @param z defines z coordinate
  101695. * @returns the face index if found (or null instead)
  101696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101697. */
  101698. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101699. /**
  101700. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101701. * @param projected sets as the (x,y,z) local projection on the facet
  101702. * @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
  101703. * @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
  101704. * @param x defines x coordinate
  101705. * @param y defines y coordinate
  101706. * @param z defines z coordinate
  101707. * @returns the face index if found (or null instead)
  101708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101709. */
  101710. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101711. /**
  101712. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101713. * @returns the parameters
  101714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101715. */
  101716. getFacetDataParameters(): any;
  101717. /**
  101718. * Disables the feature FacetData and frees the related memory
  101719. * @returns the current mesh
  101720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101721. */
  101722. disableFacetData(): AbstractMesh;
  101723. /**
  101724. * Updates the AbstractMesh indices array
  101725. * @param indices defines the data source
  101726. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101727. * @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)
  101728. * @returns the current mesh
  101729. */
  101730. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101731. /**
  101732. * Creates new normals data for the mesh
  101733. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101734. * @returns the current mesh
  101735. */
  101736. createNormals(updatable: boolean): AbstractMesh;
  101737. /**
  101738. * Align the mesh with a normal
  101739. * @param normal defines the normal to use
  101740. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101741. * @returns the current mesh
  101742. */
  101743. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101744. /** @hidden */
  101745. _checkOcclusionQuery(): boolean;
  101746. /**
  101747. * Disables the mesh edge rendering mode
  101748. * @returns the currentAbstractMesh
  101749. */
  101750. disableEdgesRendering(): AbstractMesh;
  101751. /**
  101752. * Enables the edge rendering mode on the mesh.
  101753. * This mode makes the mesh edges visible
  101754. * @param epsilon defines the maximal distance between two angles to detect a face
  101755. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101756. * @returns the currentAbstractMesh
  101757. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101758. */
  101759. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101760. }
  101761. }
  101762. declare module BABYLON {
  101763. /**
  101764. * Interface used to define ActionEvent
  101765. */
  101766. export interface IActionEvent {
  101767. /** The mesh or sprite that triggered the action */
  101768. source: any;
  101769. /** The X mouse cursor position at the time of the event */
  101770. pointerX: number;
  101771. /** The Y mouse cursor position at the time of the event */
  101772. pointerY: number;
  101773. /** The mesh that is currently pointed at (can be null) */
  101774. meshUnderPointer: Nullable<AbstractMesh>;
  101775. /** the original (browser) event that triggered the ActionEvent */
  101776. sourceEvent?: any;
  101777. /** additional data for the event */
  101778. additionalData?: any;
  101779. }
  101780. /**
  101781. * ActionEvent is the event being sent when an action is triggered.
  101782. */
  101783. export class ActionEvent implements IActionEvent {
  101784. /** The mesh or sprite that triggered the action */
  101785. source: any;
  101786. /** The X mouse cursor position at the time of the event */
  101787. pointerX: number;
  101788. /** The Y mouse cursor position at the time of the event */
  101789. pointerY: number;
  101790. /** The mesh that is currently pointed at (can be null) */
  101791. meshUnderPointer: Nullable<AbstractMesh>;
  101792. /** the original (browser) event that triggered the ActionEvent */
  101793. sourceEvent?: any;
  101794. /** additional data for the event */
  101795. additionalData?: any;
  101796. /**
  101797. * Creates a new ActionEvent
  101798. * @param source The mesh or sprite that triggered the action
  101799. * @param pointerX The X mouse cursor position at the time of the event
  101800. * @param pointerY The Y mouse cursor position at the time of the event
  101801. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101802. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101803. * @param additionalData additional data for the event
  101804. */
  101805. constructor(
  101806. /** The mesh or sprite that triggered the action */
  101807. source: any,
  101808. /** The X mouse cursor position at the time of the event */
  101809. pointerX: number,
  101810. /** The Y mouse cursor position at the time of the event */
  101811. pointerY: number,
  101812. /** The mesh that is currently pointed at (can be null) */
  101813. meshUnderPointer: Nullable<AbstractMesh>,
  101814. /** the original (browser) event that triggered the ActionEvent */
  101815. sourceEvent?: any,
  101816. /** additional data for the event */
  101817. additionalData?: any);
  101818. /**
  101819. * Helper function to auto-create an ActionEvent from a source mesh.
  101820. * @param source The source mesh that triggered the event
  101821. * @param evt The original (browser) event
  101822. * @param additionalData additional data for the event
  101823. * @returns the new ActionEvent
  101824. */
  101825. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101826. /**
  101827. * Helper function to auto-create an ActionEvent from a source sprite
  101828. * @param source The source sprite that triggered the event
  101829. * @param scene Scene associated with the sprite
  101830. * @param evt The original (browser) event
  101831. * @param additionalData additional data for the event
  101832. * @returns the new ActionEvent
  101833. */
  101834. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101835. /**
  101836. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101837. * @param scene the scene where the event occurred
  101838. * @param evt The original (browser) event
  101839. * @returns the new ActionEvent
  101840. */
  101841. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101842. /**
  101843. * Helper function to auto-create an ActionEvent from a primitive
  101844. * @param prim defines the target primitive
  101845. * @param pointerPos defines the pointer position
  101846. * @param evt The original (browser) event
  101847. * @param additionalData additional data for the event
  101848. * @returns the new ActionEvent
  101849. */
  101850. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101851. }
  101852. }
  101853. declare module BABYLON {
  101854. /**
  101855. * Abstract class used to decouple action Manager from scene and meshes.
  101856. * Do not instantiate.
  101857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101858. */
  101859. export abstract class AbstractActionManager implements IDisposable {
  101860. /** Gets the list of active triggers */
  101861. static Triggers: {
  101862. [key: string]: number;
  101863. };
  101864. /** Gets the cursor to use when hovering items */
  101865. hoverCursor: string;
  101866. /** Gets the list of actions */
  101867. actions: IAction[];
  101868. /**
  101869. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101870. */
  101871. isRecursive: boolean;
  101872. /**
  101873. * Releases all associated resources
  101874. */
  101875. abstract dispose(): void;
  101876. /**
  101877. * Does this action manager has pointer triggers
  101878. */
  101879. abstract get hasPointerTriggers(): boolean;
  101880. /**
  101881. * Does this action manager has pick triggers
  101882. */
  101883. abstract get hasPickTriggers(): boolean;
  101884. /**
  101885. * Process a specific trigger
  101886. * @param trigger defines the trigger to process
  101887. * @param evt defines the event details to be processed
  101888. */
  101889. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101890. /**
  101891. * Does this action manager handles actions of any of the given triggers
  101892. * @param triggers defines the triggers to be tested
  101893. * @return a boolean indicating whether one (or more) of the triggers is handled
  101894. */
  101895. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101896. /**
  101897. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101898. * speed.
  101899. * @param triggerA defines the trigger to be tested
  101900. * @param triggerB defines the trigger to be tested
  101901. * @return a boolean indicating whether one (or more) of the triggers is handled
  101902. */
  101903. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101904. /**
  101905. * Does this action manager handles actions of a given trigger
  101906. * @param trigger defines the trigger to be tested
  101907. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101908. * @return whether the trigger is handled
  101909. */
  101910. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101911. /**
  101912. * Serialize this manager to a JSON object
  101913. * @param name defines the property name to store this manager
  101914. * @returns a JSON representation of this manager
  101915. */
  101916. abstract serialize(name: string): any;
  101917. /**
  101918. * Registers an action to this action manager
  101919. * @param action defines the action to be registered
  101920. * @return the action amended (prepared) after registration
  101921. */
  101922. abstract registerAction(action: IAction): Nullable<IAction>;
  101923. /**
  101924. * Unregisters an action to this action manager
  101925. * @param action defines the action to be unregistered
  101926. * @return a boolean indicating whether the action has been unregistered
  101927. */
  101928. abstract unregisterAction(action: IAction): Boolean;
  101929. /**
  101930. * Does exist one action manager with at least one trigger
  101931. **/
  101932. static get HasTriggers(): boolean;
  101933. /**
  101934. * Does exist one action manager with at least one pick trigger
  101935. **/
  101936. static get HasPickTriggers(): boolean;
  101937. /**
  101938. * Does exist one action manager that handles actions of a given trigger
  101939. * @param trigger defines the trigger to be tested
  101940. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101941. **/
  101942. static HasSpecificTrigger(trigger: number): boolean;
  101943. }
  101944. }
  101945. declare module BABYLON {
  101946. /**
  101947. * Defines how a node can be built from a string name.
  101948. */
  101949. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101950. /**
  101951. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101952. */
  101953. export class Node implements IBehaviorAware<Node> {
  101954. /** @hidden */
  101955. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101956. private static _NodeConstructors;
  101957. /**
  101958. * Add a new node constructor
  101959. * @param type defines the type name of the node to construct
  101960. * @param constructorFunc defines the constructor function
  101961. */
  101962. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101963. /**
  101964. * Returns a node constructor based on type name
  101965. * @param type defines the type name
  101966. * @param name defines the new node name
  101967. * @param scene defines the hosting scene
  101968. * @param options defines optional options to transmit to constructors
  101969. * @returns the new constructor or null
  101970. */
  101971. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101972. /**
  101973. * Gets or sets the name of the node
  101974. */
  101975. name: string;
  101976. /**
  101977. * Gets or sets the id of the node
  101978. */
  101979. id: string;
  101980. /**
  101981. * Gets or sets the unique id of the node
  101982. */
  101983. uniqueId: number;
  101984. /**
  101985. * Gets or sets a string used to store user defined state for the node
  101986. */
  101987. state: string;
  101988. /**
  101989. * Gets or sets an object used to store user defined information for the node
  101990. */
  101991. metadata: any;
  101992. /**
  101993. * For internal use only. Please do not use.
  101994. */
  101995. reservedDataStore: any;
  101996. /**
  101997. * List of inspectable custom properties (used by the Inspector)
  101998. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101999. */
  102000. inspectableCustomProperties: IInspectable[];
  102001. private _doNotSerialize;
  102002. /**
  102003. * Gets or sets a boolean used to define if the node must be serialized
  102004. */
  102005. get doNotSerialize(): boolean;
  102006. set doNotSerialize(value: boolean);
  102007. /** @hidden */
  102008. _isDisposed: boolean;
  102009. /**
  102010. * Gets a list of Animations associated with the node
  102011. */
  102012. animations: Animation[];
  102013. protected _ranges: {
  102014. [name: string]: Nullable<AnimationRange>;
  102015. };
  102016. /**
  102017. * Callback raised when the node is ready to be used
  102018. */
  102019. onReady: Nullable<(node: Node) => void>;
  102020. private _isEnabled;
  102021. private _isParentEnabled;
  102022. private _isReady;
  102023. /** @hidden */
  102024. _currentRenderId: number;
  102025. private _parentUpdateId;
  102026. /** @hidden */
  102027. _childUpdateId: number;
  102028. /** @hidden */
  102029. _waitingParentId: Nullable<string>;
  102030. /** @hidden */
  102031. _scene: Scene;
  102032. /** @hidden */
  102033. _cache: any;
  102034. private _parentNode;
  102035. private _children;
  102036. /** @hidden */
  102037. _worldMatrix: Matrix;
  102038. /** @hidden */
  102039. _worldMatrixDeterminant: number;
  102040. /** @hidden */
  102041. _worldMatrixDeterminantIsDirty: boolean;
  102042. /** @hidden */
  102043. private _sceneRootNodesIndex;
  102044. /**
  102045. * Gets a boolean indicating if the node has been disposed
  102046. * @returns true if the node was disposed
  102047. */
  102048. isDisposed(): boolean;
  102049. /**
  102050. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102051. * @see https://doc.babylonjs.com/how_to/parenting
  102052. */
  102053. set parent(parent: Nullable<Node>);
  102054. get parent(): Nullable<Node>;
  102055. /** @hidden */
  102056. _addToSceneRootNodes(): void;
  102057. /** @hidden */
  102058. _removeFromSceneRootNodes(): void;
  102059. private _animationPropertiesOverride;
  102060. /**
  102061. * Gets or sets the animation properties override
  102062. */
  102063. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102064. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102065. /**
  102066. * Gets a string idenfifying the name of the class
  102067. * @returns "Node" string
  102068. */
  102069. getClassName(): string;
  102070. /** @hidden */
  102071. readonly _isNode: boolean;
  102072. /**
  102073. * An event triggered when the mesh is disposed
  102074. */
  102075. onDisposeObservable: Observable<Node>;
  102076. private _onDisposeObserver;
  102077. /**
  102078. * Sets a callback that will be raised when the node will be disposed
  102079. */
  102080. set onDispose(callback: () => void);
  102081. /**
  102082. * Creates a new Node
  102083. * @param name the name and id to be given to this node
  102084. * @param scene the scene this node will be added to
  102085. */
  102086. constructor(name: string, scene?: Nullable<Scene>);
  102087. /**
  102088. * Gets the scene of the node
  102089. * @returns a scene
  102090. */
  102091. getScene(): Scene;
  102092. /**
  102093. * Gets the engine of the node
  102094. * @returns a Engine
  102095. */
  102096. getEngine(): Engine;
  102097. private _behaviors;
  102098. /**
  102099. * Attach a behavior to the node
  102100. * @see http://doc.babylonjs.com/features/behaviour
  102101. * @param behavior defines the behavior to attach
  102102. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102103. * @returns the current Node
  102104. */
  102105. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102106. /**
  102107. * Remove an attached behavior
  102108. * @see http://doc.babylonjs.com/features/behaviour
  102109. * @param behavior defines the behavior to attach
  102110. * @returns the current Node
  102111. */
  102112. removeBehavior(behavior: Behavior<Node>): Node;
  102113. /**
  102114. * Gets the list of attached behaviors
  102115. * @see http://doc.babylonjs.com/features/behaviour
  102116. */
  102117. get behaviors(): Behavior<Node>[];
  102118. /**
  102119. * Gets an attached behavior by name
  102120. * @param name defines the name of the behavior to look for
  102121. * @see http://doc.babylonjs.com/features/behaviour
  102122. * @returns null if behavior was not found else the requested behavior
  102123. */
  102124. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102125. /**
  102126. * Returns the latest update of the World matrix
  102127. * @returns a Matrix
  102128. */
  102129. getWorldMatrix(): Matrix;
  102130. /** @hidden */
  102131. _getWorldMatrixDeterminant(): number;
  102132. /**
  102133. * Returns directly the latest state of the mesh World matrix.
  102134. * A Matrix is returned.
  102135. */
  102136. get worldMatrixFromCache(): Matrix;
  102137. /** @hidden */
  102138. _initCache(): void;
  102139. /** @hidden */
  102140. updateCache(force?: boolean): void;
  102141. /** @hidden */
  102142. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102143. /** @hidden */
  102144. _updateCache(ignoreParentClass?: boolean): void;
  102145. /** @hidden */
  102146. _isSynchronized(): boolean;
  102147. /** @hidden */
  102148. _markSyncedWithParent(): void;
  102149. /** @hidden */
  102150. isSynchronizedWithParent(): boolean;
  102151. /** @hidden */
  102152. isSynchronized(): boolean;
  102153. /**
  102154. * Is this node ready to be used/rendered
  102155. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102156. * @return true if the node is ready
  102157. */
  102158. isReady(completeCheck?: boolean): boolean;
  102159. /**
  102160. * Is this node enabled?
  102161. * 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
  102162. * @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
  102163. * @return whether this node (and its parent) is enabled
  102164. */
  102165. isEnabled(checkAncestors?: boolean): boolean;
  102166. /** @hidden */
  102167. protected _syncParentEnabledState(): void;
  102168. /**
  102169. * Set the enabled state of this node
  102170. * @param value defines the new enabled state
  102171. */
  102172. setEnabled(value: boolean): void;
  102173. /**
  102174. * Is this node a descendant of the given node?
  102175. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102176. * @param ancestor defines the parent node to inspect
  102177. * @returns a boolean indicating if this node is a descendant of the given node
  102178. */
  102179. isDescendantOf(ancestor: Node): boolean;
  102180. /** @hidden */
  102181. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102182. /**
  102183. * Will return all nodes that have this node as ascendant
  102184. * @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
  102185. * @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
  102186. * @return all children nodes of all types
  102187. */
  102188. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102189. /**
  102190. * Get all child-meshes of this node
  102191. * @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)
  102192. * @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
  102193. * @returns an array of AbstractMesh
  102194. */
  102195. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102196. /**
  102197. * Get all direct children of this node
  102198. * @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
  102199. * @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)
  102200. * @returns an array of Node
  102201. */
  102202. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102203. /** @hidden */
  102204. _setReady(state: boolean): void;
  102205. /**
  102206. * Get an animation by name
  102207. * @param name defines the name of the animation to look for
  102208. * @returns null if not found else the requested animation
  102209. */
  102210. getAnimationByName(name: string): Nullable<Animation>;
  102211. /**
  102212. * Creates an animation range for this node
  102213. * @param name defines the name of the range
  102214. * @param from defines the starting key
  102215. * @param to defines the end key
  102216. */
  102217. createAnimationRange(name: string, from: number, to: number): void;
  102218. /**
  102219. * Delete a specific animation range
  102220. * @param name defines the name of the range to delete
  102221. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102222. */
  102223. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102224. /**
  102225. * Get an animation range by name
  102226. * @param name defines the name of the animation range to look for
  102227. * @returns null if not found else the requested animation range
  102228. */
  102229. getAnimationRange(name: string): Nullable<AnimationRange>;
  102230. /**
  102231. * Gets the list of all animation ranges defined on this node
  102232. * @returns an array
  102233. */
  102234. getAnimationRanges(): Nullable<AnimationRange>[];
  102235. /**
  102236. * Will start the animation sequence
  102237. * @param name defines the range frames for animation sequence
  102238. * @param loop defines if the animation should loop (false by default)
  102239. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102240. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102241. * @returns the object created for this animation. If range does not exist, it will return null
  102242. */
  102243. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102244. /**
  102245. * Serialize animation ranges into a JSON compatible object
  102246. * @returns serialization object
  102247. */
  102248. serializeAnimationRanges(): any;
  102249. /**
  102250. * Computes the world matrix of the node
  102251. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102252. * @returns the world matrix
  102253. */
  102254. computeWorldMatrix(force?: boolean): Matrix;
  102255. /**
  102256. * Releases resources associated with this node.
  102257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102259. */
  102260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102261. /**
  102262. * Parse animation range data from a serialization object and store them into a given node
  102263. * @param node defines where to store the animation ranges
  102264. * @param parsedNode defines the serialization object to read data from
  102265. * @param scene defines the hosting scene
  102266. */
  102267. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102268. /**
  102269. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102270. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102271. * @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
  102272. * @returns the new bounding vectors
  102273. */
  102274. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102275. min: Vector3;
  102276. max: Vector3;
  102277. };
  102278. }
  102279. }
  102280. declare module BABYLON {
  102281. /**
  102282. * @hidden
  102283. */
  102284. export class _IAnimationState {
  102285. key: number;
  102286. repeatCount: number;
  102287. workValue?: any;
  102288. loopMode?: number;
  102289. offsetValue?: any;
  102290. highLimitValue?: any;
  102291. }
  102292. /**
  102293. * Class used to store any kind of animation
  102294. */
  102295. export class Animation {
  102296. /**Name of the animation */
  102297. name: string;
  102298. /**Property to animate */
  102299. targetProperty: string;
  102300. /**The frames per second of the animation */
  102301. framePerSecond: number;
  102302. /**The data type of the animation */
  102303. dataType: number;
  102304. /**The loop mode of the animation */
  102305. loopMode?: number | undefined;
  102306. /**Specifies if blending should be enabled */
  102307. enableBlending?: boolean | undefined;
  102308. /**
  102309. * Use matrix interpolation instead of using direct key value when animating matrices
  102310. */
  102311. static AllowMatricesInterpolation: boolean;
  102312. /**
  102313. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102314. */
  102315. static AllowMatrixDecomposeForInterpolation: boolean;
  102316. /**
  102317. * Stores the key frames of the animation
  102318. */
  102319. private _keys;
  102320. /**
  102321. * Stores the easing function of the animation
  102322. */
  102323. private _easingFunction;
  102324. /**
  102325. * @hidden Internal use only
  102326. */
  102327. _runtimeAnimations: RuntimeAnimation[];
  102328. /**
  102329. * The set of event that will be linked to this animation
  102330. */
  102331. private _events;
  102332. /**
  102333. * Stores an array of target property paths
  102334. */
  102335. targetPropertyPath: string[];
  102336. /**
  102337. * Stores the blending speed of the animation
  102338. */
  102339. blendingSpeed: number;
  102340. /**
  102341. * Stores the animation ranges for the animation
  102342. */
  102343. private _ranges;
  102344. /**
  102345. * @hidden Internal use
  102346. */
  102347. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102348. /**
  102349. * Sets up an animation
  102350. * @param property The property to animate
  102351. * @param animationType The animation type to apply
  102352. * @param framePerSecond The frames per second of the animation
  102353. * @param easingFunction The easing function used in the animation
  102354. * @returns The created animation
  102355. */
  102356. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102357. /**
  102358. * Create and start an animation on a node
  102359. * @param name defines the name of the global animation that will be run on all nodes
  102360. * @param node defines the root node where the animation will take place
  102361. * @param targetProperty defines property to animate
  102362. * @param framePerSecond defines the number of frame per second yo use
  102363. * @param totalFrame defines the number of frames in total
  102364. * @param from defines the initial value
  102365. * @param to defines the final value
  102366. * @param loopMode defines which loop mode you want to use (off by default)
  102367. * @param easingFunction defines the easing function to use (linear by default)
  102368. * @param onAnimationEnd defines the callback to call when animation end
  102369. * @returns the animatable created for this animation
  102370. */
  102371. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102372. /**
  102373. * Create and start an animation on a node and its descendants
  102374. * @param name defines the name of the global animation that will be run on all nodes
  102375. * @param node defines the root node where the animation will take place
  102376. * @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
  102377. * @param targetProperty defines property to animate
  102378. * @param framePerSecond defines the number of frame per second to use
  102379. * @param totalFrame defines the number of frames in total
  102380. * @param from defines the initial value
  102381. * @param to defines the final value
  102382. * @param loopMode defines which loop mode you want to use (off by default)
  102383. * @param easingFunction defines the easing function to use (linear by default)
  102384. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102385. * @returns the list of animatables created for all nodes
  102386. * @example https://www.babylonjs-playground.com/#MH0VLI
  102387. */
  102388. 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[]>;
  102389. /**
  102390. * Creates a new animation, merges it with the existing animations and starts it
  102391. * @param name Name of the animation
  102392. * @param node Node which contains the scene that begins the animations
  102393. * @param targetProperty Specifies which property to animate
  102394. * @param framePerSecond The frames per second of the animation
  102395. * @param totalFrame The total number of frames
  102396. * @param from The frame at the beginning of the animation
  102397. * @param to The frame at the end of the animation
  102398. * @param loopMode Specifies the loop mode of the animation
  102399. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102400. * @param onAnimationEnd Callback to run once the animation is complete
  102401. * @returns Nullable animation
  102402. */
  102403. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102404. /**
  102405. * Transition property of an host to the target Value
  102406. * @param property The property to transition
  102407. * @param targetValue The target Value of the property
  102408. * @param host The object where the property to animate belongs
  102409. * @param scene Scene used to run the animation
  102410. * @param frameRate Framerate (in frame/s) to use
  102411. * @param transition The transition type we want to use
  102412. * @param duration The duration of the animation, in milliseconds
  102413. * @param onAnimationEnd Callback trigger at the end of the animation
  102414. * @returns Nullable animation
  102415. */
  102416. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102417. /**
  102418. * Return the array of runtime animations currently using this animation
  102419. */
  102420. get runtimeAnimations(): RuntimeAnimation[];
  102421. /**
  102422. * Specifies if any of the runtime animations are currently running
  102423. */
  102424. get hasRunningRuntimeAnimations(): boolean;
  102425. /**
  102426. * Initializes the animation
  102427. * @param name Name of the animation
  102428. * @param targetProperty Property to animate
  102429. * @param framePerSecond The frames per second of the animation
  102430. * @param dataType The data type of the animation
  102431. * @param loopMode The loop mode of the animation
  102432. * @param enableBlending Specifies if blending should be enabled
  102433. */
  102434. constructor(
  102435. /**Name of the animation */
  102436. name: string,
  102437. /**Property to animate */
  102438. targetProperty: string,
  102439. /**The frames per second of the animation */
  102440. framePerSecond: number,
  102441. /**The data type of the animation */
  102442. dataType: number,
  102443. /**The loop mode of the animation */
  102444. loopMode?: number | undefined,
  102445. /**Specifies if blending should be enabled */
  102446. enableBlending?: boolean | undefined);
  102447. /**
  102448. * Converts the animation to a string
  102449. * @param fullDetails support for multiple levels of logging within scene loading
  102450. * @returns String form of the animation
  102451. */
  102452. toString(fullDetails?: boolean): string;
  102453. /**
  102454. * Add an event to this animation
  102455. * @param event Event to add
  102456. */
  102457. addEvent(event: AnimationEvent): void;
  102458. /**
  102459. * Remove all events found at the given frame
  102460. * @param frame The frame to remove events from
  102461. */
  102462. removeEvents(frame: number): void;
  102463. /**
  102464. * Retrieves all the events from the animation
  102465. * @returns Events from the animation
  102466. */
  102467. getEvents(): AnimationEvent[];
  102468. /**
  102469. * Creates an animation range
  102470. * @param name Name of the animation range
  102471. * @param from Starting frame of the animation range
  102472. * @param to Ending frame of the animation
  102473. */
  102474. createRange(name: string, from: number, to: number): void;
  102475. /**
  102476. * Deletes an animation range by name
  102477. * @param name Name of the animation range to delete
  102478. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102479. */
  102480. deleteRange(name: string, deleteFrames?: boolean): void;
  102481. /**
  102482. * Gets the animation range by name, or null if not defined
  102483. * @param name Name of the animation range
  102484. * @returns Nullable animation range
  102485. */
  102486. getRange(name: string): Nullable<AnimationRange>;
  102487. /**
  102488. * Gets the key frames from the animation
  102489. * @returns The key frames of the animation
  102490. */
  102491. getKeys(): Array<IAnimationKey>;
  102492. /**
  102493. * Gets the highest frame rate of the animation
  102494. * @returns Highest frame rate of the animation
  102495. */
  102496. getHighestFrame(): number;
  102497. /**
  102498. * Gets the easing function of the animation
  102499. * @returns Easing function of the animation
  102500. */
  102501. getEasingFunction(): IEasingFunction;
  102502. /**
  102503. * Sets the easing function of the animation
  102504. * @param easingFunction A custom mathematical formula for animation
  102505. */
  102506. setEasingFunction(easingFunction: EasingFunction): void;
  102507. /**
  102508. * Interpolates a scalar linearly
  102509. * @param startValue Start value of the animation curve
  102510. * @param endValue End value of the animation curve
  102511. * @param gradient Scalar amount to interpolate
  102512. * @returns Interpolated scalar value
  102513. */
  102514. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102515. /**
  102516. * Interpolates a scalar cubically
  102517. * @param startValue Start value of the animation curve
  102518. * @param outTangent End tangent of the animation
  102519. * @param endValue End value of the animation curve
  102520. * @param inTangent Start tangent of the animation curve
  102521. * @param gradient Scalar amount to interpolate
  102522. * @returns Interpolated scalar value
  102523. */
  102524. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102525. /**
  102526. * Interpolates a quaternion using a spherical linear interpolation
  102527. * @param startValue Start value of the animation curve
  102528. * @param endValue End value of the animation curve
  102529. * @param gradient Scalar amount to interpolate
  102530. * @returns Interpolated quaternion value
  102531. */
  102532. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102533. /**
  102534. * Interpolates a quaternion cubically
  102535. * @param startValue Start value of the animation curve
  102536. * @param outTangent End tangent of the animation curve
  102537. * @param endValue End value of the animation curve
  102538. * @param inTangent Start tangent of the animation curve
  102539. * @param gradient Scalar amount to interpolate
  102540. * @returns Interpolated quaternion value
  102541. */
  102542. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102543. /**
  102544. * Interpolates a Vector3 linearl
  102545. * @param startValue Start value of the animation curve
  102546. * @param endValue End value of the animation curve
  102547. * @param gradient Scalar amount to interpolate
  102548. * @returns Interpolated scalar value
  102549. */
  102550. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102551. /**
  102552. * Interpolates a Vector3 cubically
  102553. * @param startValue Start value of the animation curve
  102554. * @param outTangent End tangent of the animation
  102555. * @param endValue End value of the animation curve
  102556. * @param inTangent Start tangent of the animation curve
  102557. * @param gradient Scalar amount to interpolate
  102558. * @returns InterpolatedVector3 value
  102559. */
  102560. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102561. /**
  102562. * Interpolates a Vector2 linearly
  102563. * @param startValue Start value of the animation curve
  102564. * @param endValue End value of the animation curve
  102565. * @param gradient Scalar amount to interpolate
  102566. * @returns Interpolated Vector2 value
  102567. */
  102568. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102569. /**
  102570. * Interpolates a Vector2 cubically
  102571. * @param startValue Start value of the animation curve
  102572. * @param outTangent End tangent of the animation
  102573. * @param endValue End value of the animation curve
  102574. * @param inTangent Start tangent of the animation curve
  102575. * @param gradient Scalar amount to interpolate
  102576. * @returns Interpolated Vector2 value
  102577. */
  102578. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102579. /**
  102580. * Interpolates a size linearly
  102581. * @param startValue Start value of the animation curve
  102582. * @param endValue End value of the animation curve
  102583. * @param gradient Scalar amount to interpolate
  102584. * @returns Interpolated Size value
  102585. */
  102586. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102587. /**
  102588. * Interpolates a Color3 linearly
  102589. * @param startValue Start value of the animation curve
  102590. * @param endValue End value of the animation curve
  102591. * @param gradient Scalar amount to interpolate
  102592. * @returns Interpolated Color3 value
  102593. */
  102594. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102595. /**
  102596. * Interpolates a Color4 linearly
  102597. * @param startValue Start value of the animation curve
  102598. * @param endValue End value of the animation curve
  102599. * @param gradient Scalar amount to interpolate
  102600. * @returns Interpolated Color3 value
  102601. */
  102602. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102603. /**
  102604. * @hidden Internal use only
  102605. */
  102606. _getKeyValue(value: any): any;
  102607. /**
  102608. * @hidden Internal use only
  102609. */
  102610. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102611. /**
  102612. * Defines the function to use to interpolate matrices
  102613. * @param startValue defines the start matrix
  102614. * @param endValue defines the end matrix
  102615. * @param gradient defines the gradient between both matrices
  102616. * @param result defines an optional target matrix where to store the interpolation
  102617. * @returns the interpolated matrix
  102618. */
  102619. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102620. /**
  102621. * Makes a copy of the animation
  102622. * @returns Cloned animation
  102623. */
  102624. clone(): Animation;
  102625. /**
  102626. * Sets the key frames of the animation
  102627. * @param values The animation key frames to set
  102628. */
  102629. setKeys(values: Array<IAnimationKey>): void;
  102630. /**
  102631. * Serializes the animation to an object
  102632. * @returns Serialized object
  102633. */
  102634. serialize(): any;
  102635. /**
  102636. * Float animation type
  102637. */
  102638. static readonly ANIMATIONTYPE_FLOAT: number;
  102639. /**
  102640. * Vector3 animation type
  102641. */
  102642. static readonly ANIMATIONTYPE_VECTOR3: number;
  102643. /**
  102644. * Quaternion animation type
  102645. */
  102646. static readonly ANIMATIONTYPE_QUATERNION: number;
  102647. /**
  102648. * Matrix animation type
  102649. */
  102650. static readonly ANIMATIONTYPE_MATRIX: number;
  102651. /**
  102652. * Color3 animation type
  102653. */
  102654. static readonly ANIMATIONTYPE_COLOR3: number;
  102655. /**
  102656. * Color3 animation type
  102657. */
  102658. static readonly ANIMATIONTYPE_COLOR4: number;
  102659. /**
  102660. * Vector2 animation type
  102661. */
  102662. static readonly ANIMATIONTYPE_VECTOR2: number;
  102663. /**
  102664. * Size animation type
  102665. */
  102666. static readonly ANIMATIONTYPE_SIZE: number;
  102667. /**
  102668. * Relative Loop Mode
  102669. */
  102670. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102671. /**
  102672. * Cycle Loop Mode
  102673. */
  102674. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102675. /**
  102676. * Constant Loop Mode
  102677. */
  102678. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102679. /** @hidden */
  102680. static _UniversalLerp(left: any, right: any, amount: number): any;
  102681. /**
  102682. * Parses an animation object and creates an animation
  102683. * @param parsedAnimation Parsed animation object
  102684. * @returns Animation object
  102685. */
  102686. static Parse(parsedAnimation: any): Animation;
  102687. /**
  102688. * Appends the serialized animations from the source animations
  102689. * @param source Source containing the animations
  102690. * @param destination Target to store the animations
  102691. */
  102692. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102693. }
  102694. }
  102695. declare module BABYLON {
  102696. /**
  102697. * Interface containing an array of animations
  102698. */
  102699. export interface IAnimatable {
  102700. /**
  102701. * Array of animations
  102702. */
  102703. animations: Nullable<Array<Animation>>;
  102704. }
  102705. }
  102706. declare module BABYLON {
  102707. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102708. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102709. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102710. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102711. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102712. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102713. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102714. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102715. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102716. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102717. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102718. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102719. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102720. /**
  102721. * Decorator used to define property that can be serialized as reference to a camera
  102722. * @param sourceName defines the name of the property to decorate
  102723. */
  102724. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102725. /**
  102726. * Class used to help serialization objects
  102727. */
  102728. export class SerializationHelper {
  102729. /** @hidden */
  102730. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102731. /** @hidden */
  102732. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102733. /** @hidden */
  102734. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102735. /** @hidden */
  102736. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102737. /**
  102738. * Appends the serialized animations from the source animations
  102739. * @param source Source containing the animations
  102740. * @param destination Target to store the animations
  102741. */
  102742. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102743. /**
  102744. * Static function used to serialized a specific entity
  102745. * @param entity defines the entity to serialize
  102746. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102747. * @returns a JSON compatible object representing the serialization of the entity
  102748. */
  102749. static Serialize<T>(entity: T, serializationObject?: any): any;
  102750. /**
  102751. * Creates a new entity from a serialization data object
  102752. * @param creationFunction defines a function used to instanciated the new entity
  102753. * @param source defines the source serialization data
  102754. * @param scene defines the hosting scene
  102755. * @param rootUrl defines the root url for resources
  102756. * @returns a new entity
  102757. */
  102758. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102759. /**
  102760. * Clones an object
  102761. * @param creationFunction defines the function used to instanciate the new object
  102762. * @param source defines the source object
  102763. * @returns the cloned object
  102764. */
  102765. static Clone<T>(creationFunction: () => T, source: T): T;
  102766. /**
  102767. * Instanciates a new object based on a source one (some data will be shared between both object)
  102768. * @param creationFunction defines the function used to instanciate the new object
  102769. * @param source defines the source object
  102770. * @returns the new object
  102771. */
  102772. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102773. }
  102774. }
  102775. declare module BABYLON {
  102776. /**
  102777. * Class used to manipulate GUIDs
  102778. */
  102779. export class GUID {
  102780. /**
  102781. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102782. * Be aware Math.random() could cause collisions, but:
  102783. * "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"
  102784. * @returns a pseudo random id
  102785. */
  102786. static RandomId(): string;
  102787. }
  102788. }
  102789. declare module BABYLON {
  102790. /**
  102791. * Base class of all the textures in babylon.
  102792. * It groups all the common properties the materials, post process, lights... might need
  102793. * in order to make a correct use of the texture.
  102794. */
  102795. export class BaseTexture implements IAnimatable {
  102796. /**
  102797. * Default anisotropic filtering level for the application.
  102798. * It is set to 4 as a good tradeoff between perf and quality.
  102799. */
  102800. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102801. /**
  102802. * Gets or sets the unique id of the texture
  102803. */
  102804. uniqueId: number;
  102805. /**
  102806. * Define the name of the texture.
  102807. */
  102808. name: string;
  102809. /**
  102810. * Gets or sets an object used to store user defined information.
  102811. */
  102812. metadata: any;
  102813. /**
  102814. * For internal use only. Please do not use.
  102815. */
  102816. reservedDataStore: any;
  102817. private _hasAlpha;
  102818. /**
  102819. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102820. */
  102821. set hasAlpha(value: boolean);
  102822. get hasAlpha(): boolean;
  102823. /**
  102824. * Defines if the alpha value should be determined via the rgb values.
  102825. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102826. */
  102827. getAlphaFromRGB: boolean;
  102828. /**
  102829. * Intensity or strength of the texture.
  102830. * It is commonly used by materials to fine tune the intensity of the texture
  102831. */
  102832. level: number;
  102833. /**
  102834. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102835. * This is part of the texture as textures usually maps to one uv set.
  102836. */
  102837. coordinatesIndex: number;
  102838. private _coordinatesMode;
  102839. /**
  102840. * How a texture is mapped.
  102841. *
  102842. * | Value | Type | Description |
  102843. * | ----- | ----------------------------------- | ----------- |
  102844. * | 0 | EXPLICIT_MODE | |
  102845. * | 1 | SPHERICAL_MODE | |
  102846. * | 2 | PLANAR_MODE | |
  102847. * | 3 | CUBIC_MODE | |
  102848. * | 4 | PROJECTION_MODE | |
  102849. * | 5 | SKYBOX_MODE | |
  102850. * | 6 | INVCUBIC_MODE | |
  102851. * | 7 | EQUIRECTANGULAR_MODE | |
  102852. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102853. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102854. */
  102855. set coordinatesMode(value: number);
  102856. get coordinatesMode(): number;
  102857. /**
  102858. * | Value | Type | Description |
  102859. * | ----- | ------------------ | ----------- |
  102860. * | 0 | CLAMP_ADDRESSMODE | |
  102861. * | 1 | WRAP_ADDRESSMODE | |
  102862. * | 2 | MIRROR_ADDRESSMODE | |
  102863. */
  102864. wrapU: number;
  102865. /**
  102866. * | Value | Type | Description |
  102867. * | ----- | ------------------ | ----------- |
  102868. * | 0 | CLAMP_ADDRESSMODE | |
  102869. * | 1 | WRAP_ADDRESSMODE | |
  102870. * | 2 | MIRROR_ADDRESSMODE | |
  102871. */
  102872. wrapV: number;
  102873. /**
  102874. * | Value | Type | Description |
  102875. * | ----- | ------------------ | ----------- |
  102876. * | 0 | CLAMP_ADDRESSMODE | |
  102877. * | 1 | WRAP_ADDRESSMODE | |
  102878. * | 2 | MIRROR_ADDRESSMODE | |
  102879. */
  102880. wrapR: number;
  102881. /**
  102882. * With compliant hardware and browser (supporting anisotropic filtering)
  102883. * this defines the level of anisotropic filtering in the texture.
  102884. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102885. */
  102886. anisotropicFilteringLevel: number;
  102887. /**
  102888. * Define if the texture is a cube texture or if false a 2d texture.
  102889. */
  102890. get isCube(): boolean;
  102891. set isCube(value: boolean);
  102892. /**
  102893. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102894. */
  102895. get is3D(): boolean;
  102896. set is3D(value: boolean);
  102897. /**
  102898. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102899. */
  102900. get is2DArray(): boolean;
  102901. set is2DArray(value: boolean);
  102902. /**
  102903. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102904. * HDR texture are usually stored in linear space.
  102905. * This only impacts the PBR and Background materials
  102906. */
  102907. gammaSpace: boolean;
  102908. /**
  102909. * Gets or sets whether or not the texture contains RGBD data.
  102910. */
  102911. get isRGBD(): boolean;
  102912. set isRGBD(value: boolean);
  102913. /**
  102914. * Is Z inverted in the texture (useful in a cube texture).
  102915. */
  102916. invertZ: boolean;
  102917. /**
  102918. * Are mip maps generated for this texture or not.
  102919. */
  102920. get noMipmap(): boolean;
  102921. /**
  102922. * @hidden
  102923. */
  102924. lodLevelInAlpha: boolean;
  102925. /**
  102926. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102927. */
  102928. get lodGenerationOffset(): number;
  102929. set lodGenerationOffset(value: number);
  102930. /**
  102931. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102932. */
  102933. get lodGenerationScale(): number;
  102934. set lodGenerationScale(value: number);
  102935. /**
  102936. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102937. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102938. * average roughness values.
  102939. */
  102940. get linearSpecularLOD(): boolean;
  102941. set linearSpecularLOD(value: boolean);
  102942. /**
  102943. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102944. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102945. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102946. */
  102947. get irradianceTexture(): Nullable<BaseTexture>;
  102948. set irradianceTexture(value: Nullable<BaseTexture>);
  102949. /**
  102950. * Define if the texture is a render target.
  102951. */
  102952. isRenderTarget: boolean;
  102953. /**
  102954. * Define the unique id of the texture in the scene.
  102955. */
  102956. get uid(): string;
  102957. /**
  102958. * Return a string representation of the texture.
  102959. * @returns the texture as a string
  102960. */
  102961. toString(): string;
  102962. /**
  102963. * Get the class name of the texture.
  102964. * @returns "BaseTexture"
  102965. */
  102966. getClassName(): string;
  102967. /**
  102968. * Define the list of animation attached to the texture.
  102969. */
  102970. animations: Animation[];
  102971. /**
  102972. * An event triggered when the texture is disposed.
  102973. */
  102974. onDisposeObservable: Observable<BaseTexture>;
  102975. private _onDisposeObserver;
  102976. /**
  102977. * Callback triggered when the texture has been disposed.
  102978. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102979. */
  102980. set onDispose(callback: () => void);
  102981. /**
  102982. * Define the current state of the loading sequence when in delayed load mode.
  102983. */
  102984. delayLoadState: number;
  102985. private _scene;
  102986. /** @hidden */
  102987. _texture: Nullable<InternalTexture>;
  102988. private _uid;
  102989. /**
  102990. * Define if the texture is preventinga material to render or not.
  102991. * If not and the texture is not ready, the engine will use a default black texture instead.
  102992. */
  102993. get isBlocking(): boolean;
  102994. /**
  102995. * Instantiates a new BaseTexture.
  102996. * Base class of all the textures in babylon.
  102997. * It groups all the common properties the materials, post process, lights... might need
  102998. * in order to make a correct use of the texture.
  102999. * @param scene Define the scene the texture blongs to
  103000. */
  103001. constructor(scene: Nullable<Scene>);
  103002. /**
  103003. * Get the scene the texture belongs to.
  103004. * @returns the scene or null if undefined
  103005. */
  103006. getScene(): Nullable<Scene>;
  103007. /**
  103008. * Get the texture transform matrix used to offset tile the texture for istance.
  103009. * @returns the transformation matrix
  103010. */
  103011. getTextureMatrix(): Matrix;
  103012. /**
  103013. * Get the texture reflection matrix used to rotate/transform the reflection.
  103014. * @returns the reflection matrix
  103015. */
  103016. getReflectionTextureMatrix(): Matrix;
  103017. /**
  103018. * Get the underlying lower level texture from Babylon.
  103019. * @returns the insternal texture
  103020. */
  103021. getInternalTexture(): Nullable<InternalTexture>;
  103022. /**
  103023. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103024. * @returns true if ready or not blocking
  103025. */
  103026. isReadyOrNotBlocking(): boolean;
  103027. /**
  103028. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103029. * @returns true if fully ready
  103030. */
  103031. isReady(): boolean;
  103032. private _cachedSize;
  103033. /**
  103034. * Get the size of the texture.
  103035. * @returns the texture size.
  103036. */
  103037. getSize(): ISize;
  103038. /**
  103039. * Get the base size of the texture.
  103040. * It can be different from the size if the texture has been resized for POT for instance
  103041. * @returns the base size
  103042. */
  103043. getBaseSize(): ISize;
  103044. /**
  103045. * Update the sampling mode of the texture.
  103046. * Default is Trilinear mode.
  103047. *
  103048. * | Value | Type | Description |
  103049. * | ----- | ------------------ | ----------- |
  103050. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103051. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103052. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103053. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103054. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103055. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103056. * | 7 | NEAREST_LINEAR | |
  103057. * | 8 | NEAREST_NEAREST | |
  103058. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103059. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103060. * | 11 | LINEAR_LINEAR | |
  103061. * | 12 | LINEAR_NEAREST | |
  103062. *
  103063. * > _mag_: magnification filter (close to the viewer)
  103064. * > _min_: minification filter (far from the viewer)
  103065. * > _mip_: filter used between mip map levels
  103066. *@param samplingMode Define the new sampling mode of the texture
  103067. */
  103068. updateSamplingMode(samplingMode: number): void;
  103069. /**
  103070. * Scales the texture if is `canRescale()`
  103071. * @param ratio the resize factor we want to use to rescale
  103072. */
  103073. scale(ratio: number): void;
  103074. /**
  103075. * Get if the texture can rescale.
  103076. */
  103077. get canRescale(): boolean;
  103078. /** @hidden */
  103079. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103080. /** @hidden */
  103081. _rebuild(): void;
  103082. /**
  103083. * Triggers the load sequence in delayed load mode.
  103084. */
  103085. delayLoad(): void;
  103086. /**
  103087. * Clones the texture.
  103088. * @returns the cloned texture
  103089. */
  103090. clone(): Nullable<BaseTexture>;
  103091. /**
  103092. * Get the texture underlying type (INT, FLOAT...)
  103093. */
  103094. get textureType(): number;
  103095. /**
  103096. * Get the texture underlying format (RGB, RGBA...)
  103097. */
  103098. get textureFormat(): number;
  103099. /**
  103100. * Indicates that textures need to be re-calculated for all materials
  103101. */
  103102. protected _markAllSubMeshesAsTexturesDirty(): void;
  103103. /**
  103104. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103105. * This will returns an RGBA array buffer containing either in values (0-255) or
  103106. * float values (0-1) depending of the underlying buffer type.
  103107. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103108. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103109. * @param buffer defines a user defined buffer to fill with data (can be null)
  103110. * @returns The Array buffer containing the pixels data.
  103111. */
  103112. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103113. /**
  103114. * Release and destroy the underlying lower level texture aka internalTexture.
  103115. */
  103116. releaseInternalTexture(): void;
  103117. /** @hidden */
  103118. get _lodTextureHigh(): Nullable<BaseTexture>;
  103119. /** @hidden */
  103120. get _lodTextureMid(): Nullable<BaseTexture>;
  103121. /** @hidden */
  103122. get _lodTextureLow(): Nullable<BaseTexture>;
  103123. /**
  103124. * Dispose the texture and release its associated resources.
  103125. */
  103126. dispose(): void;
  103127. /**
  103128. * Serialize the texture into a JSON representation that can be parsed later on.
  103129. * @returns the JSON representation of the texture
  103130. */
  103131. serialize(): any;
  103132. /**
  103133. * Helper function to be called back once a list of texture contains only ready textures.
  103134. * @param textures Define the list of textures to wait for
  103135. * @param callback Define the callback triggered once the entire list will be ready
  103136. */
  103137. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103138. }
  103139. }
  103140. declare module BABYLON {
  103141. /**
  103142. * Options to be used when creating an effect.
  103143. */
  103144. export interface IEffectCreationOptions {
  103145. /**
  103146. * Atrributes that will be used in the shader.
  103147. */
  103148. attributes: string[];
  103149. /**
  103150. * Uniform varible names that will be set in the shader.
  103151. */
  103152. uniformsNames: string[];
  103153. /**
  103154. * Uniform buffer variable names that will be set in the shader.
  103155. */
  103156. uniformBuffersNames: string[];
  103157. /**
  103158. * Sampler texture variable names that will be set in the shader.
  103159. */
  103160. samplers: string[];
  103161. /**
  103162. * Define statements that will be set in the shader.
  103163. */
  103164. defines: any;
  103165. /**
  103166. * Possible fallbacks for this effect to improve performance when needed.
  103167. */
  103168. fallbacks: Nullable<IEffectFallbacks>;
  103169. /**
  103170. * Callback that will be called when the shader is compiled.
  103171. */
  103172. onCompiled: Nullable<(effect: Effect) => void>;
  103173. /**
  103174. * Callback that will be called if an error occurs during shader compilation.
  103175. */
  103176. onError: Nullable<(effect: Effect, errors: string) => void>;
  103177. /**
  103178. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103179. */
  103180. indexParameters?: any;
  103181. /**
  103182. * Max number of lights that can be used in the shader.
  103183. */
  103184. maxSimultaneousLights?: number;
  103185. /**
  103186. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103187. */
  103188. transformFeedbackVaryings?: Nullable<string[]>;
  103189. }
  103190. /**
  103191. * Effect containing vertex and fragment shader that can be executed on an object.
  103192. */
  103193. export class Effect implements IDisposable {
  103194. /**
  103195. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103196. */
  103197. static ShadersRepository: string;
  103198. /**
  103199. * Name of the effect.
  103200. */
  103201. name: any;
  103202. /**
  103203. * String container all the define statements that should be set on the shader.
  103204. */
  103205. defines: string;
  103206. /**
  103207. * Callback that will be called when the shader is compiled.
  103208. */
  103209. onCompiled: Nullable<(effect: Effect) => void>;
  103210. /**
  103211. * Callback that will be called if an error occurs during shader compilation.
  103212. */
  103213. onError: Nullable<(effect: Effect, errors: string) => void>;
  103214. /**
  103215. * Callback that will be called when effect is bound.
  103216. */
  103217. onBind: Nullable<(effect: Effect) => void>;
  103218. /**
  103219. * Unique ID of the effect.
  103220. */
  103221. uniqueId: number;
  103222. /**
  103223. * Observable that will be called when the shader is compiled.
  103224. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103225. */
  103226. onCompileObservable: Observable<Effect>;
  103227. /**
  103228. * Observable that will be called if an error occurs during shader compilation.
  103229. */
  103230. onErrorObservable: Observable<Effect>;
  103231. /** @hidden */
  103232. _onBindObservable: Nullable<Observable<Effect>>;
  103233. /**
  103234. * @hidden
  103235. * Specifies if the effect was previously ready
  103236. */
  103237. _wasPreviouslyReady: boolean;
  103238. /**
  103239. * Observable that will be called when effect is bound.
  103240. */
  103241. get onBindObservable(): Observable<Effect>;
  103242. /** @hidden */
  103243. _bonesComputationForcedToCPU: boolean;
  103244. private static _uniqueIdSeed;
  103245. private _engine;
  103246. private _uniformBuffersNames;
  103247. private _uniformsNames;
  103248. private _samplerList;
  103249. private _samplers;
  103250. private _isReady;
  103251. private _compilationError;
  103252. private _allFallbacksProcessed;
  103253. private _attributesNames;
  103254. private _attributes;
  103255. private _attributeLocationByName;
  103256. private _uniforms;
  103257. /**
  103258. * Key for the effect.
  103259. * @hidden
  103260. */
  103261. _key: string;
  103262. private _indexParameters;
  103263. private _fallbacks;
  103264. private _vertexSourceCode;
  103265. private _fragmentSourceCode;
  103266. private _vertexSourceCodeOverride;
  103267. private _fragmentSourceCodeOverride;
  103268. private _transformFeedbackVaryings;
  103269. /**
  103270. * Compiled shader to webGL program.
  103271. * @hidden
  103272. */
  103273. _pipelineContext: Nullable<IPipelineContext>;
  103274. private _valueCache;
  103275. private static _baseCache;
  103276. /**
  103277. * Instantiates an effect.
  103278. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103279. * @param baseName Name of the effect.
  103280. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103281. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103282. * @param samplers List of sampler variables that will be passed to the shader.
  103283. * @param engine Engine to be used to render the effect
  103284. * @param defines Define statements to be added to the shader.
  103285. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103286. * @param onCompiled Callback that will be called when the shader is compiled.
  103287. * @param onError Callback that will be called if an error occurs during shader compilation.
  103288. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103289. */
  103290. 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);
  103291. private _useFinalCode;
  103292. /**
  103293. * Unique key for this effect
  103294. */
  103295. get key(): string;
  103296. /**
  103297. * If the effect has been compiled and prepared.
  103298. * @returns if the effect is compiled and prepared.
  103299. */
  103300. isReady(): boolean;
  103301. private _isReadyInternal;
  103302. /**
  103303. * The engine the effect was initialized with.
  103304. * @returns the engine.
  103305. */
  103306. getEngine(): Engine;
  103307. /**
  103308. * The pipeline context for this effect
  103309. * @returns the associated pipeline context
  103310. */
  103311. getPipelineContext(): Nullable<IPipelineContext>;
  103312. /**
  103313. * The set of names of attribute variables for the shader.
  103314. * @returns An array of attribute names.
  103315. */
  103316. getAttributesNames(): string[];
  103317. /**
  103318. * Returns the attribute at the given index.
  103319. * @param index The index of the attribute.
  103320. * @returns The location of the attribute.
  103321. */
  103322. getAttributeLocation(index: number): number;
  103323. /**
  103324. * Returns the attribute based on the name of the variable.
  103325. * @param name of the attribute to look up.
  103326. * @returns the attribute location.
  103327. */
  103328. getAttributeLocationByName(name: string): number;
  103329. /**
  103330. * The number of attributes.
  103331. * @returns the numnber of attributes.
  103332. */
  103333. getAttributesCount(): number;
  103334. /**
  103335. * Gets the index of a uniform variable.
  103336. * @param uniformName of the uniform to look up.
  103337. * @returns the index.
  103338. */
  103339. getUniformIndex(uniformName: string): number;
  103340. /**
  103341. * Returns the attribute based on the name of the variable.
  103342. * @param uniformName of the uniform to look up.
  103343. * @returns the location of the uniform.
  103344. */
  103345. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103346. /**
  103347. * Returns an array of sampler variable names
  103348. * @returns The array of sampler variable neames.
  103349. */
  103350. getSamplers(): string[];
  103351. /**
  103352. * The error from the last compilation.
  103353. * @returns the error string.
  103354. */
  103355. getCompilationError(): string;
  103356. /**
  103357. * Gets a boolean indicating that all fallbacks were used during compilation
  103358. * @returns true if all fallbacks were used
  103359. */
  103360. allFallbacksProcessed(): boolean;
  103361. /**
  103362. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103363. * @param func The callback to be used.
  103364. */
  103365. executeWhenCompiled(func: (effect: Effect) => void): void;
  103366. private _checkIsReady;
  103367. private _loadShader;
  103368. /**
  103369. * Recompiles the webGL program
  103370. * @param vertexSourceCode The source code for the vertex shader.
  103371. * @param fragmentSourceCode The source code for the fragment shader.
  103372. * @param onCompiled Callback called when completed.
  103373. * @param onError Callback called on error.
  103374. * @hidden
  103375. */
  103376. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103377. /**
  103378. * Prepares the effect
  103379. * @hidden
  103380. */
  103381. _prepareEffect(): void;
  103382. private _processCompilationErrors;
  103383. /**
  103384. * Checks if the effect is supported. (Must be called after compilation)
  103385. */
  103386. get isSupported(): boolean;
  103387. /**
  103388. * Binds a texture to the engine to be used as output of the shader.
  103389. * @param channel Name of the output variable.
  103390. * @param texture Texture to bind.
  103391. * @hidden
  103392. */
  103393. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103394. /**
  103395. * Sets a texture on the engine to be used in the shader.
  103396. * @param channel Name of the sampler variable.
  103397. * @param texture Texture to set.
  103398. */
  103399. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103400. /**
  103401. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103402. * @param channel Name of the sampler variable.
  103403. * @param texture Texture to set.
  103404. */
  103405. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103406. /**
  103407. * Sets an array of textures on the engine to be used in the shader.
  103408. * @param channel Name of the variable.
  103409. * @param textures Textures to set.
  103410. */
  103411. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103412. /**
  103413. * 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)
  103414. * @param channel Name of the sampler variable.
  103415. * @param postProcess Post process to get the input texture from.
  103416. */
  103417. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103418. /**
  103419. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103420. * 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)
  103421. * @param channel Name of the sampler variable.
  103422. * @param postProcess Post process to get the output texture from.
  103423. */
  103424. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103425. /** @hidden */
  103426. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103427. /** @hidden */
  103428. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103429. /** @hidden */
  103430. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103431. /** @hidden */
  103432. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103433. /**
  103434. * Binds a buffer to a uniform.
  103435. * @param buffer Buffer to bind.
  103436. * @param name Name of the uniform variable to bind to.
  103437. */
  103438. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103439. /**
  103440. * Binds block to a uniform.
  103441. * @param blockName Name of the block to bind.
  103442. * @param index Index to bind.
  103443. */
  103444. bindUniformBlock(blockName: string, index: number): void;
  103445. /**
  103446. * Sets an interger value on a uniform variable.
  103447. * @param uniformName Name of the variable.
  103448. * @param value Value to be set.
  103449. * @returns this effect.
  103450. */
  103451. setInt(uniformName: string, value: number): Effect;
  103452. /**
  103453. * Sets an int array on a uniform variable.
  103454. * @param uniformName Name of the variable.
  103455. * @param array array to be set.
  103456. * @returns this effect.
  103457. */
  103458. setIntArray(uniformName: string, array: Int32Array): Effect;
  103459. /**
  103460. * 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)
  103461. * @param uniformName Name of the variable.
  103462. * @param array array to be set.
  103463. * @returns this effect.
  103464. */
  103465. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103466. /**
  103467. * 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)
  103468. * @param uniformName Name of the variable.
  103469. * @param array array to be set.
  103470. * @returns this effect.
  103471. */
  103472. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103473. /**
  103474. * 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)
  103475. * @param uniformName Name of the variable.
  103476. * @param array array to be set.
  103477. * @returns this effect.
  103478. */
  103479. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103480. /**
  103481. * Sets an float array on a uniform variable.
  103482. * @param uniformName Name of the variable.
  103483. * @param array array to be set.
  103484. * @returns this effect.
  103485. */
  103486. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103487. /**
  103488. * 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)
  103489. * @param uniformName Name of the variable.
  103490. * @param array array to be set.
  103491. * @returns this effect.
  103492. */
  103493. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103494. /**
  103495. * 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)
  103496. * @param uniformName Name of the variable.
  103497. * @param array array to be set.
  103498. * @returns this effect.
  103499. */
  103500. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103501. /**
  103502. * 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)
  103503. * @param uniformName Name of the variable.
  103504. * @param array array to be set.
  103505. * @returns this effect.
  103506. */
  103507. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103508. /**
  103509. * Sets an array on a uniform variable.
  103510. * @param uniformName Name of the variable.
  103511. * @param array array to be set.
  103512. * @returns this effect.
  103513. */
  103514. setArray(uniformName: string, array: number[]): Effect;
  103515. /**
  103516. * 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)
  103517. * @param uniformName Name of the variable.
  103518. * @param array array to be set.
  103519. * @returns this effect.
  103520. */
  103521. setArray2(uniformName: string, array: number[]): Effect;
  103522. /**
  103523. * 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)
  103524. * @param uniformName Name of the variable.
  103525. * @param array array to be set.
  103526. * @returns this effect.
  103527. */
  103528. setArray3(uniformName: string, array: number[]): Effect;
  103529. /**
  103530. * 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)
  103531. * @param uniformName Name of the variable.
  103532. * @param array array to be set.
  103533. * @returns this effect.
  103534. */
  103535. setArray4(uniformName: string, array: number[]): Effect;
  103536. /**
  103537. * Sets matrices on a uniform variable.
  103538. * @param uniformName Name of the variable.
  103539. * @param matrices matrices to be set.
  103540. * @returns this effect.
  103541. */
  103542. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103543. /**
  103544. * Sets matrix on a uniform variable.
  103545. * @param uniformName Name of the variable.
  103546. * @param matrix matrix to be set.
  103547. * @returns this effect.
  103548. */
  103549. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103550. /**
  103551. * 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)
  103552. * @param uniformName Name of the variable.
  103553. * @param matrix matrix to be set.
  103554. * @returns this effect.
  103555. */
  103556. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103557. /**
  103558. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103559. * @param uniformName Name of the variable.
  103560. * @param matrix matrix to be set.
  103561. * @returns this effect.
  103562. */
  103563. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103564. /**
  103565. * Sets a float on a uniform variable.
  103566. * @param uniformName Name of the variable.
  103567. * @param value value to be set.
  103568. * @returns this effect.
  103569. */
  103570. setFloat(uniformName: string, value: number): Effect;
  103571. /**
  103572. * Sets a boolean on a uniform variable.
  103573. * @param uniformName Name of the variable.
  103574. * @param bool value to be set.
  103575. * @returns this effect.
  103576. */
  103577. setBool(uniformName: string, bool: boolean): Effect;
  103578. /**
  103579. * Sets a Vector2 on a uniform variable.
  103580. * @param uniformName Name of the variable.
  103581. * @param vector2 vector2 to be set.
  103582. * @returns this effect.
  103583. */
  103584. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103585. /**
  103586. * Sets a float2 on a uniform variable.
  103587. * @param uniformName Name of the variable.
  103588. * @param x First float in float2.
  103589. * @param y Second float in float2.
  103590. * @returns this effect.
  103591. */
  103592. setFloat2(uniformName: string, x: number, y: number): Effect;
  103593. /**
  103594. * Sets a Vector3 on a uniform variable.
  103595. * @param uniformName Name of the variable.
  103596. * @param vector3 Value to be set.
  103597. * @returns this effect.
  103598. */
  103599. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103600. /**
  103601. * Sets a float3 on a uniform variable.
  103602. * @param uniformName Name of the variable.
  103603. * @param x First float in float3.
  103604. * @param y Second float in float3.
  103605. * @param z Third float in float3.
  103606. * @returns this effect.
  103607. */
  103608. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103609. /**
  103610. * Sets a Vector4 on a uniform variable.
  103611. * @param uniformName Name of the variable.
  103612. * @param vector4 Value to be set.
  103613. * @returns this effect.
  103614. */
  103615. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103616. /**
  103617. * Sets a float4 on a uniform variable.
  103618. * @param uniformName Name of the variable.
  103619. * @param x First float in float4.
  103620. * @param y Second float in float4.
  103621. * @param z Third float in float4.
  103622. * @param w Fourth float in float4.
  103623. * @returns this effect.
  103624. */
  103625. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103626. /**
  103627. * Sets a Color3 on a uniform variable.
  103628. * @param uniformName Name of the variable.
  103629. * @param color3 Value to be set.
  103630. * @returns this effect.
  103631. */
  103632. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103633. /**
  103634. * Sets a Color4 on a uniform variable.
  103635. * @param uniformName Name of the variable.
  103636. * @param color3 Value to be set.
  103637. * @param alpha Alpha value to be set.
  103638. * @returns this effect.
  103639. */
  103640. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103641. /**
  103642. * Sets a Color4 on a uniform variable
  103643. * @param uniformName defines the name of the variable
  103644. * @param color4 defines the value to be set
  103645. * @returns this effect.
  103646. */
  103647. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103648. /** Release all associated resources */
  103649. dispose(): void;
  103650. /**
  103651. * This function will add a new shader to the shader store
  103652. * @param name the name of the shader
  103653. * @param pixelShader optional pixel shader content
  103654. * @param vertexShader optional vertex shader content
  103655. */
  103656. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103657. /**
  103658. * Store of each shader (The can be looked up using effect.key)
  103659. */
  103660. static ShadersStore: {
  103661. [key: string]: string;
  103662. };
  103663. /**
  103664. * Store of each included file for a shader (The can be looked up using effect.key)
  103665. */
  103666. static IncludesShadersStore: {
  103667. [key: string]: string;
  103668. };
  103669. /**
  103670. * Resets the cache of effects.
  103671. */
  103672. static ResetCache(): void;
  103673. }
  103674. }
  103675. declare module BABYLON {
  103676. /**
  103677. * Interface used to describe the capabilities of the engine relatively to the current browser
  103678. */
  103679. export interface EngineCapabilities {
  103680. /** Maximum textures units per fragment shader */
  103681. maxTexturesImageUnits: number;
  103682. /** Maximum texture units per vertex shader */
  103683. maxVertexTextureImageUnits: number;
  103684. /** Maximum textures units in the entire pipeline */
  103685. maxCombinedTexturesImageUnits: number;
  103686. /** Maximum texture size */
  103687. maxTextureSize: number;
  103688. /** Maximum texture samples */
  103689. maxSamples?: number;
  103690. /** Maximum cube texture size */
  103691. maxCubemapTextureSize: number;
  103692. /** Maximum render texture size */
  103693. maxRenderTextureSize: number;
  103694. /** Maximum number of vertex attributes */
  103695. maxVertexAttribs: number;
  103696. /** Maximum number of varyings */
  103697. maxVaryingVectors: number;
  103698. /** Maximum number of uniforms per vertex shader */
  103699. maxVertexUniformVectors: number;
  103700. /** Maximum number of uniforms per fragment shader */
  103701. maxFragmentUniformVectors: number;
  103702. /** Defines if standard derivates (dx/dy) are supported */
  103703. standardDerivatives: boolean;
  103704. /** Defines if s3tc texture compression is supported */
  103705. s3tc?: WEBGL_compressed_texture_s3tc;
  103706. /** Defines if pvrtc texture compression is supported */
  103707. pvrtc: any;
  103708. /** Defines if etc1 texture compression is supported */
  103709. etc1: any;
  103710. /** Defines if etc2 texture compression is supported */
  103711. etc2: any;
  103712. /** Defines if astc texture compression is supported */
  103713. astc: any;
  103714. /** Defines if float textures are supported */
  103715. textureFloat: boolean;
  103716. /** Defines if vertex array objects are supported */
  103717. vertexArrayObject: boolean;
  103718. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103719. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103720. /** Gets the maximum level of anisotropy supported */
  103721. maxAnisotropy: number;
  103722. /** Defines if instancing is supported */
  103723. instancedArrays: boolean;
  103724. /** Defines if 32 bits indices are supported */
  103725. uintIndices: boolean;
  103726. /** Defines if high precision shaders are supported */
  103727. highPrecisionShaderSupported: boolean;
  103728. /** Defines if depth reading in the fragment shader is supported */
  103729. fragmentDepthSupported: boolean;
  103730. /** Defines if float texture linear filtering is supported*/
  103731. textureFloatLinearFiltering: boolean;
  103732. /** Defines if rendering to float textures is supported */
  103733. textureFloatRender: boolean;
  103734. /** Defines if half float textures are supported*/
  103735. textureHalfFloat: boolean;
  103736. /** Defines if half float texture linear filtering is supported*/
  103737. textureHalfFloatLinearFiltering: boolean;
  103738. /** Defines if rendering to half float textures is supported */
  103739. textureHalfFloatRender: boolean;
  103740. /** Defines if textureLOD shader command is supported */
  103741. textureLOD: boolean;
  103742. /** Defines if draw buffers extension is supported */
  103743. drawBuffersExtension: boolean;
  103744. /** Defines if depth textures are supported */
  103745. depthTextureExtension: boolean;
  103746. /** Defines if float color buffer are supported */
  103747. colorBufferFloat: boolean;
  103748. /** Gets disjoint timer query extension (null if not supported) */
  103749. timerQuery?: EXT_disjoint_timer_query;
  103750. /** Defines if timestamp can be used with timer query */
  103751. canUseTimestampForTimerQuery: boolean;
  103752. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103753. multiview?: any;
  103754. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103755. oculusMultiview?: any;
  103756. /** Function used to let the system compiles shaders in background */
  103757. parallelShaderCompile?: {
  103758. COMPLETION_STATUS_KHR: number;
  103759. };
  103760. /** Max number of texture samples for MSAA */
  103761. maxMSAASamples: number;
  103762. /** Defines if the blend min max extension is supported */
  103763. blendMinMax: boolean;
  103764. }
  103765. }
  103766. declare module BABYLON {
  103767. /**
  103768. * @hidden
  103769. **/
  103770. export class DepthCullingState {
  103771. private _isDepthTestDirty;
  103772. private _isDepthMaskDirty;
  103773. private _isDepthFuncDirty;
  103774. private _isCullFaceDirty;
  103775. private _isCullDirty;
  103776. private _isZOffsetDirty;
  103777. private _isFrontFaceDirty;
  103778. private _depthTest;
  103779. private _depthMask;
  103780. private _depthFunc;
  103781. private _cull;
  103782. private _cullFace;
  103783. private _zOffset;
  103784. private _frontFace;
  103785. /**
  103786. * Initializes the state.
  103787. */
  103788. constructor();
  103789. get isDirty(): boolean;
  103790. get zOffset(): number;
  103791. set zOffset(value: number);
  103792. get cullFace(): Nullable<number>;
  103793. set cullFace(value: Nullable<number>);
  103794. get cull(): Nullable<boolean>;
  103795. set cull(value: Nullable<boolean>);
  103796. get depthFunc(): Nullable<number>;
  103797. set depthFunc(value: Nullable<number>);
  103798. get depthMask(): boolean;
  103799. set depthMask(value: boolean);
  103800. get depthTest(): boolean;
  103801. set depthTest(value: boolean);
  103802. get frontFace(): Nullable<number>;
  103803. set frontFace(value: Nullable<number>);
  103804. reset(): void;
  103805. apply(gl: WebGLRenderingContext): void;
  103806. }
  103807. }
  103808. declare module BABYLON {
  103809. /**
  103810. * @hidden
  103811. **/
  103812. export class StencilState {
  103813. /** 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 */
  103814. static readonly ALWAYS: number;
  103815. /** Passed to stencilOperation to specify that stencil value must be kept */
  103816. static readonly KEEP: number;
  103817. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103818. static readonly REPLACE: number;
  103819. private _isStencilTestDirty;
  103820. private _isStencilMaskDirty;
  103821. private _isStencilFuncDirty;
  103822. private _isStencilOpDirty;
  103823. private _stencilTest;
  103824. private _stencilMask;
  103825. private _stencilFunc;
  103826. private _stencilFuncRef;
  103827. private _stencilFuncMask;
  103828. private _stencilOpStencilFail;
  103829. private _stencilOpDepthFail;
  103830. private _stencilOpStencilDepthPass;
  103831. get isDirty(): boolean;
  103832. get stencilFunc(): number;
  103833. set stencilFunc(value: number);
  103834. get stencilFuncRef(): number;
  103835. set stencilFuncRef(value: number);
  103836. get stencilFuncMask(): number;
  103837. set stencilFuncMask(value: number);
  103838. get stencilOpStencilFail(): number;
  103839. set stencilOpStencilFail(value: number);
  103840. get stencilOpDepthFail(): number;
  103841. set stencilOpDepthFail(value: number);
  103842. get stencilOpStencilDepthPass(): number;
  103843. set stencilOpStencilDepthPass(value: number);
  103844. get stencilMask(): number;
  103845. set stencilMask(value: number);
  103846. get stencilTest(): boolean;
  103847. set stencilTest(value: boolean);
  103848. constructor();
  103849. reset(): void;
  103850. apply(gl: WebGLRenderingContext): void;
  103851. }
  103852. }
  103853. declare module BABYLON {
  103854. /**
  103855. * @hidden
  103856. **/
  103857. export class AlphaState {
  103858. private _isAlphaBlendDirty;
  103859. private _isBlendFunctionParametersDirty;
  103860. private _isBlendEquationParametersDirty;
  103861. private _isBlendConstantsDirty;
  103862. private _alphaBlend;
  103863. private _blendFunctionParameters;
  103864. private _blendEquationParameters;
  103865. private _blendConstants;
  103866. /**
  103867. * Initializes the state.
  103868. */
  103869. constructor();
  103870. get isDirty(): boolean;
  103871. get alphaBlend(): boolean;
  103872. set alphaBlend(value: boolean);
  103873. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103874. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103875. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103876. reset(): void;
  103877. apply(gl: WebGLRenderingContext): void;
  103878. }
  103879. }
  103880. declare module BABYLON {
  103881. /** @hidden */
  103882. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103883. attributeProcessor(attribute: string): string;
  103884. varyingProcessor(varying: string, isFragment: boolean): string;
  103885. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103886. }
  103887. }
  103888. declare module BABYLON {
  103889. /**
  103890. * Interface for attribute information associated with buffer instanciation
  103891. */
  103892. export interface InstancingAttributeInfo {
  103893. /**
  103894. * Name of the GLSL attribute
  103895. * if attribute index is not specified, this is used to retrieve the index from the effect
  103896. */
  103897. attributeName: string;
  103898. /**
  103899. * Index/offset of the attribute in the vertex shader
  103900. * if not specified, this will be computes from the name.
  103901. */
  103902. index?: number;
  103903. /**
  103904. * size of the attribute, 1, 2, 3 or 4
  103905. */
  103906. attributeSize: number;
  103907. /**
  103908. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103909. */
  103910. offset: number;
  103911. /**
  103912. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103913. * default to 1
  103914. */
  103915. divisor?: number;
  103916. /**
  103917. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103918. * default is FLOAT
  103919. */
  103920. attributeType?: number;
  103921. /**
  103922. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103923. */
  103924. normalized?: boolean;
  103925. }
  103926. }
  103927. declare module BABYLON {
  103928. interface ThinEngine {
  103929. /**
  103930. * Update a video texture
  103931. * @param texture defines the texture to update
  103932. * @param video defines the video element to use
  103933. * @param invertY defines if data must be stored with Y axis inverted
  103934. */
  103935. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103936. }
  103937. }
  103938. declare module BABYLON {
  103939. /**
  103940. * Settings for finer control over video usage
  103941. */
  103942. export interface VideoTextureSettings {
  103943. /**
  103944. * Applies `autoplay` to video, if specified
  103945. */
  103946. autoPlay?: boolean;
  103947. /**
  103948. * Applies `loop` to video, if specified
  103949. */
  103950. loop?: boolean;
  103951. /**
  103952. * Automatically updates internal texture from video at every frame in the render loop
  103953. */
  103954. autoUpdateTexture: boolean;
  103955. /**
  103956. * Image src displayed during the video loading or until the user interacts with the video.
  103957. */
  103958. poster?: string;
  103959. }
  103960. /**
  103961. * If you want to display a video in your scene, this is the special texture for that.
  103962. * This special texture works similar to other textures, with the exception of a few parameters.
  103963. * @see https://doc.babylonjs.com/how_to/video_texture
  103964. */
  103965. export class VideoTexture extends Texture {
  103966. /**
  103967. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103968. */
  103969. readonly autoUpdateTexture: boolean;
  103970. /**
  103971. * The video instance used by the texture internally
  103972. */
  103973. readonly video: HTMLVideoElement;
  103974. private _onUserActionRequestedObservable;
  103975. /**
  103976. * Event triggerd when a dom action is required by the user to play the video.
  103977. * This happens due to recent changes in browser policies preventing video to auto start.
  103978. */
  103979. get onUserActionRequestedObservable(): Observable<Texture>;
  103980. private _generateMipMaps;
  103981. private _engine;
  103982. private _stillImageCaptured;
  103983. private _displayingPosterTexture;
  103984. private _settings;
  103985. private _createInternalTextureOnEvent;
  103986. private _frameId;
  103987. private _currentSrc;
  103988. /**
  103989. * Creates a video texture.
  103990. * If you want to display a video in your scene, this is the special texture for that.
  103991. * This special texture works similar to other textures, with the exception of a few parameters.
  103992. * @see https://doc.babylonjs.com/how_to/video_texture
  103993. * @param name optional name, will detect from video source, if not defined
  103994. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103995. * @param scene is obviously the current scene.
  103996. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103997. * @param invertY is false by default but can be used to invert video on Y axis
  103998. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  103999. * @param settings allows finer control over video usage
  104000. */
  104001. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104002. private _getName;
  104003. private _getVideo;
  104004. private _createInternalTexture;
  104005. private reset;
  104006. /**
  104007. * @hidden Internal method to initiate `update`.
  104008. */
  104009. _rebuild(): void;
  104010. /**
  104011. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104012. */
  104013. update(): void;
  104014. /**
  104015. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104016. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104017. */
  104018. updateTexture(isVisible: boolean): void;
  104019. protected _updateInternalTexture: () => void;
  104020. /**
  104021. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104022. * @param url New url.
  104023. */
  104024. updateURL(url: string): void;
  104025. /**
  104026. * Clones the texture.
  104027. * @returns the cloned texture
  104028. */
  104029. clone(): VideoTexture;
  104030. /**
  104031. * Dispose the texture and release its associated resources.
  104032. */
  104033. dispose(): void;
  104034. /**
  104035. * Creates a video texture straight from a stream.
  104036. * @param scene Define the scene the texture should be created in
  104037. * @param stream Define the stream the texture should be created from
  104038. * @returns The created video texture as a promise
  104039. */
  104040. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104041. /**
  104042. * Creates a video texture straight from your WebCam video feed.
  104043. * @param scene Define the scene the texture should be created in
  104044. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104045. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104046. * @returns The created video texture as a promise
  104047. */
  104048. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104049. minWidth: number;
  104050. maxWidth: number;
  104051. minHeight: number;
  104052. maxHeight: number;
  104053. deviceId: string;
  104054. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104055. /**
  104056. * Creates a video texture straight from your WebCam video feed.
  104057. * @param scene Define the scene the texture should be created in
  104058. * @param onReady Define a callback to triggered once the texture will be ready
  104059. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104060. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104061. */
  104062. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104063. minWidth: number;
  104064. maxWidth: number;
  104065. minHeight: number;
  104066. maxHeight: number;
  104067. deviceId: string;
  104068. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104069. }
  104070. }
  104071. declare module BABYLON {
  104072. /**
  104073. * Defines the interface used by objects working like Scene
  104074. * @hidden
  104075. */
  104076. interface ISceneLike {
  104077. _addPendingData(data: any): void;
  104078. _removePendingData(data: any): void;
  104079. offlineProvider: IOfflineProvider;
  104080. }
  104081. /** Interface defining initialization parameters for Engine class */
  104082. export interface EngineOptions extends WebGLContextAttributes {
  104083. /**
  104084. * Defines if the engine should no exceed a specified device ratio
  104085. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104086. */
  104087. limitDeviceRatio?: number;
  104088. /**
  104089. * Defines if webvr should be enabled automatically
  104090. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104091. */
  104092. autoEnableWebVR?: boolean;
  104093. /**
  104094. * Defines if webgl2 should be turned off even if supported
  104095. * @see http://doc.babylonjs.com/features/webgl2
  104096. */
  104097. disableWebGL2Support?: boolean;
  104098. /**
  104099. * Defines if webaudio should be initialized as well
  104100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104101. */
  104102. audioEngine?: boolean;
  104103. /**
  104104. * Defines if animations should run using a deterministic lock step
  104105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104106. */
  104107. deterministicLockstep?: boolean;
  104108. /** Defines the maximum steps to use with deterministic lock step mode */
  104109. lockstepMaxSteps?: number;
  104110. /** Defines the seconds between each deterministic lock step */
  104111. timeStep?: number;
  104112. /**
  104113. * Defines that engine should ignore context lost events
  104114. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104115. */
  104116. doNotHandleContextLost?: boolean;
  104117. /**
  104118. * Defines that engine should ignore modifying touch action attribute and style
  104119. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104120. */
  104121. doNotHandleTouchAction?: boolean;
  104122. /**
  104123. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104124. */
  104125. useHighPrecisionFloats?: boolean;
  104126. }
  104127. /**
  104128. * The base engine class (root of all engines)
  104129. */
  104130. export class ThinEngine {
  104131. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104132. static ExceptionList: ({
  104133. key: string;
  104134. capture: string;
  104135. captureConstraint: number;
  104136. targets: string[];
  104137. } | {
  104138. key: string;
  104139. capture: null;
  104140. captureConstraint: null;
  104141. targets: string[];
  104142. })[];
  104143. /** @hidden */
  104144. static _TextureLoaders: IInternalTextureLoader[];
  104145. /**
  104146. * Returns the current npm package of the sdk
  104147. */
  104148. static get NpmPackage(): string;
  104149. /**
  104150. * Returns the current version of the framework
  104151. */
  104152. static get Version(): string;
  104153. /**
  104154. * Returns a string describing the current engine
  104155. */
  104156. get description(): string;
  104157. /**
  104158. * Gets or sets the epsilon value used by collision engine
  104159. */
  104160. static CollisionsEpsilon: number;
  104161. /**
  104162. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104163. */
  104164. static get ShadersRepository(): string;
  104165. static set ShadersRepository(value: string);
  104166. /**
  104167. * Gets or sets the textures that the engine should not attempt to load as compressed
  104168. */
  104169. protected _excludedCompressedTextures: string[];
  104170. /**
  104171. * Filters the compressed texture formats to only include
  104172. * files that are not included in the skippable list
  104173. *
  104174. * @param url the current extension
  104175. * @param textureFormatInUse the current compressed texture format
  104176. * @returns "format" string
  104177. */
  104178. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  104179. /** @hidden */
  104180. _shaderProcessor: IShaderProcessor;
  104181. /**
  104182. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104183. */
  104184. forcePOTTextures: boolean;
  104185. /**
  104186. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104187. */
  104188. isFullscreen: boolean;
  104189. /**
  104190. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104191. */
  104192. cullBackFaces: boolean;
  104193. /**
  104194. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104195. */
  104196. renderEvenInBackground: boolean;
  104197. /**
  104198. * Gets or sets a boolean indicating that cache can be kept between frames
  104199. */
  104200. preventCacheWipeBetweenFrames: boolean;
  104201. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104202. validateShaderPrograms: boolean;
  104203. /**
  104204. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104205. * This can provide greater z depth for distant objects.
  104206. */
  104207. useReverseDepthBuffer: boolean;
  104208. /**
  104209. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104210. */
  104211. disableUniformBuffers: boolean;
  104212. /** @hidden */
  104213. _uniformBuffers: UniformBuffer[];
  104214. /**
  104215. * Gets a boolean indicating that the engine supports uniform buffers
  104216. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104217. */
  104218. get supportsUniformBuffers(): boolean;
  104219. /** @hidden */
  104220. _gl: WebGLRenderingContext;
  104221. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104222. protected _windowIsBackground: boolean;
  104223. protected _webGLVersion: number;
  104224. protected _creationOptions: EngineOptions;
  104225. protected _highPrecisionShadersAllowed: boolean;
  104226. /** @hidden */
  104227. get _shouldUseHighPrecisionShader(): boolean;
  104228. /**
  104229. * Gets a boolean indicating that only power of 2 textures are supported
  104230. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104231. */
  104232. get needPOTTextures(): boolean;
  104233. /** @hidden */
  104234. _badOS: boolean;
  104235. /** @hidden */
  104236. _badDesktopOS: boolean;
  104237. private _hardwareScalingLevel;
  104238. /** @hidden */
  104239. _caps: EngineCapabilities;
  104240. private _isStencilEnable;
  104241. private _glVersion;
  104242. private _glRenderer;
  104243. private _glVendor;
  104244. /** @hidden */
  104245. _videoTextureSupported: boolean;
  104246. protected _renderingQueueLaunched: boolean;
  104247. protected _activeRenderLoops: (() => void)[];
  104248. /**
  104249. * Observable signaled when a context lost event is raised
  104250. */
  104251. onContextLostObservable: Observable<ThinEngine>;
  104252. /**
  104253. * Observable signaled when a context restored event is raised
  104254. */
  104255. onContextRestoredObservable: Observable<ThinEngine>;
  104256. private _onContextLost;
  104257. private _onContextRestored;
  104258. protected _contextWasLost: boolean;
  104259. /** @hidden */
  104260. _doNotHandleContextLost: boolean;
  104261. /**
  104262. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104264. */
  104265. get doNotHandleContextLost(): boolean;
  104266. set doNotHandleContextLost(value: boolean);
  104267. /**
  104268. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104269. */
  104270. disableVertexArrayObjects: boolean;
  104271. /** @hidden */
  104272. protected _colorWrite: boolean;
  104273. /** @hidden */
  104274. protected _colorWriteChanged: boolean;
  104275. /** @hidden */
  104276. protected _depthCullingState: DepthCullingState;
  104277. /** @hidden */
  104278. protected _stencilState: StencilState;
  104279. /** @hidden */
  104280. _alphaState: AlphaState;
  104281. /** @hidden */
  104282. _alphaMode: number;
  104283. /** @hidden */
  104284. _alphaEquation: number;
  104285. /** @hidden */
  104286. _internalTexturesCache: InternalTexture[];
  104287. /** @hidden */
  104288. protected _activeChannel: number;
  104289. private _currentTextureChannel;
  104290. /** @hidden */
  104291. protected _boundTexturesCache: {
  104292. [key: string]: Nullable<InternalTexture>;
  104293. };
  104294. /** @hidden */
  104295. protected _currentEffect: Nullable<Effect>;
  104296. /** @hidden */
  104297. protected _currentProgram: Nullable<WebGLProgram>;
  104298. private _compiledEffects;
  104299. private _vertexAttribArraysEnabled;
  104300. /** @hidden */
  104301. protected _cachedViewport: Nullable<IViewportLike>;
  104302. private _cachedVertexArrayObject;
  104303. /** @hidden */
  104304. protected _cachedVertexBuffers: any;
  104305. /** @hidden */
  104306. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104307. /** @hidden */
  104308. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104309. /** @hidden */
  104310. _currentRenderTarget: Nullable<InternalTexture>;
  104311. private _uintIndicesCurrentlySet;
  104312. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104313. /** @hidden */
  104314. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104315. private _currentBufferPointers;
  104316. private _currentInstanceLocations;
  104317. private _currentInstanceBuffers;
  104318. private _textureUnits;
  104319. /** @hidden */
  104320. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104321. /** @hidden */
  104322. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104323. /** @hidden */
  104324. _boundRenderFunction: any;
  104325. private _vaoRecordInProgress;
  104326. private _mustWipeVertexAttributes;
  104327. private _emptyTexture;
  104328. private _emptyCubeTexture;
  104329. private _emptyTexture3D;
  104330. private _emptyTexture2DArray;
  104331. /** @hidden */
  104332. _frameHandler: number;
  104333. private _nextFreeTextureSlots;
  104334. private _maxSimultaneousTextures;
  104335. private _activeRequests;
  104336. protected _texturesSupported: string[];
  104337. /** @hidden */
  104338. _textureFormatInUse: Nullable<string>;
  104339. protected get _supportsHardwareTextureRescaling(): boolean;
  104340. /**
  104341. * Gets the list of texture formats supported
  104342. */
  104343. get texturesSupported(): Array<string>;
  104344. /**
  104345. * Gets the list of texture formats in use
  104346. */
  104347. get textureFormatInUse(): Nullable<string>;
  104348. /**
  104349. * Gets the current viewport
  104350. */
  104351. get currentViewport(): Nullable<IViewportLike>;
  104352. /**
  104353. * Gets the default empty texture
  104354. */
  104355. get emptyTexture(): InternalTexture;
  104356. /**
  104357. * Gets the default empty 3D texture
  104358. */
  104359. get emptyTexture3D(): InternalTexture;
  104360. /**
  104361. * Gets the default empty 2D array texture
  104362. */
  104363. get emptyTexture2DArray(): InternalTexture;
  104364. /**
  104365. * Gets the default empty cube texture
  104366. */
  104367. get emptyCubeTexture(): InternalTexture;
  104368. /**
  104369. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104370. */
  104371. readonly premultipliedAlpha: boolean;
  104372. /**
  104373. * Observable event triggered before each texture is initialized
  104374. */
  104375. onBeforeTextureInitObservable: Observable<Texture>;
  104376. /**
  104377. * Creates a new engine
  104378. * @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
  104379. * @param antialias defines enable antialiasing (default: false)
  104380. * @param options defines further options to be sent to the getContext() function
  104381. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104382. */
  104383. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104384. private _rebuildInternalTextures;
  104385. private _rebuildEffects;
  104386. /**
  104387. * Gets a boolean indicating if all created effects are ready
  104388. * @returns true if all effects are ready
  104389. */
  104390. areAllEffectsReady(): boolean;
  104391. protected _rebuildBuffers(): void;
  104392. private _initGLContext;
  104393. /**
  104394. * Gets version of the current webGL context
  104395. */
  104396. get webGLVersion(): number;
  104397. /**
  104398. * Gets a string idenfifying the name of the class
  104399. * @returns "Engine" string
  104400. */
  104401. getClassName(): string;
  104402. /**
  104403. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104404. */
  104405. get isStencilEnable(): boolean;
  104406. /** @hidden */
  104407. _prepareWorkingCanvas(): void;
  104408. /**
  104409. * Reset the texture cache to empty state
  104410. */
  104411. resetTextureCache(): void;
  104412. /**
  104413. * Gets an object containing information about the current webGL context
  104414. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104415. */
  104416. getGlInfo(): {
  104417. vendor: string;
  104418. renderer: string;
  104419. version: string;
  104420. };
  104421. /**
  104422. * Defines the hardware scaling level.
  104423. * By default the hardware scaling level is computed from the window device ratio.
  104424. * 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.
  104425. * @param level defines the level to use
  104426. */
  104427. setHardwareScalingLevel(level: number): void;
  104428. /**
  104429. * Gets the current hardware scaling level.
  104430. * By default the hardware scaling level is computed from the window device ratio.
  104431. * 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.
  104432. * @returns a number indicating the current hardware scaling level
  104433. */
  104434. getHardwareScalingLevel(): number;
  104435. /**
  104436. * Gets the list of loaded textures
  104437. * @returns an array containing all loaded textures
  104438. */
  104439. getLoadedTexturesCache(): InternalTexture[];
  104440. /**
  104441. * Gets the object containing all engine capabilities
  104442. * @returns the EngineCapabilities object
  104443. */
  104444. getCaps(): EngineCapabilities;
  104445. /**
  104446. * stop executing a render loop function and remove it from the execution array
  104447. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104448. */
  104449. stopRenderLoop(renderFunction?: () => void): void;
  104450. /** @hidden */
  104451. _renderLoop(): void;
  104452. /**
  104453. * Gets the HTML canvas attached with the current webGL context
  104454. * @returns a HTML canvas
  104455. */
  104456. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104457. /**
  104458. * Gets host window
  104459. * @returns the host window object
  104460. */
  104461. getHostWindow(): Nullable<Window>;
  104462. /**
  104463. * Gets the current render width
  104464. * @param useScreen defines if screen size must be used (or the current render target if any)
  104465. * @returns a number defining the current render width
  104466. */
  104467. getRenderWidth(useScreen?: boolean): number;
  104468. /**
  104469. * Gets the current render height
  104470. * @param useScreen defines if screen size must be used (or the current render target if any)
  104471. * @returns a number defining the current render height
  104472. */
  104473. getRenderHeight(useScreen?: boolean): number;
  104474. /**
  104475. * Can be used to override the current requestAnimationFrame requester.
  104476. * @hidden
  104477. */
  104478. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104479. /**
  104480. * Register and execute a render loop. The engine can have more than one render function
  104481. * @param renderFunction defines the function to continuously execute
  104482. */
  104483. runRenderLoop(renderFunction: () => void): void;
  104484. /**
  104485. * Clear the current render buffer or the current render target (if any is set up)
  104486. * @param color defines the color to use
  104487. * @param backBuffer defines if the back buffer must be cleared
  104488. * @param depth defines if the depth buffer must be cleared
  104489. * @param stencil defines if the stencil buffer must be cleared
  104490. */
  104491. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104492. private _viewportCached;
  104493. /** @hidden */
  104494. _viewport(x: number, y: number, width: number, height: number): void;
  104495. /**
  104496. * Set the WebGL's viewport
  104497. * @param viewport defines the viewport element to be used
  104498. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104499. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104500. */
  104501. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104502. /**
  104503. * Begin a new frame
  104504. */
  104505. beginFrame(): void;
  104506. /**
  104507. * Enf the current frame
  104508. */
  104509. endFrame(): void;
  104510. /**
  104511. * Resize the view according to the canvas' size
  104512. */
  104513. resize(): void;
  104514. /**
  104515. * Force a specific size of the canvas
  104516. * @param width defines the new canvas' width
  104517. * @param height defines the new canvas' height
  104518. */
  104519. setSize(width: number, height: number): void;
  104520. /**
  104521. * Binds the frame buffer to the specified texture.
  104522. * @param texture The texture to render to or null for the default canvas
  104523. * @param faceIndex The face of the texture to render to in case of cube texture
  104524. * @param requiredWidth The width of the target to render to
  104525. * @param requiredHeight The height of the target to render to
  104526. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104527. * @param lodLevel defines the lod level to bind to the frame buffer
  104528. * @param layer defines the 2d array index to bind to frame buffer to
  104529. */
  104530. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104531. /** @hidden */
  104532. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104533. /**
  104534. * Unbind the current render target texture from the webGL context
  104535. * @param texture defines the render target texture to unbind
  104536. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104537. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104538. */
  104539. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104540. /**
  104541. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104542. */
  104543. flushFramebuffer(): void;
  104544. /**
  104545. * Unbind the current render target and bind the default framebuffer
  104546. */
  104547. restoreDefaultFramebuffer(): void;
  104548. /** @hidden */
  104549. protected _resetVertexBufferBinding(): void;
  104550. /**
  104551. * Creates a vertex buffer
  104552. * @param data the data for the vertex buffer
  104553. * @returns the new WebGL static buffer
  104554. */
  104555. createVertexBuffer(data: DataArray): DataBuffer;
  104556. private _createVertexBuffer;
  104557. /**
  104558. * Creates a dynamic vertex buffer
  104559. * @param data the data for the dynamic vertex buffer
  104560. * @returns the new WebGL dynamic buffer
  104561. */
  104562. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104563. protected _resetIndexBufferBinding(): void;
  104564. /**
  104565. * Creates a new index buffer
  104566. * @param indices defines the content of the index buffer
  104567. * @param updatable defines if the index buffer must be updatable
  104568. * @returns a new webGL buffer
  104569. */
  104570. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104571. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104572. /**
  104573. * Bind a webGL buffer to the webGL context
  104574. * @param buffer defines the buffer to bind
  104575. */
  104576. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104577. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104578. private bindBuffer;
  104579. /**
  104580. * update the bound buffer with the given data
  104581. * @param data defines the data to update
  104582. */
  104583. updateArrayBuffer(data: Float32Array): void;
  104584. private _vertexAttribPointer;
  104585. /** @hidden */
  104586. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104587. private _bindVertexBuffersAttributes;
  104588. /**
  104589. * Records a vertex array object
  104590. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104591. * @param vertexBuffers defines the list of vertex buffers to store
  104592. * @param indexBuffer defines the index buffer to store
  104593. * @param effect defines the effect to store
  104594. * @returns the new vertex array object
  104595. */
  104596. recordVertexArrayObject(vertexBuffers: {
  104597. [key: string]: VertexBuffer;
  104598. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104599. /**
  104600. * Bind a specific vertex array object
  104601. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104602. * @param vertexArrayObject defines the vertex array object to bind
  104603. * @param indexBuffer defines the index buffer to bind
  104604. */
  104605. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104606. /**
  104607. * Bind webGl buffers directly to the webGL context
  104608. * @param vertexBuffer defines the vertex buffer to bind
  104609. * @param indexBuffer defines the index buffer to bind
  104610. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104611. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104612. * @param effect defines the effect associated with the vertex buffer
  104613. */
  104614. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104615. private _unbindVertexArrayObject;
  104616. /**
  104617. * Bind a list of vertex buffers to the webGL context
  104618. * @param vertexBuffers defines the list of vertex buffers to bind
  104619. * @param indexBuffer defines the index buffer to bind
  104620. * @param effect defines the effect associated with the vertex buffers
  104621. */
  104622. bindBuffers(vertexBuffers: {
  104623. [key: string]: Nullable<VertexBuffer>;
  104624. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104625. /**
  104626. * Unbind all instance attributes
  104627. */
  104628. unbindInstanceAttributes(): void;
  104629. /**
  104630. * Release and free the memory of a vertex array object
  104631. * @param vao defines the vertex array object to delete
  104632. */
  104633. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104634. /** @hidden */
  104635. _releaseBuffer(buffer: DataBuffer): boolean;
  104636. protected _deleteBuffer(buffer: DataBuffer): void;
  104637. /**
  104638. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104639. * @param instancesBuffer defines the webGL buffer to update and bind
  104640. * @param data defines the data to store in the buffer
  104641. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104642. */
  104643. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104644. /**
  104645. * Bind the content of a webGL buffer used with instantiation
  104646. * @param instancesBuffer defines the webGL buffer to bind
  104647. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104648. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104649. */
  104650. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104651. /**
  104652. * Disable the instance attribute corresponding to the name in parameter
  104653. * @param name defines the name of the attribute to disable
  104654. */
  104655. disableInstanceAttributeByName(name: string): void;
  104656. /**
  104657. * Disable the instance attribute corresponding to the location in parameter
  104658. * @param attributeLocation defines the attribute location of the attribute to disable
  104659. */
  104660. disableInstanceAttribute(attributeLocation: number): void;
  104661. /**
  104662. * Disable the attribute corresponding to the location in parameter
  104663. * @param attributeLocation defines the attribute location of the attribute to disable
  104664. */
  104665. disableAttributeByIndex(attributeLocation: number): void;
  104666. /**
  104667. * Send a draw order
  104668. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104669. * @param indexStart defines the starting index
  104670. * @param indexCount defines the number of index to draw
  104671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104672. */
  104673. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104674. /**
  104675. * Draw a list of points
  104676. * @param verticesStart defines the index of first vertex to draw
  104677. * @param verticesCount defines the count of vertices to draw
  104678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104679. */
  104680. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104681. /**
  104682. * Draw a list of unindexed primitives
  104683. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104684. * @param verticesStart defines the index of first vertex to draw
  104685. * @param verticesCount defines the count of vertices to draw
  104686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104687. */
  104688. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104689. /**
  104690. * Draw a list of indexed primitives
  104691. * @param fillMode defines the primitive to use
  104692. * @param indexStart defines the starting index
  104693. * @param indexCount defines the number of index to draw
  104694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104695. */
  104696. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104697. /**
  104698. * Draw a list of unindexed primitives
  104699. * @param fillMode defines the primitive to use
  104700. * @param verticesStart defines the index of first vertex to draw
  104701. * @param verticesCount defines the count of vertices to draw
  104702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104703. */
  104704. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104705. private _drawMode;
  104706. /** @hidden */
  104707. protected _reportDrawCall(): void;
  104708. /** @hidden */
  104709. _releaseEffect(effect: Effect): void;
  104710. /** @hidden */
  104711. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104712. /**
  104713. * Create a new effect (used to store vertex/fragment shaders)
  104714. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104715. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104716. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104717. * @param samplers defines an array of string used to represent textures
  104718. * @param defines defines the string containing the defines to use to compile the shaders
  104719. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104720. * @param onCompiled defines a function to call when the effect creation is successful
  104721. * @param onError defines a function to call when the effect creation has failed
  104722. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104723. * @returns the new Effect
  104724. */
  104725. 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;
  104726. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104727. private _compileShader;
  104728. private _compileRawShader;
  104729. /**
  104730. * Directly creates a webGL program
  104731. * @param pipelineContext defines the pipeline context to attach to
  104732. * @param vertexCode defines the vertex shader code to use
  104733. * @param fragmentCode defines the fragment shader code to use
  104734. * @param context defines the webGL context to use (if not set, the current one will be used)
  104735. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104736. * @returns the new webGL program
  104737. */
  104738. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104739. /**
  104740. * Creates a webGL program
  104741. * @param pipelineContext defines the pipeline context to attach to
  104742. * @param vertexCode defines the vertex shader code to use
  104743. * @param fragmentCode defines the fragment shader code to use
  104744. * @param defines defines the string containing the defines to use to compile the shaders
  104745. * @param context defines the webGL context to use (if not set, the current one will be used)
  104746. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104747. * @returns the new webGL program
  104748. */
  104749. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104750. /**
  104751. * Creates a new pipeline context
  104752. * @returns the new pipeline
  104753. */
  104754. createPipelineContext(): IPipelineContext;
  104755. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104756. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104757. /** @hidden */
  104758. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104759. /** @hidden */
  104760. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104761. /** @hidden */
  104762. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104763. /**
  104764. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104765. * @param pipelineContext defines the pipeline context to use
  104766. * @param uniformsNames defines the list of uniform names
  104767. * @returns an array of webGL uniform locations
  104768. */
  104769. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104770. /**
  104771. * Gets the lsit of active attributes for a given webGL program
  104772. * @param pipelineContext defines the pipeline context to use
  104773. * @param attributesNames defines the list of attribute names to get
  104774. * @returns an array of indices indicating the offset of each attribute
  104775. */
  104776. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104777. /**
  104778. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104779. * @param effect defines the effect to activate
  104780. */
  104781. enableEffect(effect: Nullable<Effect>): void;
  104782. /**
  104783. * Set the value of an uniform to a number (int)
  104784. * @param uniform defines the webGL uniform location where to store the value
  104785. * @param value defines the int number to store
  104786. */
  104787. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104788. /**
  104789. * Set the value of an uniform to an array of int32
  104790. * @param uniform defines the webGL uniform location where to store the value
  104791. * @param array defines the array of int32 to store
  104792. */
  104793. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104794. /**
  104795. * Set the value of an uniform to an array of int32 (stored as vec2)
  104796. * @param uniform defines the webGL uniform location where to store the value
  104797. * @param array defines the array of int32 to store
  104798. */
  104799. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104800. /**
  104801. * Set the value of an uniform to an array of int32 (stored as vec3)
  104802. * @param uniform defines the webGL uniform location where to store the value
  104803. * @param array defines the array of int32 to store
  104804. */
  104805. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104806. /**
  104807. * Set the value of an uniform to an array of int32 (stored as vec4)
  104808. * @param uniform defines the webGL uniform location where to store the value
  104809. * @param array defines the array of int32 to store
  104810. */
  104811. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104812. /**
  104813. * Set the value of an uniform to an array of number
  104814. * @param uniform defines the webGL uniform location where to store the value
  104815. * @param array defines the array of number to store
  104816. */
  104817. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104818. /**
  104819. * Set the value of an uniform to an array of number (stored as vec2)
  104820. * @param uniform defines the webGL uniform location where to store the value
  104821. * @param array defines the array of number to store
  104822. */
  104823. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104824. /**
  104825. * Set the value of an uniform to an array of number (stored as vec3)
  104826. * @param uniform defines the webGL uniform location where to store the value
  104827. * @param array defines the array of number to store
  104828. */
  104829. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104830. /**
  104831. * Set the value of an uniform to an array of number (stored as vec4)
  104832. * @param uniform defines the webGL uniform location where to store the value
  104833. * @param array defines the array of number to store
  104834. */
  104835. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104836. /**
  104837. * Set the value of an uniform to an array of float32 (stored as matrices)
  104838. * @param uniform defines the webGL uniform location where to store the value
  104839. * @param matrices defines the array of float32 to store
  104840. */
  104841. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104842. /**
  104843. * Set the value of an uniform to a matrix (3x3)
  104844. * @param uniform defines the webGL uniform location where to store the value
  104845. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104846. */
  104847. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104848. /**
  104849. * Set the value of an uniform to a matrix (2x2)
  104850. * @param uniform defines the webGL uniform location where to store the value
  104851. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104852. */
  104853. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104854. /**
  104855. * Set the value of an uniform to a number (float)
  104856. * @param uniform defines the webGL uniform location where to store the value
  104857. * @param value defines the float number to store
  104858. */
  104859. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104860. /**
  104861. * Set the value of an uniform to a vec2
  104862. * @param uniform defines the webGL uniform location where to store the value
  104863. * @param x defines the 1st component of the value
  104864. * @param y defines the 2nd component of the value
  104865. */
  104866. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104867. /**
  104868. * Set the value of an uniform to a vec3
  104869. * @param uniform defines the webGL uniform location where to store the value
  104870. * @param x defines the 1st component of the value
  104871. * @param y defines the 2nd component of the value
  104872. * @param z defines the 3rd component of the value
  104873. */
  104874. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104875. /**
  104876. * Set the value of an uniform to a vec4
  104877. * @param uniform defines the webGL uniform location where to store the value
  104878. * @param x defines the 1st component of the value
  104879. * @param y defines the 2nd component of the value
  104880. * @param z defines the 3rd component of the value
  104881. * @param w defines the 4th component of the value
  104882. */
  104883. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104884. /**
  104885. * Apply all cached states (depth, culling, stencil and alpha)
  104886. */
  104887. applyStates(): void;
  104888. /**
  104889. * Enable or disable color writing
  104890. * @param enable defines the state to set
  104891. */
  104892. setColorWrite(enable: boolean): void;
  104893. /**
  104894. * Gets a boolean indicating if color writing is enabled
  104895. * @returns the current color writing state
  104896. */
  104897. getColorWrite(): boolean;
  104898. /**
  104899. * Gets the depth culling state manager
  104900. */
  104901. get depthCullingState(): DepthCullingState;
  104902. /**
  104903. * Gets the alpha state manager
  104904. */
  104905. get alphaState(): AlphaState;
  104906. /**
  104907. * Gets the stencil state manager
  104908. */
  104909. get stencilState(): StencilState;
  104910. /**
  104911. * Clears the list of texture accessible through engine.
  104912. * This can help preventing texture load conflict due to name collision.
  104913. */
  104914. clearInternalTexturesCache(): void;
  104915. /**
  104916. * Force the entire cache to be cleared
  104917. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104918. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104919. */
  104920. wipeCaches(bruteForce?: boolean): void;
  104921. /** @hidden */
  104922. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104923. min: number;
  104924. mag: number;
  104925. };
  104926. /** @hidden */
  104927. _createTexture(): WebGLTexture;
  104928. /**
  104929. * Usually called from Texture.ts.
  104930. * Passed information to create a WebGLTexture
  104931. * @param urlArg defines a value which contains one of the following:
  104932. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104933. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104934. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104935. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104936. * @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)
  104937. * @param scene needed for loading to the correct scene
  104938. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104939. * @param onLoad optional callback to be called upon successful completion
  104940. * @param onError optional callback to be called upon failure
  104941. * @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
  104942. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104943. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104944. * @param forcedExtension defines the extension to use to pick the right loader
  104945. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104946. * @param mimeType defines an optional mime type
  104947. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104948. */
  104949. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  104950. /**
  104951. * Loads an image as an HTMLImageElement.
  104952. * @param input url string, ArrayBuffer, or Blob to load
  104953. * @param onLoad callback called when the image successfully loads
  104954. * @param onError callback called when the image fails to load
  104955. * @param offlineProvider offline provider for caching
  104956. * @param mimeType optional mime type
  104957. * @returns the HTMLImageElement of the loaded image
  104958. * @hidden
  104959. */
  104960. 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>;
  104961. /**
  104962. * @hidden
  104963. */
  104964. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104965. /**
  104966. * Creates a raw texture
  104967. * @param data defines the data to store in the texture
  104968. * @param width defines the width of the texture
  104969. * @param height defines the height of the texture
  104970. * @param format defines the format of the data
  104971. * @param generateMipMaps defines if the engine should generate the mip levels
  104972. * @param invertY defines if data must be stored with Y axis inverted
  104973. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104974. * @param compression defines the compression used (null by default)
  104975. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104976. * @returns the raw texture inside an InternalTexture
  104977. */
  104978. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104979. /**
  104980. * Creates a new raw cube texture
  104981. * @param data defines the array of data to use to create each face
  104982. * @param size defines the size of the textures
  104983. * @param format defines the format of the data
  104984. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104985. * @param generateMipMaps defines if the engine should generate the mip levels
  104986. * @param invertY defines if data must be stored with Y axis inverted
  104987. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104988. * @param compression defines the compression used (null by default)
  104989. * @returns the cube texture as an InternalTexture
  104990. */
  104991. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104992. /**
  104993. * Creates a new raw 3D texture
  104994. * @param data defines the data used to create the texture
  104995. * @param width defines the width of the texture
  104996. * @param height defines the height of the texture
  104997. * @param depth defines the depth of the texture
  104998. * @param format defines the format of the texture
  104999. * @param generateMipMaps defines if the engine must generate mip levels
  105000. * @param invertY defines if data must be stored with Y axis inverted
  105001. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105002. * @param compression defines the compressed used (can be null)
  105003. * @param textureType defines the compressed used (can be null)
  105004. * @returns a new raw 3D texture (stored in an InternalTexture)
  105005. */
  105006. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105007. /**
  105008. * Creates a new raw 2D array texture
  105009. * @param data defines the data used to create the texture
  105010. * @param width defines the width of the texture
  105011. * @param height defines the height of the texture
  105012. * @param depth defines the number of layers of the texture
  105013. * @param format defines the format of the texture
  105014. * @param generateMipMaps defines if the engine must generate mip levels
  105015. * @param invertY defines if data must be stored with Y axis inverted
  105016. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105017. * @param compression defines the compressed used (can be null)
  105018. * @param textureType defines the compressed used (can be null)
  105019. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105020. */
  105021. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105022. private _unpackFlipYCached;
  105023. /**
  105024. * In case you are sharing the context with other applications, it might
  105025. * be interested to not cache the unpack flip y state to ensure a consistent
  105026. * value would be set.
  105027. */
  105028. enableUnpackFlipYCached: boolean;
  105029. /** @hidden */
  105030. _unpackFlipY(value: boolean): void;
  105031. /** @hidden */
  105032. _getUnpackAlignement(): number;
  105033. private _getTextureTarget;
  105034. /**
  105035. * Update the sampling mode of a given texture
  105036. * @param samplingMode defines the required sampling mode
  105037. * @param texture defines the texture to update
  105038. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105039. */
  105040. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105041. /**
  105042. * Update the sampling mode of a given texture
  105043. * @param texture defines the texture to update
  105044. * @param wrapU defines the texture wrap mode of the u coordinates
  105045. * @param wrapV defines the texture wrap mode of the v coordinates
  105046. * @param wrapR defines the texture wrap mode of the r coordinates
  105047. */
  105048. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105049. /** @hidden */
  105050. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105051. width: number;
  105052. height: number;
  105053. layers?: number;
  105054. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105055. /** @hidden */
  105056. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105057. /** @hidden */
  105058. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105059. /**
  105060. * Update a portion of an internal texture
  105061. * @param texture defines the texture to update
  105062. * @param imageData defines the data to store into the texture
  105063. * @param xOffset defines the x coordinates of the update rectangle
  105064. * @param yOffset defines the y coordinates of the update rectangle
  105065. * @param width defines the width of the update rectangle
  105066. * @param height defines the height of the update rectangle
  105067. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105068. * @param lod defines the lod level to update (0 by default)
  105069. */
  105070. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105071. /** @hidden */
  105072. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105073. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105074. private _prepareWebGLTexture;
  105075. /** @hidden */
  105076. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105077. private _getDepthStencilBuffer;
  105078. /** @hidden */
  105079. _releaseFramebufferObjects(texture: InternalTexture): void;
  105080. /** @hidden */
  105081. _releaseTexture(texture: InternalTexture): void;
  105082. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105083. protected _setProgram(program: WebGLProgram): void;
  105084. protected _boundUniforms: {
  105085. [key: number]: WebGLUniformLocation;
  105086. };
  105087. /**
  105088. * Binds an effect to the webGL context
  105089. * @param effect defines the effect to bind
  105090. */
  105091. bindSamplers(effect: Effect): void;
  105092. private _activateCurrentTexture;
  105093. /** @hidden */
  105094. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105095. /** @hidden */
  105096. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105097. /**
  105098. * Unbind all textures from the webGL context
  105099. */
  105100. unbindAllTextures(): void;
  105101. /**
  105102. * Sets a texture to the according uniform.
  105103. * @param channel The texture channel
  105104. * @param uniform The uniform to set
  105105. * @param texture The texture to apply
  105106. */
  105107. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105108. private _bindSamplerUniformToChannel;
  105109. private _getTextureWrapMode;
  105110. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105111. /**
  105112. * Sets an array of texture to the webGL context
  105113. * @param channel defines the channel where the texture array must be set
  105114. * @param uniform defines the associated uniform location
  105115. * @param textures defines the array of textures to bind
  105116. */
  105117. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105118. /** @hidden */
  105119. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105120. private _setTextureParameterFloat;
  105121. private _setTextureParameterInteger;
  105122. /**
  105123. * Unbind all vertex attributes from the webGL context
  105124. */
  105125. unbindAllAttributes(): void;
  105126. /**
  105127. * 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
  105128. */
  105129. releaseEffects(): void;
  105130. /**
  105131. * Dispose and release all associated resources
  105132. */
  105133. dispose(): void;
  105134. /**
  105135. * Attach a new callback raised when context lost event is fired
  105136. * @param callback defines the callback to call
  105137. */
  105138. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105139. /**
  105140. * Attach a new callback raised when context restored event is fired
  105141. * @param callback defines the callback to call
  105142. */
  105143. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105144. /**
  105145. * Get the current error code of the webGL context
  105146. * @returns the error code
  105147. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105148. */
  105149. getError(): number;
  105150. private _canRenderToFloatFramebuffer;
  105151. private _canRenderToHalfFloatFramebuffer;
  105152. private _canRenderToFramebuffer;
  105153. /** @hidden */
  105154. _getWebGLTextureType(type: number): number;
  105155. /** @hidden */
  105156. _getInternalFormat(format: number): number;
  105157. /** @hidden */
  105158. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105159. /** @hidden */
  105160. _getRGBAMultiSampleBufferFormat(type: number): number;
  105161. /** @hidden */
  105162. _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;
  105163. /**
  105164. * Loads a file from a url
  105165. * @param url url to load
  105166. * @param onSuccess callback called when the file successfully loads
  105167. * @param onProgress callback called while file is loading (if the server supports this mode)
  105168. * @param offlineProvider defines the offline provider for caching
  105169. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105170. * @param onError callback called when the file fails to load
  105171. * @returns a file request object
  105172. * @hidden
  105173. */
  105174. 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;
  105175. /**
  105176. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105177. * @param x defines the x coordinate of the rectangle where pixels must be read
  105178. * @param y defines the y coordinate of the rectangle where pixels must be read
  105179. * @param width defines the width of the rectangle where pixels must be read
  105180. * @param height defines the height of the rectangle where pixels must be read
  105181. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105182. * @returns a Uint8Array containing RGBA colors
  105183. */
  105184. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105185. private static _isSupported;
  105186. /**
  105187. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105188. * @returns true if the engine can be created
  105189. * @ignorenaming
  105190. */
  105191. static isSupported(): boolean;
  105192. /**
  105193. * Find the next highest power of two.
  105194. * @param x Number to start search from.
  105195. * @return Next highest power of two.
  105196. */
  105197. static CeilingPOT(x: number): number;
  105198. /**
  105199. * Find the next lowest power of two.
  105200. * @param x Number to start search from.
  105201. * @return Next lowest power of two.
  105202. */
  105203. static FloorPOT(x: number): number;
  105204. /**
  105205. * Find the nearest power of two.
  105206. * @param x Number to start search from.
  105207. * @return Next nearest power of two.
  105208. */
  105209. static NearestPOT(x: number): number;
  105210. /**
  105211. * Get the closest exponent of two
  105212. * @param value defines the value to approximate
  105213. * @param max defines the maximum value to return
  105214. * @param mode defines how to define the closest value
  105215. * @returns closest exponent of two of the given value
  105216. */
  105217. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105218. /**
  105219. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105220. * @param func - the function to be called
  105221. * @param requester - the object that will request the next frame. Falls back to window.
  105222. * @returns frame number
  105223. */
  105224. static QueueNewFrame(func: () => void, requester?: any): number;
  105225. /**
  105226. * Gets host document
  105227. * @returns the host document object
  105228. */
  105229. getHostDocument(): Nullable<Document>;
  105230. }
  105231. }
  105232. declare module BABYLON {
  105233. /**
  105234. * Class representing spherical harmonics coefficients to the 3rd degree
  105235. */
  105236. export class SphericalHarmonics {
  105237. /**
  105238. * Defines whether or not the harmonics have been prescaled for rendering.
  105239. */
  105240. preScaled: boolean;
  105241. /**
  105242. * The l0,0 coefficients of the spherical harmonics
  105243. */
  105244. l00: Vector3;
  105245. /**
  105246. * The l1,-1 coefficients of the spherical harmonics
  105247. */
  105248. l1_1: Vector3;
  105249. /**
  105250. * The l1,0 coefficients of the spherical harmonics
  105251. */
  105252. l10: Vector3;
  105253. /**
  105254. * The l1,1 coefficients of the spherical harmonics
  105255. */
  105256. l11: Vector3;
  105257. /**
  105258. * The l2,-2 coefficients of the spherical harmonics
  105259. */
  105260. l2_2: Vector3;
  105261. /**
  105262. * The l2,-1 coefficients of the spherical harmonics
  105263. */
  105264. l2_1: Vector3;
  105265. /**
  105266. * The l2,0 coefficients of the spherical harmonics
  105267. */
  105268. l20: Vector3;
  105269. /**
  105270. * The l2,1 coefficients of the spherical harmonics
  105271. */
  105272. l21: Vector3;
  105273. /**
  105274. * The l2,2 coefficients of the spherical harmonics
  105275. */
  105276. l22: Vector3;
  105277. /**
  105278. * Adds a light to the spherical harmonics
  105279. * @param direction the direction of the light
  105280. * @param color the color of the light
  105281. * @param deltaSolidAngle the delta solid angle of the light
  105282. */
  105283. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105284. /**
  105285. * Scales the spherical harmonics by the given amount
  105286. * @param scale the amount to scale
  105287. */
  105288. scaleInPlace(scale: number): void;
  105289. /**
  105290. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105291. *
  105292. * ```
  105293. * E_lm = A_l * L_lm
  105294. * ```
  105295. *
  105296. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105297. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105298. * the scaling factors are given in equation 9.
  105299. */
  105300. convertIncidentRadianceToIrradiance(): void;
  105301. /**
  105302. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105303. *
  105304. * ```
  105305. * L = (1/pi) * E * rho
  105306. * ```
  105307. *
  105308. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105309. */
  105310. convertIrradianceToLambertianRadiance(): void;
  105311. /**
  105312. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105313. * required operations at run time.
  105314. *
  105315. * This is simply done by scaling back the SH with Ylm constants parameter.
  105316. * The trigonometric part being applied by the shader at run time.
  105317. */
  105318. preScaleForRendering(): void;
  105319. /**
  105320. * Constructs a spherical harmonics from an array.
  105321. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105322. * @returns the spherical harmonics
  105323. */
  105324. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105325. /**
  105326. * Gets the spherical harmonics from polynomial
  105327. * @param polynomial the spherical polynomial
  105328. * @returns the spherical harmonics
  105329. */
  105330. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105331. }
  105332. /**
  105333. * Class representing spherical polynomial coefficients to the 3rd degree
  105334. */
  105335. export class SphericalPolynomial {
  105336. private _harmonics;
  105337. /**
  105338. * The spherical harmonics used to create the polynomials.
  105339. */
  105340. get preScaledHarmonics(): SphericalHarmonics;
  105341. /**
  105342. * The x coefficients of the spherical polynomial
  105343. */
  105344. x: Vector3;
  105345. /**
  105346. * The y coefficients of the spherical polynomial
  105347. */
  105348. y: Vector3;
  105349. /**
  105350. * The z coefficients of the spherical polynomial
  105351. */
  105352. z: Vector3;
  105353. /**
  105354. * The xx coefficients of the spherical polynomial
  105355. */
  105356. xx: Vector3;
  105357. /**
  105358. * The yy coefficients of the spherical polynomial
  105359. */
  105360. yy: Vector3;
  105361. /**
  105362. * The zz coefficients of the spherical polynomial
  105363. */
  105364. zz: Vector3;
  105365. /**
  105366. * The xy coefficients of the spherical polynomial
  105367. */
  105368. xy: Vector3;
  105369. /**
  105370. * The yz coefficients of the spherical polynomial
  105371. */
  105372. yz: Vector3;
  105373. /**
  105374. * The zx coefficients of the spherical polynomial
  105375. */
  105376. zx: Vector3;
  105377. /**
  105378. * Adds an ambient color to the spherical polynomial
  105379. * @param color the color to add
  105380. */
  105381. addAmbient(color: Color3): void;
  105382. /**
  105383. * Scales the spherical polynomial by the given amount
  105384. * @param scale the amount to scale
  105385. */
  105386. scaleInPlace(scale: number): void;
  105387. /**
  105388. * Gets the spherical polynomial from harmonics
  105389. * @param harmonics the spherical harmonics
  105390. * @returns the spherical polynomial
  105391. */
  105392. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105393. /**
  105394. * Constructs a spherical polynomial from an array.
  105395. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105396. * @returns the spherical polynomial
  105397. */
  105398. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105399. }
  105400. }
  105401. declare module BABYLON {
  105402. /**
  105403. * Defines the source of the internal texture
  105404. */
  105405. export enum InternalTextureSource {
  105406. /**
  105407. * The source of the texture data is unknown
  105408. */
  105409. Unknown = 0,
  105410. /**
  105411. * Texture data comes from an URL
  105412. */
  105413. Url = 1,
  105414. /**
  105415. * Texture data is only used for temporary storage
  105416. */
  105417. Temp = 2,
  105418. /**
  105419. * Texture data comes from raw data (ArrayBuffer)
  105420. */
  105421. Raw = 3,
  105422. /**
  105423. * Texture content is dynamic (video or dynamic texture)
  105424. */
  105425. Dynamic = 4,
  105426. /**
  105427. * Texture content is generated by rendering to it
  105428. */
  105429. RenderTarget = 5,
  105430. /**
  105431. * Texture content is part of a multi render target process
  105432. */
  105433. MultiRenderTarget = 6,
  105434. /**
  105435. * Texture data comes from a cube data file
  105436. */
  105437. Cube = 7,
  105438. /**
  105439. * Texture data comes from a raw cube data
  105440. */
  105441. CubeRaw = 8,
  105442. /**
  105443. * Texture data come from a prefiltered cube data file
  105444. */
  105445. CubePrefiltered = 9,
  105446. /**
  105447. * Texture content is raw 3D data
  105448. */
  105449. Raw3D = 10,
  105450. /**
  105451. * Texture content is raw 2D array data
  105452. */
  105453. Raw2DArray = 11,
  105454. /**
  105455. * Texture content is a depth texture
  105456. */
  105457. Depth = 12,
  105458. /**
  105459. * Texture data comes from a raw cube data encoded with RGBD
  105460. */
  105461. CubeRawRGBD = 13
  105462. }
  105463. /**
  105464. * Class used to store data associated with WebGL texture data for the engine
  105465. * This class should not be used directly
  105466. */
  105467. export class InternalTexture {
  105468. /** @hidden */
  105469. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105470. /**
  105471. * Defines if the texture is ready
  105472. */
  105473. isReady: boolean;
  105474. /**
  105475. * Defines if the texture is a cube texture
  105476. */
  105477. isCube: boolean;
  105478. /**
  105479. * Defines if the texture contains 3D data
  105480. */
  105481. is3D: boolean;
  105482. /**
  105483. * Defines if the texture contains 2D array data
  105484. */
  105485. is2DArray: boolean;
  105486. /**
  105487. * Defines if the texture contains multiview data
  105488. */
  105489. isMultiview: boolean;
  105490. /**
  105491. * Gets the URL used to load this texture
  105492. */
  105493. url: string;
  105494. /**
  105495. * Gets the sampling mode of the texture
  105496. */
  105497. samplingMode: number;
  105498. /**
  105499. * Gets a boolean indicating if the texture needs mipmaps generation
  105500. */
  105501. generateMipMaps: boolean;
  105502. /**
  105503. * Gets the number of samples used by the texture (WebGL2+ only)
  105504. */
  105505. samples: number;
  105506. /**
  105507. * Gets the type of the texture (int, float...)
  105508. */
  105509. type: number;
  105510. /**
  105511. * Gets the format of the texture (RGB, RGBA...)
  105512. */
  105513. format: number;
  105514. /**
  105515. * Observable called when the texture is loaded
  105516. */
  105517. onLoadedObservable: Observable<InternalTexture>;
  105518. /**
  105519. * Gets the width of the texture
  105520. */
  105521. width: number;
  105522. /**
  105523. * Gets the height of the texture
  105524. */
  105525. height: number;
  105526. /**
  105527. * Gets the depth of the texture
  105528. */
  105529. depth: number;
  105530. /**
  105531. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105532. */
  105533. baseWidth: number;
  105534. /**
  105535. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105536. */
  105537. baseHeight: number;
  105538. /**
  105539. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105540. */
  105541. baseDepth: number;
  105542. /**
  105543. * Gets a boolean indicating if the texture is inverted on Y axis
  105544. */
  105545. invertY: boolean;
  105546. /** @hidden */
  105547. _invertVScale: boolean;
  105548. /** @hidden */
  105549. _associatedChannel: number;
  105550. /** @hidden */
  105551. _source: InternalTextureSource;
  105552. /** @hidden */
  105553. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105554. /** @hidden */
  105555. _bufferView: Nullable<ArrayBufferView>;
  105556. /** @hidden */
  105557. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105558. /** @hidden */
  105559. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105560. /** @hidden */
  105561. _size: number;
  105562. /** @hidden */
  105563. _extension: string;
  105564. /** @hidden */
  105565. _files: Nullable<string[]>;
  105566. /** @hidden */
  105567. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105568. /** @hidden */
  105569. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105570. /** @hidden */
  105571. _framebuffer: Nullable<WebGLFramebuffer>;
  105572. /** @hidden */
  105573. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105574. /** @hidden */
  105575. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105576. /** @hidden */
  105577. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105578. /** @hidden */
  105579. _attachments: Nullable<number[]>;
  105580. /** @hidden */
  105581. _cachedCoordinatesMode: Nullable<number>;
  105582. /** @hidden */
  105583. _cachedWrapU: Nullable<number>;
  105584. /** @hidden */
  105585. _cachedWrapV: Nullable<number>;
  105586. /** @hidden */
  105587. _cachedWrapR: Nullable<number>;
  105588. /** @hidden */
  105589. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105590. /** @hidden */
  105591. _isDisabled: boolean;
  105592. /** @hidden */
  105593. _compression: Nullable<string>;
  105594. /** @hidden */
  105595. _generateStencilBuffer: boolean;
  105596. /** @hidden */
  105597. _generateDepthBuffer: boolean;
  105598. /** @hidden */
  105599. _comparisonFunction: number;
  105600. /** @hidden */
  105601. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105602. /** @hidden */
  105603. _lodGenerationScale: number;
  105604. /** @hidden */
  105605. _lodGenerationOffset: number;
  105606. /** @hidden */
  105607. _depthStencilTexture: Nullable<InternalTexture>;
  105608. /** @hidden */
  105609. _colorTextureArray: Nullable<WebGLTexture>;
  105610. /** @hidden */
  105611. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105612. /** @hidden */
  105613. _lodTextureHigh: Nullable<BaseTexture>;
  105614. /** @hidden */
  105615. _lodTextureMid: Nullable<BaseTexture>;
  105616. /** @hidden */
  105617. _lodTextureLow: Nullable<BaseTexture>;
  105618. /** @hidden */
  105619. _isRGBD: boolean;
  105620. /** @hidden */
  105621. _linearSpecularLOD: boolean;
  105622. /** @hidden */
  105623. _irradianceTexture: Nullable<BaseTexture>;
  105624. /** @hidden */
  105625. _webGLTexture: Nullable<WebGLTexture>;
  105626. /** @hidden */
  105627. _references: number;
  105628. private _engine;
  105629. /**
  105630. * Gets the Engine the texture belongs to.
  105631. * @returns The babylon engine
  105632. */
  105633. getEngine(): ThinEngine;
  105634. /**
  105635. * Gets the data source type of the texture
  105636. */
  105637. get source(): InternalTextureSource;
  105638. /**
  105639. * Creates a new InternalTexture
  105640. * @param engine defines the engine to use
  105641. * @param source defines the type of data that will be used
  105642. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105643. */
  105644. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105645. /**
  105646. * Increments the number of references (ie. the number of Texture that point to it)
  105647. */
  105648. incrementReferences(): void;
  105649. /**
  105650. * Change the size of the texture (not the size of the content)
  105651. * @param width defines the new width
  105652. * @param height defines the new height
  105653. * @param depth defines the new depth (1 by default)
  105654. */
  105655. updateSize(width: int, height: int, depth?: int): void;
  105656. /** @hidden */
  105657. _rebuild(): void;
  105658. /** @hidden */
  105659. _swapAndDie(target: InternalTexture): void;
  105660. /**
  105661. * Dispose the current allocated resources
  105662. */
  105663. dispose(): void;
  105664. }
  105665. }
  105666. declare module BABYLON {
  105667. /**
  105668. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105670. */
  105671. export class Analyser {
  105672. /**
  105673. * Gets or sets the smoothing
  105674. * @ignorenaming
  105675. */
  105676. SMOOTHING: number;
  105677. /**
  105678. * Gets or sets the FFT table size
  105679. * @ignorenaming
  105680. */
  105681. FFT_SIZE: number;
  105682. /**
  105683. * Gets or sets the bar graph amplitude
  105684. * @ignorenaming
  105685. */
  105686. BARGRAPHAMPLITUDE: number;
  105687. /**
  105688. * Gets or sets the position of the debug canvas
  105689. * @ignorenaming
  105690. */
  105691. DEBUGCANVASPOS: {
  105692. x: number;
  105693. y: number;
  105694. };
  105695. /**
  105696. * Gets or sets the debug canvas size
  105697. * @ignorenaming
  105698. */
  105699. DEBUGCANVASSIZE: {
  105700. width: number;
  105701. height: number;
  105702. };
  105703. private _byteFreqs;
  105704. private _byteTime;
  105705. private _floatFreqs;
  105706. private _webAudioAnalyser;
  105707. private _debugCanvas;
  105708. private _debugCanvasContext;
  105709. private _scene;
  105710. private _registerFunc;
  105711. private _audioEngine;
  105712. /**
  105713. * Creates a new analyser
  105714. * @param scene defines hosting scene
  105715. */
  105716. constructor(scene: Scene);
  105717. /**
  105718. * Get the number of data values you will have to play with for the visualization
  105719. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105720. * @returns a number
  105721. */
  105722. getFrequencyBinCount(): number;
  105723. /**
  105724. * Gets the current frequency data as a byte array
  105725. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105726. * @returns a Uint8Array
  105727. */
  105728. getByteFrequencyData(): Uint8Array;
  105729. /**
  105730. * Gets the current waveform as a byte array
  105731. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105732. * @returns a Uint8Array
  105733. */
  105734. getByteTimeDomainData(): Uint8Array;
  105735. /**
  105736. * Gets the current frequency data as a float array
  105737. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105738. * @returns a Float32Array
  105739. */
  105740. getFloatFrequencyData(): Float32Array;
  105741. /**
  105742. * Renders the debug canvas
  105743. */
  105744. drawDebugCanvas(): void;
  105745. /**
  105746. * Stops rendering the debug canvas and removes it
  105747. */
  105748. stopDebugCanvas(): void;
  105749. /**
  105750. * Connects two audio nodes
  105751. * @param inputAudioNode defines first node to connect
  105752. * @param outputAudioNode defines second node to connect
  105753. */
  105754. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105755. /**
  105756. * Releases all associated resources
  105757. */
  105758. dispose(): void;
  105759. }
  105760. }
  105761. declare module BABYLON {
  105762. /**
  105763. * This represents an audio engine and it is responsible
  105764. * to play, synchronize and analyse sounds throughout the application.
  105765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105766. */
  105767. export interface IAudioEngine extends IDisposable {
  105768. /**
  105769. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105770. */
  105771. readonly canUseWebAudio: boolean;
  105772. /**
  105773. * Gets the current AudioContext if available.
  105774. */
  105775. readonly audioContext: Nullable<AudioContext>;
  105776. /**
  105777. * The master gain node defines the global audio volume of your audio engine.
  105778. */
  105779. readonly masterGain: GainNode;
  105780. /**
  105781. * Gets whether or not mp3 are supported by your browser.
  105782. */
  105783. readonly isMP3supported: boolean;
  105784. /**
  105785. * Gets whether or not ogg are supported by your browser.
  105786. */
  105787. readonly isOGGsupported: boolean;
  105788. /**
  105789. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105790. * @ignoreNaming
  105791. */
  105792. WarnedWebAudioUnsupported: boolean;
  105793. /**
  105794. * Defines if the audio engine relies on a custom unlocked button.
  105795. * In this case, the embedded button will not be displayed.
  105796. */
  105797. useCustomUnlockedButton: boolean;
  105798. /**
  105799. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105800. */
  105801. readonly unlocked: boolean;
  105802. /**
  105803. * Event raised when audio has been unlocked on the browser.
  105804. */
  105805. onAudioUnlockedObservable: Observable<AudioEngine>;
  105806. /**
  105807. * Event raised when audio has been locked on the browser.
  105808. */
  105809. onAudioLockedObservable: Observable<AudioEngine>;
  105810. /**
  105811. * Flags the audio engine in Locked state.
  105812. * This happens due to new browser policies preventing audio to autoplay.
  105813. */
  105814. lock(): void;
  105815. /**
  105816. * Unlocks the audio engine once a user action has been done on the dom.
  105817. * This is helpful to resume play once browser policies have been satisfied.
  105818. */
  105819. unlock(): void;
  105820. }
  105821. /**
  105822. * This represents the default audio engine used in babylon.
  105823. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105825. */
  105826. export class AudioEngine implements IAudioEngine {
  105827. private _audioContext;
  105828. private _audioContextInitialized;
  105829. private _muteButton;
  105830. private _hostElement;
  105831. /**
  105832. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105833. */
  105834. canUseWebAudio: boolean;
  105835. /**
  105836. * The master gain node defines the global audio volume of your audio engine.
  105837. */
  105838. masterGain: GainNode;
  105839. /**
  105840. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105841. * @ignoreNaming
  105842. */
  105843. WarnedWebAudioUnsupported: boolean;
  105844. /**
  105845. * Gets whether or not mp3 are supported by your browser.
  105846. */
  105847. isMP3supported: boolean;
  105848. /**
  105849. * Gets whether or not ogg are supported by your browser.
  105850. */
  105851. isOGGsupported: boolean;
  105852. /**
  105853. * Gets whether audio has been unlocked on the device.
  105854. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105855. * a user interaction has happened.
  105856. */
  105857. unlocked: boolean;
  105858. /**
  105859. * Defines if the audio engine relies on a custom unlocked button.
  105860. * In this case, the embedded button will not be displayed.
  105861. */
  105862. useCustomUnlockedButton: boolean;
  105863. /**
  105864. * Event raised when audio has been unlocked on the browser.
  105865. */
  105866. onAudioUnlockedObservable: Observable<AudioEngine>;
  105867. /**
  105868. * Event raised when audio has been locked on the browser.
  105869. */
  105870. onAudioLockedObservable: Observable<AudioEngine>;
  105871. /**
  105872. * Gets the current AudioContext if available.
  105873. */
  105874. get audioContext(): Nullable<AudioContext>;
  105875. private _connectedAnalyser;
  105876. /**
  105877. * Instantiates a new audio engine.
  105878. *
  105879. * There should be only one per page as some browsers restrict the number
  105880. * of audio contexts you can create.
  105881. * @param hostElement defines the host element where to display the mute icon if necessary
  105882. */
  105883. constructor(hostElement?: Nullable<HTMLElement>);
  105884. /**
  105885. * Flags the audio engine in Locked state.
  105886. * This happens due to new browser policies preventing audio to autoplay.
  105887. */
  105888. lock(): void;
  105889. /**
  105890. * Unlocks the audio engine once a user action has been done on the dom.
  105891. * This is helpful to resume play once browser policies have been satisfied.
  105892. */
  105893. unlock(): void;
  105894. private _resumeAudioContext;
  105895. private _initializeAudioContext;
  105896. private _tryToRun;
  105897. private _triggerRunningState;
  105898. private _triggerSuspendedState;
  105899. private _displayMuteButton;
  105900. private _moveButtonToTopLeft;
  105901. private _onResize;
  105902. private _hideMuteButton;
  105903. /**
  105904. * Destroy and release the resources associated with the audio ccontext.
  105905. */
  105906. dispose(): void;
  105907. /**
  105908. * Gets the global volume sets on the master gain.
  105909. * @returns the global volume if set or -1 otherwise
  105910. */
  105911. getGlobalVolume(): number;
  105912. /**
  105913. * Sets the global volume of your experience (sets on the master gain).
  105914. * @param newVolume Defines the new global volume of the application
  105915. */
  105916. setGlobalVolume(newVolume: number): void;
  105917. /**
  105918. * Connect the audio engine to an audio analyser allowing some amazing
  105919. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105921. * @param analyser The analyser to connect to the engine
  105922. */
  105923. connectToAnalyser(analyser: Analyser): void;
  105924. }
  105925. }
  105926. declare module BABYLON {
  105927. /**
  105928. * Interface used to present a loading screen while loading a scene
  105929. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105930. */
  105931. export interface ILoadingScreen {
  105932. /**
  105933. * Function called to display the loading screen
  105934. */
  105935. displayLoadingUI: () => void;
  105936. /**
  105937. * Function called to hide the loading screen
  105938. */
  105939. hideLoadingUI: () => void;
  105940. /**
  105941. * Gets or sets the color to use for the background
  105942. */
  105943. loadingUIBackgroundColor: string;
  105944. /**
  105945. * Gets or sets the text to display while loading
  105946. */
  105947. loadingUIText: string;
  105948. }
  105949. /**
  105950. * Class used for the default loading screen
  105951. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105952. */
  105953. export class DefaultLoadingScreen implements ILoadingScreen {
  105954. private _renderingCanvas;
  105955. private _loadingText;
  105956. private _loadingDivBackgroundColor;
  105957. private _loadingDiv;
  105958. private _loadingTextDiv;
  105959. /** Gets or sets the logo url to use for the default loading screen */
  105960. static DefaultLogoUrl: string;
  105961. /** Gets or sets the spinner url to use for the default loading screen */
  105962. static DefaultSpinnerUrl: string;
  105963. /**
  105964. * Creates a new default loading screen
  105965. * @param _renderingCanvas defines the canvas used to render the scene
  105966. * @param _loadingText defines the default text to display
  105967. * @param _loadingDivBackgroundColor defines the default background color
  105968. */
  105969. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105970. /**
  105971. * Function called to display the loading screen
  105972. */
  105973. displayLoadingUI(): void;
  105974. /**
  105975. * Function called to hide the loading screen
  105976. */
  105977. hideLoadingUI(): void;
  105978. /**
  105979. * Gets or sets the text to display while loading
  105980. */
  105981. set loadingUIText(text: string);
  105982. get loadingUIText(): string;
  105983. /**
  105984. * Gets or sets the color to use for the background
  105985. */
  105986. get loadingUIBackgroundColor(): string;
  105987. set loadingUIBackgroundColor(color: string);
  105988. private _resizeLoadingUI;
  105989. }
  105990. }
  105991. declare module BABYLON {
  105992. /**
  105993. * Interface for any object that can request an animation frame
  105994. */
  105995. export interface ICustomAnimationFrameRequester {
  105996. /**
  105997. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105998. */
  105999. renderFunction?: Function;
  106000. /**
  106001. * Called to request the next frame to render to
  106002. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106003. */
  106004. requestAnimationFrame: Function;
  106005. /**
  106006. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106007. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106008. */
  106009. requestID?: number;
  106010. }
  106011. }
  106012. declare module BABYLON {
  106013. /**
  106014. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106015. */
  106016. export class PerformanceMonitor {
  106017. private _enabled;
  106018. private _rollingFrameTime;
  106019. private _lastFrameTimeMs;
  106020. /**
  106021. * constructor
  106022. * @param frameSampleSize The number of samples required to saturate the sliding window
  106023. */
  106024. constructor(frameSampleSize?: number);
  106025. /**
  106026. * Samples current frame
  106027. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106028. */
  106029. sampleFrame(timeMs?: number): void;
  106030. /**
  106031. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106032. */
  106033. get averageFrameTime(): number;
  106034. /**
  106035. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106036. */
  106037. get averageFrameTimeVariance(): number;
  106038. /**
  106039. * Returns the frame time of the most recent frame
  106040. */
  106041. get instantaneousFrameTime(): number;
  106042. /**
  106043. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106044. */
  106045. get averageFPS(): number;
  106046. /**
  106047. * Returns the average framerate in frames per second using the most recent frame time
  106048. */
  106049. get instantaneousFPS(): number;
  106050. /**
  106051. * Returns true if enough samples have been taken to completely fill the sliding window
  106052. */
  106053. get isSaturated(): boolean;
  106054. /**
  106055. * Enables contributions to the sliding window sample set
  106056. */
  106057. enable(): void;
  106058. /**
  106059. * Disables contributions to the sliding window sample set
  106060. * Samples will not be interpolated over the disabled period
  106061. */
  106062. disable(): void;
  106063. /**
  106064. * Returns true if sampling is enabled
  106065. */
  106066. get isEnabled(): boolean;
  106067. /**
  106068. * Resets performance monitor
  106069. */
  106070. reset(): void;
  106071. }
  106072. /**
  106073. * RollingAverage
  106074. *
  106075. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106076. */
  106077. export class RollingAverage {
  106078. /**
  106079. * Current average
  106080. */
  106081. average: number;
  106082. /**
  106083. * Current variance
  106084. */
  106085. variance: number;
  106086. protected _samples: Array<number>;
  106087. protected _sampleCount: number;
  106088. protected _pos: number;
  106089. protected _m2: number;
  106090. /**
  106091. * constructor
  106092. * @param length The number of samples required to saturate the sliding window
  106093. */
  106094. constructor(length: number);
  106095. /**
  106096. * Adds a sample to the sample set
  106097. * @param v The sample value
  106098. */
  106099. add(v: number): void;
  106100. /**
  106101. * Returns previously added values or null if outside of history or outside the sliding window domain
  106102. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106103. * @return Value previously recorded with add() or null if outside of range
  106104. */
  106105. history(i: number): number;
  106106. /**
  106107. * Returns true if enough samples have been taken to completely fill the sliding window
  106108. * @return true if sample-set saturated
  106109. */
  106110. isSaturated(): boolean;
  106111. /**
  106112. * Resets the rolling average (equivalent to 0 samples taken so far)
  106113. */
  106114. reset(): void;
  106115. /**
  106116. * Wraps a value around the sample range boundaries
  106117. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106118. * @return Wrapped position in sample range
  106119. */
  106120. protected _wrapPosition(i: number): number;
  106121. }
  106122. }
  106123. declare module BABYLON {
  106124. /**
  106125. * This class is used to track a performance counter which is number based.
  106126. * The user has access to many properties which give statistics of different nature.
  106127. *
  106128. * The implementer can track two kinds of Performance Counter: time and count.
  106129. * 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.
  106130. * 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.
  106131. */
  106132. export class PerfCounter {
  106133. /**
  106134. * Gets or sets a global boolean to turn on and off all the counters
  106135. */
  106136. static Enabled: boolean;
  106137. /**
  106138. * Returns the smallest value ever
  106139. */
  106140. get min(): number;
  106141. /**
  106142. * Returns the biggest value ever
  106143. */
  106144. get max(): number;
  106145. /**
  106146. * Returns the average value since the performance counter is running
  106147. */
  106148. get average(): number;
  106149. /**
  106150. * Returns the average value of the last second the counter was monitored
  106151. */
  106152. get lastSecAverage(): number;
  106153. /**
  106154. * Returns the current value
  106155. */
  106156. get current(): number;
  106157. /**
  106158. * Gets the accumulated total
  106159. */
  106160. get total(): number;
  106161. /**
  106162. * Gets the total value count
  106163. */
  106164. get count(): number;
  106165. /**
  106166. * Creates a new counter
  106167. */
  106168. constructor();
  106169. /**
  106170. * Call this method to start monitoring a new frame.
  106171. * 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.
  106172. */
  106173. fetchNewFrame(): void;
  106174. /**
  106175. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106176. * @param newCount the count value to add to the monitored count
  106177. * @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.
  106178. */
  106179. addCount(newCount: number, fetchResult: boolean): void;
  106180. /**
  106181. * Start monitoring this performance counter
  106182. */
  106183. beginMonitoring(): void;
  106184. /**
  106185. * Compute the time lapsed since the previous beginMonitoring() call.
  106186. * @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
  106187. */
  106188. endMonitoring(newFrame?: boolean): void;
  106189. private _fetchResult;
  106190. private _startMonitoringTime;
  106191. private _min;
  106192. private _max;
  106193. private _average;
  106194. private _current;
  106195. private _totalValueCount;
  106196. private _totalAccumulated;
  106197. private _lastSecAverage;
  106198. private _lastSecAccumulated;
  106199. private _lastSecTime;
  106200. private _lastSecValueCount;
  106201. }
  106202. }
  106203. declare module BABYLON {
  106204. interface ThinEngine {
  106205. /**
  106206. * Sets alpha constants used by some alpha blending modes
  106207. * @param r defines the red component
  106208. * @param g defines the green component
  106209. * @param b defines the blue component
  106210. * @param a defines the alpha component
  106211. */
  106212. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106213. /**
  106214. * Sets the current alpha mode
  106215. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106216. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106217. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106218. */
  106219. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106220. /**
  106221. * Gets the current alpha mode
  106222. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106223. * @returns the current alpha mode
  106224. */
  106225. getAlphaMode(): number;
  106226. /**
  106227. * Sets the current alpha equation
  106228. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106229. */
  106230. setAlphaEquation(equation: number): void;
  106231. /**
  106232. * Gets the current alpha equation.
  106233. * @returns the current alpha equation
  106234. */
  106235. getAlphaEquation(): number;
  106236. }
  106237. }
  106238. declare module BABYLON {
  106239. /**
  106240. * Defines the interface used by display changed events
  106241. */
  106242. export interface IDisplayChangedEventArgs {
  106243. /** Gets the vrDisplay object (if any) */
  106244. vrDisplay: Nullable<any>;
  106245. /** Gets a boolean indicating if webVR is supported */
  106246. vrSupported: boolean;
  106247. }
  106248. /**
  106249. * Defines the interface used by objects containing a viewport (like a camera)
  106250. */
  106251. interface IViewportOwnerLike {
  106252. /**
  106253. * Gets or sets the viewport
  106254. */
  106255. viewport: IViewportLike;
  106256. }
  106257. /**
  106258. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106259. */
  106260. export class Engine extends ThinEngine {
  106261. /** Defines that alpha blending is disabled */
  106262. static readonly ALPHA_DISABLE: number;
  106263. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106264. static readonly ALPHA_ADD: number;
  106265. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106266. static readonly ALPHA_COMBINE: number;
  106267. /** Defines that alpha blending to DEST - SRC * DEST */
  106268. static readonly ALPHA_SUBTRACT: number;
  106269. /** Defines that alpha blending to SRC * DEST */
  106270. static readonly ALPHA_MULTIPLY: number;
  106271. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106272. static readonly ALPHA_MAXIMIZED: number;
  106273. /** Defines that alpha blending to SRC + DEST */
  106274. static readonly ALPHA_ONEONE: number;
  106275. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106276. static readonly ALPHA_PREMULTIPLIED: number;
  106277. /**
  106278. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106279. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106280. */
  106281. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106282. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106283. static readonly ALPHA_INTERPOLATE: number;
  106284. /**
  106285. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106286. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106287. */
  106288. static readonly ALPHA_SCREENMODE: number;
  106289. /** Defines that the ressource is not delayed*/
  106290. static readonly DELAYLOADSTATE_NONE: number;
  106291. /** Defines that the ressource was successfully delay loaded */
  106292. static readonly DELAYLOADSTATE_LOADED: number;
  106293. /** Defines that the ressource is currently delay loading */
  106294. static readonly DELAYLOADSTATE_LOADING: number;
  106295. /** Defines that the ressource is delayed and has not started loading */
  106296. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106297. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106298. static readonly NEVER: number;
  106299. /** 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 */
  106300. static readonly ALWAYS: number;
  106301. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106302. static readonly LESS: number;
  106303. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106304. static readonly EQUAL: number;
  106305. /** 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 */
  106306. static readonly LEQUAL: number;
  106307. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106308. static readonly GREATER: number;
  106309. /** 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 */
  106310. static readonly GEQUAL: number;
  106311. /** 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 */
  106312. static readonly NOTEQUAL: number;
  106313. /** Passed to stencilOperation to specify that stencil value must be kept */
  106314. static readonly KEEP: number;
  106315. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106316. static readonly REPLACE: number;
  106317. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106318. static readonly INCR: number;
  106319. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106320. static readonly DECR: number;
  106321. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106322. static readonly INVERT: number;
  106323. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106324. static readonly INCR_WRAP: number;
  106325. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106326. static readonly DECR_WRAP: number;
  106327. /** Texture is not repeating outside of 0..1 UVs */
  106328. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106329. /** Texture is repeating outside of 0..1 UVs */
  106330. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106331. /** Texture is repeating and mirrored */
  106332. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106333. /** ALPHA */
  106334. static readonly TEXTUREFORMAT_ALPHA: number;
  106335. /** LUMINANCE */
  106336. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106337. /** LUMINANCE_ALPHA */
  106338. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106339. /** RGB */
  106340. static readonly TEXTUREFORMAT_RGB: number;
  106341. /** RGBA */
  106342. static readonly TEXTUREFORMAT_RGBA: number;
  106343. /** RED */
  106344. static readonly TEXTUREFORMAT_RED: number;
  106345. /** RED (2nd reference) */
  106346. static readonly TEXTUREFORMAT_R: number;
  106347. /** RG */
  106348. static readonly TEXTUREFORMAT_RG: number;
  106349. /** RED_INTEGER */
  106350. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106351. /** RED_INTEGER (2nd reference) */
  106352. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106353. /** RG_INTEGER */
  106354. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106355. /** RGB_INTEGER */
  106356. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106357. /** RGBA_INTEGER */
  106358. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106359. /** UNSIGNED_BYTE */
  106360. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106361. /** UNSIGNED_BYTE (2nd reference) */
  106362. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106363. /** FLOAT */
  106364. static readonly TEXTURETYPE_FLOAT: number;
  106365. /** HALF_FLOAT */
  106366. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106367. /** BYTE */
  106368. static readonly TEXTURETYPE_BYTE: number;
  106369. /** SHORT */
  106370. static readonly TEXTURETYPE_SHORT: number;
  106371. /** UNSIGNED_SHORT */
  106372. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106373. /** INT */
  106374. static readonly TEXTURETYPE_INT: number;
  106375. /** UNSIGNED_INT */
  106376. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106377. /** UNSIGNED_SHORT_4_4_4_4 */
  106378. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106379. /** UNSIGNED_SHORT_5_5_5_1 */
  106380. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106381. /** UNSIGNED_SHORT_5_6_5 */
  106382. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106383. /** UNSIGNED_INT_2_10_10_10_REV */
  106384. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106385. /** UNSIGNED_INT_24_8 */
  106386. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106387. /** UNSIGNED_INT_10F_11F_11F_REV */
  106388. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106389. /** UNSIGNED_INT_5_9_9_9_REV */
  106390. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106391. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106392. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106393. /** nearest is mag = nearest and min = nearest and mip = linear */
  106394. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106395. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106396. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106397. /** Trilinear is mag = linear and min = linear and mip = linear */
  106398. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106399. /** nearest is mag = nearest and min = nearest and mip = linear */
  106400. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106401. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106402. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106403. /** Trilinear is mag = linear and min = linear and mip = linear */
  106404. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106405. /** mag = nearest and min = nearest and mip = nearest */
  106406. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106407. /** mag = nearest and min = linear and mip = nearest */
  106408. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106409. /** mag = nearest and min = linear and mip = linear */
  106410. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106411. /** mag = nearest and min = linear and mip = none */
  106412. static readonly TEXTURE_NEAREST_LINEAR: number;
  106413. /** mag = nearest and min = nearest and mip = none */
  106414. static readonly TEXTURE_NEAREST_NEAREST: number;
  106415. /** mag = linear and min = nearest and mip = nearest */
  106416. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106417. /** mag = linear and min = nearest and mip = linear */
  106418. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106419. /** mag = linear and min = linear and mip = none */
  106420. static readonly TEXTURE_LINEAR_LINEAR: number;
  106421. /** mag = linear and min = nearest and mip = none */
  106422. static readonly TEXTURE_LINEAR_NEAREST: number;
  106423. /** Explicit coordinates mode */
  106424. static readonly TEXTURE_EXPLICIT_MODE: number;
  106425. /** Spherical coordinates mode */
  106426. static readonly TEXTURE_SPHERICAL_MODE: number;
  106427. /** Planar coordinates mode */
  106428. static readonly TEXTURE_PLANAR_MODE: number;
  106429. /** Cubic coordinates mode */
  106430. static readonly TEXTURE_CUBIC_MODE: number;
  106431. /** Projection coordinates mode */
  106432. static readonly TEXTURE_PROJECTION_MODE: number;
  106433. /** Skybox coordinates mode */
  106434. static readonly TEXTURE_SKYBOX_MODE: number;
  106435. /** Inverse Cubic coordinates mode */
  106436. static readonly TEXTURE_INVCUBIC_MODE: number;
  106437. /** Equirectangular coordinates mode */
  106438. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106439. /** Equirectangular Fixed coordinates mode */
  106440. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106441. /** Equirectangular Fixed Mirrored coordinates mode */
  106442. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106443. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106444. static readonly SCALEMODE_FLOOR: number;
  106445. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106446. static readonly SCALEMODE_NEAREST: number;
  106447. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106448. static readonly SCALEMODE_CEILING: number;
  106449. /**
  106450. * Returns the current npm package of the sdk
  106451. */
  106452. static get NpmPackage(): string;
  106453. /**
  106454. * Returns the current version of the framework
  106455. */
  106456. static get Version(): string;
  106457. /** Gets the list of created engines */
  106458. static get Instances(): Engine[];
  106459. /**
  106460. * Gets the latest created engine
  106461. */
  106462. static get LastCreatedEngine(): Nullable<Engine>;
  106463. /**
  106464. * Gets the latest created scene
  106465. */
  106466. static get LastCreatedScene(): Nullable<Scene>;
  106467. /**
  106468. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106469. * @param flag defines which part of the materials must be marked as dirty
  106470. * @param predicate defines a predicate used to filter which materials should be affected
  106471. */
  106472. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106473. /**
  106474. * Method called to create the default loading screen.
  106475. * This can be overriden in your own app.
  106476. * @param canvas The rendering canvas element
  106477. * @returns The loading screen
  106478. */
  106479. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106480. /**
  106481. * Method called to create the default rescale post process on each engine.
  106482. */
  106483. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106484. /**
  106485. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106486. **/
  106487. enableOfflineSupport: boolean;
  106488. /**
  106489. * 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)
  106490. **/
  106491. disableManifestCheck: boolean;
  106492. /**
  106493. * Gets the list of created scenes
  106494. */
  106495. scenes: Scene[];
  106496. /**
  106497. * Event raised when a new scene is created
  106498. */
  106499. onNewSceneAddedObservable: Observable<Scene>;
  106500. /**
  106501. * Gets the list of created postprocesses
  106502. */
  106503. postProcesses: PostProcess[];
  106504. /**
  106505. * Gets a boolean indicating if the pointer is currently locked
  106506. */
  106507. isPointerLock: boolean;
  106508. /**
  106509. * Observable event triggered each time the rendering canvas is resized
  106510. */
  106511. onResizeObservable: Observable<Engine>;
  106512. /**
  106513. * Observable event triggered each time the canvas loses focus
  106514. */
  106515. onCanvasBlurObservable: Observable<Engine>;
  106516. /**
  106517. * Observable event triggered each time the canvas gains focus
  106518. */
  106519. onCanvasFocusObservable: Observable<Engine>;
  106520. /**
  106521. * Observable event triggered each time the canvas receives pointerout event
  106522. */
  106523. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106524. /**
  106525. * Observable raised when the engine begins a new frame
  106526. */
  106527. onBeginFrameObservable: Observable<Engine>;
  106528. /**
  106529. * If set, will be used to request the next animation frame for the render loop
  106530. */
  106531. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106532. /**
  106533. * Observable raised when the engine ends the current frame
  106534. */
  106535. onEndFrameObservable: Observable<Engine>;
  106536. /**
  106537. * Observable raised when the engine is about to compile a shader
  106538. */
  106539. onBeforeShaderCompilationObservable: Observable<Engine>;
  106540. /**
  106541. * Observable raised when the engine has jsut compiled a shader
  106542. */
  106543. onAfterShaderCompilationObservable: Observable<Engine>;
  106544. /**
  106545. * Gets the audio engine
  106546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106547. * @ignorenaming
  106548. */
  106549. static audioEngine: IAudioEngine;
  106550. /**
  106551. * Default AudioEngine factory responsible of creating the Audio Engine.
  106552. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106553. */
  106554. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106555. /**
  106556. * Default offline support factory responsible of creating a tool used to store data locally.
  106557. * By default, this will create a Database object if the workload has been embedded.
  106558. */
  106559. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106560. private _loadingScreen;
  106561. private _pointerLockRequested;
  106562. private _dummyFramebuffer;
  106563. private _rescalePostProcess;
  106564. private _deterministicLockstep;
  106565. private _lockstepMaxSteps;
  106566. private _timeStep;
  106567. protected get _supportsHardwareTextureRescaling(): boolean;
  106568. private _fps;
  106569. private _deltaTime;
  106570. /** @hidden */
  106571. _drawCalls: PerfCounter;
  106572. /** 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 */
  106573. canvasTabIndex: number;
  106574. /**
  106575. * Turn this value on if you want to pause FPS computation when in background
  106576. */
  106577. disablePerformanceMonitorInBackground: boolean;
  106578. private _performanceMonitor;
  106579. /**
  106580. * Gets the performance monitor attached to this engine
  106581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106582. */
  106583. get performanceMonitor(): PerformanceMonitor;
  106584. private _onFocus;
  106585. private _onBlur;
  106586. private _onCanvasPointerOut;
  106587. private _onCanvasBlur;
  106588. private _onCanvasFocus;
  106589. private _onFullscreenChange;
  106590. private _onPointerLockChange;
  106591. /**
  106592. * Gets the HTML element used to attach event listeners
  106593. * @returns a HTML element
  106594. */
  106595. getInputElement(): Nullable<HTMLElement>;
  106596. /**
  106597. * Creates a new engine
  106598. * @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
  106599. * @param antialias defines enable antialiasing (default: false)
  106600. * @param options defines further options to be sent to the getContext() function
  106601. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106602. */
  106603. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106604. /**
  106605. * Gets current aspect ratio
  106606. * @param viewportOwner defines the camera to use to get the aspect ratio
  106607. * @param useScreen defines if screen size must be used (or the current render target if any)
  106608. * @returns a number defining the aspect ratio
  106609. */
  106610. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106611. /**
  106612. * Gets current screen aspect ratio
  106613. * @returns a number defining the aspect ratio
  106614. */
  106615. getScreenAspectRatio(): number;
  106616. /**
  106617. * Gets the client rect of the HTML canvas attached with the current webGL context
  106618. * @returns a client rectanglee
  106619. */
  106620. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106621. /**
  106622. * Gets the client rect of the HTML element used for events
  106623. * @returns a client rectanglee
  106624. */
  106625. getInputElementClientRect(): Nullable<ClientRect>;
  106626. /**
  106627. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106629. * @returns true if engine is in deterministic lock step mode
  106630. */
  106631. isDeterministicLockStep(): boolean;
  106632. /**
  106633. * Gets the max steps when engine is running in deterministic lock step
  106634. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106635. * @returns the max steps
  106636. */
  106637. getLockstepMaxSteps(): number;
  106638. /**
  106639. * Returns the time in ms between steps when using deterministic lock step.
  106640. * @returns time step in (ms)
  106641. */
  106642. getTimeStep(): number;
  106643. /**
  106644. * Force the mipmap generation for the given render target texture
  106645. * @param texture defines the render target texture to use
  106646. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106647. */
  106648. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106649. /** States */
  106650. /**
  106651. * Set various states to the webGL context
  106652. * @param culling defines backface culling state
  106653. * @param zOffset defines the value to apply to zOffset (0 by default)
  106654. * @param force defines if states must be applied even if cache is up to date
  106655. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106656. */
  106657. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106658. /**
  106659. * Set the z offset to apply to current rendering
  106660. * @param value defines the offset to apply
  106661. */
  106662. setZOffset(value: number): void;
  106663. /**
  106664. * Gets the current value of the zOffset
  106665. * @returns the current zOffset state
  106666. */
  106667. getZOffset(): number;
  106668. /**
  106669. * Enable or disable depth buffering
  106670. * @param enable defines the state to set
  106671. */
  106672. setDepthBuffer(enable: boolean): void;
  106673. /**
  106674. * Gets a boolean indicating if depth writing is enabled
  106675. * @returns the current depth writing state
  106676. */
  106677. getDepthWrite(): boolean;
  106678. /**
  106679. * Enable or disable depth writing
  106680. * @param enable defines the state to set
  106681. */
  106682. setDepthWrite(enable: boolean): void;
  106683. /**
  106684. * Gets a boolean indicating if stencil buffer is enabled
  106685. * @returns the current stencil buffer state
  106686. */
  106687. getStencilBuffer(): boolean;
  106688. /**
  106689. * Enable or disable the stencil buffer
  106690. * @param enable defines if the stencil buffer must be enabled or disabled
  106691. */
  106692. setStencilBuffer(enable: boolean): void;
  106693. /**
  106694. * Gets the current stencil mask
  106695. * @returns a number defining the new stencil mask to use
  106696. */
  106697. getStencilMask(): number;
  106698. /**
  106699. * Sets the current stencil mask
  106700. * @param mask defines the new stencil mask to use
  106701. */
  106702. setStencilMask(mask: number): void;
  106703. /**
  106704. * Gets the current stencil function
  106705. * @returns a number defining the stencil function to use
  106706. */
  106707. getStencilFunction(): number;
  106708. /**
  106709. * Gets the current stencil reference value
  106710. * @returns a number defining the stencil reference value to use
  106711. */
  106712. getStencilFunctionReference(): number;
  106713. /**
  106714. * Gets the current stencil mask
  106715. * @returns a number defining the stencil mask to use
  106716. */
  106717. getStencilFunctionMask(): number;
  106718. /**
  106719. * Sets the current stencil function
  106720. * @param stencilFunc defines the new stencil function to use
  106721. */
  106722. setStencilFunction(stencilFunc: number): void;
  106723. /**
  106724. * Sets the current stencil reference
  106725. * @param reference defines the new stencil reference to use
  106726. */
  106727. setStencilFunctionReference(reference: number): void;
  106728. /**
  106729. * Sets the current stencil mask
  106730. * @param mask defines the new stencil mask to use
  106731. */
  106732. setStencilFunctionMask(mask: number): void;
  106733. /**
  106734. * Gets the current stencil operation when stencil fails
  106735. * @returns a number defining stencil operation to use when stencil fails
  106736. */
  106737. getStencilOperationFail(): number;
  106738. /**
  106739. * Gets the current stencil operation when depth fails
  106740. * @returns a number defining stencil operation to use when depth fails
  106741. */
  106742. getStencilOperationDepthFail(): number;
  106743. /**
  106744. * Gets the current stencil operation when stencil passes
  106745. * @returns a number defining stencil operation to use when stencil passes
  106746. */
  106747. getStencilOperationPass(): number;
  106748. /**
  106749. * Sets the stencil operation to use when stencil fails
  106750. * @param operation defines the stencil operation to use when stencil fails
  106751. */
  106752. setStencilOperationFail(operation: number): void;
  106753. /**
  106754. * Sets the stencil operation to use when depth fails
  106755. * @param operation defines the stencil operation to use when depth fails
  106756. */
  106757. setStencilOperationDepthFail(operation: number): void;
  106758. /**
  106759. * Sets the stencil operation to use when stencil passes
  106760. * @param operation defines the stencil operation to use when stencil passes
  106761. */
  106762. setStencilOperationPass(operation: number): void;
  106763. /**
  106764. * Sets a boolean indicating if the dithering state is enabled or disabled
  106765. * @param value defines the dithering state
  106766. */
  106767. setDitheringState(value: boolean): void;
  106768. /**
  106769. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106770. * @param value defines the rasterizer state
  106771. */
  106772. setRasterizerState(value: boolean): void;
  106773. /**
  106774. * Gets the current depth function
  106775. * @returns a number defining the depth function
  106776. */
  106777. getDepthFunction(): Nullable<number>;
  106778. /**
  106779. * Sets the current depth function
  106780. * @param depthFunc defines the function to use
  106781. */
  106782. setDepthFunction(depthFunc: number): void;
  106783. /**
  106784. * Sets the current depth function to GREATER
  106785. */
  106786. setDepthFunctionToGreater(): void;
  106787. /**
  106788. * Sets the current depth function to GEQUAL
  106789. */
  106790. setDepthFunctionToGreaterOrEqual(): void;
  106791. /**
  106792. * Sets the current depth function to LESS
  106793. */
  106794. setDepthFunctionToLess(): void;
  106795. /**
  106796. * Sets the current depth function to LEQUAL
  106797. */
  106798. setDepthFunctionToLessOrEqual(): void;
  106799. private _cachedStencilBuffer;
  106800. private _cachedStencilFunction;
  106801. private _cachedStencilMask;
  106802. private _cachedStencilOperationPass;
  106803. private _cachedStencilOperationFail;
  106804. private _cachedStencilOperationDepthFail;
  106805. private _cachedStencilReference;
  106806. /**
  106807. * Caches the the state of the stencil buffer
  106808. */
  106809. cacheStencilState(): void;
  106810. /**
  106811. * Restores the state of the stencil buffer
  106812. */
  106813. restoreStencilState(): void;
  106814. /**
  106815. * Directly set the WebGL Viewport
  106816. * @param x defines the x coordinate of the viewport (in screen space)
  106817. * @param y defines the y coordinate of the viewport (in screen space)
  106818. * @param width defines the width of the viewport (in screen space)
  106819. * @param height defines the height of the viewport (in screen space)
  106820. * @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
  106821. */
  106822. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106823. /**
  106824. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106825. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106826. * @param y defines the y-coordinate of the corner of the clear rectangle
  106827. * @param width defines the width of the clear rectangle
  106828. * @param height defines the height of the clear rectangle
  106829. * @param clearColor defines the clear color
  106830. */
  106831. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106832. /**
  106833. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106834. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106835. * @param y defines the y-coordinate of the corner of the clear rectangle
  106836. * @param width defines the width of the clear rectangle
  106837. * @param height defines the height of the clear rectangle
  106838. */
  106839. enableScissor(x: number, y: number, width: number, height: number): void;
  106840. /**
  106841. * Disable previously set scissor test rectangle
  106842. */
  106843. disableScissor(): void;
  106844. protected _reportDrawCall(): void;
  106845. /**
  106846. * Initializes a webVR display and starts listening to display change events
  106847. * The onVRDisplayChangedObservable will be notified upon these changes
  106848. * @returns The onVRDisplayChangedObservable
  106849. */
  106850. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106851. /** @hidden */
  106852. _prepareVRComponent(): void;
  106853. /** @hidden */
  106854. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106855. /** @hidden */
  106856. _submitVRFrame(): void;
  106857. /**
  106858. * Call this function to leave webVR mode
  106859. * Will do nothing if webVR is not supported or if there is no webVR device
  106860. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106861. */
  106862. disableVR(): void;
  106863. /**
  106864. * Gets a boolean indicating that the system is in VR mode and is presenting
  106865. * @returns true if VR mode is engaged
  106866. */
  106867. isVRPresenting(): boolean;
  106868. /** @hidden */
  106869. _requestVRFrame(): void;
  106870. /** @hidden */
  106871. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106872. /**
  106873. * Gets the source code of the vertex shader associated with a specific webGL program
  106874. * @param program defines the program to use
  106875. * @returns a string containing the source code of the vertex shader associated with the program
  106876. */
  106877. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106878. /**
  106879. * Gets the source code of the fragment shader associated with a specific webGL program
  106880. * @param program defines the program to use
  106881. * @returns a string containing the source code of the fragment shader associated with the program
  106882. */
  106883. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106884. /**
  106885. * Sets a depth stencil texture from a render target to the according uniform.
  106886. * @param channel The texture channel
  106887. * @param uniform The uniform to set
  106888. * @param texture The render target texture containing the depth stencil texture to apply
  106889. */
  106890. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106891. /**
  106892. * Sets a texture to the webGL context from a postprocess
  106893. * @param channel defines the channel to use
  106894. * @param postProcess defines the source postprocess
  106895. */
  106896. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106897. /**
  106898. * Binds the output of the passed in post process to the texture channel specified
  106899. * @param channel The channel the texture should be bound to
  106900. * @param postProcess The post process which's output should be bound
  106901. */
  106902. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106903. /** @hidden */
  106904. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106905. protected _rebuildBuffers(): void;
  106906. /** @hidden */
  106907. _renderFrame(): void;
  106908. _renderLoop(): void;
  106909. /** @hidden */
  106910. _renderViews(): boolean;
  106911. /**
  106912. * Toggle full screen mode
  106913. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106914. */
  106915. switchFullscreen(requestPointerLock: boolean): void;
  106916. /**
  106917. * Enters full screen mode
  106918. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106919. */
  106920. enterFullscreen(requestPointerLock: boolean): void;
  106921. /**
  106922. * Exits full screen mode
  106923. */
  106924. exitFullscreen(): void;
  106925. /**
  106926. * Enters Pointerlock mode
  106927. */
  106928. enterPointerlock(): void;
  106929. /**
  106930. * Exits Pointerlock mode
  106931. */
  106932. exitPointerlock(): void;
  106933. /**
  106934. * Begin a new frame
  106935. */
  106936. beginFrame(): void;
  106937. /**
  106938. * Enf the current frame
  106939. */
  106940. endFrame(): void;
  106941. resize(): void;
  106942. /**
  106943. * Set the compressed texture format to use, based on the formats you have, and the formats
  106944. * supported by the hardware / browser.
  106945. *
  106946. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106947. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106948. * to API arguments needed to compressed textures. This puts the burden on the container
  106949. * generator to house the arcane code for determining these for current & future formats.
  106950. *
  106951. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106952. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106953. *
  106954. * Note: The result of this call is not taken into account when a texture is base64.
  106955. *
  106956. * @param formatsAvailable defines the list of those format families you have created
  106957. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106958. *
  106959. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106960. * @returns The extension selected.
  106961. */
  106962. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106963. /**
  106964. * Set the compressed texture extensions or file names to skip.
  106965. *
  106966. * @param skippedFiles defines the list of those texture files you want to skip
  106967. * Example: [".dds", ".env", "myfile.png"]
  106968. */
  106969. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106970. /**
  106971. * Force a specific size of the canvas
  106972. * @param width defines the new canvas' width
  106973. * @param height defines the new canvas' height
  106974. */
  106975. setSize(width: number, height: number): void;
  106976. /**
  106977. * Updates a dynamic vertex buffer.
  106978. * @param vertexBuffer the vertex buffer to update
  106979. * @param data the data used to update the vertex buffer
  106980. * @param byteOffset the byte offset of the data
  106981. * @param byteLength the byte length of the data
  106982. */
  106983. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106984. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106985. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106986. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106987. _releaseTexture(texture: InternalTexture): void;
  106988. /**
  106989. * @hidden
  106990. * Rescales a texture
  106991. * @param source input texutre
  106992. * @param destination destination texture
  106993. * @param scene scene to use to render the resize
  106994. * @param internalFormat format to use when resizing
  106995. * @param onComplete callback to be called when resize has completed
  106996. */
  106997. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106998. /**
  106999. * Gets the current framerate
  107000. * @returns a number representing the framerate
  107001. */
  107002. getFps(): number;
  107003. /**
  107004. * Gets the time spent between current and previous frame
  107005. * @returns a number representing the delta time in ms
  107006. */
  107007. getDeltaTime(): number;
  107008. private _measureFps;
  107009. /** @hidden */
  107010. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107011. /**
  107012. * Update a dynamic index buffer
  107013. * @param indexBuffer defines the target index buffer
  107014. * @param indices defines the data to update
  107015. * @param offset defines the offset in the target index buffer where update should start
  107016. */
  107017. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107018. /**
  107019. * Updates the sample count of a render target texture
  107020. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107021. * @param texture defines the texture to update
  107022. * @param samples defines the sample count to set
  107023. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107024. */
  107025. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107026. /**
  107027. * Updates a depth texture Comparison Mode and Function.
  107028. * If the comparison Function is equal to 0, the mode will be set to none.
  107029. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107030. * @param texture The texture to set the comparison function for
  107031. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107032. */
  107033. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107034. /**
  107035. * Creates a webGL buffer to use with instanciation
  107036. * @param capacity defines the size of the buffer
  107037. * @returns the webGL buffer
  107038. */
  107039. createInstancesBuffer(capacity: number): DataBuffer;
  107040. /**
  107041. * Delete a webGL buffer used with instanciation
  107042. * @param buffer defines the webGL buffer to delete
  107043. */
  107044. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107045. /** @hidden */
  107046. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107047. dispose(): void;
  107048. private _disableTouchAction;
  107049. /**
  107050. * Display the loading screen
  107051. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107052. */
  107053. displayLoadingUI(): void;
  107054. /**
  107055. * Hide the loading screen
  107056. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107057. */
  107058. hideLoadingUI(): void;
  107059. /**
  107060. * Gets the current loading screen object
  107061. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107062. */
  107063. get loadingScreen(): ILoadingScreen;
  107064. /**
  107065. * Sets the current loading screen object
  107066. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107067. */
  107068. set loadingScreen(loadingScreen: ILoadingScreen);
  107069. /**
  107070. * Sets the current loading screen text
  107071. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107072. */
  107073. set loadingUIText(text: string);
  107074. /**
  107075. * Sets the current loading screen background color
  107076. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107077. */
  107078. set loadingUIBackgroundColor(color: string);
  107079. /** Pointerlock and fullscreen */
  107080. /**
  107081. * Ask the browser to promote the current element to pointerlock mode
  107082. * @param element defines the DOM element to promote
  107083. */
  107084. static _RequestPointerlock(element: HTMLElement): void;
  107085. /**
  107086. * Asks the browser to exit pointerlock mode
  107087. */
  107088. static _ExitPointerlock(): void;
  107089. /**
  107090. * Ask the browser to promote the current element to fullscreen rendering mode
  107091. * @param element defines the DOM element to promote
  107092. */
  107093. static _RequestFullscreen(element: HTMLElement): void;
  107094. /**
  107095. * Asks the browser to exit fullscreen mode
  107096. */
  107097. static _ExitFullscreen(): void;
  107098. }
  107099. }
  107100. declare module BABYLON {
  107101. /**
  107102. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107103. * during the life time of the application.
  107104. */
  107105. export class EngineStore {
  107106. /** Gets the list of created engines */
  107107. static Instances: Engine[];
  107108. /** @hidden */
  107109. static _LastCreatedScene: Nullable<Scene>;
  107110. /**
  107111. * Gets the latest created engine
  107112. */
  107113. static get LastCreatedEngine(): Nullable<Engine>;
  107114. /**
  107115. * Gets the latest created scene
  107116. */
  107117. static get LastCreatedScene(): Nullable<Scene>;
  107118. /**
  107119. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107120. * @ignorenaming
  107121. */
  107122. static UseFallbackTexture: boolean;
  107123. /**
  107124. * Texture content used if a texture cannot loaded
  107125. * @ignorenaming
  107126. */
  107127. static FallbackTexture: string;
  107128. }
  107129. }
  107130. declare module BABYLON {
  107131. /**
  107132. * Helper class that provides a small promise polyfill
  107133. */
  107134. export class PromisePolyfill {
  107135. /**
  107136. * Static function used to check if the polyfill is required
  107137. * If this is the case then the function will inject the polyfill to window.Promise
  107138. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107139. */
  107140. static Apply(force?: boolean): void;
  107141. }
  107142. }
  107143. declare module BABYLON {
  107144. /**
  107145. * Interface for screenshot methods with describe argument called `size` as object with options
  107146. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107147. */
  107148. export interface IScreenshotSize {
  107149. /**
  107150. * number in pixels for canvas height
  107151. */
  107152. height?: number;
  107153. /**
  107154. * multiplier allowing render at a higher or lower resolution
  107155. * If value is defined then height and width will be ignored and taken from camera
  107156. */
  107157. precision?: number;
  107158. /**
  107159. * number in pixels for canvas width
  107160. */
  107161. width?: number;
  107162. }
  107163. }
  107164. declare module BABYLON {
  107165. interface IColor4Like {
  107166. r: float;
  107167. g: float;
  107168. b: float;
  107169. a: float;
  107170. }
  107171. /**
  107172. * Class containing a set of static utilities functions
  107173. */
  107174. export class Tools {
  107175. /**
  107176. * Gets or sets the base URL to use to load assets
  107177. */
  107178. static get BaseUrl(): string;
  107179. static set BaseUrl(value: string);
  107180. /**
  107181. * Enable/Disable Custom HTTP Request Headers globally.
  107182. * default = false
  107183. * @see CustomRequestHeaders
  107184. */
  107185. static UseCustomRequestHeaders: boolean;
  107186. /**
  107187. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107188. * i.e. when loading files, where the server/service expects an Authorization header
  107189. */
  107190. static CustomRequestHeaders: {
  107191. [key: string]: string;
  107192. };
  107193. /**
  107194. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107195. */
  107196. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107197. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107198. /**
  107199. * Default behaviour for cors in the application.
  107200. * It can be a string if the expected behavior is identical in the entire app.
  107201. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107202. */
  107203. static CorsBehavior: string | ((url: string | string[]) => string);
  107204. /**
  107205. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107206. * @ignorenaming
  107207. */
  107208. static get UseFallbackTexture(): boolean;
  107209. static set UseFallbackTexture(value: boolean);
  107210. /**
  107211. * Use this object to register external classes like custom textures or material
  107212. * to allow the laoders to instantiate them
  107213. */
  107214. static get RegisteredExternalClasses(): {
  107215. [key: string]: Object;
  107216. };
  107217. static set RegisteredExternalClasses(classes: {
  107218. [key: string]: Object;
  107219. });
  107220. /**
  107221. * Texture content used if a texture cannot loaded
  107222. * @ignorenaming
  107223. */
  107224. static get fallbackTexture(): string;
  107225. static set fallbackTexture(value: string);
  107226. /**
  107227. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107228. * @param u defines the coordinate on X axis
  107229. * @param v defines the coordinate on Y axis
  107230. * @param width defines the width of the source data
  107231. * @param height defines the height of the source data
  107232. * @param pixels defines the source byte array
  107233. * @param color defines the output color
  107234. */
  107235. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107236. /**
  107237. * Interpolates between a and b via alpha
  107238. * @param a The lower value (returned when alpha = 0)
  107239. * @param b The upper value (returned when alpha = 1)
  107240. * @param alpha The interpolation-factor
  107241. * @return The mixed value
  107242. */
  107243. static Mix(a: number, b: number, alpha: number): number;
  107244. /**
  107245. * Tries to instantiate a new object from a given class name
  107246. * @param className defines the class name to instantiate
  107247. * @returns the new object or null if the system was not able to do the instantiation
  107248. */
  107249. static Instantiate(className: string): any;
  107250. /**
  107251. * Provides a slice function that will work even on IE
  107252. * @param data defines the array to slice
  107253. * @param start defines the start of the data (optional)
  107254. * @param end defines the end of the data (optional)
  107255. * @returns the new sliced array
  107256. */
  107257. static Slice<T>(data: T, start?: number, end?: number): T;
  107258. /**
  107259. * Polyfill for setImmediate
  107260. * @param action defines the action to execute after the current execution block
  107261. */
  107262. static SetImmediate(action: () => void): void;
  107263. /**
  107264. * Function indicating if a number is an exponent of 2
  107265. * @param value defines the value to test
  107266. * @returns true if the value is an exponent of 2
  107267. */
  107268. static IsExponentOfTwo(value: number): boolean;
  107269. private static _tmpFloatArray;
  107270. /**
  107271. * Returns the nearest 32-bit single precision float representation of a Number
  107272. * @param value A Number. If the parameter is of a different type, it will get converted
  107273. * to a number or to NaN if it cannot be converted
  107274. * @returns number
  107275. */
  107276. static FloatRound(value: number): number;
  107277. /**
  107278. * Extracts the filename from a path
  107279. * @param path defines the path to use
  107280. * @returns the filename
  107281. */
  107282. static GetFilename(path: string): string;
  107283. /**
  107284. * Extracts the "folder" part of a path (everything before the filename).
  107285. * @param uri The URI to extract the info from
  107286. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107287. * @returns The "folder" part of the path
  107288. */
  107289. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107290. /**
  107291. * Extracts text content from a DOM element hierarchy
  107292. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107293. */
  107294. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107295. /**
  107296. * Convert an angle in radians to degrees
  107297. * @param angle defines the angle to convert
  107298. * @returns the angle in degrees
  107299. */
  107300. static ToDegrees(angle: number): number;
  107301. /**
  107302. * Convert an angle in degrees to radians
  107303. * @param angle defines the angle to convert
  107304. * @returns the angle in radians
  107305. */
  107306. static ToRadians(angle: number): number;
  107307. /**
  107308. * Returns an array if obj is not an array
  107309. * @param obj defines the object to evaluate as an array
  107310. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107311. * @returns either obj directly if obj is an array or a new array containing obj
  107312. */
  107313. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107314. /**
  107315. * Gets the pointer prefix to use
  107316. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107317. */
  107318. static GetPointerPrefix(): string;
  107319. /**
  107320. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107321. * @param url define the url we are trying
  107322. * @param element define the dom element where to configure the cors policy
  107323. */
  107324. static SetCorsBehavior(url: string | string[], element: {
  107325. crossOrigin: string | null;
  107326. }): void;
  107327. /**
  107328. * Removes unwanted characters from an url
  107329. * @param url defines the url to clean
  107330. * @returns the cleaned url
  107331. */
  107332. static CleanUrl(url: string): string;
  107333. /**
  107334. * Gets or sets a function used to pre-process url before using them to load assets
  107335. */
  107336. static get PreprocessUrl(): (url: string) => string;
  107337. static set PreprocessUrl(processor: (url: string) => string);
  107338. /**
  107339. * Loads an image as an HTMLImageElement.
  107340. * @param input url string, ArrayBuffer, or Blob to load
  107341. * @param onLoad callback called when the image successfully loads
  107342. * @param onError callback called when the image fails to load
  107343. * @param offlineProvider offline provider for caching
  107344. * @param mimeType optional mime type
  107345. * @returns the HTMLImageElement of the loaded image
  107346. */
  107347. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107348. /**
  107349. * Loads a file from a url
  107350. * @param url url string, ArrayBuffer, or Blob to load
  107351. * @param onSuccess callback called when the file successfully loads
  107352. * @param onProgress callback called while file is loading (if the server supports this mode)
  107353. * @param offlineProvider defines the offline provider for caching
  107354. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107355. * @param onError callback called when the file fails to load
  107356. * @returns a file request object
  107357. */
  107358. 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;
  107359. /**
  107360. * Loads a file from a url
  107361. * @param url the file url to load
  107362. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107363. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107364. */
  107365. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107366. /**
  107367. * Load a script (identified by an url). When the url returns, the
  107368. * content of this file is added into a new script element, attached to the DOM (body element)
  107369. * @param scriptUrl defines the url of the script to laod
  107370. * @param onSuccess defines the callback called when the script is loaded
  107371. * @param onError defines the callback to call if an error occurs
  107372. * @param scriptId defines the id of the script element
  107373. */
  107374. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107375. /**
  107376. * Load an asynchronous script (identified by an url). When the url returns, the
  107377. * content of this file is added into a new script element, attached to the DOM (body element)
  107378. * @param scriptUrl defines the url of the script to laod
  107379. * @param scriptId defines the id of the script element
  107380. * @returns a promise request object
  107381. */
  107382. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107383. /**
  107384. * Loads a file from a blob
  107385. * @param fileToLoad defines the blob to use
  107386. * @param callback defines the callback to call when data is loaded
  107387. * @param progressCallback defines the callback to call during loading process
  107388. * @returns a file request object
  107389. */
  107390. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107391. /**
  107392. * Reads a file from a File object
  107393. * @param file defines the file to load
  107394. * @param onSuccess defines the callback to call when data is loaded
  107395. * @param onProgress defines the callback to call during loading process
  107396. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107397. * @param onError defines the callback to call when an error occurs
  107398. * @returns a file request object
  107399. */
  107400. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107401. /**
  107402. * Creates a data url from a given string content
  107403. * @param content defines the content to convert
  107404. * @returns the new data url link
  107405. */
  107406. static FileAsURL(content: string): string;
  107407. /**
  107408. * Format the given number to a specific decimal format
  107409. * @param value defines the number to format
  107410. * @param decimals defines the number of decimals to use
  107411. * @returns the formatted string
  107412. */
  107413. static Format(value: number, decimals?: number): string;
  107414. /**
  107415. * Tries to copy an object by duplicating every property
  107416. * @param source defines the source object
  107417. * @param destination defines the target object
  107418. * @param doNotCopyList defines a list of properties to avoid
  107419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107420. */
  107421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107422. /**
  107423. * Gets a boolean indicating if the given object has no own property
  107424. * @param obj defines the object to test
  107425. * @returns true if object has no own property
  107426. */
  107427. static IsEmpty(obj: any): boolean;
  107428. /**
  107429. * Function used to register events at window level
  107430. * @param windowElement defines the Window object to use
  107431. * @param events defines the events to register
  107432. */
  107433. static RegisterTopRootEvents(windowElement: Window, events: {
  107434. name: string;
  107435. handler: Nullable<(e: FocusEvent) => any>;
  107436. }[]): void;
  107437. /**
  107438. * Function used to unregister events from window level
  107439. * @param windowElement defines the Window object to use
  107440. * @param events defines the events to unregister
  107441. */
  107442. static UnregisterTopRootEvents(windowElement: Window, events: {
  107443. name: string;
  107444. handler: Nullable<(e: FocusEvent) => any>;
  107445. }[]): void;
  107446. /**
  107447. * @ignore
  107448. */
  107449. static _ScreenshotCanvas: HTMLCanvasElement;
  107450. /**
  107451. * Dumps the current bound framebuffer
  107452. * @param width defines the rendering width
  107453. * @param height defines the rendering height
  107454. * @param engine defines the hosting engine
  107455. * @param successCallback defines the callback triggered once the data are available
  107456. * @param mimeType defines the mime type of the result
  107457. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107458. */
  107459. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107460. /**
  107461. * Converts the canvas data to blob.
  107462. * This acts as a polyfill for browsers not supporting the to blob function.
  107463. * @param canvas Defines the canvas to extract the data from
  107464. * @param successCallback Defines the callback triggered once the data are available
  107465. * @param mimeType Defines the mime type of the result
  107466. */
  107467. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107468. /**
  107469. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107470. * @param successCallback defines the callback triggered once the data are available
  107471. * @param mimeType defines the mime type of the result
  107472. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107473. */
  107474. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107475. /**
  107476. * Downloads a blob in the browser
  107477. * @param blob defines the blob to download
  107478. * @param fileName defines the name of the downloaded file
  107479. */
  107480. static Download(blob: Blob, fileName: string): void;
  107481. /**
  107482. * Captures a screenshot of the current rendering
  107483. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107484. * @param engine defines the rendering engine
  107485. * @param camera defines the source camera
  107486. * @param size This parameter can be set to a single number or to an object with the
  107487. * following (optional) properties: precision, width, height. If a single number is passed,
  107488. * it will be used for both width and height. If an object is passed, the screenshot size
  107489. * will be derived from the parameters. The precision property is a multiplier allowing
  107490. * rendering at a higher or lower resolution
  107491. * @param successCallback defines the callback receives a single parameter which contains the
  107492. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107493. * src parameter of an <img> to display it
  107494. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107495. * Check your browser for supported MIME types
  107496. */
  107497. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107498. /**
  107499. * Captures a screenshot of the current rendering
  107500. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107501. * @param engine defines the rendering engine
  107502. * @param camera defines the source camera
  107503. * @param size This parameter can be set to a single number or to an object with the
  107504. * following (optional) properties: precision, width, height. If a single number is passed,
  107505. * it will be used for both width and height. If an object is passed, the screenshot size
  107506. * will be derived from the parameters. The precision property is a multiplier allowing
  107507. * rendering at a higher or lower resolution
  107508. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107509. * Check your browser for supported MIME types
  107510. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107511. * to the src parameter of an <img> to display it
  107512. */
  107513. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107514. /**
  107515. * Generates an image screenshot from the specified camera.
  107516. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107517. * @param engine The engine to use for rendering
  107518. * @param camera The camera to use for rendering
  107519. * @param size This parameter can be set to a single number or to an object with the
  107520. * following (optional) properties: precision, width, height. If a single number is passed,
  107521. * it will be used for both width and height. If an object is passed, the screenshot size
  107522. * will be derived from the parameters. The precision property is a multiplier allowing
  107523. * rendering at a higher or lower resolution
  107524. * @param successCallback The callback receives a single parameter which contains the
  107525. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107526. * src parameter of an <img> to display it
  107527. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107528. * Check your browser for supported MIME types
  107529. * @param samples Texture samples (default: 1)
  107530. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107531. * @param fileName A name for for the downloaded file.
  107532. */
  107533. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107534. /**
  107535. * Generates an image screenshot from the specified camera.
  107536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107537. * @param engine The engine to use for rendering
  107538. * @param camera The camera to use for rendering
  107539. * @param size This parameter can be set to a single number or to an object with the
  107540. * following (optional) properties: precision, width, height. If a single number is passed,
  107541. * it will be used for both width and height. If an object is passed, the screenshot size
  107542. * will be derived from the parameters. The precision property is a multiplier allowing
  107543. * rendering at a higher or lower resolution
  107544. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107545. * Check your browser for supported MIME types
  107546. * @param samples Texture samples (default: 1)
  107547. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107548. * @param fileName A name for for the downloaded file.
  107549. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107550. * to the src parameter of an <img> to display it
  107551. */
  107552. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107553. /**
  107554. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107555. * Be aware Math.random() could cause collisions, but:
  107556. * "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"
  107557. * @returns a pseudo random id
  107558. */
  107559. static RandomId(): string;
  107560. /**
  107561. * Test if the given uri is a base64 string
  107562. * @param uri The uri to test
  107563. * @return True if the uri is a base64 string or false otherwise
  107564. */
  107565. static IsBase64(uri: string): boolean;
  107566. /**
  107567. * Decode the given base64 uri.
  107568. * @param uri The uri to decode
  107569. * @return The decoded base64 data.
  107570. */
  107571. static DecodeBase64(uri: string): ArrayBuffer;
  107572. /**
  107573. * Gets the absolute url.
  107574. * @param url the input url
  107575. * @return the absolute url
  107576. */
  107577. static GetAbsoluteUrl(url: string): string;
  107578. /**
  107579. * No log
  107580. */
  107581. static readonly NoneLogLevel: number;
  107582. /**
  107583. * Only message logs
  107584. */
  107585. static readonly MessageLogLevel: number;
  107586. /**
  107587. * Only warning logs
  107588. */
  107589. static readonly WarningLogLevel: number;
  107590. /**
  107591. * Only error logs
  107592. */
  107593. static readonly ErrorLogLevel: number;
  107594. /**
  107595. * All logs
  107596. */
  107597. static readonly AllLogLevel: number;
  107598. /**
  107599. * Gets a value indicating the number of loading errors
  107600. * @ignorenaming
  107601. */
  107602. static get errorsCount(): number;
  107603. /**
  107604. * Callback called when a new log is added
  107605. */
  107606. static OnNewCacheEntry: (entry: string) => void;
  107607. /**
  107608. * Log a message to the console
  107609. * @param message defines the message to log
  107610. */
  107611. static Log(message: string): void;
  107612. /**
  107613. * Write a warning message to the console
  107614. * @param message defines the message to log
  107615. */
  107616. static Warn(message: string): void;
  107617. /**
  107618. * Write an error message to the console
  107619. * @param message defines the message to log
  107620. */
  107621. static Error(message: string): void;
  107622. /**
  107623. * Gets current log cache (list of logs)
  107624. */
  107625. static get LogCache(): string;
  107626. /**
  107627. * Clears the log cache
  107628. */
  107629. static ClearLogCache(): void;
  107630. /**
  107631. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107632. */
  107633. static set LogLevels(level: number);
  107634. /**
  107635. * Checks if the window object exists
  107636. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107637. */
  107638. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107639. /**
  107640. * No performance log
  107641. */
  107642. static readonly PerformanceNoneLogLevel: number;
  107643. /**
  107644. * Use user marks to log performance
  107645. */
  107646. static readonly PerformanceUserMarkLogLevel: number;
  107647. /**
  107648. * Log performance to the console
  107649. */
  107650. static readonly PerformanceConsoleLogLevel: number;
  107651. private static _performance;
  107652. /**
  107653. * Sets the current performance log level
  107654. */
  107655. static set PerformanceLogLevel(level: number);
  107656. private static _StartPerformanceCounterDisabled;
  107657. private static _EndPerformanceCounterDisabled;
  107658. private static _StartUserMark;
  107659. private static _EndUserMark;
  107660. private static _StartPerformanceConsole;
  107661. private static _EndPerformanceConsole;
  107662. /**
  107663. * Starts a performance counter
  107664. */
  107665. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107666. /**
  107667. * Ends a specific performance coutner
  107668. */
  107669. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107670. /**
  107671. * Gets either window.performance.now() if supported or Date.now() else
  107672. */
  107673. static get Now(): number;
  107674. /**
  107675. * This method will return the name of the class used to create the instance of the given object.
  107676. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107677. * @param object the object to get the class name from
  107678. * @param isType defines if the object is actually a type
  107679. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107680. */
  107681. static GetClassName(object: any, isType?: boolean): string;
  107682. /**
  107683. * Gets the first element of an array satisfying a given predicate
  107684. * @param array defines the array to browse
  107685. * @param predicate defines the predicate to use
  107686. * @returns null if not found or the element
  107687. */
  107688. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107689. /**
  107690. * This method will return the name of the full name of the class, including its owning module (if any).
  107691. * 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).
  107692. * @param object the object to get the class name from
  107693. * @param isType defines if the object is actually a type
  107694. * @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.
  107695. * @ignorenaming
  107696. */
  107697. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107698. /**
  107699. * Returns a promise that resolves after the given amount of time.
  107700. * @param delay Number of milliseconds to delay
  107701. * @returns Promise that resolves after the given amount of time
  107702. */
  107703. static DelayAsync(delay: number): Promise<void>;
  107704. /**
  107705. * Utility function to detect if the current user agent is Safari
  107706. * @returns whether or not the current user agent is safari
  107707. */
  107708. static IsSafari(): boolean;
  107709. }
  107710. /**
  107711. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107712. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107713. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107714. * @param name The name of the class, case should be preserved
  107715. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107716. */
  107717. export function className(name: string, module?: string): (target: Object) => void;
  107718. /**
  107719. * An implementation of a loop for asynchronous functions.
  107720. */
  107721. export class AsyncLoop {
  107722. /**
  107723. * Defines the number of iterations for the loop
  107724. */
  107725. iterations: number;
  107726. /**
  107727. * Defines the current index of the loop.
  107728. */
  107729. index: number;
  107730. private _done;
  107731. private _fn;
  107732. private _successCallback;
  107733. /**
  107734. * Constructor.
  107735. * @param iterations the number of iterations.
  107736. * @param func the function to run each iteration
  107737. * @param successCallback the callback that will be called upon succesful execution
  107738. * @param offset starting offset.
  107739. */
  107740. constructor(
  107741. /**
  107742. * Defines the number of iterations for the loop
  107743. */
  107744. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107745. /**
  107746. * Execute the next iteration. Must be called after the last iteration was finished.
  107747. */
  107748. executeNext(): void;
  107749. /**
  107750. * Break the loop and run the success callback.
  107751. */
  107752. breakLoop(): void;
  107753. /**
  107754. * Create and run an async loop.
  107755. * @param iterations the number of iterations.
  107756. * @param fn the function to run each iteration
  107757. * @param successCallback the callback that will be called upon succesful execution
  107758. * @param offset starting offset.
  107759. * @returns the created async loop object
  107760. */
  107761. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107762. /**
  107763. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107764. * @param iterations total number of iterations
  107765. * @param syncedIterations number of synchronous iterations in each async iteration.
  107766. * @param fn the function to call each iteration.
  107767. * @param callback a success call back that will be called when iterating stops.
  107768. * @param breakFunction a break condition (optional)
  107769. * @param timeout timeout settings for the setTimeout function. default - 0.
  107770. * @returns the created async loop object
  107771. */
  107772. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107773. }
  107774. }
  107775. declare module BABYLON {
  107776. /**
  107777. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107778. * The underlying implementation relies on an associative array to ensure the best performances.
  107779. * The value can be anything including 'null' but except 'undefined'
  107780. */
  107781. export class StringDictionary<T> {
  107782. /**
  107783. * This will clear this dictionary and copy the content from the 'source' one.
  107784. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107785. * @param source the dictionary to take the content from and copy to this dictionary
  107786. */
  107787. copyFrom(source: StringDictionary<T>): void;
  107788. /**
  107789. * Get a value based from its key
  107790. * @param key the given key to get the matching value from
  107791. * @return the value if found, otherwise undefined is returned
  107792. */
  107793. get(key: string): T | undefined;
  107794. /**
  107795. * Get a value from its key or add it if it doesn't exist.
  107796. * This method will ensure you that a given key/data will be present in the dictionary.
  107797. * @param key the given key to get the matching value from
  107798. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107799. * The factory will only be invoked if there's no data for the given key.
  107800. * @return the value corresponding to the key.
  107801. */
  107802. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107803. /**
  107804. * Get a value from its key if present in the dictionary otherwise add it
  107805. * @param key the key to get the value from
  107806. * @param val if there's no such key/value pair in the dictionary add it with this value
  107807. * @return the value corresponding to the key
  107808. */
  107809. getOrAdd(key: string, val: T): T;
  107810. /**
  107811. * Check if there's a given key in the dictionary
  107812. * @param key the key to check for
  107813. * @return true if the key is present, false otherwise
  107814. */
  107815. contains(key: string): boolean;
  107816. /**
  107817. * Add a new key and its corresponding value
  107818. * @param key the key to add
  107819. * @param value the value corresponding to the key
  107820. * @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
  107821. */
  107822. add(key: string, value: T): boolean;
  107823. /**
  107824. * Update a specific value associated to a key
  107825. * @param key defines the key to use
  107826. * @param value defines the value to store
  107827. * @returns true if the value was updated (or false if the key was not found)
  107828. */
  107829. set(key: string, value: T): boolean;
  107830. /**
  107831. * Get the element of the given key and remove it from the dictionary
  107832. * @param key defines the key to search
  107833. * @returns the value associated with the key or null if not found
  107834. */
  107835. getAndRemove(key: string): Nullable<T>;
  107836. /**
  107837. * Remove a key/value from the dictionary.
  107838. * @param key the key to remove
  107839. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107840. */
  107841. remove(key: string): boolean;
  107842. /**
  107843. * Clear the whole content of the dictionary
  107844. */
  107845. clear(): void;
  107846. /**
  107847. * Gets the current count
  107848. */
  107849. get count(): number;
  107850. /**
  107851. * Execute a callback on each key/val of the dictionary.
  107852. * Note that you can remove any element in this dictionary in the callback implementation
  107853. * @param callback the callback to execute on a given key/value pair
  107854. */
  107855. forEach(callback: (key: string, val: T) => void): void;
  107856. /**
  107857. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107858. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107859. * Note that you can remove any element in this dictionary in the callback implementation
  107860. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107861. * @returns the first item
  107862. */
  107863. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107864. private _count;
  107865. private _data;
  107866. }
  107867. }
  107868. declare module BABYLON {
  107869. /** @hidden */
  107870. export interface ICollisionCoordinator {
  107871. createCollider(): Collider;
  107872. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107873. init(scene: Scene): void;
  107874. }
  107875. /** @hidden */
  107876. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107877. private _scene;
  107878. private _scaledPosition;
  107879. private _scaledVelocity;
  107880. private _finalPosition;
  107881. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107882. createCollider(): Collider;
  107883. init(scene: Scene): void;
  107884. private _collideWithWorld;
  107885. }
  107886. }
  107887. declare module BABYLON {
  107888. /**
  107889. * Class used to manage all inputs for the scene.
  107890. */
  107891. export class InputManager {
  107892. /** The distance in pixel that you have to move to prevent some events */
  107893. static DragMovementThreshold: number;
  107894. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107895. static LongPressDelay: number;
  107896. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107897. static DoubleClickDelay: number;
  107898. /** If you need to check double click without raising a single click at first click, enable this flag */
  107899. static ExclusiveDoubleClickMode: boolean;
  107900. private _wheelEventName;
  107901. private _onPointerMove;
  107902. private _onPointerDown;
  107903. private _onPointerUp;
  107904. private _initClickEvent;
  107905. private _initActionManager;
  107906. private _delayedSimpleClick;
  107907. private _delayedSimpleClickTimeout;
  107908. private _previousDelayedSimpleClickTimeout;
  107909. private _meshPickProceed;
  107910. private _previousButtonPressed;
  107911. private _currentPickResult;
  107912. private _previousPickResult;
  107913. private _totalPointersPressed;
  107914. private _doubleClickOccured;
  107915. private _pointerOverMesh;
  107916. private _pickedDownMesh;
  107917. private _pickedUpMesh;
  107918. private _pointerX;
  107919. private _pointerY;
  107920. private _unTranslatedPointerX;
  107921. private _unTranslatedPointerY;
  107922. private _startingPointerPosition;
  107923. private _previousStartingPointerPosition;
  107924. private _startingPointerTime;
  107925. private _previousStartingPointerTime;
  107926. private _pointerCaptures;
  107927. private _onKeyDown;
  107928. private _onKeyUp;
  107929. private _onCanvasFocusObserver;
  107930. private _onCanvasBlurObserver;
  107931. private _scene;
  107932. /**
  107933. * Creates a new InputManager
  107934. * @param scene defines the hosting scene
  107935. */
  107936. constructor(scene: Scene);
  107937. /**
  107938. * Gets the mesh that is currently under the pointer
  107939. */
  107940. get meshUnderPointer(): Nullable<AbstractMesh>;
  107941. /**
  107942. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107943. */
  107944. get unTranslatedPointer(): Vector2;
  107945. /**
  107946. * Gets or sets the current on-screen X position of the pointer
  107947. */
  107948. get pointerX(): number;
  107949. set pointerX(value: number);
  107950. /**
  107951. * Gets or sets the current on-screen Y position of the pointer
  107952. */
  107953. get pointerY(): number;
  107954. set pointerY(value: number);
  107955. private _updatePointerPosition;
  107956. private _processPointerMove;
  107957. private _setRayOnPointerInfo;
  107958. private _checkPrePointerObservable;
  107959. /**
  107960. * Use this method to simulate a pointer move on a mesh
  107961. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107962. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107963. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107964. */
  107965. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107966. /**
  107967. * Use this method to simulate a pointer down on a mesh
  107968. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107969. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107970. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107971. */
  107972. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107973. private _processPointerDown;
  107974. /** @hidden */
  107975. _isPointerSwiping(): boolean;
  107976. /**
  107977. * Use this method to simulate a pointer up on a mesh
  107978. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107979. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107980. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107981. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107982. */
  107983. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107984. private _processPointerUp;
  107985. /**
  107986. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107987. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107988. * @returns true if the pointer was captured
  107989. */
  107990. isPointerCaptured(pointerId?: number): boolean;
  107991. /**
  107992. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107993. * @param attachUp defines if you want to attach events to pointerup
  107994. * @param attachDown defines if you want to attach events to pointerdown
  107995. * @param attachMove defines if you want to attach events to pointermove
  107996. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107997. */
  107998. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107999. /**
  108000. * Detaches all event handlers
  108001. */
  108002. detachControl(): void;
  108003. /**
  108004. * Force the value of meshUnderPointer
  108005. * @param mesh defines the mesh to use
  108006. */
  108007. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108008. /**
  108009. * Gets the mesh under the pointer
  108010. * @returns a Mesh or null if no mesh is under the pointer
  108011. */
  108012. getPointerOverMesh(): Nullable<AbstractMesh>;
  108013. }
  108014. }
  108015. declare module BABYLON {
  108016. /**
  108017. * Helper class used to generate session unique ID
  108018. */
  108019. export class UniqueIdGenerator {
  108020. private static _UniqueIdCounter;
  108021. /**
  108022. * Gets an unique (relatively to the current scene) Id
  108023. */
  108024. static get UniqueId(): number;
  108025. }
  108026. }
  108027. declare module BABYLON {
  108028. /**
  108029. * This class defines the direct association between an animation and a target
  108030. */
  108031. export class TargetedAnimation {
  108032. /**
  108033. * Animation to perform
  108034. */
  108035. animation: Animation;
  108036. /**
  108037. * Target to animate
  108038. */
  108039. target: any;
  108040. /**
  108041. * Serialize the object
  108042. * @returns the JSON object representing the current entity
  108043. */
  108044. serialize(): any;
  108045. }
  108046. /**
  108047. * Use this class to create coordinated animations on multiple targets
  108048. */
  108049. export class AnimationGroup implements IDisposable {
  108050. /** The name of the animation group */
  108051. name: string;
  108052. private _scene;
  108053. private _targetedAnimations;
  108054. private _animatables;
  108055. private _from;
  108056. private _to;
  108057. private _isStarted;
  108058. private _isPaused;
  108059. private _speedRatio;
  108060. private _loopAnimation;
  108061. /**
  108062. * Gets or sets the unique id of the node
  108063. */
  108064. uniqueId: number;
  108065. /**
  108066. * This observable will notify when one animation have ended
  108067. */
  108068. onAnimationEndObservable: Observable<TargetedAnimation>;
  108069. /**
  108070. * Observer raised when one animation loops
  108071. */
  108072. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108073. /**
  108074. * Observer raised when all animations have looped
  108075. */
  108076. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108077. /**
  108078. * This observable will notify when all animations have ended.
  108079. */
  108080. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108081. /**
  108082. * This observable will notify when all animations have paused.
  108083. */
  108084. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108085. /**
  108086. * This observable will notify when all animations are playing.
  108087. */
  108088. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108089. /**
  108090. * Gets the first frame
  108091. */
  108092. get from(): number;
  108093. /**
  108094. * Gets the last frame
  108095. */
  108096. get to(): number;
  108097. /**
  108098. * Define if the animations are started
  108099. */
  108100. get isStarted(): boolean;
  108101. /**
  108102. * Gets a value indicating that the current group is playing
  108103. */
  108104. get isPlaying(): boolean;
  108105. /**
  108106. * Gets or sets the speed ratio to use for all animations
  108107. */
  108108. get speedRatio(): number;
  108109. /**
  108110. * Gets or sets the speed ratio to use for all animations
  108111. */
  108112. set speedRatio(value: number);
  108113. /**
  108114. * Gets or sets if all animations should loop or not
  108115. */
  108116. get loopAnimation(): boolean;
  108117. set loopAnimation(value: boolean);
  108118. /**
  108119. * Gets the targeted animations for this animation group
  108120. */
  108121. get targetedAnimations(): Array<TargetedAnimation>;
  108122. /**
  108123. * returning the list of animatables controlled by this animation group.
  108124. */
  108125. get animatables(): Array<Animatable>;
  108126. /**
  108127. * Instantiates a new Animation Group.
  108128. * This helps managing several animations at once.
  108129. * @see http://doc.babylonjs.com/how_to/group
  108130. * @param name Defines the name of the group
  108131. * @param scene Defines the scene the group belongs to
  108132. */
  108133. constructor(
  108134. /** The name of the animation group */
  108135. name: string, scene?: Nullable<Scene>);
  108136. /**
  108137. * Add an animation (with its target) in the group
  108138. * @param animation defines the animation we want to add
  108139. * @param target defines the target of the animation
  108140. * @returns the TargetedAnimation object
  108141. */
  108142. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108143. /**
  108144. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108145. * It can add constant keys at begin or end
  108146. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108147. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108148. * @returns the animation group
  108149. */
  108150. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108151. private _animationLoopCount;
  108152. private _animationLoopFlags;
  108153. private _processLoop;
  108154. /**
  108155. * Start all animations on given targets
  108156. * @param loop defines if animations must loop
  108157. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108158. * @param from defines the from key (optional)
  108159. * @param to defines the to key (optional)
  108160. * @returns the current animation group
  108161. */
  108162. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108163. /**
  108164. * Pause all animations
  108165. * @returns the animation group
  108166. */
  108167. pause(): AnimationGroup;
  108168. /**
  108169. * Play all animations to initial state
  108170. * This function will start() the animations if they were not started or will restart() them if they were paused
  108171. * @param loop defines if animations must loop
  108172. * @returns the animation group
  108173. */
  108174. play(loop?: boolean): AnimationGroup;
  108175. /**
  108176. * Reset all animations to initial state
  108177. * @returns the animation group
  108178. */
  108179. reset(): AnimationGroup;
  108180. /**
  108181. * Restart animations from key 0
  108182. * @returns the animation group
  108183. */
  108184. restart(): AnimationGroup;
  108185. /**
  108186. * Stop all animations
  108187. * @returns the animation group
  108188. */
  108189. stop(): AnimationGroup;
  108190. /**
  108191. * Set animation weight for all animatables
  108192. * @param weight defines the weight to use
  108193. * @return the animationGroup
  108194. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108195. */
  108196. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108197. /**
  108198. * Synchronize and normalize all animatables with a source animatable
  108199. * @param root defines the root animatable to synchronize with
  108200. * @return the animationGroup
  108201. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108202. */
  108203. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108204. /**
  108205. * Goes to a specific frame in this animation group
  108206. * @param frame the frame number to go to
  108207. * @return the animationGroup
  108208. */
  108209. goToFrame(frame: number): AnimationGroup;
  108210. /**
  108211. * Dispose all associated resources
  108212. */
  108213. dispose(): void;
  108214. private _checkAnimationGroupEnded;
  108215. /**
  108216. * Clone the current animation group and returns a copy
  108217. * @param newName defines the name of the new group
  108218. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108219. * @returns the new aniamtion group
  108220. */
  108221. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108222. /**
  108223. * Serializes the animationGroup to an object
  108224. * @returns Serialized object
  108225. */
  108226. serialize(): any;
  108227. /**
  108228. * Returns a new AnimationGroup object parsed from the source provided.
  108229. * @param parsedAnimationGroup defines the source
  108230. * @param scene defines the scene that will receive the animationGroup
  108231. * @returns a new AnimationGroup
  108232. */
  108233. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108234. /**
  108235. * Returns the string "AnimationGroup"
  108236. * @returns "AnimationGroup"
  108237. */
  108238. getClassName(): string;
  108239. /**
  108240. * Creates a detailled string about the object
  108241. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108242. * @returns a string representing the object
  108243. */
  108244. toString(fullDetails?: boolean): string;
  108245. }
  108246. }
  108247. declare module BABYLON {
  108248. /**
  108249. * Define an interface for all classes that will hold resources
  108250. */
  108251. export interface IDisposable {
  108252. /**
  108253. * Releases all held resources
  108254. */
  108255. dispose(): void;
  108256. }
  108257. /** Interface defining initialization parameters for Scene class */
  108258. export interface SceneOptions {
  108259. /**
  108260. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108261. * It will improve performance when the number of geometries becomes important.
  108262. */
  108263. useGeometryUniqueIdsMap?: boolean;
  108264. /**
  108265. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108266. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108267. */
  108268. useMaterialMeshMap?: boolean;
  108269. /**
  108270. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108271. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108272. */
  108273. useClonedMeshMap?: boolean;
  108274. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108275. virtual?: boolean;
  108276. }
  108277. /**
  108278. * Represents a scene to be rendered by the engine.
  108279. * @see http://doc.babylonjs.com/features/scene
  108280. */
  108281. export class Scene extends AbstractScene implements IAnimatable {
  108282. /** The fog is deactivated */
  108283. static readonly FOGMODE_NONE: number;
  108284. /** The fog density is following an exponential function */
  108285. static readonly FOGMODE_EXP: number;
  108286. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108287. static readonly FOGMODE_EXP2: number;
  108288. /** The fog density is following a linear function. */
  108289. static readonly FOGMODE_LINEAR: number;
  108290. /**
  108291. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108292. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108293. */
  108294. static MinDeltaTime: number;
  108295. /**
  108296. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108298. */
  108299. static MaxDeltaTime: number;
  108300. /**
  108301. * Factory used to create the default material.
  108302. * @param name The name of the material to create
  108303. * @param scene The scene to create the material for
  108304. * @returns The default material
  108305. */
  108306. static DefaultMaterialFactory(scene: Scene): Material;
  108307. /**
  108308. * Factory used to create the a collision coordinator.
  108309. * @returns The collision coordinator
  108310. */
  108311. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108312. /** @hidden */
  108313. _inputManager: InputManager;
  108314. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108315. cameraToUseForPointers: Nullable<Camera>;
  108316. /** @hidden */
  108317. readonly _isScene: boolean;
  108318. /**
  108319. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108320. */
  108321. autoClear: boolean;
  108322. /**
  108323. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108324. */
  108325. autoClearDepthAndStencil: boolean;
  108326. /**
  108327. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108328. */
  108329. clearColor: Color4;
  108330. /**
  108331. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108332. */
  108333. ambientColor: Color3;
  108334. /**
  108335. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108336. * It should only be one of the following (if not the default embedded one):
  108337. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108338. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108339. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108340. * The material properties need to be setup according to the type of texture in use.
  108341. */
  108342. environmentBRDFTexture: BaseTexture;
  108343. /** @hidden */
  108344. protected _environmentTexture: Nullable<BaseTexture>;
  108345. /**
  108346. * Texture used in all pbr material as the reflection texture.
  108347. * As in the majority of the scene they are the same (exception for multi room and so on),
  108348. * this is easier to reference from here than from all the materials.
  108349. */
  108350. get environmentTexture(): Nullable<BaseTexture>;
  108351. /**
  108352. * Texture used in all pbr material as the reflection texture.
  108353. * As in the majority of the scene they are the same (exception for multi room and so on),
  108354. * this is easier to set here than in all the materials.
  108355. */
  108356. set environmentTexture(value: Nullable<BaseTexture>);
  108357. /** @hidden */
  108358. protected _environmentIntensity: number;
  108359. /**
  108360. * Intensity of the environment in all pbr material.
  108361. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108362. * As in the majority of the scene they are the same (exception for multi room and so on),
  108363. * this is easier to reference from here than from all the materials.
  108364. */
  108365. get environmentIntensity(): number;
  108366. /**
  108367. * Intensity of the environment in all pbr material.
  108368. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108369. * As in the majority of the scene they are the same (exception for multi room and so on),
  108370. * this is easier to set here than in all the materials.
  108371. */
  108372. set environmentIntensity(value: number);
  108373. /** @hidden */
  108374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108375. /**
  108376. * Default image processing configuration used either in the rendering
  108377. * Forward main pass or through the imageProcessingPostProcess if present.
  108378. * As in the majority of the scene they are the same (exception for multi camera),
  108379. * this is easier to reference from here than from all the materials and post process.
  108380. *
  108381. * No setter as we it is a shared configuration, you can set the values instead.
  108382. */
  108383. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108384. private _forceWireframe;
  108385. /**
  108386. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108387. */
  108388. set forceWireframe(value: boolean);
  108389. get forceWireframe(): boolean;
  108390. private _skipFrustumClipping;
  108391. /**
  108392. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108393. */
  108394. set skipFrustumClipping(value: boolean);
  108395. get skipFrustumClipping(): boolean;
  108396. private _forcePointsCloud;
  108397. /**
  108398. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108399. */
  108400. set forcePointsCloud(value: boolean);
  108401. get forcePointsCloud(): boolean;
  108402. /**
  108403. * Gets or sets the active clipplane 1
  108404. */
  108405. clipPlane: Nullable<Plane>;
  108406. /**
  108407. * Gets or sets the active clipplane 2
  108408. */
  108409. clipPlane2: Nullable<Plane>;
  108410. /**
  108411. * Gets or sets the active clipplane 3
  108412. */
  108413. clipPlane3: Nullable<Plane>;
  108414. /**
  108415. * Gets or sets the active clipplane 4
  108416. */
  108417. clipPlane4: Nullable<Plane>;
  108418. /**
  108419. * Gets or sets the active clipplane 5
  108420. */
  108421. clipPlane5: Nullable<Plane>;
  108422. /**
  108423. * Gets or sets the active clipplane 6
  108424. */
  108425. clipPlane6: Nullable<Plane>;
  108426. /**
  108427. * Gets or sets a boolean indicating if animations are enabled
  108428. */
  108429. animationsEnabled: boolean;
  108430. private _animationPropertiesOverride;
  108431. /**
  108432. * Gets or sets the animation properties override
  108433. */
  108434. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108435. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108436. /**
  108437. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108438. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108439. */
  108440. useConstantAnimationDeltaTime: boolean;
  108441. /**
  108442. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108443. * Please note that it requires to run a ray cast through the scene on every frame
  108444. */
  108445. constantlyUpdateMeshUnderPointer: boolean;
  108446. /**
  108447. * Defines the HTML cursor to use when hovering over interactive elements
  108448. */
  108449. hoverCursor: string;
  108450. /**
  108451. * Defines the HTML default cursor to use (empty by default)
  108452. */
  108453. defaultCursor: string;
  108454. /**
  108455. * Defines whether cursors are handled by the scene.
  108456. */
  108457. doNotHandleCursors: boolean;
  108458. /**
  108459. * This is used to call preventDefault() on pointer down
  108460. * in order to block unwanted artifacts like system double clicks
  108461. */
  108462. preventDefaultOnPointerDown: boolean;
  108463. /**
  108464. * This is used to call preventDefault() on pointer up
  108465. * in order to block unwanted artifacts like system double clicks
  108466. */
  108467. preventDefaultOnPointerUp: boolean;
  108468. /**
  108469. * Gets or sets user defined metadata
  108470. */
  108471. metadata: any;
  108472. /**
  108473. * For internal use only. Please do not use.
  108474. */
  108475. reservedDataStore: any;
  108476. /**
  108477. * Gets the name of the plugin used to load this scene (null by default)
  108478. */
  108479. loadingPluginName: string;
  108480. /**
  108481. * Use this array to add regular expressions used to disable offline support for specific urls
  108482. */
  108483. disableOfflineSupportExceptionRules: RegExp[];
  108484. /**
  108485. * An event triggered when the scene is disposed.
  108486. */
  108487. onDisposeObservable: Observable<Scene>;
  108488. private _onDisposeObserver;
  108489. /** Sets a function to be executed when this scene is disposed. */
  108490. set onDispose(callback: () => void);
  108491. /**
  108492. * An event triggered before rendering the scene (right after animations and physics)
  108493. */
  108494. onBeforeRenderObservable: Observable<Scene>;
  108495. private _onBeforeRenderObserver;
  108496. /** Sets a function to be executed before rendering this scene */
  108497. set beforeRender(callback: Nullable<() => void>);
  108498. /**
  108499. * An event triggered after rendering the scene
  108500. */
  108501. onAfterRenderObservable: Observable<Scene>;
  108502. /**
  108503. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108504. */
  108505. onAfterRenderCameraObservable: Observable<Camera>;
  108506. private _onAfterRenderObserver;
  108507. /** Sets a function to be executed after rendering this scene */
  108508. set afterRender(callback: Nullable<() => void>);
  108509. /**
  108510. * An event triggered before animating the scene
  108511. */
  108512. onBeforeAnimationsObservable: Observable<Scene>;
  108513. /**
  108514. * An event triggered after animations processing
  108515. */
  108516. onAfterAnimationsObservable: Observable<Scene>;
  108517. /**
  108518. * An event triggered before draw calls are ready to be sent
  108519. */
  108520. onBeforeDrawPhaseObservable: Observable<Scene>;
  108521. /**
  108522. * An event triggered after draw calls have been sent
  108523. */
  108524. onAfterDrawPhaseObservable: Observable<Scene>;
  108525. /**
  108526. * An event triggered when the scene is ready
  108527. */
  108528. onReadyObservable: Observable<Scene>;
  108529. /**
  108530. * An event triggered before rendering a camera
  108531. */
  108532. onBeforeCameraRenderObservable: Observable<Camera>;
  108533. private _onBeforeCameraRenderObserver;
  108534. /** Sets a function to be executed before rendering a camera*/
  108535. set beforeCameraRender(callback: () => void);
  108536. /**
  108537. * An event triggered after rendering a camera
  108538. */
  108539. onAfterCameraRenderObservable: Observable<Camera>;
  108540. private _onAfterCameraRenderObserver;
  108541. /** Sets a function to be executed after rendering a camera*/
  108542. set afterCameraRender(callback: () => void);
  108543. /**
  108544. * An event triggered when active meshes evaluation is about to start
  108545. */
  108546. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108547. /**
  108548. * An event triggered when active meshes evaluation is done
  108549. */
  108550. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108551. /**
  108552. * An event triggered when particles rendering is about to start
  108553. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108554. */
  108555. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108556. /**
  108557. * An event triggered when particles rendering is done
  108558. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108559. */
  108560. onAfterParticlesRenderingObservable: Observable<Scene>;
  108561. /**
  108562. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108563. */
  108564. onDataLoadedObservable: Observable<Scene>;
  108565. /**
  108566. * An event triggered when a camera is created
  108567. */
  108568. onNewCameraAddedObservable: Observable<Camera>;
  108569. /**
  108570. * An event triggered when a camera is removed
  108571. */
  108572. onCameraRemovedObservable: Observable<Camera>;
  108573. /**
  108574. * An event triggered when a light is created
  108575. */
  108576. onNewLightAddedObservable: Observable<Light>;
  108577. /**
  108578. * An event triggered when a light is removed
  108579. */
  108580. onLightRemovedObservable: Observable<Light>;
  108581. /**
  108582. * An event triggered when a geometry is created
  108583. */
  108584. onNewGeometryAddedObservable: Observable<Geometry>;
  108585. /**
  108586. * An event triggered when a geometry is removed
  108587. */
  108588. onGeometryRemovedObservable: Observable<Geometry>;
  108589. /**
  108590. * An event triggered when a transform node is created
  108591. */
  108592. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108593. /**
  108594. * An event triggered when a transform node is removed
  108595. */
  108596. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108597. /**
  108598. * An event triggered when a mesh is created
  108599. */
  108600. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108601. /**
  108602. * An event triggered when a mesh is removed
  108603. */
  108604. onMeshRemovedObservable: Observable<AbstractMesh>;
  108605. /**
  108606. * An event triggered when a skeleton is created
  108607. */
  108608. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108609. /**
  108610. * An event triggered when a skeleton is removed
  108611. */
  108612. onSkeletonRemovedObservable: Observable<Skeleton>;
  108613. /**
  108614. * An event triggered when a material is created
  108615. */
  108616. onNewMaterialAddedObservable: Observable<Material>;
  108617. /**
  108618. * An event triggered when a material is removed
  108619. */
  108620. onMaterialRemovedObservable: Observable<Material>;
  108621. /**
  108622. * An event triggered when a texture is created
  108623. */
  108624. onNewTextureAddedObservable: Observable<BaseTexture>;
  108625. /**
  108626. * An event triggered when a texture is removed
  108627. */
  108628. onTextureRemovedObservable: Observable<BaseTexture>;
  108629. /**
  108630. * An event triggered when render targets are about to be rendered
  108631. * Can happen multiple times per frame.
  108632. */
  108633. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108634. /**
  108635. * An event triggered when render targets were rendered.
  108636. * Can happen multiple times per frame.
  108637. */
  108638. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108639. /**
  108640. * An event triggered before calculating deterministic simulation step
  108641. */
  108642. onBeforeStepObservable: Observable<Scene>;
  108643. /**
  108644. * An event triggered after calculating deterministic simulation step
  108645. */
  108646. onAfterStepObservable: Observable<Scene>;
  108647. /**
  108648. * An event triggered when the activeCamera property is updated
  108649. */
  108650. onActiveCameraChanged: Observable<Scene>;
  108651. /**
  108652. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108653. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108654. * 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)
  108655. */
  108656. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108657. /**
  108658. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108659. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108660. * 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)
  108661. */
  108662. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108663. /**
  108664. * This Observable will when a mesh has been imported into the scene.
  108665. */
  108666. onMeshImportedObservable: Observable<AbstractMesh>;
  108667. /**
  108668. * This Observable will when an animation file has been imported into the scene.
  108669. */
  108670. onAnimationFileImportedObservable: Observable<Scene>;
  108671. /**
  108672. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108673. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108674. */
  108675. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108676. /** @hidden */
  108677. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108678. /**
  108679. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108680. */
  108681. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108682. /**
  108683. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108684. */
  108685. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108686. /**
  108687. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108688. */
  108689. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108690. /** Callback called when a pointer move is detected */
  108691. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108692. /** Callback called when a pointer down is detected */
  108693. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108694. /** Callback called when a pointer up is detected */
  108695. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108696. /** Callback called when a pointer pick is detected */
  108697. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108698. /**
  108699. * 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).
  108700. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108701. */
  108702. onPrePointerObservable: Observable<PointerInfoPre>;
  108703. /**
  108704. * Observable event triggered each time an input event is received from the rendering canvas
  108705. */
  108706. onPointerObservable: Observable<PointerInfo>;
  108707. /**
  108708. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108709. */
  108710. get unTranslatedPointer(): Vector2;
  108711. /**
  108712. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108713. */
  108714. static get DragMovementThreshold(): number;
  108715. static set DragMovementThreshold(value: number);
  108716. /**
  108717. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108718. */
  108719. static get LongPressDelay(): number;
  108720. static set LongPressDelay(value: number);
  108721. /**
  108722. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108723. */
  108724. static get DoubleClickDelay(): number;
  108725. static set DoubleClickDelay(value: number);
  108726. /** If you need to check double click without raising a single click at first click, enable this flag */
  108727. static get ExclusiveDoubleClickMode(): boolean;
  108728. static set ExclusiveDoubleClickMode(value: boolean);
  108729. /** @hidden */
  108730. _mirroredCameraPosition: Nullable<Vector3>;
  108731. /**
  108732. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108733. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108734. */
  108735. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108736. /**
  108737. * Observable event triggered each time an keyboard event is received from the hosting window
  108738. */
  108739. onKeyboardObservable: Observable<KeyboardInfo>;
  108740. private _useRightHandedSystem;
  108741. /**
  108742. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108743. */
  108744. set useRightHandedSystem(value: boolean);
  108745. get useRightHandedSystem(): boolean;
  108746. private _timeAccumulator;
  108747. private _currentStepId;
  108748. private _currentInternalStep;
  108749. /**
  108750. * Sets the step Id used by deterministic lock step
  108751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108752. * @param newStepId defines the step Id
  108753. */
  108754. setStepId(newStepId: number): void;
  108755. /**
  108756. * Gets the step Id used by deterministic lock step
  108757. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108758. * @returns the step Id
  108759. */
  108760. getStepId(): number;
  108761. /**
  108762. * Gets the internal step used by deterministic lock step
  108763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108764. * @returns the internal step
  108765. */
  108766. getInternalStep(): number;
  108767. private _fogEnabled;
  108768. /**
  108769. * Gets or sets a boolean indicating if fog is enabled on this scene
  108770. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108771. * (Default is true)
  108772. */
  108773. set fogEnabled(value: boolean);
  108774. get fogEnabled(): boolean;
  108775. private _fogMode;
  108776. /**
  108777. * Gets or sets the fog mode to use
  108778. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108779. * | mode | value |
  108780. * | --- | --- |
  108781. * | FOGMODE_NONE | 0 |
  108782. * | FOGMODE_EXP | 1 |
  108783. * | FOGMODE_EXP2 | 2 |
  108784. * | FOGMODE_LINEAR | 3 |
  108785. */
  108786. set fogMode(value: number);
  108787. get fogMode(): number;
  108788. /**
  108789. * Gets or sets the fog color to use
  108790. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108791. * (Default is Color3(0.2, 0.2, 0.3))
  108792. */
  108793. fogColor: Color3;
  108794. /**
  108795. * Gets or sets the fog density to use
  108796. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108797. * (Default is 0.1)
  108798. */
  108799. fogDensity: number;
  108800. /**
  108801. * Gets or sets the fog start distance to use
  108802. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108803. * (Default is 0)
  108804. */
  108805. fogStart: number;
  108806. /**
  108807. * Gets or sets the fog end distance to use
  108808. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108809. * (Default is 1000)
  108810. */
  108811. fogEnd: number;
  108812. private _shadowsEnabled;
  108813. /**
  108814. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108815. */
  108816. set shadowsEnabled(value: boolean);
  108817. get shadowsEnabled(): boolean;
  108818. private _lightsEnabled;
  108819. /**
  108820. * Gets or sets a boolean indicating if lights are enabled on this scene
  108821. */
  108822. set lightsEnabled(value: boolean);
  108823. get lightsEnabled(): boolean;
  108824. /** All of the active cameras added to this scene. */
  108825. activeCameras: Camera[];
  108826. /** @hidden */
  108827. _activeCamera: Nullable<Camera>;
  108828. /** Gets or sets the current active camera */
  108829. get activeCamera(): Nullable<Camera>;
  108830. set activeCamera(value: Nullable<Camera>);
  108831. private _defaultMaterial;
  108832. /** The default material used on meshes when no material is affected */
  108833. get defaultMaterial(): Material;
  108834. /** The default material used on meshes when no material is affected */
  108835. set defaultMaterial(value: Material);
  108836. private _texturesEnabled;
  108837. /**
  108838. * Gets or sets a boolean indicating if textures are enabled on this scene
  108839. */
  108840. set texturesEnabled(value: boolean);
  108841. get texturesEnabled(): boolean;
  108842. /**
  108843. * Gets or sets a boolean indicating if particles are enabled on this scene
  108844. */
  108845. particlesEnabled: boolean;
  108846. /**
  108847. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108848. */
  108849. spritesEnabled: boolean;
  108850. private _skeletonsEnabled;
  108851. /**
  108852. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108853. */
  108854. set skeletonsEnabled(value: boolean);
  108855. get skeletonsEnabled(): boolean;
  108856. /**
  108857. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108858. */
  108859. lensFlaresEnabled: boolean;
  108860. /**
  108861. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108863. */
  108864. collisionsEnabled: boolean;
  108865. private _collisionCoordinator;
  108866. /** @hidden */
  108867. get collisionCoordinator(): ICollisionCoordinator;
  108868. /**
  108869. * Defines the gravity applied to this scene (used only for collisions)
  108870. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108871. */
  108872. gravity: Vector3;
  108873. /**
  108874. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108875. */
  108876. postProcessesEnabled: boolean;
  108877. /**
  108878. * The list of postprocesses added to the scene
  108879. */
  108880. postProcesses: PostProcess[];
  108881. /**
  108882. * Gets the current postprocess manager
  108883. */
  108884. postProcessManager: PostProcessManager;
  108885. /**
  108886. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108887. */
  108888. renderTargetsEnabled: boolean;
  108889. /**
  108890. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108891. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108892. */
  108893. dumpNextRenderTargets: boolean;
  108894. /**
  108895. * The list of user defined render targets added to the scene
  108896. */
  108897. customRenderTargets: RenderTargetTexture[];
  108898. /**
  108899. * Defines if texture loading must be delayed
  108900. * If true, textures will only be loaded when they need to be rendered
  108901. */
  108902. useDelayedTextureLoading: boolean;
  108903. /**
  108904. * Gets the list of meshes imported to the scene through SceneLoader
  108905. */
  108906. importedMeshesFiles: String[];
  108907. /**
  108908. * Gets or sets a boolean indicating if probes are enabled on this scene
  108909. */
  108910. probesEnabled: boolean;
  108911. /**
  108912. * Gets or sets the current offline provider to use to store scene data
  108913. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108914. */
  108915. offlineProvider: IOfflineProvider;
  108916. /**
  108917. * Gets or sets the action manager associated with the scene
  108918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108919. */
  108920. actionManager: AbstractActionManager;
  108921. private _meshesForIntersections;
  108922. /**
  108923. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108924. */
  108925. proceduralTexturesEnabled: boolean;
  108926. private _engine;
  108927. private _totalVertices;
  108928. /** @hidden */
  108929. _activeIndices: PerfCounter;
  108930. /** @hidden */
  108931. _activeParticles: PerfCounter;
  108932. /** @hidden */
  108933. _activeBones: PerfCounter;
  108934. private _animationRatio;
  108935. /** @hidden */
  108936. _animationTimeLast: number;
  108937. /** @hidden */
  108938. _animationTime: number;
  108939. /**
  108940. * Gets or sets a general scale for animation speed
  108941. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108942. */
  108943. animationTimeScale: number;
  108944. /** @hidden */
  108945. _cachedMaterial: Nullable<Material>;
  108946. /** @hidden */
  108947. _cachedEffect: Nullable<Effect>;
  108948. /** @hidden */
  108949. _cachedVisibility: Nullable<number>;
  108950. private _renderId;
  108951. private _frameId;
  108952. private _executeWhenReadyTimeoutId;
  108953. private _intermediateRendering;
  108954. private _viewUpdateFlag;
  108955. private _projectionUpdateFlag;
  108956. /** @hidden */
  108957. _toBeDisposed: Nullable<IDisposable>[];
  108958. private _activeRequests;
  108959. /** @hidden */
  108960. _pendingData: any[];
  108961. private _isDisposed;
  108962. /**
  108963. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108964. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108965. */
  108966. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108967. private _activeMeshes;
  108968. private _processedMaterials;
  108969. private _renderTargets;
  108970. /** @hidden */
  108971. _activeParticleSystems: SmartArray<IParticleSystem>;
  108972. private _activeSkeletons;
  108973. private _softwareSkinnedMeshes;
  108974. private _renderingManager;
  108975. /** @hidden */
  108976. _activeAnimatables: Animatable[];
  108977. private _transformMatrix;
  108978. private _sceneUbo;
  108979. /** @hidden */
  108980. _viewMatrix: Matrix;
  108981. private _projectionMatrix;
  108982. /** @hidden */
  108983. _forcedViewPosition: Nullable<Vector3>;
  108984. /** @hidden */
  108985. _frustumPlanes: Plane[];
  108986. /**
  108987. * Gets the list of frustum planes (built from the active camera)
  108988. */
  108989. get frustumPlanes(): Plane[];
  108990. /**
  108991. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108992. * This is useful if there are more lights that the maximum simulteanous authorized
  108993. */
  108994. requireLightSorting: boolean;
  108995. /** @hidden */
  108996. readonly useMaterialMeshMap: boolean;
  108997. /** @hidden */
  108998. readonly useClonedMeshMap: boolean;
  108999. private _externalData;
  109000. private _uid;
  109001. /**
  109002. * @hidden
  109003. * Backing store of defined scene components.
  109004. */
  109005. _components: ISceneComponent[];
  109006. /**
  109007. * @hidden
  109008. * Backing store of defined scene components.
  109009. */
  109010. _serializableComponents: ISceneSerializableComponent[];
  109011. /**
  109012. * List of components to register on the next registration step.
  109013. */
  109014. private _transientComponents;
  109015. /**
  109016. * Registers the transient components if needed.
  109017. */
  109018. private _registerTransientComponents;
  109019. /**
  109020. * @hidden
  109021. * Add a component to the scene.
  109022. * Note that the ccomponent could be registered on th next frame if this is called after
  109023. * the register component stage.
  109024. * @param component Defines the component to add to the scene
  109025. */
  109026. _addComponent(component: ISceneComponent): void;
  109027. /**
  109028. * @hidden
  109029. * Gets a component from the scene.
  109030. * @param name defines the name of the component to retrieve
  109031. * @returns the component or null if not present
  109032. */
  109033. _getComponent(name: string): Nullable<ISceneComponent>;
  109034. /**
  109035. * @hidden
  109036. * Defines the actions happening before camera updates.
  109037. */
  109038. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109039. /**
  109040. * @hidden
  109041. * Defines the actions happening before clear the canvas.
  109042. */
  109043. _beforeClearStage: Stage<SimpleStageAction>;
  109044. /**
  109045. * @hidden
  109046. * Defines the actions when collecting render targets for the frame.
  109047. */
  109048. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109049. /**
  109050. * @hidden
  109051. * Defines the actions happening for one camera in the frame.
  109052. */
  109053. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109054. /**
  109055. * @hidden
  109056. * Defines the actions happening during the per mesh ready checks.
  109057. */
  109058. _isReadyForMeshStage: Stage<MeshStageAction>;
  109059. /**
  109060. * @hidden
  109061. * Defines the actions happening before evaluate active mesh checks.
  109062. */
  109063. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109064. /**
  109065. * @hidden
  109066. * Defines the actions happening during the evaluate sub mesh checks.
  109067. */
  109068. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109069. /**
  109070. * @hidden
  109071. * Defines the actions happening during the active mesh stage.
  109072. */
  109073. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109074. /**
  109075. * @hidden
  109076. * Defines the actions happening during the per camera render target step.
  109077. */
  109078. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109079. /**
  109080. * @hidden
  109081. * Defines the actions happening just before the active camera is drawing.
  109082. */
  109083. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109084. /**
  109085. * @hidden
  109086. * Defines the actions happening just before a render target is drawing.
  109087. */
  109088. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109089. /**
  109090. * @hidden
  109091. * Defines the actions happening just before a rendering group is drawing.
  109092. */
  109093. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109094. /**
  109095. * @hidden
  109096. * Defines the actions happening just before a mesh is drawing.
  109097. */
  109098. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109099. /**
  109100. * @hidden
  109101. * Defines the actions happening just after a mesh has been drawn.
  109102. */
  109103. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109104. /**
  109105. * @hidden
  109106. * Defines the actions happening just after a rendering group has been drawn.
  109107. */
  109108. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109109. /**
  109110. * @hidden
  109111. * Defines the actions happening just after the active camera has been drawn.
  109112. */
  109113. _afterCameraDrawStage: Stage<CameraStageAction>;
  109114. /**
  109115. * @hidden
  109116. * Defines the actions happening just after a render target has been drawn.
  109117. */
  109118. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109119. /**
  109120. * @hidden
  109121. * Defines the actions happening just after rendering all cameras and computing intersections.
  109122. */
  109123. _afterRenderStage: Stage<SimpleStageAction>;
  109124. /**
  109125. * @hidden
  109126. * Defines the actions happening when a pointer move event happens.
  109127. */
  109128. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109129. /**
  109130. * @hidden
  109131. * Defines the actions happening when a pointer down event happens.
  109132. */
  109133. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109134. /**
  109135. * @hidden
  109136. * Defines the actions happening when a pointer up event happens.
  109137. */
  109138. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109139. /**
  109140. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109141. */
  109142. private geometriesByUniqueId;
  109143. /**
  109144. * Creates a new Scene
  109145. * @param engine defines the engine to use to render this scene
  109146. * @param options defines the scene options
  109147. */
  109148. constructor(engine: Engine, options?: SceneOptions);
  109149. /**
  109150. * Gets a string idenfifying the name of the class
  109151. * @returns "Scene" string
  109152. */
  109153. getClassName(): string;
  109154. private _defaultMeshCandidates;
  109155. /**
  109156. * @hidden
  109157. */
  109158. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109159. private _defaultSubMeshCandidates;
  109160. /**
  109161. * @hidden
  109162. */
  109163. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109164. /**
  109165. * Sets the default candidate providers for the scene.
  109166. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109167. * and getCollidingSubMeshCandidates to their default function
  109168. */
  109169. setDefaultCandidateProviders(): void;
  109170. /**
  109171. * Gets the mesh that is currently under the pointer
  109172. */
  109173. get meshUnderPointer(): Nullable<AbstractMesh>;
  109174. /**
  109175. * Gets or sets the current on-screen X position of the pointer
  109176. */
  109177. get pointerX(): number;
  109178. set pointerX(value: number);
  109179. /**
  109180. * Gets or sets the current on-screen Y position of the pointer
  109181. */
  109182. get pointerY(): number;
  109183. set pointerY(value: number);
  109184. /**
  109185. * Gets the cached material (ie. the latest rendered one)
  109186. * @returns the cached material
  109187. */
  109188. getCachedMaterial(): Nullable<Material>;
  109189. /**
  109190. * Gets the cached effect (ie. the latest rendered one)
  109191. * @returns the cached effect
  109192. */
  109193. getCachedEffect(): Nullable<Effect>;
  109194. /**
  109195. * Gets the cached visibility state (ie. the latest rendered one)
  109196. * @returns the cached visibility state
  109197. */
  109198. getCachedVisibility(): Nullable<number>;
  109199. /**
  109200. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109201. * @param material defines the current material
  109202. * @param effect defines the current effect
  109203. * @param visibility defines the current visibility state
  109204. * @returns true if one parameter is not cached
  109205. */
  109206. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109207. /**
  109208. * Gets the engine associated with the scene
  109209. * @returns an Engine
  109210. */
  109211. getEngine(): Engine;
  109212. /**
  109213. * Gets the total number of vertices rendered per frame
  109214. * @returns the total number of vertices rendered per frame
  109215. */
  109216. getTotalVertices(): number;
  109217. /**
  109218. * Gets the performance counter for total vertices
  109219. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109220. */
  109221. get totalVerticesPerfCounter(): PerfCounter;
  109222. /**
  109223. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109224. * @returns the total number of active indices rendered per frame
  109225. */
  109226. getActiveIndices(): number;
  109227. /**
  109228. * Gets the performance counter for active indices
  109229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109230. */
  109231. get totalActiveIndicesPerfCounter(): PerfCounter;
  109232. /**
  109233. * Gets the total number of active particles rendered per frame
  109234. * @returns the total number of active particles rendered per frame
  109235. */
  109236. getActiveParticles(): number;
  109237. /**
  109238. * Gets the performance counter for active particles
  109239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109240. */
  109241. get activeParticlesPerfCounter(): PerfCounter;
  109242. /**
  109243. * Gets the total number of active bones rendered per frame
  109244. * @returns the total number of active bones rendered per frame
  109245. */
  109246. getActiveBones(): number;
  109247. /**
  109248. * Gets the performance counter for active bones
  109249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109250. */
  109251. get activeBonesPerfCounter(): PerfCounter;
  109252. /**
  109253. * Gets the array of active meshes
  109254. * @returns an array of AbstractMesh
  109255. */
  109256. getActiveMeshes(): SmartArray<AbstractMesh>;
  109257. /**
  109258. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109259. * @returns a number
  109260. */
  109261. getAnimationRatio(): number;
  109262. /**
  109263. * Gets an unique Id for the current render phase
  109264. * @returns a number
  109265. */
  109266. getRenderId(): number;
  109267. /**
  109268. * Gets an unique Id for the current frame
  109269. * @returns a number
  109270. */
  109271. getFrameId(): number;
  109272. /** Call this function if you want to manually increment the render Id*/
  109273. incrementRenderId(): void;
  109274. private _createUbo;
  109275. /**
  109276. * Use this method to simulate a pointer move on a mesh
  109277. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109278. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109279. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109280. * @returns the current scene
  109281. */
  109282. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109283. /**
  109284. * Use this method to simulate a pointer down on a mesh
  109285. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109286. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109287. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109288. * @returns the current scene
  109289. */
  109290. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109291. /**
  109292. * Use this method to simulate a pointer up on a mesh
  109293. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109294. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109295. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109296. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109297. * @returns the current scene
  109298. */
  109299. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109300. /**
  109301. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109302. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109303. * @returns true if the pointer was captured
  109304. */
  109305. isPointerCaptured(pointerId?: number): boolean;
  109306. /**
  109307. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109308. * @param attachUp defines if you want to attach events to pointerup
  109309. * @param attachDown defines if you want to attach events to pointerdown
  109310. * @param attachMove defines if you want to attach events to pointermove
  109311. */
  109312. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109313. /** Detaches all event handlers*/
  109314. detachControl(): void;
  109315. /**
  109316. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109317. * Delay loaded resources are not taking in account
  109318. * @return true if all required resources are ready
  109319. */
  109320. isReady(): boolean;
  109321. /** Resets all cached information relative to material (including effect and visibility) */
  109322. resetCachedMaterial(): void;
  109323. /**
  109324. * Registers a function to be called before every frame render
  109325. * @param func defines the function to register
  109326. */
  109327. registerBeforeRender(func: () => void): void;
  109328. /**
  109329. * Unregisters a function called before every frame render
  109330. * @param func defines the function to unregister
  109331. */
  109332. unregisterBeforeRender(func: () => void): void;
  109333. /**
  109334. * Registers a function to be called after every frame render
  109335. * @param func defines the function to register
  109336. */
  109337. registerAfterRender(func: () => void): void;
  109338. /**
  109339. * Unregisters a function called after every frame render
  109340. * @param func defines the function to unregister
  109341. */
  109342. unregisterAfterRender(func: () => void): void;
  109343. private _executeOnceBeforeRender;
  109344. /**
  109345. * The provided function will run before render once and will be disposed afterwards.
  109346. * A timeout delay can be provided so that the function will be executed in N ms.
  109347. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109348. * @param func The function to be executed.
  109349. * @param timeout optional delay in ms
  109350. */
  109351. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109352. /** @hidden */
  109353. _addPendingData(data: any): void;
  109354. /** @hidden */
  109355. _removePendingData(data: any): void;
  109356. /**
  109357. * Returns the number of items waiting to be loaded
  109358. * @returns the number of items waiting to be loaded
  109359. */
  109360. getWaitingItemsCount(): number;
  109361. /**
  109362. * Returns a boolean indicating if the scene is still loading data
  109363. */
  109364. get isLoading(): boolean;
  109365. /**
  109366. * Registers a function to be executed when the scene is ready
  109367. * @param {Function} func - the function to be executed
  109368. */
  109369. executeWhenReady(func: () => void): void;
  109370. /**
  109371. * Returns a promise that resolves when the scene is ready
  109372. * @returns A promise that resolves when the scene is ready
  109373. */
  109374. whenReadyAsync(): Promise<void>;
  109375. /** @hidden */
  109376. _checkIsReady(): void;
  109377. /**
  109378. * Gets all animatable attached to the scene
  109379. */
  109380. get animatables(): Animatable[];
  109381. /**
  109382. * Resets the last animation time frame.
  109383. * Useful to override when animations start running when loading a scene for the first time.
  109384. */
  109385. resetLastAnimationTimeFrame(): void;
  109386. /**
  109387. * Gets the current view matrix
  109388. * @returns a Matrix
  109389. */
  109390. getViewMatrix(): Matrix;
  109391. /**
  109392. * Gets the current projection matrix
  109393. * @returns a Matrix
  109394. */
  109395. getProjectionMatrix(): Matrix;
  109396. /**
  109397. * Gets the current transform matrix
  109398. * @returns a Matrix made of View * Projection
  109399. */
  109400. getTransformMatrix(): Matrix;
  109401. /**
  109402. * Sets the current transform matrix
  109403. * @param viewL defines the View matrix to use
  109404. * @param projectionL defines the Projection matrix to use
  109405. * @param viewR defines the right View matrix to use (if provided)
  109406. * @param projectionR defines the right Projection matrix to use (if provided)
  109407. */
  109408. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109409. /**
  109410. * Gets the uniform buffer used to store scene data
  109411. * @returns a UniformBuffer
  109412. */
  109413. getSceneUniformBuffer(): UniformBuffer;
  109414. /**
  109415. * Gets an unique (relatively to the current scene) Id
  109416. * @returns an unique number for the scene
  109417. */
  109418. getUniqueId(): number;
  109419. /**
  109420. * Add a mesh to the list of scene's meshes
  109421. * @param newMesh defines the mesh to add
  109422. * @param recursive if all child meshes should also be added to the scene
  109423. */
  109424. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109425. /**
  109426. * Remove a mesh for the list of scene's meshes
  109427. * @param toRemove defines the mesh to remove
  109428. * @param recursive if all child meshes should also be removed from the scene
  109429. * @returns the index where the mesh was in the mesh list
  109430. */
  109431. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109432. /**
  109433. * Add a transform node to the list of scene's transform nodes
  109434. * @param newTransformNode defines the transform node to add
  109435. */
  109436. addTransformNode(newTransformNode: TransformNode): void;
  109437. /**
  109438. * Remove a transform node for the list of scene's transform nodes
  109439. * @param toRemove defines the transform node to remove
  109440. * @returns the index where the transform node was in the transform node list
  109441. */
  109442. removeTransformNode(toRemove: TransformNode): number;
  109443. /**
  109444. * Remove a skeleton for the list of scene's skeletons
  109445. * @param toRemove defines the skeleton to remove
  109446. * @returns the index where the skeleton was in the skeleton list
  109447. */
  109448. removeSkeleton(toRemove: Skeleton): number;
  109449. /**
  109450. * Remove a morph target for the list of scene's morph targets
  109451. * @param toRemove defines the morph target to remove
  109452. * @returns the index where the morph target was in the morph target list
  109453. */
  109454. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109455. /**
  109456. * Remove a light for the list of scene's lights
  109457. * @param toRemove defines the light to remove
  109458. * @returns the index where the light was in the light list
  109459. */
  109460. removeLight(toRemove: Light): number;
  109461. /**
  109462. * Remove a camera for the list of scene's cameras
  109463. * @param toRemove defines the camera to remove
  109464. * @returns the index where the camera was in the camera list
  109465. */
  109466. removeCamera(toRemove: Camera): number;
  109467. /**
  109468. * Remove a particle system for the list of scene's particle systems
  109469. * @param toRemove defines the particle system to remove
  109470. * @returns the index where the particle system was in the particle system list
  109471. */
  109472. removeParticleSystem(toRemove: IParticleSystem): number;
  109473. /**
  109474. * Remove a animation for the list of scene's animations
  109475. * @param toRemove defines the animation to remove
  109476. * @returns the index where the animation was in the animation list
  109477. */
  109478. removeAnimation(toRemove: Animation): number;
  109479. /**
  109480. * Will stop the animation of the given target
  109481. * @param target - the target
  109482. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109483. * @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)
  109484. */
  109485. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109486. /**
  109487. * Removes the given animation group from this scene.
  109488. * @param toRemove The animation group to remove
  109489. * @returns The index of the removed animation group
  109490. */
  109491. removeAnimationGroup(toRemove: AnimationGroup): number;
  109492. /**
  109493. * Removes the given multi-material from this scene.
  109494. * @param toRemove The multi-material to remove
  109495. * @returns The index of the removed multi-material
  109496. */
  109497. removeMultiMaterial(toRemove: MultiMaterial): number;
  109498. /**
  109499. * Removes the given material from this scene.
  109500. * @param toRemove The material to remove
  109501. * @returns The index of the removed material
  109502. */
  109503. removeMaterial(toRemove: Material): number;
  109504. /**
  109505. * Removes the given action manager from this scene.
  109506. * @param toRemove The action manager to remove
  109507. * @returns The index of the removed action manager
  109508. */
  109509. removeActionManager(toRemove: AbstractActionManager): number;
  109510. /**
  109511. * Removes the given texture from this scene.
  109512. * @param toRemove The texture to remove
  109513. * @returns The index of the removed texture
  109514. */
  109515. removeTexture(toRemove: BaseTexture): number;
  109516. /**
  109517. * Adds the given light to this scene
  109518. * @param newLight The light to add
  109519. */
  109520. addLight(newLight: Light): void;
  109521. /**
  109522. * Sorts the list list based on light priorities
  109523. */
  109524. sortLightsByPriority(): void;
  109525. /**
  109526. * Adds the given camera to this scene
  109527. * @param newCamera The camera to add
  109528. */
  109529. addCamera(newCamera: Camera): void;
  109530. /**
  109531. * Adds the given skeleton to this scene
  109532. * @param newSkeleton The skeleton to add
  109533. */
  109534. addSkeleton(newSkeleton: Skeleton): void;
  109535. /**
  109536. * Adds the given particle system to this scene
  109537. * @param newParticleSystem The particle system to add
  109538. */
  109539. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109540. /**
  109541. * Adds the given animation to this scene
  109542. * @param newAnimation The animation to add
  109543. */
  109544. addAnimation(newAnimation: Animation): void;
  109545. /**
  109546. * Adds the given animation group to this scene.
  109547. * @param newAnimationGroup The animation group to add
  109548. */
  109549. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109550. /**
  109551. * Adds the given multi-material to this scene
  109552. * @param newMultiMaterial The multi-material to add
  109553. */
  109554. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109555. /**
  109556. * Adds the given material to this scene
  109557. * @param newMaterial The material to add
  109558. */
  109559. addMaterial(newMaterial: Material): void;
  109560. /**
  109561. * Adds the given morph target to this scene
  109562. * @param newMorphTargetManager The morph target to add
  109563. */
  109564. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109565. /**
  109566. * Adds the given geometry to this scene
  109567. * @param newGeometry The geometry to add
  109568. */
  109569. addGeometry(newGeometry: Geometry): void;
  109570. /**
  109571. * Adds the given action manager to this scene
  109572. * @param newActionManager The action manager to add
  109573. */
  109574. addActionManager(newActionManager: AbstractActionManager): void;
  109575. /**
  109576. * Adds the given texture to this scene.
  109577. * @param newTexture The texture to add
  109578. */
  109579. addTexture(newTexture: BaseTexture): void;
  109580. /**
  109581. * Switch active camera
  109582. * @param newCamera defines the new active camera
  109583. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109584. */
  109585. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109586. /**
  109587. * sets the active camera of the scene using its ID
  109588. * @param id defines the camera's ID
  109589. * @return the new active camera or null if none found.
  109590. */
  109591. setActiveCameraByID(id: string): Nullable<Camera>;
  109592. /**
  109593. * sets the active camera of the scene using its name
  109594. * @param name defines the camera's name
  109595. * @returns the new active camera or null if none found.
  109596. */
  109597. setActiveCameraByName(name: string): Nullable<Camera>;
  109598. /**
  109599. * get an animation group using its name
  109600. * @param name defines the material's name
  109601. * @return the animation group or null if none found.
  109602. */
  109603. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109604. /**
  109605. * Get a material using its unique id
  109606. * @param uniqueId defines the material's unique id
  109607. * @return the material or null if none found.
  109608. */
  109609. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109610. /**
  109611. * get a material using its id
  109612. * @param id defines the material's ID
  109613. * @return the material or null if none found.
  109614. */
  109615. getMaterialByID(id: string): Nullable<Material>;
  109616. /**
  109617. * Gets a the last added material using a given id
  109618. * @param id defines the material's ID
  109619. * @return the last material with the given id or null if none found.
  109620. */
  109621. getLastMaterialByID(id: string): Nullable<Material>;
  109622. /**
  109623. * Gets a material using its name
  109624. * @param name defines the material's name
  109625. * @return the material or null if none found.
  109626. */
  109627. getMaterialByName(name: string): Nullable<Material>;
  109628. /**
  109629. * Get a texture using its unique id
  109630. * @param uniqueId defines the texture's unique id
  109631. * @return the texture or null if none found.
  109632. */
  109633. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109634. /**
  109635. * Gets a camera using its id
  109636. * @param id defines the id to look for
  109637. * @returns the camera or null if not found
  109638. */
  109639. getCameraByID(id: string): Nullable<Camera>;
  109640. /**
  109641. * Gets a camera using its unique id
  109642. * @param uniqueId defines the unique id to look for
  109643. * @returns the camera or null if not found
  109644. */
  109645. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109646. /**
  109647. * Gets a camera using its name
  109648. * @param name defines the camera's name
  109649. * @return the camera or null if none found.
  109650. */
  109651. getCameraByName(name: string): Nullable<Camera>;
  109652. /**
  109653. * Gets a bone using its id
  109654. * @param id defines the bone's id
  109655. * @return the bone or null if not found
  109656. */
  109657. getBoneByID(id: string): Nullable<Bone>;
  109658. /**
  109659. * Gets a bone using its id
  109660. * @param name defines the bone's name
  109661. * @return the bone or null if not found
  109662. */
  109663. getBoneByName(name: string): Nullable<Bone>;
  109664. /**
  109665. * Gets a light node using its name
  109666. * @param name defines the the light's name
  109667. * @return the light or null if none found.
  109668. */
  109669. getLightByName(name: string): Nullable<Light>;
  109670. /**
  109671. * Gets a light node using its id
  109672. * @param id defines the light's id
  109673. * @return the light or null if none found.
  109674. */
  109675. getLightByID(id: string): Nullable<Light>;
  109676. /**
  109677. * Gets a light node using its scene-generated unique ID
  109678. * @param uniqueId defines the light's unique id
  109679. * @return the light or null if none found.
  109680. */
  109681. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109682. /**
  109683. * Gets a particle system by id
  109684. * @param id defines the particle system id
  109685. * @return the corresponding system or null if none found
  109686. */
  109687. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109688. /**
  109689. * Gets a geometry using its ID
  109690. * @param id defines the geometry's id
  109691. * @return the geometry or null if none found.
  109692. */
  109693. getGeometryByID(id: string): Nullable<Geometry>;
  109694. private _getGeometryByUniqueID;
  109695. /**
  109696. * Add a new geometry to this scene
  109697. * @param geometry defines the geometry to be added to the scene.
  109698. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109699. * @return a boolean defining if the geometry was added or not
  109700. */
  109701. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109702. /**
  109703. * Removes an existing geometry
  109704. * @param geometry defines the geometry to be removed from the scene
  109705. * @return a boolean defining if the geometry was removed or not
  109706. */
  109707. removeGeometry(geometry: Geometry): boolean;
  109708. /**
  109709. * Gets the list of geometries attached to the scene
  109710. * @returns an array of Geometry
  109711. */
  109712. getGeometries(): Geometry[];
  109713. /**
  109714. * Gets the first added mesh found of a given ID
  109715. * @param id defines the id to search for
  109716. * @return the mesh found or null if not found at all
  109717. */
  109718. getMeshByID(id: string): Nullable<AbstractMesh>;
  109719. /**
  109720. * Gets a list of meshes using their id
  109721. * @param id defines the id to search for
  109722. * @returns a list of meshes
  109723. */
  109724. getMeshesByID(id: string): Array<AbstractMesh>;
  109725. /**
  109726. * Gets the first added transform node found of a given ID
  109727. * @param id defines the id to search for
  109728. * @return the found transform node or null if not found at all.
  109729. */
  109730. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109731. /**
  109732. * Gets a transform node with its auto-generated unique id
  109733. * @param uniqueId efines the unique id to search for
  109734. * @return the found transform node or null if not found at all.
  109735. */
  109736. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109737. /**
  109738. * Gets a list of transform nodes using their id
  109739. * @param id defines the id to search for
  109740. * @returns a list of transform nodes
  109741. */
  109742. getTransformNodesByID(id: string): Array<TransformNode>;
  109743. /**
  109744. * Gets a mesh with its auto-generated unique id
  109745. * @param uniqueId defines the unique id to search for
  109746. * @return the found mesh or null if not found at all.
  109747. */
  109748. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109749. /**
  109750. * Gets a the last added mesh using a given id
  109751. * @param id defines the id to search for
  109752. * @return the found mesh or null if not found at all.
  109753. */
  109754. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109755. /**
  109756. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109757. * @param id defines the id to search for
  109758. * @return the found node or null if not found at all
  109759. */
  109760. getLastEntryByID(id: string): Nullable<Node>;
  109761. /**
  109762. * Gets a node (Mesh, Camera, Light) using a given id
  109763. * @param id defines the id to search for
  109764. * @return the found node or null if not found at all
  109765. */
  109766. getNodeByID(id: string): Nullable<Node>;
  109767. /**
  109768. * Gets a node (Mesh, Camera, Light) using a given name
  109769. * @param name defines the name to search for
  109770. * @return the found node or null if not found at all.
  109771. */
  109772. getNodeByName(name: string): Nullable<Node>;
  109773. /**
  109774. * Gets a mesh using a given name
  109775. * @param name defines the name to search for
  109776. * @return the found mesh or null if not found at all.
  109777. */
  109778. getMeshByName(name: string): Nullable<AbstractMesh>;
  109779. /**
  109780. * Gets a transform node using a given name
  109781. * @param name defines the name to search for
  109782. * @return the found transform node or null if not found at all.
  109783. */
  109784. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109785. /**
  109786. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109787. * @param id defines the id to search for
  109788. * @return the found skeleton or null if not found at all.
  109789. */
  109790. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109791. /**
  109792. * Gets a skeleton using a given auto generated unique id
  109793. * @param uniqueId defines the unique id to search for
  109794. * @return the found skeleton or null if not found at all.
  109795. */
  109796. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109797. /**
  109798. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109799. * @param id defines the id to search for
  109800. * @return the found skeleton or null if not found at all.
  109801. */
  109802. getSkeletonById(id: string): Nullable<Skeleton>;
  109803. /**
  109804. * Gets a skeleton using a given name
  109805. * @param name defines the name to search for
  109806. * @return the found skeleton or null if not found at all.
  109807. */
  109808. getSkeletonByName(name: string): Nullable<Skeleton>;
  109809. /**
  109810. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109811. * @param id defines the id to search for
  109812. * @return the found morph target manager or null if not found at all.
  109813. */
  109814. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109815. /**
  109816. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109817. * @param id defines the id to search for
  109818. * @return the found morph target or null if not found at all.
  109819. */
  109820. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109821. /**
  109822. * Gets a boolean indicating if the given mesh is active
  109823. * @param mesh defines the mesh to look for
  109824. * @returns true if the mesh is in the active list
  109825. */
  109826. isActiveMesh(mesh: AbstractMesh): boolean;
  109827. /**
  109828. * Return a unique id as a string which can serve as an identifier for the scene
  109829. */
  109830. get uid(): string;
  109831. /**
  109832. * Add an externaly attached data from its key.
  109833. * This method call will fail and return false, if such key already exists.
  109834. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109835. * @param key the unique key that identifies the data
  109836. * @param data the data object to associate to the key for this Engine instance
  109837. * @return true if no such key were already present and the data was added successfully, false otherwise
  109838. */
  109839. addExternalData<T>(key: string, data: T): boolean;
  109840. /**
  109841. * Get an externaly attached data from its key
  109842. * @param key the unique key that identifies the data
  109843. * @return the associated data, if present (can be null), or undefined if not present
  109844. */
  109845. getExternalData<T>(key: string): Nullable<T>;
  109846. /**
  109847. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109848. * @param key the unique key that identifies the data
  109849. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109850. * @return the associated data, can be null if the factory returned null.
  109851. */
  109852. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109853. /**
  109854. * Remove an externaly attached data from the Engine instance
  109855. * @param key the unique key that identifies the data
  109856. * @return true if the data was successfully removed, false if it doesn't exist
  109857. */
  109858. removeExternalData(key: string): boolean;
  109859. private _evaluateSubMesh;
  109860. /**
  109861. * Clear the processed materials smart array preventing retention point in material dispose.
  109862. */
  109863. freeProcessedMaterials(): void;
  109864. private _preventFreeActiveMeshesAndRenderingGroups;
  109865. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109866. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109867. * when disposing several meshes in a row or a hierarchy of meshes.
  109868. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109869. */
  109870. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109871. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109872. /**
  109873. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109874. */
  109875. freeActiveMeshes(): void;
  109876. /**
  109877. * Clear the info related to rendering groups preventing retention points during dispose.
  109878. */
  109879. freeRenderingGroups(): void;
  109880. /** @hidden */
  109881. _isInIntermediateRendering(): boolean;
  109882. /**
  109883. * Lambda returning the list of potentially active meshes.
  109884. */
  109885. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109886. /**
  109887. * Lambda returning the list of potentially active sub meshes.
  109888. */
  109889. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109890. /**
  109891. * Lambda returning the list of potentially intersecting sub meshes.
  109892. */
  109893. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109894. /**
  109895. * Lambda returning the list of potentially colliding sub meshes.
  109896. */
  109897. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109898. private _activeMeshesFrozen;
  109899. private _skipEvaluateActiveMeshesCompletely;
  109900. /**
  109901. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109902. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109903. * @returns the current scene
  109904. */
  109905. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109906. /**
  109907. * Use this function to restart evaluating active meshes on every frame
  109908. * @returns the current scene
  109909. */
  109910. unfreezeActiveMeshes(): Scene;
  109911. private _evaluateActiveMeshes;
  109912. private _activeMesh;
  109913. /**
  109914. * Update the transform matrix to update from the current active camera
  109915. * @param force defines a boolean used to force the update even if cache is up to date
  109916. */
  109917. updateTransformMatrix(force?: boolean): void;
  109918. private _bindFrameBuffer;
  109919. /** @hidden */
  109920. _allowPostProcessClearColor: boolean;
  109921. /** @hidden */
  109922. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109923. private _processSubCameras;
  109924. private _checkIntersections;
  109925. /** @hidden */
  109926. _advancePhysicsEngineStep(step: number): void;
  109927. /**
  109928. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109929. */
  109930. getDeterministicFrameTime: () => number;
  109931. /** @hidden */
  109932. _animate(): void;
  109933. /** Execute all animations (for a frame) */
  109934. animate(): void;
  109935. /**
  109936. * Render the scene
  109937. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109938. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109939. */
  109940. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109941. /**
  109942. * Freeze all materials
  109943. * A frozen material will not be updatable but should be faster to render
  109944. */
  109945. freezeMaterials(): void;
  109946. /**
  109947. * Unfreeze all materials
  109948. * A frozen material will not be updatable but should be faster to render
  109949. */
  109950. unfreezeMaterials(): void;
  109951. /**
  109952. * Releases all held ressources
  109953. */
  109954. dispose(): void;
  109955. /**
  109956. * Gets if the scene is already disposed
  109957. */
  109958. get isDisposed(): boolean;
  109959. /**
  109960. * Call this function to reduce memory footprint of the scene.
  109961. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109962. */
  109963. clearCachedVertexData(): void;
  109964. /**
  109965. * This function will remove the local cached buffer data from texture.
  109966. * It will save memory but will prevent the texture from being rebuilt
  109967. */
  109968. cleanCachedTextureBuffer(): void;
  109969. /**
  109970. * Get the world extend vectors with an optional filter
  109971. *
  109972. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109973. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109974. */
  109975. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109976. min: Vector3;
  109977. max: Vector3;
  109978. };
  109979. /**
  109980. * Creates a ray that can be used to pick in the scene
  109981. * @param x defines the x coordinate of the origin (on-screen)
  109982. * @param y defines the y coordinate of the origin (on-screen)
  109983. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109984. * @param camera defines the camera to use for the picking
  109985. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109986. * @returns a Ray
  109987. */
  109988. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109989. /**
  109990. * Creates a ray that can be used to pick in the scene
  109991. * @param x defines the x coordinate of the origin (on-screen)
  109992. * @param y defines the y coordinate of the origin (on-screen)
  109993. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109994. * @param result defines the ray where to store the picking ray
  109995. * @param camera defines the camera to use for the picking
  109996. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109997. * @returns the current scene
  109998. */
  109999. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110000. /**
  110001. * Creates a ray that can be used to pick in the scene
  110002. * @param x defines the x coordinate of the origin (on-screen)
  110003. * @param y defines the y coordinate of the origin (on-screen)
  110004. * @param camera defines the camera to use for the picking
  110005. * @returns a Ray
  110006. */
  110007. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110008. /**
  110009. * Creates a ray that can be used to pick in the scene
  110010. * @param x defines the x coordinate of the origin (on-screen)
  110011. * @param y defines the y coordinate of the origin (on-screen)
  110012. * @param result defines the ray where to store the picking ray
  110013. * @param camera defines the camera to use for the picking
  110014. * @returns the current scene
  110015. */
  110016. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110017. /** Launch a ray to try to pick a mesh in the scene
  110018. * @param x position on screen
  110019. * @param y position on screen
  110020. * @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
  110021. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110022. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110023. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110024. * @returns a PickingInfo
  110025. */
  110026. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110027. /** Use the given ray to pick a mesh in the scene
  110028. * @param ray The ray to use to pick meshes
  110029. * @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
  110030. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110031. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110032. * @returns a PickingInfo
  110033. */
  110034. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110035. /**
  110036. * Launch a ray to try to pick a mesh in the scene
  110037. * @param x X position on screen
  110038. * @param y Y position on screen
  110039. * @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
  110040. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110042. * @returns an array of PickingInfo
  110043. */
  110044. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110045. /**
  110046. * Launch a ray to try to pick a mesh in the scene
  110047. * @param ray Ray to use
  110048. * @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
  110049. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110050. * @returns an array of PickingInfo
  110051. */
  110052. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110053. /**
  110054. * Force the value of meshUnderPointer
  110055. * @param mesh defines the mesh to use
  110056. */
  110057. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110058. /**
  110059. * Gets the mesh under the pointer
  110060. * @returns a Mesh or null if no mesh is under the pointer
  110061. */
  110062. getPointerOverMesh(): Nullable<AbstractMesh>;
  110063. /** @hidden */
  110064. _rebuildGeometries(): void;
  110065. /** @hidden */
  110066. _rebuildTextures(): void;
  110067. private _getByTags;
  110068. /**
  110069. * Get a list of meshes by tags
  110070. * @param tagsQuery defines the tags query to use
  110071. * @param forEach defines a predicate used to filter results
  110072. * @returns an array of Mesh
  110073. */
  110074. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110075. /**
  110076. * Get a list of cameras by tags
  110077. * @param tagsQuery defines the tags query to use
  110078. * @param forEach defines a predicate used to filter results
  110079. * @returns an array of Camera
  110080. */
  110081. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110082. /**
  110083. * Get a list of lights by tags
  110084. * @param tagsQuery defines the tags query to use
  110085. * @param forEach defines a predicate used to filter results
  110086. * @returns an array of Light
  110087. */
  110088. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110089. /**
  110090. * Get a list of materials by tags
  110091. * @param tagsQuery defines the tags query to use
  110092. * @param forEach defines a predicate used to filter results
  110093. * @returns an array of Material
  110094. */
  110095. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110096. /**
  110097. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110098. * This allowed control for front to back rendering or reversly depending of the special needs.
  110099. *
  110100. * @param renderingGroupId The rendering group id corresponding to its index
  110101. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110102. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110103. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110104. */
  110105. 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;
  110106. /**
  110107. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110108. *
  110109. * @param renderingGroupId The rendering group id corresponding to its index
  110110. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110111. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110112. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110113. */
  110114. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110115. /**
  110116. * Gets the current auto clear configuration for one rendering group of the rendering
  110117. * manager.
  110118. * @param index the rendering group index to get the information for
  110119. * @returns The auto clear setup for the requested rendering group
  110120. */
  110121. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110122. private _blockMaterialDirtyMechanism;
  110123. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110124. get blockMaterialDirtyMechanism(): boolean;
  110125. set blockMaterialDirtyMechanism(value: boolean);
  110126. /**
  110127. * Will flag all materials as dirty to trigger new shader compilation
  110128. * @param flag defines the flag used to specify which material part must be marked as dirty
  110129. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110130. */
  110131. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110132. /** @hidden */
  110133. _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;
  110134. /** @hidden */
  110135. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110136. /** @hidden */
  110137. _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;
  110138. /** @hidden */
  110139. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110140. /** @hidden */
  110141. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110142. /** @hidden */
  110143. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110144. }
  110145. }
  110146. declare module BABYLON {
  110147. /**
  110148. * Set of assets to keep when moving a scene into an asset container.
  110149. */
  110150. export class KeepAssets extends AbstractScene {
  110151. }
  110152. /**
  110153. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110154. */
  110155. export class InstantiatedEntries {
  110156. /**
  110157. * List of new root nodes (eg. nodes with no parent)
  110158. */
  110159. rootNodes: TransformNode[];
  110160. /**
  110161. * List of new skeletons
  110162. */
  110163. skeletons: Skeleton[];
  110164. /**
  110165. * List of new animation groups
  110166. */
  110167. animationGroups: AnimationGroup[];
  110168. }
  110169. /**
  110170. * Container with a set of assets that can be added or removed from a scene.
  110171. */
  110172. export class AssetContainer extends AbstractScene {
  110173. /**
  110174. * The scene the AssetContainer belongs to.
  110175. */
  110176. scene: Scene;
  110177. /**
  110178. * Instantiates an AssetContainer.
  110179. * @param scene The scene the AssetContainer belongs to.
  110180. */
  110181. constructor(scene: Scene);
  110182. /**
  110183. * Instantiate or clone all meshes and add the new ones to the scene.
  110184. * Skeletons and animation groups will all be cloned
  110185. * @param nameFunction defines an optional function used to get new names for clones
  110186. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110187. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110188. */
  110189. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110190. /**
  110191. * Adds all the assets from the container to the scene.
  110192. */
  110193. addAllToScene(): void;
  110194. /**
  110195. * Removes all the assets in the container from the scene
  110196. */
  110197. removeAllFromScene(): void;
  110198. /**
  110199. * Disposes all the assets in the container
  110200. */
  110201. dispose(): void;
  110202. private _moveAssets;
  110203. /**
  110204. * Removes all the assets contained in the scene and adds them to the container.
  110205. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110206. */
  110207. moveAllFromScene(keepAssets?: KeepAssets): void;
  110208. /**
  110209. * 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.
  110210. * @returns the root mesh
  110211. */
  110212. createRootMesh(): Mesh;
  110213. /**
  110214. * Merge animations from this asset container into a scene
  110215. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110216. * @param animatables set of animatables to retarget to a node from the scene
  110217. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110218. */
  110219. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110220. }
  110221. }
  110222. declare module BABYLON {
  110223. /**
  110224. * Defines how the parser contract is defined.
  110225. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110226. */
  110227. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110228. /**
  110229. * Defines how the individual parser contract is defined.
  110230. * These parser can parse an individual asset
  110231. */
  110232. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110233. /**
  110234. * Base class of the scene acting as a container for the different elements composing a scene.
  110235. * This class is dynamically extended by the different components of the scene increasing
  110236. * flexibility and reducing coupling
  110237. */
  110238. export abstract class AbstractScene {
  110239. /**
  110240. * Stores the list of available parsers in the application.
  110241. */
  110242. private static _BabylonFileParsers;
  110243. /**
  110244. * Stores the list of available individual parsers in the application.
  110245. */
  110246. private static _IndividualBabylonFileParsers;
  110247. /**
  110248. * Adds a parser in the list of available ones
  110249. * @param name Defines the name of the parser
  110250. * @param parser Defines the parser to add
  110251. */
  110252. static AddParser(name: string, parser: BabylonFileParser): void;
  110253. /**
  110254. * Gets a general parser from the list of avaialble ones
  110255. * @param name Defines the name of the parser
  110256. * @returns the requested parser or null
  110257. */
  110258. static GetParser(name: string): Nullable<BabylonFileParser>;
  110259. /**
  110260. * Adds n individual parser in the list of available ones
  110261. * @param name Defines the name of the parser
  110262. * @param parser Defines the parser to add
  110263. */
  110264. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110265. /**
  110266. * Gets an individual parser from the list of avaialble ones
  110267. * @param name Defines the name of the parser
  110268. * @returns the requested parser or null
  110269. */
  110270. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110271. /**
  110272. * Parser json data and populate both a scene and its associated container object
  110273. * @param jsonData Defines the data to parse
  110274. * @param scene Defines the scene to parse the data for
  110275. * @param container Defines the container attached to the parsing sequence
  110276. * @param rootUrl Defines the root url of the data
  110277. */
  110278. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110279. /**
  110280. * Gets the list of root nodes (ie. nodes with no parent)
  110281. */
  110282. rootNodes: Node[];
  110283. /** All of the cameras added to this scene
  110284. * @see http://doc.babylonjs.com/babylon101/cameras
  110285. */
  110286. cameras: Camera[];
  110287. /**
  110288. * All of the lights added to this scene
  110289. * @see http://doc.babylonjs.com/babylon101/lights
  110290. */
  110291. lights: Light[];
  110292. /**
  110293. * All of the (abstract) meshes added to this scene
  110294. */
  110295. meshes: AbstractMesh[];
  110296. /**
  110297. * The list of skeletons added to the scene
  110298. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110299. */
  110300. skeletons: Skeleton[];
  110301. /**
  110302. * All of the particle systems added to this scene
  110303. * @see http://doc.babylonjs.com/babylon101/particles
  110304. */
  110305. particleSystems: IParticleSystem[];
  110306. /**
  110307. * Gets a list of Animations associated with the scene
  110308. */
  110309. animations: Animation[];
  110310. /**
  110311. * All of the animation groups added to this scene
  110312. * @see http://doc.babylonjs.com/how_to/group
  110313. */
  110314. animationGroups: AnimationGroup[];
  110315. /**
  110316. * All of the multi-materials added to this scene
  110317. * @see http://doc.babylonjs.com/how_to/multi_materials
  110318. */
  110319. multiMaterials: MultiMaterial[];
  110320. /**
  110321. * All of the materials added to this scene
  110322. * In the context of a Scene, it is not supposed to be modified manually.
  110323. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110324. * Note also that the order of the Material within the array is not significant and might change.
  110325. * @see http://doc.babylonjs.com/babylon101/materials
  110326. */
  110327. materials: Material[];
  110328. /**
  110329. * The list of morph target managers added to the scene
  110330. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110331. */
  110332. morphTargetManagers: MorphTargetManager[];
  110333. /**
  110334. * The list of geometries used in the scene.
  110335. */
  110336. geometries: Geometry[];
  110337. /**
  110338. * All of the tranform nodes added to this scene
  110339. * In the context of a Scene, it is not supposed to be modified manually.
  110340. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110341. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110342. * @see http://doc.babylonjs.com/how_to/transformnode
  110343. */
  110344. transformNodes: TransformNode[];
  110345. /**
  110346. * ActionManagers available on the scene.
  110347. */
  110348. actionManagers: AbstractActionManager[];
  110349. /**
  110350. * Textures to keep.
  110351. */
  110352. textures: BaseTexture[];
  110353. /**
  110354. * Environment texture for the scene
  110355. */
  110356. environmentTexture: Nullable<BaseTexture>;
  110357. /**
  110358. * @returns all meshes, lights, cameras, transformNodes and bones
  110359. */
  110360. getNodes(): Array<Node>;
  110361. }
  110362. }
  110363. declare module BABYLON {
  110364. /**
  110365. * Interface used to define options for Sound class
  110366. */
  110367. export interface ISoundOptions {
  110368. /**
  110369. * Does the sound autoplay once loaded.
  110370. */
  110371. autoplay?: boolean;
  110372. /**
  110373. * Does the sound loop after it finishes playing once.
  110374. */
  110375. loop?: boolean;
  110376. /**
  110377. * Sound's volume
  110378. */
  110379. volume?: number;
  110380. /**
  110381. * Is it a spatial sound?
  110382. */
  110383. spatialSound?: boolean;
  110384. /**
  110385. * Maximum distance to hear that sound
  110386. */
  110387. maxDistance?: number;
  110388. /**
  110389. * Uses user defined attenuation function
  110390. */
  110391. useCustomAttenuation?: boolean;
  110392. /**
  110393. * Define the roll off factor of spatial sounds.
  110394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110395. */
  110396. rolloffFactor?: number;
  110397. /**
  110398. * Define the reference distance the sound should be heard perfectly.
  110399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110400. */
  110401. refDistance?: number;
  110402. /**
  110403. * Define the distance attenuation model the sound will follow.
  110404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110405. */
  110406. distanceModel?: string;
  110407. /**
  110408. * Defines the playback speed (1 by default)
  110409. */
  110410. playbackRate?: number;
  110411. /**
  110412. * Defines if the sound is from a streaming source
  110413. */
  110414. streaming?: boolean;
  110415. /**
  110416. * Defines an optional length (in seconds) inside the sound file
  110417. */
  110418. length?: number;
  110419. /**
  110420. * Defines an optional offset (in seconds) inside the sound file
  110421. */
  110422. offset?: number;
  110423. /**
  110424. * If true, URLs will not be required to state the audio file codec to use.
  110425. */
  110426. skipCodecCheck?: boolean;
  110427. }
  110428. /**
  110429. * Defines a sound that can be played in the application.
  110430. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110432. */
  110433. export class Sound {
  110434. /**
  110435. * The name of the sound in the scene.
  110436. */
  110437. name: string;
  110438. /**
  110439. * Does the sound autoplay once loaded.
  110440. */
  110441. autoplay: boolean;
  110442. /**
  110443. * Does the sound loop after it finishes playing once.
  110444. */
  110445. loop: boolean;
  110446. /**
  110447. * Does the sound use a custom attenuation curve to simulate the falloff
  110448. * happening when the source gets further away from the camera.
  110449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110450. */
  110451. useCustomAttenuation: boolean;
  110452. /**
  110453. * The sound track id this sound belongs to.
  110454. */
  110455. soundTrackId: number;
  110456. /**
  110457. * Is this sound currently played.
  110458. */
  110459. isPlaying: boolean;
  110460. /**
  110461. * Is this sound currently paused.
  110462. */
  110463. isPaused: boolean;
  110464. /**
  110465. * Does this sound enables spatial sound.
  110466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110467. */
  110468. spatialSound: boolean;
  110469. /**
  110470. * Define the reference distance the sound should be heard perfectly.
  110471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110472. */
  110473. refDistance: number;
  110474. /**
  110475. * Define the roll off factor of spatial sounds.
  110476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110477. */
  110478. rolloffFactor: number;
  110479. /**
  110480. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110482. */
  110483. maxDistance: number;
  110484. /**
  110485. * Define the distance attenuation model the sound will follow.
  110486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110487. */
  110488. distanceModel: string;
  110489. /**
  110490. * @hidden
  110491. * Back Compat
  110492. **/
  110493. onended: () => any;
  110494. /**
  110495. * Observable event when the current playing sound finishes.
  110496. */
  110497. onEndedObservable: Observable<Sound>;
  110498. private _panningModel;
  110499. private _playbackRate;
  110500. private _streaming;
  110501. private _startTime;
  110502. private _startOffset;
  110503. private _position;
  110504. /** @hidden */
  110505. _positionInEmitterSpace: boolean;
  110506. private _localDirection;
  110507. private _volume;
  110508. private _isReadyToPlay;
  110509. private _isDirectional;
  110510. private _readyToPlayCallback;
  110511. private _audioBuffer;
  110512. private _soundSource;
  110513. private _streamingSource;
  110514. private _soundPanner;
  110515. private _soundGain;
  110516. private _inputAudioNode;
  110517. private _outputAudioNode;
  110518. private _coneInnerAngle;
  110519. private _coneOuterAngle;
  110520. private _coneOuterGain;
  110521. private _scene;
  110522. private _connectedTransformNode;
  110523. private _customAttenuationFunction;
  110524. private _registerFunc;
  110525. private _isOutputConnected;
  110526. private _htmlAudioElement;
  110527. private _urlType;
  110528. private _length?;
  110529. private _offset?;
  110530. /** @hidden */
  110531. static _SceneComponentInitialization: (scene: Scene) => void;
  110532. /**
  110533. * Create a sound and attach it to a scene
  110534. * @param name Name of your sound
  110535. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110536. * @param scene defines the scene the sound belongs to
  110537. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110538. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110539. */
  110540. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110541. /**
  110542. * Release the sound and its associated resources
  110543. */
  110544. dispose(): void;
  110545. /**
  110546. * Gets if the sounds is ready to be played or not.
  110547. * @returns true if ready, otherwise false
  110548. */
  110549. isReady(): boolean;
  110550. private _soundLoaded;
  110551. /**
  110552. * Sets the data of the sound from an audiobuffer
  110553. * @param audioBuffer The audioBuffer containing the data
  110554. */
  110555. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110556. /**
  110557. * Updates the current sounds options such as maxdistance, loop...
  110558. * @param options A JSON object containing values named as the object properties
  110559. */
  110560. updateOptions(options: ISoundOptions): void;
  110561. private _createSpatialParameters;
  110562. private _updateSpatialParameters;
  110563. /**
  110564. * Switch the panning model to HRTF:
  110565. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110567. */
  110568. switchPanningModelToHRTF(): void;
  110569. /**
  110570. * Switch the panning model to Equal Power:
  110571. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110573. */
  110574. switchPanningModelToEqualPower(): void;
  110575. private _switchPanningModel;
  110576. /**
  110577. * Connect this sound to a sound track audio node like gain...
  110578. * @param soundTrackAudioNode the sound track audio node to connect to
  110579. */
  110580. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110581. /**
  110582. * Transform this sound into a directional source
  110583. * @param coneInnerAngle Size of the inner cone in degree
  110584. * @param coneOuterAngle Size of the outer cone in degree
  110585. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110586. */
  110587. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110588. /**
  110589. * Gets or sets the inner angle for the directional cone.
  110590. */
  110591. get directionalConeInnerAngle(): number;
  110592. /**
  110593. * Gets or sets the inner angle for the directional cone.
  110594. */
  110595. set directionalConeInnerAngle(value: number);
  110596. /**
  110597. * Gets or sets the outer angle for the directional cone.
  110598. */
  110599. get directionalConeOuterAngle(): number;
  110600. /**
  110601. * Gets or sets the outer angle for the directional cone.
  110602. */
  110603. set directionalConeOuterAngle(value: number);
  110604. /**
  110605. * Sets the position of the emitter if spatial sound is enabled
  110606. * @param newPosition Defines the new posisiton
  110607. */
  110608. setPosition(newPosition: Vector3): void;
  110609. /**
  110610. * Sets the local direction of the emitter if spatial sound is enabled
  110611. * @param newLocalDirection Defines the new local direction
  110612. */
  110613. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110614. private _updateDirection;
  110615. /** @hidden */
  110616. updateDistanceFromListener(): void;
  110617. /**
  110618. * Sets a new custom attenuation function for the sound.
  110619. * @param callback Defines the function used for the attenuation
  110620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110621. */
  110622. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110623. /**
  110624. * Play the sound
  110625. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110626. * @param offset (optional) Start the sound at a specific time in seconds
  110627. * @param length (optional) Sound duration (in seconds)
  110628. */
  110629. play(time?: number, offset?: number, length?: number): void;
  110630. private _onended;
  110631. /**
  110632. * Stop the sound
  110633. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110634. */
  110635. stop(time?: number): void;
  110636. /**
  110637. * Put the sound in pause
  110638. */
  110639. pause(): void;
  110640. /**
  110641. * Sets a dedicated volume for this sounds
  110642. * @param newVolume Define the new volume of the sound
  110643. * @param time Define time for gradual change to new volume
  110644. */
  110645. setVolume(newVolume: number, time?: number): void;
  110646. /**
  110647. * Set the sound play back rate
  110648. * @param newPlaybackRate Define the playback rate the sound should be played at
  110649. */
  110650. setPlaybackRate(newPlaybackRate: number): void;
  110651. /**
  110652. * Gets the volume of the sound.
  110653. * @returns the volume of the sound
  110654. */
  110655. getVolume(): number;
  110656. /**
  110657. * Attach the sound to a dedicated mesh
  110658. * @param transformNode The transform node to connect the sound with
  110659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110660. */
  110661. attachToMesh(transformNode: TransformNode): void;
  110662. /**
  110663. * Detach the sound from the previously attached mesh
  110664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110665. */
  110666. detachFromMesh(): void;
  110667. private _onRegisterAfterWorldMatrixUpdate;
  110668. /**
  110669. * Clone the current sound in the scene.
  110670. * @returns the new sound clone
  110671. */
  110672. clone(): Nullable<Sound>;
  110673. /**
  110674. * Gets the current underlying audio buffer containing the data
  110675. * @returns the audio buffer
  110676. */
  110677. getAudioBuffer(): Nullable<AudioBuffer>;
  110678. /**
  110679. * Serializes the Sound in a JSON representation
  110680. * @returns the JSON representation of the sound
  110681. */
  110682. serialize(): any;
  110683. /**
  110684. * Parse a JSON representation of a sound to innstantiate in a given scene
  110685. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110686. * @param scene Define the scene the new parsed sound should be created in
  110687. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110688. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110689. * @returns the newly parsed sound
  110690. */
  110691. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110692. }
  110693. }
  110694. declare module BABYLON {
  110695. /**
  110696. * This defines an action helpful to play a defined sound on a triggered action.
  110697. */
  110698. export class PlaySoundAction extends Action {
  110699. private _sound;
  110700. /**
  110701. * Instantiate the action
  110702. * @param triggerOptions defines the trigger options
  110703. * @param sound defines the sound to play
  110704. * @param condition defines the trigger related conditions
  110705. */
  110706. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110707. /** @hidden */
  110708. _prepare(): void;
  110709. /**
  110710. * Execute the action and play the sound.
  110711. */
  110712. execute(): void;
  110713. /**
  110714. * Serializes the actions and its related information.
  110715. * @param parent defines the object to serialize in
  110716. * @returns the serialized object
  110717. */
  110718. serialize(parent: any): any;
  110719. }
  110720. /**
  110721. * This defines an action helpful to stop a defined sound on a triggered action.
  110722. */
  110723. export class StopSoundAction extends Action {
  110724. private _sound;
  110725. /**
  110726. * Instantiate the action
  110727. * @param triggerOptions defines the trigger options
  110728. * @param sound defines the sound to stop
  110729. * @param condition defines the trigger related conditions
  110730. */
  110731. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110732. /** @hidden */
  110733. _prepare(): void;
  110734. /**
  110735. * Execute the action and stop the sound.
  110736. */
  110737. execute(): void;
  110738. /**
  110739. * Serializes the actions and its related information.
  110740. * @param parent defines the object to serialize in
  110741. * @returns the serialized object
  110742. */
  110743. serialize(parent: any): any;
  110744. }
  110745. }
  110746. declare module BABYLON {
  110747. /**
  110748. * This defines an action responsible to change the value of a property
  110749. * by interpolating between its current value and the newly set one once triggered.
  110750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110751. */
  110752. export class InterpolateValueAction extends Action {
  110753. /**
  110754. * Defines the path of the property where the value should be interpolated
  110755. */
  110756. propertyPath: string;
  110757. /**
  110758. * Defines the target value at the end of the interpolation.
  110759. */
  110760. value: any;
  110761. /**
  110762. * Defines the time it will take for the property to interpolate to the value.
  110763. */
  110764. duration: number;
  110765. /**
  110766. * Defines if the other scene animations should be stopped when the action has been triggered
  110767. */
  110768. stopOtherAnimations?: boolean;
  110769. /**
  110770. * Defines a callback raised once the interpolation animation has been done.
  110771. */
  110772. onInterpolationDone?: () => void;
  110773. /**
  110774. * Observable triggered once the interpolation animation has been done.
  110775. */
  110776. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110777. private _target;
  110778. private _effectiveTarget;
  110779. private _property;
  110780. /**
  110781. * Instantiate the action
  110782. * @param triggerOptions defines the trigger options
  110783. * @param target defines the object containing the value to interpolate
  110784. * @param propertyPath defines the path to the property in the target object
  110785. * @param value defines the target value at the end of the interpolation
  110786. * @param duration deines the time it will take for the property to interpolate to the value.
  110787. * @param condition defines the trigger related conditions
  110788. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110789. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110790. */
  110791. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110792. /** @hidden */
  110793. _prepare(): void;
  110794. /**
  110795. * Execute the action starts the value interpolation.
  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. * Options allowed during the creation of a sound track.
  110809. */
  110810. export interface ISoundTrackOptions {
  110811. /**
  110812. * The volume the sound track should take during creation
  110813. */
  110814. volume?: number;
  110815. /**
  110816. * Define if the sound track is the main sound track of the scene
  110817. */
  110818. mainTrack?: boolean;
  110819. }
  110820. /**
  110821. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110822. * It will be also used in a future release to apply effects on a specific track.
  110823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110824. */
  110825. export class SoundTrack {
  110826. /**
  110827. * The unique identifier of the sound track in the scene.
  110828. */
  110829. id: number;
  110830. /**
  110831. * The list of sounds included in the sound track.
  110832. */
  110833. soundCollection: Array<Sound>;
  110834. private _outputAudioNode;
  110835. private _scene;
  110836. private _connectedAnalyser;
  110837. private _options;
  110838. private _isInitialized;
  110839. /**
  110840. * Creates a new sound track.
  110841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110842. * @param scene Define the scene the sound track belongs to
  110843. * @param options
  110844. */
  110845. constructor(scene: Scene, options?: ISoundTrackOptions);
  110846. private _initializeSoundTrackAudioGraph;
  110847. /**
  110848. * Release the sound track and its associated resources
  110849. */
  110850. dispose(): void;
  110851. /**
  110852. * Adds a sound to this sound track
  110853. * @param sound define the cound to add
  110854. * @ignoreNaming
  110855. */
  110856. AddSound(sound: Sound): void;
  110857. /**
  110858. * Removes a sound to this sound track
  110859. * @param sound define the cound to remove
  110860. * @ignoreNaming
  110861. */
  110862. RemoveSound(sound: Sound): void;
  110863. /**
  110864. * Set a global volume for the full sound track.
  110865. * @param newVolume Define the new volume of the sound track
  110866. */
  110867. setVolume(newVolume: number): void;
  110868. /**
  110869. * Switch the panning model to HRTF:
  110870. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110872. */
  110873. switchPanningModelToHRTF(): void;
  110874. /**
  110875. * Switch the panning model to Equal Power:
  110876. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110878. */
  110879. switchPanningModelToEqualPower(): void;
  110880. /**
  110881. * Connect the sound track to an audio analyser allowing some amazing
  110882. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110884. * @param analyser The analyser to connect to the engine
  110885. */
  110886. connectToAnalyser(analyser: Analyser): void;
  110887. }
  110888. }
  110889. declare module BABYLON {
  110890. interface AbstractScene {
  110891. /**
  110892. * The list of sounds used in the scene.
  110893. */
  110894. sounds: Nullable<Array<Sound>>;
  110895. }
  110896. interface Scene {
  110897. /**
  110898. * @hidden
  110899. * Backing field
  110900. */
  110901. _mainSoundTrack: SoundTrack;
  110902. /**
  110903. * The main sound track played by the scene.
  110904. * It cotains your primary collection of sounds.
  110905. */
  110906. mainSoundTrack: SoundTrack;
  110907. /**
  110908. * The list of sound tracks added to the scene
  110909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110910. */
  110911. soundTracks: Nullable<Array<SoundTrack>>;
  110912. /**
  110913. * Gets a sound using a given name
  110914. * @param name defines the name to search for
  110915. * @return the found sound or null if not found at all.
  110916. */
  110917. getSoundByName(name: string): Nullable<Sound>;
  110918. /**
  110919. * Gets or sets if audio support is enabled
  110920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110921. */
  110922. audioEnabled: boolean;
  110923. /**
  110924. * Gets or sets if audio will be output to headphones
  110925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110926. */
  110927. headphone: boolean;
  110928. /**
  110929. * Gets or sets custom audio listener position provider
  110930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110931. */
  110932. audioListenerPositionProvider: Nullable<() => Vector3>;
  110933. /**
  110934. * Gets or sets a refresh rate when using 3D audio positioning
  110935. */
  110936. audioPositioningRefreshRate: number;
  110937. }
  110938. /**
  110939. * Defines the sound scene component responsible to manage any sounds
  110940. * in a given scene.
  110941. */
  110942. export class AudioSceneComponent implements ISceneSerializableComponent {
  110943. /**
  110944. * The component name helpfull to identify the component in the list of scene components.
  110945. */
  110946. readonly name: string;
  110947. /**
  110948. * The scene the component belongs to.
  110949. */
  110950. scene: Scene;
  110951. private _audioEnabled;
  110952. /**
  110953. * Gets whether audio is enabled or not.
  110954. * Please use related enable/disable method to switch state.
  110955. */
  110956. get audioEnabled(): boolean;
  110957. private _headphone;
  110958. /**
  110959. * Gets whether audio is outputing to headphone or not.
  110960. * Please use the according Switch methods to change output.
  110961. */
  110962. get headphone(): boolean;
  110963. /**
  110964. * Gets or sets a refresh rate when using 3D audio positioning
  110965. */
  110966. audioPositioningRefreshRate: number;
  110967. private _audioListenerPositionProvider;
  110968. /**
  110969. * Gets the current audio listener position provider
  110970. */
  110971. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110972. /**
  110973. * Sets a custom listener position for all sounds in the scene
  110974. * By default, this is the position of the first active camera
  110975. */
  110976. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110977. /**
  110978. * Creates a new instance of the component for the given scene
  110979. * @param scene Defines the scene to register the component in
  110980. */
  110981. constructor(scene: Scene);
  110982. /**
  110983. * Registers the component in a given scene
  110984. */
  110985. register(): void;
  110986. /**
  110987. * Rebuilds the elements related to this component in case of
  110988. * context lost for instance.
  110989. */
  110990. rebuild(): void;
  110991. /**
  110992. * Serializes the component data to the specified json object
  110993. * @param serializationObject The object to serialize to
  110994. */
  110995. serialize(serializationObject: any): void;
  110996. /**
  110997. * Adds all the elements from the container to the scene
  110998. * @param container the container holding the elements
  110999. */
  111000. addFromContainer(container: AbstractScene): void;
  111001. /**
  111002. * Removes all the elements in the container from the scene
  111003. * @param container contains the elements to remove
  111004. * @param dispose if the removed element should be disposed (default: false)
  111005. */
  111006. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111007. /**
  111008. * Disposes the component and the associated ressources.
  111009. */
  111010. dispose(): void;
  111011. /**
  111012. * Disables audio in the associated scene.
  111013. */
  111014. disableAudio(): void;
  111015. /**
  111016. * Enables audio in the associated scene.
  111017. */
  111018. enableAudio(): void;
  111019. /**
  111020. * Switch audio to headphone output.
  111021. */
  111022. switchAudioModeForHeadphones(): void;
  111023. /**
  111024. * Switch audio to normal speakers.
  111025. */
  111026. switchAudioModeForNormalSpeakers(): void;
  111027. private _cachedCameraDirection;
  111028. private _cachedCameraPosition;
  111029. private _lastCheck;
  111030. private _afterRender;
  111031. }
  111032. }
  111033. declare module BABYLON {
  111034. /**
  111035. * Wraps one or more Sound objects and selects one with random weight for playback.
  111036. */
  111037. export class WeightedSound {
  111038. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111039. loop: boolean;
  111040. private _coneInnerAngle;
  111041. private _coneOuterAngle;
  111042. private _volume;
  111043. /** A Sound is currently playing. */
  111044. isPlaying: boolean;
  111045. /** A Sound is currently paused. */
  111046. isPaused: boolean;
  111047. private _sounds;
  111048. private _weights;
  111049. private _currentIndex?;
  111050. /**
  111051. * Creates a new WeightedSound from the list of sounds given.
  111052. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111053. * @param sounds Array of Sounds that will be selected from.
  111054. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111055. */
  111056. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111057. /**
  111058. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111059. */
  111060. get directionalConeInnerAngle(): number;
  111061. /**
  111062. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111063. */
  111064. set directionalConeInnerAngle(value: number);
  111065. /**
  111066. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111067. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111068. */
  111069. get directionalConeOuterAngle(): number;
  111070. /**
  111071. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111072. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111073. */
  111074. set directionalConeOuterAngle(value: number);
  111075. /**
  111076. * Playback volume.
  111077. */
  111078. get volume(): number;
  111079. /**
  111080. * Playback volume.
  111081. */
  111082. set volume(value: number);
  111083. private _onended;
  111084. /**
  111085. * Suspend playback
  111086. */
  111087. pause(): void;
  111088. /**
  111089. * Stop playback
  111090. */
  111091. stop(): void;
  111092. /**
  111093. * Start playback.
  111094. * @param startOffset Position the clip head at a specific time in seconds.
  111095. */
  111096. play(startOffset?: number): void;
  111097. }
  111098. }
  111099. declare module BABYLON {
  111100. /**
  111101. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111102. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111103. */
  111104. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111105. /**
  111106. * Gets the name of the behavior.
  111107. */
  111108. get name(): string;
  111109. /**
  111110. * The easing function used by animations
  111111. */
  111112. static EasingFunction: BackEase;
  111113. /**
  111114. * The easing mode used by animations
  111115. */
  111116. static EasingMode: number;
  111117. /**
  111118. * The duration of the animation, in milliseconds
  111119. */
  111120. transitionDuration: number;
  111121. /**
  111122. * Length of the distance animated by the transition when lower radius is reached
  111123. */
  111124. lowerRadiusTransitionRange: number;
  111125. /**
  111126. * Length of the distance animated by the transition when upper radius is reached
  111127. */
  111128. upperRadiusTransitionRange: number;
  111129. private _autoTransitionRange;
  111130. /**
  111131. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111132. */
  111133. get autoTransitionRange(): boolean;
  111134. /**
  111135. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111136. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111137. */
  111138. set autoTransitionRange(value: boolean);
  111139. private _attachedCamera;
  111140. private _onAfterCheckInputsObserver;
  111141. private _onMeshTargetChangedObserver;
  111142. /**
  111143. * Initializes the behavior.
  111144. */
  111145. init(): void;
  111146. /**
  111147. * Attaches the behavior to its arc rotate camera.
  111148. * @param camera Defines the camera to attach the behavior to
  111149. */
  111150. attach(camera: ArcRotateCamera): void;
  111151. /**
  111152. * Detaches the behavior from its current arc rotate camera.
  111153. */
  111154. detach(): void;
  111155. private _radiusIsAnimating;
  111156. private _radiusBounceTransition;
  111157. private _animatables;
  111158. private _cachedWheelPrecision;
  111159. /**
  111160. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111161. * @param radiusLimit The limit to check against.
  111162. * @return Bool to indicate if at limit.
  111163. */
  111164. private _isRadiusAtLimit;
  111165. /**
  111166. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111167. * @param radiusDelta The delta by which to animate to. Can be negative.
  111168. */
  111169. private _applyBoundRadiusAnimation;
  111170. /**
  111171. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111172. */
  111173. protected _clearAnimationLocks(): void;
  111174. /**
  111175. * Stops and removes all animations that have been applied to the camera
  111176. */
  111177. stopAllAnimations(): void;
  111178. }
  111179. }
  111180. declare module BABYLON {
  111181. /**
  111182. * 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.
  111183. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111184. */
  111185. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111186. /**
  111187. * Gets the name of the behavior.
  111188. */
  111189. get name(): string;
  111190. private _mode;
  111191. private _radiusScale;
  111192. private _positionScale;
  111193. private _defaultElevation;
  111194. private _elevationReturnTime;
  111195. private _elevationReturnWaitTime;
  111196. private _zoomStopsAnimation;
  111197. private _framingTime;
  111198. /**
  111199. * The easing function used by animations
  111200. */
  111201. static EasingFunction: ExponentialEase;
  111202. /**
  111203. * The easing mode used by animations
  111204. */
  111205. static EasingMode: number;
  111206. /**
  111207. * Sets the current mode used by the behavior
  111208. */
  111209. set mode(mode: number);
  111210. /**
  111211. * Gets current mode used by the behavior.
  111212. */
  111213. get mode(): number;
  111214. /**
  111215. * Sets the scale applied to the radius (1 by default)
  111216. */
  111217. set radiusScale(radius: number);
  111218. /**
  111219. * Gets the scale applied to the radius
  111220. */
  111221. get radiusScale(): number;
  111222. /**
  111223. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111224. */
  111225. set positionScale(scale: number);
  111226. /**
  111227. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111228. */
  111229. get positionScale(): number;
  111230. /**
  111231. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111232. * behaviour is triggered, in radians.
  111233. */
  111234. set defaultElevation(elevation: number);
  111235. /**
  111236. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111237. * behaviour is triggered, in radians.
  111238. */
  111239. get defaultElevation(): number;
  111240. /**
  111241. * Sets the time (in milliseconds) taken to return to the default beta position.
  111242. * Negative value indicates camera should not return to default.
  111243. */
  111244. set elevationReturnTime(speed: number);
  111245. /**
  111246. * Gets the time (in milliseconds) taken to return to the default beta position.
  111247. * Negative value indicates camera should not return to default.
  111248. */
  111249. get elevationReturnTime(): number;
  111250. /**
  111251. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111252. */
  111253. set elevationReturnWaitTime(time: number);
  111254. /**
  111255. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111256. */
  111257. get elevationReturnWaitTime(): number;
  111258. /**
  111259. * Sets the flag that indicates if user zooming should stop animation.
  111260. */
  111261. set zoomStopsAnimation(flag: boolean);
  111262. /**
  111263. * Gets the flag that indicates if user zooming should stop animation.
  111264. */
  111265. get zoomStopsAnimation(): boolean;
  111266. /**
  111267. * Sets the transition time when framing the mesh, in milliseconds
  111268. */
  111269. set framingTime(time: number);
  111270. /**
  111271. * Gets the transition time when framing the mesh, in milliseconds
  111272. */
  111273. get framingTime(): number;
  111274. /**
  111275. * Define if the behavior should automatically change the configured
  111276. * camera limits and sensibilities.
  111277. */
  111278. autoCorrectCameraLimitsAndSensibility: boolean;
  111279. private _onPrePointerObservableObserver;
  111280. private _onAfterCheckInputsObserver;
  111281. private _onMeshTargetChangedObserver;
  111282. private _attachedCamera;
  111283. private _isPointerDown;
  111284. private _lastInteractionTime;
  111285. /**
  111286. * Initializes the behavior.
  111287. */
  111288. init(): void;
  111289. /**
  111290. * Attaches the behavior to its arc rotate camera.
  111291. * @param camera Defines the camera to attach the behavior to
  111292. */
  111293. attach(camera: ArcRotateCamera): void;
  111294. /**
  111295. * Detaches the behavior from its current arc rotate camera.
  111296. */
  111297. detach(): void;
  111298. private _animatables;
  111299. private _betaIsAnimating;
  111300. private _betaTransition;
  111301. private _radiusTransition;
  111302. private _vectorTransition;
  111303. /**
  111304. * Targets the given mesh and updates zoom level accordingly.
  111305. * @param mesh The mesh to target.
  111306. * @param radius Optional. If a cached radius position already exists, overrides default.
  111307. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111308. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111309. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111310. */
  111311. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111312. /**
  111313. * Targets the given mesh with its children and updates zoom level accordingly.
  111314. * @param mesh The mesh to target.
  111315. * @param radius Optional. If a cached radius position already exists, overrides default.
  111316. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111317. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111318. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111319. */
  111320. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111321. /**
  111322. * Targets the given meshes with their children and updates zoom level accordingly.
  111323. * @param meshes The mesh to target.
  111324. * @param radius Optional. If a cached radius position already exists, overrides default.
  111325. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111326. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111327. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111328. */
  111329. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111330. /**
  111331. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111332. * @param minimumWorld Determines the smaller position of the bounding box extend
  111333. * @param maximumWorld Determines the bigger position of the bounding box extend
  111334. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111335. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111336. */
  111337. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111338. /**
  111339. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111340. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111341. * frustum width.
  111342. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111343. * to fully enclose the mesh in the viewing frustum.
  111344. */
  111345. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111346. /**
  111347. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111348. * is automatically returned to its default position (expected to be above ground plane).
  111349. */
  111350. private _maintainCameraAboveGround;
  111351. /**
  111352. * Returns the frustum slope based on the canvas ratio and camera FOV
  111353. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111354. */
  111355. private _getFrustumSlope;
  111356. /**
  111357. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111358. */
  111359. private _clearAnimationLocks;
  111360. /**
  111361. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111362. */
  111363. private _applyUserInteraction;
  111364. /**
  111365. * Stops and removes all animations that have been applied to the camera
  111366. */
  111367. stopAllAnimations(): void;
  111368. /**
  111369. * Gets a value indicating if the user is moving the camera
  111370. */
  111371. get isUserIsMoving(): boolean;
  111372. /**
  111373. * The camera can move all the way towards the mesh.
  111374. */
  111375. static IgnoreBoundsSizeMode: number;
  111376. /**
  111377. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111378. */
  111379. static FitFrustumSidesMode: number;
  111380. }
  111381. }
  111382. declare module BABYLON {
  111383. /**
  111384. * Base class for Camera Pointer Inputs.
  111385. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111386. * for example usage.
  111387. */
  111388. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111389. /**
  111390. * Defines the camera the input is attached to.
  111391. */
  111392. abstract camera: Camera;
  111393. /**
  111394. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111395. */
  111396. protected _altKey: boolean;
  111397. protected _ctrlKey: boolean;
  111398. protected _metaKey: boolean;
  111399. protected _shiftKey: boolean;
  111400. /**
  111401. * Which mouse buttons were pressed at time of last mouse event.
  111402. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111403. */
  111404. protected _buttonsPressed: number;
  111405. /**
  111406. * Defines the buttons associated with the input to handle camera move.
  111407. */
  111408. buttons: number[];
  111409. /**
  111410. * Attach the input controls to a specific dom element to get the input from.
  111411. * @param element Defines the element the controls should be listened from
  111412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111413. */
  111414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111415. /**
  111416. * Detach the current controls from the specified dom element.
  111417. * @param element Defines the element to stop listening the inputs from
  111418. */
  111419. detachControl(element: Nullable<HTMLElement>): void;
  111420. /**
  111421. * Gets the class name of the current input.
  111422. * @returns the class name
  111423. */
  111424. getClassName(): string;
  111425. /**
  111426. * Get the friendly name associated with the input class.
  111427. * @returns the input friendly name
  111428. */
  111429. getSimpleName(): string;
  111430. /**
  111431. * Called on pointer POINTERDOUBLETAP event.
  111432. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111433. */
  111434. protected onDoubleTap(type: string): void;
  111435. /**
  111436. * Called on pointer POINTERMOVE event if only a single touch is active.
  111437. * Override this method to provide functionality.
  111438. */
  111439. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111440. /**
  111441. * Called on pointer POINTERMOVE event if multiple touches are active.
  111442. * Override this method to provide functionality.
  111443. */
  111444. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111445. /**
  111446. * Called on JS contextmenu event.
  111447. * Override this method to provide functionality.
  111448. */
  111449. protected onContextMenu(evt: PointerEvent): void;
  111450. /**
  111451. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111452. * press.
  111453. * Override this method to provide functionality.
  111454. */
  111455. protected onButtonDown(evt: PointerEvent): void;
  111456. /**
  111457. * Called each time a new POINTERUP event occurs. Ie, for each button
  111458. * release.
  111459. * Override this method to provide functionality.
  111460. */
  111461. protected onButtonUp(evt: PointerEvent): void;
  111462. /**
  111463. * Called when window becomes inactive.
  111464. * Override this method to provide functionality.
  111465. */
  111466. protected onLostFocus(): void;
  111467. private _pointerInput;
  111468. private _observer;
  111469. private _onLostFocus;
  111470. private pointA;
  111471. private pointB;
  111472. }
  111473. }
  111474. declare module BABYLON {
  111475. /**
  111476. * Manage the pointers inputs to control an arc rotate camera.
  111477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111478. */
  111479. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111480. /**
  111481. * Defines the camera the input is attached to.
  111482. */
  111483. camera: ArcRotateCamera;
  111484. /**
  111485. * Gets the class name of the current input.
  111486. * @returns the class name
  111487. */
  111488. getClassName(): string;
  111489. /**
  111490. * Defines the buttons associated with the input to handle camera move.
  111491. */
  111492. buttons: number[];
  111493. /**
  111494. * Defines the pointer angular sensibility along the X axis or how fast is
  111495. * the camera rotating.
  111496. */
  111497. angularSensibilityX: number;
  111498. /**
  111499. * Defines the pointer angular sensibility along the Y axis or how fast is
  111500. * the camera rotating.
  111501. */
  111502. angularSensibilityY: number;
  111503. /**
  111504. * Defines the pointer pinch precision or how fast is the camera zooming.
  111505. */
  111506. pinchPrecision: number;
  111507. /**
  111508. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111509. * from 0.
  111510. * It defines the percentage of current camera.radius to use as delta when
  111511. * pinch zoom is used.
  111512. */
  111513. pinchDeltaPercentage: number;
  111514. /**
  111515. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111516. * that any object in the plane at the camera's target point will scale
  111517. * perfectly with finger motion.
  111518. * Overrides pinchDeltaPercentage and pinchPrecision.
  111519. */
  111520. useNaturalPinchZoom: boolean;
  111521. /**
  111522. * Defines the pointer panning sensibility or how fast is the camera moving.
  111523. */
  111524. panningSensibility: number;
  111525. /**
  111526. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111527. */
  111528. multiTouchPanning: boolean;
  111529. /**
  111530. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111531. * zoom (pinch) through multitouch.
  111532. */
  111533. multiTouchPanAndZoom: boolean;
  111534. /**
  111535. * Revers pinch action direction.
  111536. */
  111537. pinchInwards: boolean;
  111538. private _isPanClick;
  111539. private _twoFingerActivityCount;
  111540. private _isPinching;
  111541. /**
  111542. * Called on pointer POINTERMOVE event if only a single touch is active.
  111543. */
  111544. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111545. /**
  111546. * Called on pointer POINTERDOUBLETAP event.
  111547. */
  111548. protected onDoubleTap(type: string): void;
  111549. /**
  111550. * Called on pointer POINTERMOVE event if multiple touches are active.
  111551. */
  111552. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111553. /**
  111554. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111555. * press.
  111556. */
  111557. protected onButtonDown(evt: PointerEvent): void;
  111558. /**
  111559. * Called each time a new POINTERUP event occurs. Ie, for each button
  111560. * release.
  111561. */
  111562. protected onButtonUp(evt: PointerEvent): void;
  111563. /**
  111564. * Called when window becomes inactive.
  111565. */
  111566. protected onLostFocus(): void;
  111567. }
  111568. }
  111569. declare module BABYLON {
  111570. /**
  111571. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111573. */
  111574. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111575. /**
  111576. * Defines the camera the input is attached to.
  111577. */
  111578. camera: ArcRotateCamera;
  111579. /**
  111580. * Defines the list of key codes associated with the up action (increase alpha)
  111581. */
  111582. keysUp: number[];
  111583. /**
  111584. * Defines the list of key codes associated with the down action (decrease alpha)
  111585. */
  111586. keysDown: number[];
  111587. /**
  111588. * Defines the list of key codes associated with the left action (increase beta)
  111589. */
  111590. keysLeft: number[];
  111591. /**
  111592. * Defines the list of key codes associated with the right action (decrease beta)
  111593. */
  111594. keysRight: number[];
  111595. /**
  111596. * Defines the list of key codes associated with the reset action.
  111597. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111598. */
  111599. keysReset: number[];
  111600. /**
  111601. * Defines the panning sensibility of the inputs.
  111602. * (How fast is the camera panning)
  111603. */
  111604. panningSensibility: number;
  111605. /**
  111606. * Defines the zooming sensibility of the inputs.
  111607. * (How fast is the camera zooming)
  111608. */
  111609. zoomingSensibility: number;
  111610. /**
  111611. * Defines whether maintaining the alt key down switch the movement mode from
  111612. * orientation to zoom.
  111613. */
  111614. useAltToZoom: boolean;
  111615. /**
  111616. * Rotation speed of the camera
  111617. */
  111618. angularSpeed: number;
  111619. private _keys;
  111620. private _ctrlPressed;
  111621. private _altPressed;
  111622. private _onCanvasBlurObserver;
  111623. private _onKeyboardObserver;
  111624. private _engine;
  111625. private _scene;
  111626. /**
  111627. * Attach the input controls to a specific dom element to get the input from.
  111628. * @param element Defines the element the controls should be listened from
  111629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111630. */
  111631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111632. /**
  111633. * Detach the current controls from the specified dom element.
  111634. * @param element Defines the element to stop listening the inputs from
  111635. */
  111636. detachControl(element: Nullable<HTMLElement>): void;
  111637. /**
  111638. * Update the current camera state depending on the inputs that have been used this frame.
  111639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111640. */
  111641. checkInputs(): void;
  111642. /**
  111643. * Gets the class name of the current intput.
  111644. * @returns the class name
  111645. */
  111646. getClassName(): string;
  111647. /**
  111648. * Get the friendly name associated with the input class.
  111649. * @returns the input friendly name
  111650. */
  111651. getSimpleName(): string;
  111652. }
  111653. }
  111654. declare module BABYLON {
  111655. /**
  111656. * Manage the mouse wheel inputs to control an arc rotate camera.
  111657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111658. */
  111659. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111660. /**
  111661. * Defines the camera the input is attached to.
  111662. */
  111663. camera: ArcRotateCamera;
  111664. /**
  111665. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111666. */
  111667. wheelPrecision: number;
  111668. /**
  111669. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111670. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111671. */
  111672. wheelDeltaPercentage: number;
  111673. private _wheel;
  111674. private _observer;
  111675. private computeDeltaFromMouseWheelLegacyEvent;
  111676. /**
  111677. * Attach the input controls to a specific dom element to get the input from.
  111678. * @param element Defines the element the controls should be listened from
  111679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111680. */
  111681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111682. /**
  111683. * Detach the current controls from the specified dom element.
  111684. * @param element Defines the element to stop listening the inputs from
  111685. */
  111686. detachControl(element: Nullable<HTMLElement>): void;
  111687. /**
  111688. * Gets the class name of the current intput.
  111689. * @returns the class name
  111690. */
  111691. getClassName(): string;
  111692. /**
  111693. * Get the friendly name associated with the input class.
  111694. * @returns the input friendly name
  111695. */
  111696. getSimpleName(): string;
  111697. }
  111698. }
  111699. declare module BABYLON {
  111700. /**
  111701. * Default Inputs manager for the ArcRotateCamera.
  111702. * It groups all the default supported inputs for ease of use.
  111703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111704. */
  111705. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111706. /**
  111707. * Instantiates a new ArcRotateCameraInputsManager.
  111708. * @param camera Defines the camera the inputs belong to
  111709. */
  111710. constructor(camera: ArcRotateCamera);
  111711. /**
  111712. * Add mouse wheel input support to the input manager.
  111713. * @returns the current input manager
  111714. */
  111715. addMouseWheel(): ArcRotateCameraInputsManager;
  111716. /**
  111717. * Add pointers input support to the input manager.
  111718. * @returns the current input manager
  111719. */
  111720. addPointers(): ArcRotateCameraInputsManager;
  111721. /**
  111722. * Add keyboard input support to the input manager.
  111723. * @returns the current input manager
  111724. */
  111725. addKeyboard(): ArcRotateCameraInputsManager;
  111726. }
  111727. }
  111728. declare module BABYLON {
  111729. /**
  111730. * This represents an orbital type of camera.
  111731. *
  111732. * 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.
  111733. * 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.
  111734. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111735. */
  111736. export class ArcRotateCamera extends TargetCamera {
  111737. /**
  111738. * Defines the rotation angle of the camera along the longitudinal axis.
  111739. */
  111740. alpha: number;
  111741. /**
  111742. * Defines the rotation angle of the camera along the latitudinal axis.
  111743. */
  111744. beta: number;
  111745. /**
  111746. * Defines the radius of the camera from it s target point.
  111747. */
  111748. radius: number;
  111749. protected _target: Vector3;
  111750. protected _targetHost: Nullable<AbstractMesh>;
  111751. /**
  111752. * Defines the target point of the camera.
  111753. * The camera looks towards it form the radius distance.
  111754. */
  111755. get target(): Vector3;
  111756. set target(value: Vector3);
  111757. /**
  111758. * Define the current local position of the camera in the scene
  111759. */
  111760. get position(): Vector3;
  111761. set position(newPosition: Vector3);
  111762. protected _upVector: Vector3;
  111763. protected _upToYMatrix: Matrix;
  111764. protected _YToUpMatrix: Matrix;
  111765. /**
  111766. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111767. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111768. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111769. */
  111770. set upVector(vec: Vector3);
  111771. get upVector(): Vector3;
  111772. /**
  111773. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111774. */
  111775. setMatUp(): void;
  111776. /**
  111777. * Current inertia value on the longitudinal axis.
  111778. * The bigger this number the longer it will take for the camera to stop.
  111779. */
  111780. inertialAlphaOffset: number;
  111781. /**
  111782. * Current inertia value on the latitudinal axis.
  111783. * The bigger this number the longer it will take for the camera to stop.
  111784. */
  111785. inertialBetaOffset: number;
  111786. /**
  111787. * Current inertia value on the radius axis.
  111788. * The bigger this number the longer it will take for the camera to stop.
  111789. */
  111790. inertialRadiusOffset: number;
  111791. /**
  111792. * Minimum allowed angle on the longitudinal axis.
  111793. * This can help limiting how the Camera is able to move in the scene.
  111794. */
  111795. lowerAlphaLimit: Nullable<number>;
  111796. /**
  111797. * Maximum allowed angle on the longitudinal axis.
  111798. * This can help limiting how the Camera is able to move in the scene.
  111799. */
  111800. upperAlphaLimit: Nullable<number>;
  111801. /**
  111802. * Minimum allowed angle on the latitudinal axis.
  111803. * This can help limiting how the Camera is able to move in the scene.
  111804. */
  111805. lowerBetaLimit: number;
  111806. /**
  111807. * Maximum allowed angle on the latitudinal axis.
  111808. * This can help limiting how the Camera is able to move in the scene.
  111809. */
  111810. upperBetaLimit: number;
  111811. /**
  111812. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111813. * This can help limiting how the Camera is able to move in the scene.
  111814. */
  111815. lowerRadiusLimit: Nullable<number>;
  111816. /**
  111817. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111818. * This can help limiting how the Camera is able to move in the scene.
  111819. */
  111820. upperRadiusLimit: Nullable<number>;
  111821. /**
  111822. * Defines the current inertia value used during panning of the camera along the X axis.
  111823. */
  111824. inertialPanningX: number;
  111825. /**
  111826. * Defines the current inertia value used during panning of the camera along the Y axis.
  111827. */
  111828. inertialPanningY: number;
  111829. /**
  111830. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111831. * Basically if your fingers moves away from more than this distance you will be considered
  111832. * in pinch mode.
  111833. */
  111834. pinchToPanMaxDistance: number;
  111835. /**
  111836. * Defines the maximum distance the camera can pan.
  111837. * This could help keeping the cammera always in your scene.
  111838. */
  111839. panningDistanceLimit: Nullable<number>;
  111840. /**
  111841. * Defines the target of the camera before paning.
  111842. */
  111843. panningOriginTarget: Vector3;
  111844. /**
  111845. * Defines the value of the inertia used during panning.
  111846. * 0 would mean stop inertia and one would mean no decelleration at all.
  111847. */
  111848. panningInertia: number;
  111849. /**
  111850. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111851. */
  111852. get angularSensibilityX(): number;
  111853. set angularSensibilityX(value: number);
  111854. /**
  111855. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111856. */
  111857. get angularSensibilityY(): number;
  111858. set angularSensibilityY(value: number);
  111859. /**
  111860. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111861. */
  111862. get pinchPrecision(): number;
  111863. set pinchPrecision(value: number);
  111864. /**
  111865. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111866. * It will be used instead of pinchDeltaPrecision if different from 0.
  111867. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111868. */
  111869. get pinchDeltaPercentage(): number;
  111870. set pinchDeltaPercentage(value: number);
  111871. /**
  111872. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111873. * and pinch delta percentage.
  111874. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111875. * that any object in the plane at the camera's target point will scale
  111876. * perfectly with finger motion.
  111877. */
  111878. get useNaturalPinchZoom(): boolean;
  111879. set useNaturalPinchZoom(value: boolean);
  111880. /**
  111881. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111882. */
  111883. get panningSensibility(): number;
  111884. set panningSensibility(value: number);
  111885. /**
  111886. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111887. */
  111888. get keysUp(): number[];
  111889. set keysUp(value: number[]);
  111890. /**
  111891. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111892. */
  111893. get keysDown(): number[];
  111894. set keysDown(value: number[]);
  111895. /**
  111896. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111897. */
  111898. get keysLeft(): number[];
  111899. set keysLeft(value: number[]);
  111900. /**
  111901. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111902. */
  111903. get keysRight(): number[];
  111904. set keysRight(value: number[]);
  111905. /**
  111906. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111907. */
  111908. get wheelPrecision(): number;
  111909. set wheelPrecision(value: number);
  111910. /**
  111911. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111912. * It will be used instead of pinchDeltaPrecision if different from 0.
  111913. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111914. */
  111915. get wheelDeltaPercentage(): number;
  111916. set wheelDeltaPercentage(value: number);
  111917. /**
  111918. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111919. */
  111920. zoomOnFactor: number;
  111921. /**
  111922. * Defines a screen offset for the camera position.
  111923. */
  111924. targetScreenOffset: Vector2;
  111925. /**
  111926. * Allows the camera to be completely reversed.
  111927. * If false the camera can not arrive upside down.
  111928. */
  111929. allowUpsideDown: boolean;
  111930. /**
  111931. * Define if double tap/click is used to restore the previously saved state of the camera.
  111932. */
  111933. useInputToRestoreState: boolean;
  111934. /** @hidden */
  111935. _viewMatrix: Matrix;
  111936. /** @hidden */
  111937. _useCtrlForPanning: boolean;
  111938. /** @hidden */
  111939. _panningMouseButton: number;
  111940. /**
  111941. * Defines the input associated to the camera.
  111942. */
  111943. inputs: ArcRotateCameraInputsManager;
  111944. /** @hidden */
  111945. _reset: () => void;
  111946. /**
  111947. * Defines the allowed panning axis.
  111948. */
  111949. panningAxis: Vector3;
  111950. protected _localDirection: Vector3;
  111951. protected _transformedDirection: Vector3;
  111952. private _bouncingBehavior;
  111953. /**
  111954. * Gets the bouncing behavior of the camera if it has been enabled.
  111955. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111956. */
  111957. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111958. /**
  111959. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111960. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111961. */
  111962. get useBouncingBehavior(): boolean;
  111963. set useBouncingBehavior(value: boolean);
  111964. private _framingBehavior;
  111965. /**
  111966. * Gets the framing behavior of the camera if it has been enabled.
  111967. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111968. */
  111969. get framingBehavior(): Nullable<FramingBehavior>;
  111970. /**
  111971. * Defines if the framing behavior of the camera is enabled on the camera.
  111972. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111973. */
  111974. get useFramingBehavior(): boolean;
  111975. set useFramingBehavior(value: boolean);
  111976. private _autoRotationBehavior;
  111977. /**
  111978. * Gets the auto rotation behavior of the camera if it has been enabled.
  111979. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111980. */
  111981. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111982. /**
  111983. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111984. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111985. */
  111986. get useAutoRotationBehavior(): boolean;
  111987. set useAutoRotationBehavior(value: boolean);
  111988. /**
  111989. * Observable triggered when the mesh target has been changed on the camera.
  111990. */
  111991. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111992. /**
  111993. * Event raised when the camera is colliding with a mesh.
  111994. */
  111995. onCollide: (collidedMesh: AbstractMesh) => void;
  111996. /**
  111997. * Defines whether the camera should check collision with the objects oh the scene.
  111998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111999. */
  112000. checkCollisions: boolean;
  112001. /**
  112002. * Defines the collision radius of the camera.
  112003. * This simulates a sphere around the camera.
  112004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112005. */
  112006. collisionRadius: Vector3;
  112007. protected _collider: Collider;
  112008. protected _previousPosition: Vector3;
  112009. protected _collisionVelocity: Vector3;
  112010. protected _newPosition: Vector3;
  112011. protected _previousAlpha: number;
  112012. protected _previousBeta: number;
  112013. protected _previousRadius: number;
  112014. protected _collisionTriggered: boolean;
  112015. protected _targetBoundingCenter: Nullable<Vector3>;
  112016. private _computationVector;
  112017. /**
  112018. * Instantiates a new ArcRotateCamera in a given scene
  112019. * @param name Defines the name of the camera
  112020. * @param alpha Defines the camera rotation along the logitudinal axis
  112021. * @param beta Defines the camera rotation along the latitudinal axis
  112022. * @param radius Defines the camera distance from its target
  112023. * @param target Defines the camera target
  112024. * @param scene Defines the scene the camera belongs to
  112025. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112026. */
  112027. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112028. /** @hidden */
  112029. _initCache(): void;
  112030. /** @hidden */
  112031. _updateCache(ignoreParentClass?: boolean): void;
  112032. protected _getTargetPosition(): Vector3;
  112033. private _storedAlpha;
  112034. private _storedBeta;
  112035. private _storedRadius;
  112036. private _storedTarget;
  112037. private _storedTargetScreenOffset;
  112038. /**
  112039. * Stores the current state of the camera (alpha, beta, radius and target)
  112040. * @returns the camera itself
  112041. */
  112042. storeState(): Camera;
  112043. /**
  112044. * @hidden
  112045. * Restored camera state. You must call storeState() first
  112046. */
  112047. _restoreStateValues(): boolean;
  112048. /** @hidden */
  112049. _isSynchronizedViewMatrix(): boolean;
  112050. /**
  112051. * Attached controls to the current camera.
  112052. * @param element Defines the element the controls should be listened from
  112053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112054. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112055. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112056. */
  112057. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112058. /**
  112059. * Detach the current controls from the camera.
  112060. * The camera will stop reacting to inputs.
  112061. * @param element Defines the element to stop listening the inputs from
  112062. */
  112063. detachControl(element: HTMLElement): void;
  112064. /** @hidden */
  112065. _checkInputs(): void;
  112066. protected _checkLimits(): void;
  112067. /**
  112068. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112069. */
  112070. rebuildAnglesAndRadius(): void;
  112071. /**
  112072. * Use a position to define the current camera related information like alpha, beta and radius
  112073. * @param position Defines the position to set the camera at
  112074. */
  112075. setPosition(position: Vector3): void;
  112076. /**
  112077. * Defines the target the camera should look at.
  112078. * This will automatically adapt alpha beta and radius to fit within the new target.
  112079. * @param target Defines the new target as a Vector or a mesh
  112080. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112081. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112082. */
  112083. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112084. /** @hidden */
  112085. _getViewMatrix(): Matrix;
  112086. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112087. /**
  112088. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112089. * @param meshes Defines the mesh to zoom on
  112090. * @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)
  112091. */
  112092. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112093. /**
  112094. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112095. * The target will be changed but the radius
  112096. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112097. * @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)
  112098. */
  112099. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112100. min: Vector3;
  112101. max: Vector3;
  112102. distance: number;
  112103. }, doNotUpdateMaxZ?: boolean): void;
  112104. /**
  112105. * @override
  112106. * Override Camera.createRigCamera
  112107. */
  112108. createRigCamera(name: string, cameraIndex: number): Camera;
  112109. /**
  112110. * @hidden
  112111. * @override
  112112. * Override Camera._updateRigCameras
  112113. */
  112114. _updateRigCameras(): void;
  112115. /**
  112116. * Destroy the camera and release the current resources hold by it.
  112117. */
  112118. dispose(): void;
  112119. /**
  112120. * Gets the current object class name.
  112121. * @return the class name
  112122. */
  112123. getClassName(): string;
  112124. }
  112125. }
  112126. declare module BABYLON {
  112127. /**
  112128. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112130. */
  112131. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112132. /**
  112133. * Gets the name of the behavior.
  112134. */
  112135. get name(): string;
  112136. private _zoomStopsAnimation;
  112137. private _idleRotationSpeed;
  112138. private _idleRotationWaitTime;
  112139. private _idleRotationSpinupTime;
  112140. /**
  112141. * Sets the flag that indicates if user zooming should stop animation.
  112142. */
  112143. set zoomStopsAnimation(flag: boolean);
  112144. /**
  112145. * Gets the flag that indicates if user zooming should stop animation.
  112146. */
  112147. get zoomStopsAnimation(): boolean;
  112148. /**
  112149. * Sets the default speed at which the camera rotates around the model.
  112150. */
  112151. set idleRotationSpeed(speed: number);
  112152. /**
  112153. * Gets the default speed at which the camera rotates around the model.
  112154. */
  112155. get idleRotationSpeed(): number;
  112156. /**
  112157. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112158. */
  112159. set idleRotationWaitTime(time: number);
  112160. /**
  112161. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112162. */
  112163. get idleRotationWaitTime(): number;
  112164. /**
  112165. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112166. */
  112167. set idleRotationSpinupTime(time: number);
  112168. /**
  112169. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112170. */
  112171. get idleRotationSpinupTime(): number;
  112172. /**
  112173. * Gets a value indicating if the camera is currently rotating because of this behavior
  112174. */
  112175. get rotationInProgress(): boolean;
  112176. private _onPrePointerObservableObserver;
  112177. private _onAfterCheckInputsObserver;
  112178. private _attachedCamera;
  112179. private _isPointerDown;
  112180. private _lastFrameTime;
  112181. private _lastInteractionTime;
  112182. private _cameraRotationSpeed;
  112183. /**
  112184. * Initializes the behavior.
  112185. */
  112186. init(): void;
  112187. /**
  112188. * Attaches the behavior to its arc rotate camera.
  112189. * @param camera Defines the camera to attach the behavior to
  112190. */
  112191. attach(camera: ArcRotateCamera): void;
  112192. /**
  112193. * Detaches the behavior from its current arc rotate camera.
  112194. */
  112195. detach(): void;
  112196. /**
  112197. * Returns true if user is scrolling.
  112198. * @return true if user is scrolling.
  112199. */
  112200. private _userIsZooming;
  112201. private _lastFrameRadius;
  112202. private _shouldAnimationStopForInteraction;
  112203. /**
  112204. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112205. */
  112206. private _applyUserInteraction;
  112207. private _userIsMoving;
  112208. }
  112209. }
  112210. declare module BABYLON {
  112211. /**
  112212. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112213. */
  112214. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112215. private ui;
  112216. /**
  112217. * The name of the behavior
  112218. */
  112219. name: string;
  112220. /**
  112221. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112222. */
  112223. distanceAwayFromFace: number;
  112224. /**
  112225. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112226. */
  112227. distanceAwayFromBottomOfFace: number;
  112228. private _faceVectors;
  112229. private _target;
  112230. private _scene;
  112231. private _onRenderObserver;
  112232. private _tmpMatrix;
  112233. private _tmpVector;
  112234. /**
  112235. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112236. * @param ui The transform node that should be attched to the mesh
  112237. */
  112238. constructor(ui: TransformNode);
  112239. /**
  112240. * Initializes the behavior
  112241. */
  112242. init(): void;
  112243. private _closestFace;
  112244. private _zeroVector;
  112245. private _lookAtTmpMatrix;
  112246. private _lookAtToRef;
  112247. /**
  112248. * Attaches the AttachToBoxBehavior to the passed in mesh
  112249. * @param target The mesh that the specified node will be attached to
  112250. */
  112251. attach(target: Mesh): void;
  112252. /**
  112253. * Detaches the behavior from the mesh
  112254. */
  112255. detach(): void;
  112256. }
  112257. }
  112258. declare module BABYLON {
  112259. /**
  112260. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112261. */
  112262. export class FadeInOutBehavior implements Behavior<Mesh> {
  112263. /**
  112264. * Time in milliseconds to delay before fading in (Default: 0)
  112265. */
  112266. delay: number;
  112267. /**
  112268. * Time in milliseconds for the mesh to fade in (Default: 300)
  112269. */
  112270. fadeInTime: number;
  112271. private _millisecondsPerFrame;
  112272. private _hovered;
  112273. private _hoverValue;
  112274. private _ownerNode;
  112275. /**
  112276. * Instatiates the FadeInOutBehavior
  112277. */
  112278. constructor();
  112279. /**
  112280. * The name of the behavior
  112281. */
  112282. get name(): string;
  112283. /**
  112284. * Initializes the behavior
  112285. */
  112286. init(): void;
  112287. /**
  112288. * Attaches the fade behavior on the passed in mesh
  112289. * @param ownerNode The mesh that will be faded in/out once attached
  112290. */
  112291. attach(ownerNode: Mesh): void;
  112292. /**
  112293. * Detaches the behavior from the mesh
  112294. */
  112295. detach(): void;
  112296. /**
  112297. * Triggers the mesh to begin fading in or out
  112298. * @param value if the object should fade in or out (true to fade in)
  112299. */
  112300. fadeIn(value: boolean): void;
  112301. private _update;
  112302. private _setAllVisibility;
  112303. }
  112304. }
  112305. declare module BABYLON {
  112306. /**
  112307. * Class containing a set of static utilities functions for managing Pivots
  112308. * @hidden
  112309. */
  112310. export class PivotTools {
  112311. private static _PivotCached;
  112312. private static _OldPivotPoint;
  112313. private static _PivotTranslation;
  112314. private static _PivotTmpVector;
  112315. /** @hidden */
  112316. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112317. /** @hidden */
  112318. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112319. }
  112320. }
  112321. declare module BABYLON {
  112322. /**
  112323. * Class containing static functions to help procedurally build meshes
  112324. */
  112325. export class PlaneBuilder {
  112326. /**
  112327. * Creates a plane mesh
  112328. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112329. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112330. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112334. * @param name defines the name of the mesh
  112335. * @param options defines the options used to create the mesh
  112336. * @param scene defines the hosting scene
  112337. * @returns the plane mesh
  112338. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112339. */
  112340. static CreatePlane(name: string, options: {
  112341. size?: number;
  112342. width?: number;
  112343. height?: number;
  112344. sideOrientation?: number;
  112345. frontUVs?: Vector4;
  112346. backUVs?: Vector4;
  112347. updatable?: boolean;
  112348. sourcePlane?: Plane;
  112349. }, scene?: Nullable<Scene>): Mesh;
  112350. }
  112351. }
  112352. declare module BABYLON {
  112353. /**
  112354. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112355. */
  112356. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112357. private static _AnyMouseID;
  112358. /**
  112359. * Abstract mesh the behavior is set on
  112360. */
  112361. attachedNode: AbstractMesh;
  112362. private _dragPlane;
  112363. private _scene;
  112364. private _pointerObserver;
  112365. private _beforeRenderObserver;
  112366. private static _planeScene;
  112367. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112368. /**
  112369. * 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)
  112370. */
  112371. maxDragAngle: number;
  112372. /**
  112373. * @hidden
  112374. */
  112375. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112376. /**
  112377. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112378. */
  112379. currentDraggingPointerID: number;
  112380. /**
  112381. * The last position where the pointer hit the drag plane in world space
  112382. */
  112383. lastDragPosition: Vector3;
  112384. /**
  112385. * If the behavior is currently in a dragging state
  112386. */
  112387. dragging: boolean;
  112388. /**
  112389. * 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)
  112390. */
  112391. dragDeltaRatio: number;
  112392. /**
  112393. * If the drag plane orientation should be updated during the dragging (Default: true)
  112394. */
  112395. updateDragPlane: boolean;
  112396. private _debugMode;
  112397. private _moving;
  112398. /**
  112399. * Fires each time the attached mesh is dragged with the pointer
  112400. * * delta between last drag position and current drag position in world space
  112401. * * dragDistance along the drag axis
  112402. * * dragPlaneNormal normal of the current drag plane used during the drag
  112403. * * dragPlanePoint in world space where the drag intersects the drag plane
  112404. */
  112405. onDragObservable: Observable<{
  112406. delta: Vector3;
  112407. dragPlanePoint: Vector3;
  112408. dragPlaneNormal: Vector3;
  112409. dragDistance: number;
  112410. pointerId: number;
  112411. }>;
  112412. /**
  112413. * Fires each time a drag begins (eg. mouse down on mesh)
  112414. */
  112415. onDragStartObservable: Observable<{
  112416. dragPlanePoint: Vector3;
  112417. pointerId: number;
  112418. }>;
  112419. /**
  112420. * Fires each time a drag ends (eg. mouse release after drag)
  112421. */
  112422. onDragEndObservable: Observable<{
  112423. dragPlanePoint: Vector3;
  112424. pointerId: number;
  112425. }>;
  112426. /**
  112427. * If the attached mesh should be moved when dragged
  112428. */
  112429. moveAttached: boolean;
  112430. /**
  112431. * If the drag behavior will react to drag events (Default: true)
  112432. */
  112433. enabled: boolean;
  112434. /**
  112435. * If pointer events should start and release the drag (Default: true)
  112436. */
  112437. startAndReleaseDragOnPointerEvents: boolean;
  112438. /**
  112439. * If camera controls should be detached during the drag
  112440. */
  112441. detachCameraControls: boolean;
  112442. /**
  112443. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112444. */
  112445. useObjectOrientationForDragging: boolean;
  112446. private _options;
  112447. /**
  112448. * Gets the options used by the behavior
  112449. */
  112450. get options(): {
  112451. dragAxis?: Vector3;
  112452. dragPlaneNormal?: Vector3;
  112453. };
  112454. /**
  112455. * Sets the options used by the behavior
  112456. */
  112457. set options(options: {
  112458. dragAxis?: Vector3;
  112459. dragPlaneNormal?: Vector3;
  112460. });
  112461. /**
  112462. * Creates a pointer drag behavior that can be attached to a mesh
  112463. * @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)
  112464. */
  112465. constructor(options?: {
  112466. dragAxis?: Vector3;
  112467. dragPlaneNormal?: Vector3;
  112468. });
  112469. /**
  112470. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112471. */
  112472. validateDrag: (targetPosition: Vector3) => boolean;
  112473. /**
  112474. * The name of the behavior
  112475. */
  112476. get name(): string;
  112477. /**
  112478. * Initializes the behavior
  112479. */
  112480. init(): void;
  112481. private _tmpVector;
  112482. private _alternatePickedPoint;
  112483. private _worldDragAxis;
  112484. private _targetPosition;
  112485. private _attachedElement;
  112486. /**
  112487. * Attaches the drag behavior the passed in mesh
  112488. * @param ownerNode The mesh that will be dragged around once attached
  112489. * @param predicate Predicate to use for pick filtering
  112490. */
  112491. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112492. /**
  112493. * Force relase the drag action by code.
  112494. */
  112495. releaseDrag(): void;
  112496. private _startDragRay;
  112497. private _lastPointerRay;
  112498. /**
  112499. * Simulates the start of a pointer drag event on the behavior
  112500. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112501. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112502. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112503. */
  112504. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112505. private _startDrag;
  112506. private _dragDelta;
  112507. private _moveDrag;
  112508. private _pickWithRayOnDragPlane;
  112509. private _pointA;
  112510. private _pointB;
  112511. private _pointC;
  112512. private _lineA;
  112513. private _lineB;
  112514. private _localAxis;
  112515. private _lookAt;
  112516. private _updateDragPlanePosition;
  112517. /**
  112518. * Detaches the behavior from the mesh
  112519. */
  112520. detach(): void;
  112521. }
  112522. }
  112523. declare module BABYLON {
  112524. /**
  112525. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112526. */
  112527. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112528. private _dragBehaviorA;
  112529. private _dragBehaviorB;
  112530. private _startDistance;
  112531. private _initialScale;
  112532. private _targetScale;
  112533. private _ownerNode;
  112534. private _sceneRenderObserver;
  112535. /**
  112536. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112537. */
  112538. constructor();
  112539. /**
  112540. * The name of the behavior
  112541. */
  112542. get name(): string;
  112543. /**
  112544. * Initializes the behavior
  112545. */
  112546. init(): void;
  112547. private _getCurrentDistance;
  112548. /**
  112549. * Attaches the scale behavior the passed in mesh
  112550. * @param ownerNode The mesh that will be scaled around once attached
  112551. */
  112552. attach(ownerNode: Mesh): void;
  112553. /**
  112554. * Detaches the behavior from the mesh
  112555. */
  112556. detach(): void;
  112557. }
  112558. }
  112559. declare module BABYLON {
  112560. /**
  112561. * 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
  112562. */
  112563. export class SixDofDragBehavior implements Behavior<Mesh> {
  112564. private static _virtualScene;
  112565. private _ownerNode;
  112566. private _sceneRenderObserver;
  112567. private _scene;
  112568. private _targetPosition;
  112569. private _virtualOriginMesh;
  112570. private _virtualDragMesh;
  112571. private _pointerObserver;
  112572. private _moving;
  112573. private _startingOrientation;
  112574. /**
  112575. * 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)
  112576. */
  112577. private zDragFactor;
  112578. /**
  112579. * If the object should rotate to face the drag origin
  112580. */
  112581. rotateDraggedObject: boolean;
  112582. /**
  112583. * If the behavior is currently in a dragging state
  112584. */
  112585. dragging: boolean;
  112586. /**
  112587. * 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)
  112588. */
  112589. dragDeltaRatio: number;
  112590. /**
  112591. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112592. */
  112593. currentDraggingPointerID: number;
  112594. /**
  112595. * If camera controls should be detached during the drag
  112596. */
  112597. detachCameraControls: boolean;
  112598. /**
  112599. * Fires each time a drag starts
  112600. */
  112601. onDragStartObservable: Observable<{}>;
  112602. /**
  112603. * Fires each time a drag ends (eg. mouse release after drag)
  112604. */
  112605. onDragEndObservable: Observable<{}>;
  112606. /**
  112607. * 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
  112608. */
  112609. constructor();
  112610. /**
  112611. * The name of the behavior
  112612. */
  112613. get name(): string;
  112614. /**
  112615. * Initializes the behavior
  112616. */
  112617. init(): void;
  112618. /**
  112619. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112620. */
  112621. private get _pointerCamera();
  112622. /**
  112623. * Attaches the scale behavior the passed in mesh
  112624. * @param ownerNode The mesh that will be scaled around once attached
  112625. */
  112626. attach(ownerNode: Mesh): void;
  112627. /**
  112628. * Detaches the behavior from the mesh
  112629. */
  112630. detach(): void;
  112631. }
  112632. }
  112633. declare module BABYLON {
  112634. /**
  112635. * Class used to apply inverse kinematics to bones
  112636. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112637. */
  112638. export class BoneIKController {
  112639. private static _tmpVecs;
  112640. private static _tmpQuat;
  112641. private static _tmpMats;
  112642. /**
  112643. * Gets or sets the target mesh
  112644. */
  112645. targetMesh: AbstractMesh;
  112646. /** Gets or sets the mesh used as pole */
  112647. poleTargetMesh: AbstractMesh;
  112648. /**
  112649. * Gets or sets the bone used as pole
  112650. */
  112651. poleTargetBone: Nullable<Bone>;
  112652. /**
  112653. * Gets or sets the target position
  112654. */
  112655. targetPosition: Vector3;
  112656. /**
  112657. * Gets or sets the pole target position
  112658. */
  112659. poleTargetPosition: Vector3;
  112660. /**
  112661. * Gets or sets the pole target local offset
  112662. */
  112663. poleTargetLocalOffset: Vector3;
  112664. /**
  112665. * Gets or sets the pole angle
  112666. */
  112667. poleAngle: number;
  112668. /**
  112669. * Gets or sets the mesh associated with the controller
  112670. */
  112671. mesh: AbstractMesh;
  112672. /**
  112673. * 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)
  112674. */
  112675. slerpAmount: number;
  112676. private _bone1Quat;
  112677. private _bone1Mat;
  112678. private _bone2Ang;
  112679. private _bone1;
  112680. private _bone2;
  112681. private _bone1Length;
  112682. private _bone2Length;
  112683. private _maxAngle;
  112684. private _maxReach;
  112685. private _rightHandedSystem;
  112686. private _bendAxis;
  112687. private _slerping;
  112688. private _adjustRoll;
  112689. /**
  112690. * Gets or sets maximum allowed angle
  112691. */
  112692. get maxAngle(): number;
  112693. set maxAngle(value: number);
  112694. /**
  112695. * Creates a new BoneIKController
  112696. * @param mesh defines the mesh to control
  112697. * @param bone defines the bone to control
  112698. * @param options defines options to set up the controller
  112699. */
  112700. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112701. targetMesh?: AbstractMesh;
  112702. poleTargetMesh?: AbstractMesh;
  112703. poleTargetBone?: Bone;
  112704. poleTargetLocalOffset?: Vector3;
  112705. poleAngle?: number;
  112706. bendAxis?: Vector3;
  112707. maxAngle?: number;
  112708. slerpAmount?: number;
  112709. });
  112710. private _setMaxAngle;
  112711. /**
  112712. * Force the controller to update the bones
  112713. */
  112714. update(): void;
  112715. }
  112716. }
  112717. declare module BABYLON {
  112718. /**
  112719. * Class used to make a bone look toward a point in space
  112720. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112721. */
  112722. export class BoneLookController {
  112723. private static _tmpVecs;
  112724. private static _tmpQuat;
  112725. private static _tmpMats;
  112726. /**
  112727. * The target Vector3 that the bone will look at
  112728. */
  112729. target: Vector3;
  112730. /**
  112731. * The mesh that the bone is attached to
  112732. */
  112733. mesh: AbstractMesh;
  112734. /**
  112735. * The bone that will be looking to the target
  112736. */
  112737. bone: Bone;
  112738. /**
  112739. * The up axis of the coordinate system that is used when the bone is rotated
  112740. */
  112741. upAxis: Vector3;
  112742. /**
  112743. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112744. */
  112745. upAxisSpace: Space;
  112746. /**
  112747. * Used to make an adjustment to the yaw of the bone
  112748. */
  112749. adjustYaw: number;
  112750. /**
  112751. * Used to make an adjustment to the pitch of the bone
  112752. */
  112753. adjustPitch: number;
  112754. /**
  112755. * Used to make an adjustment to the roll of the bone
  112756. */
  112757. adjustRoll: number;
  112758. /**
  112759. * 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)
  112760. */
  112761. slerpAmount: number;
  112762. private _minYaw;
  112763. private _maxYaw;
  112764. private _minPitch;
  112765. private _maxPitch;
  112766. private _minYawSin;
  112767. private _minYawCos;
  112768. private _maxYawSin;
  112769. private _maxYawCos;
  112770. private _midYawConstraint;
  112771. private _minPitchTan;
  112772. private _maxPitchTan;
  112773. private _boneQuat;
  112774. private _slerping;
  112775. private _transformYawPitch;
  112776. private _transformYawPitchInv;
  112777. private _firstFrameSkipped;
  112778. private _yawRange;
  112779. private _fowardAxis;
  112780. /**
  112781. * Gets or sets the minimum yaw angle that the bone can look to
  112782. */
  112783. get minYaw(): number;
  112784. set minYaw(value: number);
  112785. /**
  112786. * Gets or sets the maximum yaw angle that the bone can look to
  112787. */
  112788. get maxYaw(): number;
  112789. set maxYaw(value: number);
  112790. /**
  112791. * Gets or sets the minimum pitch angle that the bone can look to
  112792. */
  112793. get minPitch(): number;
  112794. set minPitch(value: number);
  112795. /**
  112796. * Gets or sets the maximum pitch angle that the bone can look to
  112797. */
  112798. get maxPitch(): number;
  112799. set maxPitch(value: number);
  112800. /**
  112801. * Create a BoneLookController
  112802. * @param mesh the mesh that the bone belongs to
  112803. * @param bone the bone that will be looking to the target
  112804. * @param target the target Vector3 to look at
  112805. * @param options optional settings:
  112806. * * maxYaw: the maximum angle the bone will yaw to
  112807. * * minYaw: the minimum angle the bone will yaw to
  112808. * * maxPitch: the maximum angle the bone will pitch to
  112809. * * minPitch: the minimum angle the bone will yaw to
  112810. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112811. * * upAxis: the up axis of the coordinate system
  112812. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112813. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112814. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112815. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112816. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112817. * * adjustRoll: used to make an adjustment to the roll of the bone
  112818. **/
  112819. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112820. maxYaw?: number;
  112821. minYaw?: number;
  112822. maxPitch?: number;
  112823. minPitch?: number;
  112824. slerpAmount?: number;
  112825. upAxis?: Vector3;
  112826. upAxisSpace?: Space;
  112827. yawAxis?: Vector3;
  112828. pitchAxis?: Vector3;
  112829. adjustYaw?: number;
  112830. adjustPitch?: number;
  112831. adjustRoll?: number;
  112832. });
  112833. /**
  112834. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112835. */
  112836. update(): void;
  112837. private _getAngleDiff;
  112838. private _getAngleBetween;
  112839. private _isAngleBetween;
  112840. }
  112841. }
  112842. declare module BABYLON {
  112843. /**
  112844. * Manage the gamepad inputs to control an arc rotate camera.
  112845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112846. */
  112847. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112848. /**
  112849. * Defines the camera the input is attached to.
  112850. */
  112851. camera: ArcRotateCamera;
  112852. /**
  112853. * Defines the gamepad the input is gathering event from.
  112854. */
  112855. gamepad: Nullable<Gamepad>;
  112856. /**
  112857. * Defines the gamepad rotation sensiblity.
  112858. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112859. */
  112860. gamepadRotationSensibility: number;
  112861. /**
  112862. * Defines the gamepad move sensiblity.
  112863. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112864. */
  112865. gamepadMoveSensibility: number;
  112866. private _yAxisScale;
  112867. /**
  112868. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112869. */
  112870. get invertYAxis(): boolean;
  112871. set invertYAxis(value: boolean);
  112872. private _onGamepadConnectedObserver;
  112873. private _onGamepadDisconnectedObserver;
  112874. /**
  112875. * Attach the input controls to a specific dom element to get the input from.
  112876. * @param element Defines the element the controls should be listened from
  112877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112878. */
  112879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112880. /**
  112881. * Detach the current controls from the specified dom element.
  112882. * @param element Defines the element to stop listening the inputs from
  112883. */
  112884. detachControl(element: Nullable<HTMLElement>): void;
  112885. /**
  112886. * Update the current camera state depending on the inputs that have been used this frame.
  112887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112888. */
  112889. checkInputs(): void;
  112890. /**
  112891. * Gets the class name of the current intput.
  112892. * @returns the class name
  112893. */
  112894. getClassName(): string;
  112895. /**
  112896. * Get the friendly name associated with the input class.
  112897. * @returns the input friendly name
  112898. */
  112899. getSimpleName(): string;
  112900. }
  112901. }
  112902. declare module BABYLON {
  112903. interface ArcRotateCameraInputsManager {
  112904. /**
  112905. * Add orientation input support to the input manager.
  112906. * @returns the current input manager
  112907. */
  112908. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112909. }
  112910. /**
  112911. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112913. */
  112914. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112915. /**
  112916. * Defines the camera the input is attached to.
  112917. */
  112918. camera: ArcRotateCamera;
  112919. /**
  112920. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112921. */
  112922. alphaCorrection: number;
  112923. /**
  112924. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112925. */
  112926. gammaCorrection: number;
  112927. private _alpha;
  112928. private _gamma;
  112929. private _dirty;
  112930. private _deviceOrientationHandler;
  112931. /**
  112932. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112933. */
  112934. constructor();
  112935. /**
  112936. * Attach the input controls to a specific dom element to get the input from.
  112937. * @param element Defines the element the controls should be listened from
  112938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112939. */
  112940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112941. /** @hidden */
  112942. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112943. /**
  112944. * Update the current camera state depending on the inputs that have been used this frame.
  112945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112946. */
  112947. checkInputs(): void;
  112948. /**
  112949. * Detach the current controls from the specified dom element.
  112950. * @param element Defines the element to stop listening the inputs from
  112951. */
  112952. detachControl(element: Nullable<HTMLElement>): void;
  112953. /**
  112954. * Gets the class name of the current intput.
  112955. * @returns the class name
  112956. */
  112957. getClassName(): string;
  112958. /**
  112959. * Get the friendly name associated with the input class.
  112960. * @returns the input friendly name
  112961. */
  112962. getSimpleName(): string;
  112963. }
  112964. }
  112965. declare module BABYLON {
  112966. /**
  112967. * Listen to mouse events to control the camera.
  112968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112969. */
  112970. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112971. /**
  112972. * Defines the camera the input is attached to.
  112973. */
  112974. camera: FlyCamera;
  112975. /**
  112976. * Defines if touch is enabled. (Default is true.)
  112977. */
  112978. touchEnabled: boolean;
  112979. /**
  112980. * Defines the buttons associated with the input to handle camera rotation.
  112981. */
  112982. buttons: number[];
  112983. /**
  112984. * Assign buttons for Yaw control.
  112985. */
  112986. buttonsYaw: number[];
  112987. /**
  112988. * Assign buttons for Pitch control.
  112989. */
  112990. buttonsPitch: number[];
  112991. /**
  112992. * Assign buttons for Roll control.
  112993. */
  112994. buttonsRoll: number[];
  112995. /**
  112996. * Detect if any button is being pressed while mouse is moved.
  112997. * -1 = Mouse locked.
  112998. * 0 = Left button.
  112999. * 1 = Middle Button.
  113000. * 2 = Right Button.
  113001. */
  113002. activeButton: number;
  113003. /**
  113004. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113005. * Higher values reduce its sensitivity.
  113006. */
  113007. angularSensibility: number;
  113008. private _mousemoveCallback;
  113009. private _observer;
  113010. private _rollObserver;
  113011. private previousPosition;
  113012. private noPreventDefault;
  113013. private element;
  113014. /**
  113015. * Listen to mouse events to control the camera.
  113016. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113018. */
  113019. constructor(touchEnabled?: boolean);
  113020. /**
  113021. * Attach the mouse control to the HTML DOM element.
  113022. * @param element Defines the element that listens to the input events.
  113023. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113024. */
  113025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113026. /**
  113027. * Detach the current controls from the specified dom element.
  113028. * @param element Defines the element to stop listening the inputs from
  113029. */
  113030. detachControl(element: Nullable<HTMLElement>): void;
  113031. /**
  113032. * Gets the class name of the current input.
  113033. * @returns the class name.
  113034. */
  113035. getClassName(): string;
  113036. /**
  113037. * Get the friendly name associated with the input class.
  113038. * @returns the input's friendly name.
  113039. */
  113040. getSimpleName(): string;
  113041. private _pointerInput;
  113042. private _onMouseMove;
  113043. /**
  113044. * Rotate camera by mouse offset.
  113045. */
  113046. private rotateCamera;
  113047. }
  113048. }
  113049. declare module BABYLON {
  113050. /**
  113051. * Default Inputs manager for the FlyCamera.
  113052. * It groups all the default supported inputs for ease of use.
  113053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113054. */
  113055. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113056. /**
  113057. * Instantiates a new FlyCameraInputsManager.
  113058. * @param camera Defines the camera the inputs belong to.
  113059. */
  113060. constructor(camera: FlyCamera);
  113061. /**
  113062. * Add keyboard input support to the input manager.
  113063. * @returns the new FlyCameraKeyboardMoveInput().
  113064. */
  113065. addKeyboard(): FlyCameraInputsManager;
  113066. /**
  113067. * Add mouse input support to the input manager.
  113068. * @param touchEnabled Enable touch screen support.
  113069. * @returns the new FlyCameraMouseInput().
  113070. */
  113071. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113072. }
  113073. }
  113074. declare module BABYLON {
  113075. /**
  113076. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113077. * such as in a 3D Space Shooter or a Flight Simulator.
  113078. */
  113079. export class FlyCamera extends TargetCamera {
  113080. /**
  113081. * Define the collision ellipsoid of the camera.
  113082. * This is helpful for simulating a camera body, like a player's body.
  113083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113084. */
  113085. ellipsoid: Vector3;
  113086. /**
  113087. * Define an offset for the position of the ellipsoid around the camera.
  113088. * This can be helpful if the camera is attached away from the player's body center,
  113089. * such as at its head.
  113090. */
  113091. ellipsoidOffset: Vector3;
  113092. /**
  113093. * Enable or disable collisions of the camera with the rest of the scene objects.
  113094. */
  113095. checkCollisions: boolean;
  113096. /**
  113097. * Enable or disable gravity on the camera.
  113098. */
  113099. applyGravity: boolean;
  113100. /**
  113101. * Define the current direction the camera is moving to.
  113102. */
  113103. cameraDirection: Vector3;
  113104. /**
  113105. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113106. * This overrides and empties cameraRotation.
  113107. */
  113108. rotationQuaternion: Quaternion;
  113109. /**
  113110. * Track Roll to maintain the wanted Rolling when looking around.
  113111. */
  113112. _trackRoll: number;
  113113. /**
  113114. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113115. */
  113116. rollCorrect: number;
  113117. /**
  113118. * Mimic a banked turn, Rolling the camera when Yawing.
  113119. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113120. */
  113121. bankedTurn: boolean;
  113122. /**
  113123. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113124. */
  113125. bankedTurnLimit: number;
  113126. /**
  113127. * Value of 0 disables the banked Roll.
  113128. * Value of 1 is equal to the Yaw angle in radians.
  113129. */
  113130. bankedTurnMultiplier: number;
  113131. /**
  113132. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113133. */
  113134. inputs: FlyCameraInputsManager;
  113135. /**
  113136. * Gets the input sensibility for mouse input.
  113137. * Higher values reduce sensitivity.
  113138. */
  113139. get angularSensibility(): number;
  113140. /**
  113141. * Sets the input sensibility for a mouse input.
  113142. * Higher values reduce sensitivity.
  113143. */
  113144. set angularSensibility(value: number);
  113145. /**
  113146. * Get the keys for camera movement forward.
  113147. */
  113148. get keysForward(): number[];
  113149. /**
  113150. * Set the keys for camera movement forward.
  113151. */
  113152. set keysForward(value: number[]);
  113153. /**
  113154. * Get the keys for camera movement backward.
  113155. */
  113156. get keysBackward(): number[];
  113157. set keysBackward(value: number[]);
  113158. /**
  113159. * Get the keys for camera movement up.
  113160. */
  113161. get keysUp(): number[];
  113162. /**
  113163. * Set the keys for camera movement up.
  113164. */
  113165. set keysUp(value: number[]);
  113166. /**
  113167. * Get the keys for camera movement down.
  113168. */
  113169. get keysDown(): number[];
  113170. /**
  113171. * Set the keys for camera movement down.
  113172. */
  113173. set keysDown(value: number[]);
  113174. /**
  113175. * Get the keys for camera movement left.
  113176. */
  113177. get keysLeft(): number[];
  113178. /**
  113179. * Set the keys for camera movement left.
  113180. */
  113181. set keysLeft(value: number[]);
  113182. /**
  113183. * Set the keys for camera movement right.
  113184. */
  113185. get keysRight(): number[];
  113186. /**
  113187. * Set the keys for camera movement right.
  113188. */
  113189. set keysRight(value: number[]);
  113190. /**
  113191. * Event raised when the camera collides with a mesh in the scene.
  113192. */
  113193. onCollide: (collidedMesh: AbstractMesh) => void;
  113194. private _collider;
  113195. private _needMoveForGravity;
  113196. private _oldPosition;
  113197. private _diffPosition;
  113198. private _newPosition;
  113199. /** @hidden */
  113200. _localDirection: Vector3;
  113201. /** @hidden */
  113202. _transformedDirection: Vector3;
  113203. /**
  113204. * Instantiates a FlyCamera.
  113205. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113206. * such as in a 3D Space Shooter or a Flight Simulator.
  113207. * @param name Define the name of the camera in the scene.
  113208. * @param position Define the starting position of the camera in the scene.
  113209. * @param scene Define the scene the camera belongs to.
  113210. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113211. */
  113212. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113213. /**
  113214. * Attach a control to the HTML DOM element.
  113215. * @param element Defines the element that listens to the input events.
  113216. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113217. */
  113218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113219. /**
  113220. * Detach a control from the HTML DOM element.
  113221. * The camera will stop reacting to that input.
  113222. * @param element Defines the element that listens to the input events.
  113223. */
  113224. detachControl(element: HTMLElement): void;
  113225. private _collisionMask;
  113226. /**
  113227. * Get the mask that the camera ignores in collision events.
  113228. */
  113229. get collisionMask(): number;
  113230. /**
  113231. * Set the mask that the camera ignores in collision events.
  113232. */
  113233. set collisionMask(mask: number);
  113234. /** @hidden */
  113235. _collideWithWorld(displacement: Vector3): void;
  113236. /** @hidden */
  113237. private _onCollisionPositionChange;
  113238. /** @hidden */
  113239. _checkInputs(): void;
  113240. /** @hidden */
  113241. _decideIfNeedsToMove(): boolean;
  113242. /** @hidden */
  113243. _updatePosition(): void;
  113244. /**
  113245. * Restore the Roll to its target value at the rate specified.
  113246. * @param rate - Higher means slower restoring.
  113247. * @hidden
  113248. */
  113249. restoreRoll(rate: number): void;
  113250. /**
  113251. * Destroy the camera and release the current resources held by it.
  113252. */
  113253. dispose(): void;
  113254. /**
  113255. * Get the current object class name.
  113256. * @returns the class name.
  113257. */
  113258. getClassName(): string;
  113259. }
  113260. }
  113261. declare module BABYLON {
  113262. /**
  113263. * Listen to keyboard events to control the camera.
  113264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113265. */
  113266. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113267. /**
  113268. * Defines the camera the input is attached to.
  113269. */
  113270. camera: FlyCamera;
  113271. /**
  113272. * The list of keyboard keys used to control the forward move of the camera.
  113273. */
  113274. keysForward: number[];
  113275. /**
  113276. * The list of keyboard keys used to control the backward move of the camera.
  113277. */
  113278. keysBackward: number[];
  113279. /**
  113280. * The list of keyboard keys used to control the forward move of the camera.
  113281. */
  113282. keysUp: number[];
  113283. /**
  113284. * The list of keyboard keys used to control the backward move of the camera.
  113285. */
  113286. keysDown: number[];
  113287. /**
  113288. * The list of keyboard keys used to control the right strafe move of the camera.
  113289. */
  113290. keysRight: number[];
  113291. /**
  113292. * The list of keyboard keys used to control the left strafe move of the camera.
  113293. */
  113294. keysLeft: number[];
  113295. private _keys;
  113296. private _onCanvasBlurObserver;
  113297. private _onKeyboardObserver;
  113298. private _engine;
  113299. private _scene;
  113300. /**
  113301. * Attach the input controls to a specific dom element to get the input from.
  113302. * @param element Defines the element the controls should be listened from
  113303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113304. */
  113305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113306. /**
  113307. * Detach the current controls from the specified dom element.
  113308. * @param element Defines the element to stop listening the inputs from
  113309. */
  113310. detachControl(element: Nullable<HTMLElement>): void;
  113311. /**
  113312. * Gets the class name of the current intput.
  113313. * @returns the class name
  113314. */
  113315. getClassName(): string;
  113316. /** @hidden */
  113317. _onLostFocus(e: FocusEvent): void;
  113318. /**
  113319. * Get the friendly name associated with the input class.
  113320. * @returns the input friendly name
  113321. */
  113322. getSimpleName(): string;
  113323. /**
  113324. * Update the current camera state depending on the inputs that have been used this frame.
  113325. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113326. */
  113327. checkInputs(): void;
  113328. }
  113329. }
  113330. declare module BABYLON {
  113331. /**
  113332. * Manage the mouse wheel inputs to control a follow camera.
  113333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113334. */
  113335. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113336. /**
  113337. * Defines the camera the input is attached to.
  113338. */
  113339. camera: FollowCamera;
  113340. /**
  113341. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113342. */
  113343. axisControlRadius: boolean;
  113344. /**
  113345. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113346. */
  113347. axisControlHeight: boolean;
  113348. /**
  113349. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113350. */
  113351. axisControlRotation: boolean;
  113352. /**
  113353. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113354. * relation to mouseWheel events.
  113355. */
  113356. wheelPrecision: number;
  113357. /**
  113358. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113359. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113360. */
  113361. wheelDeltaPercentage: number;
  113362. private _wheel;
  113363. private _observer;
  113364. /**
  113365. * Attach the input controls to a specific dom element to get the input from.
  113366. * @param element Defines the element the controls should be listened from
  113367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113368. */
  113369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113370. /**
  113371. * Detach the current controls from the specified dom element.
  113372. * @param element Defines the element to stop listening the inputs from
  113373. */
  113374. detachControl(element: Nullable<HTMLElement>): void;
  113375. /**
  113376. * Gets the class name of the current intput.
  113377. * @returns the class name
  113378. */
  113379. getClassName(): string;
  113380. /**
  113381. * Get the friendly name associated with the input class.
  113382. * @returns the input friendly name
  113383. */
  113384. getSimpleName(): string;
  113385. }
  113386. }
  113387. declare module BABYLON {
  113388. /**
  113389. * Manage the pointers inputs to control an follow camera.
  113390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113391. */
  113392. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113393. /**
  113394. * Defines the camera the input is attached to.
  113395. */
  113396. camera: FollowCamera;
  113397. /**
  113398. * Gets the class name of the current input.
  113399. * @returns the class name
  113400. */
  113401. getClassName(): string;
  113402. /**
  113403. * Defines the pointer angular sensibility along the X axis or how fast is
  113404. * the camera rotating.
  113405. * A negative number will reverse the axis direction.
  113406. */
  113407. angularSensibilityX: number;
  113408. /**
  113409. * Defines the pointer angular sensibility along the Y axis or how fast is
  113410. * the camera rotating.
  113411. * A negative number will reverse the axis direction.
  113412. */
  113413. angularSensibilityY: number;
  113414. /**
  113415. * Defines the pointer pinch precision or how fast is the camera zooming.
  113416. * A negative number will reverse the axis direction.
  113417. */
  113418. pinchPrecision: number;
  113419. /**
  113420. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113421. * from 0.
  113422. * It defines the percentage of current camera.radius to use as delta when
  113423. * pinch zoom is used.
  113424. */
  113425. pinchDeltaPercentage: number;
  113426. /**
  113427. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113428. */
  113429. axisXControlRadius: boolean;
  113430. /**
  113431. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113432. */
  113433. axisXControlHeight: boolean;
  113434. /**
  113435. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113436. */
  113437. axisXControlRotation: boolean;
  113438. /**
  113439. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113440. */
  113441. axisYControlRadius: boolean;
  113442. /**
  113443. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113444. */
  113445. axisYControlHeight: boolean;
  113446. /**
  113447. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113448. */
  113449. axisYControlRotation: boolean;
  113450. /**
  113451. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113452. */
  113453. axisPinchControlRadius: boolean;
  113454. /**
  113455. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113456. */
  113457. axisPinchControlHeight: boolean;
  113458. /**
  113459. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113460. */
  113461. axisPinchControlRotation: boolean;
  113462. /**
  113463. * Log error messages if basic misconfiguration has occurred.
  113464. */
  113465. warningEnable: boolean;
  113466. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113467. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113468. private _warningCounter;
  113469. private _warning;
  113470. }
  113471. }
  113472. declare module BABYLON {
  113473. /**
  113474. * Default Inputs manager for the FollowCamera.
  113475. * It groups all the default supported inputs for ease of use.
  113476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113477. */
  113478. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113479. /**
  113480. * Instantiates a new FollowCameraInputsManager.
  113481. * @param camera Defines the camera the inputs belong to
  113482. */
  113483. constructor(camera: FollowCamera);
  113484. /**
  113485. * Add keyboard input support to the input manager.
  113486. * @returns the current input manager
  113487. */
  113488. addKeyboard(): FollowCameraInputsManager;
  113489. /**
  113490. * Add mouse wheel input support to the input manager.
  113491. * @returns the current input manager
  113492. */
  113493. addMouseWheel(): FollowCameraInputsManager;
  113494. /**
  113495. * Add pointers input support to the input manager.
  113496. * @returns the current input manager
  113497. */
  113498. addPointers(): FollowCameraInputsManager;
  113499. /**
  113500. * Add orientation input support to the input manager.
  113501. * @returns the current input manager
  113502. */
  113503. addVRDeviceOrientation(): FollowCameraInputsManager;
  113504. }
  113505. }
  113506. declare module BABYLON {
  113507. /**
  113508. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113509. * an arc rotate version arcFollowCamera are available.
  113510. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113511. */
  113512. export class FollowCamera extends TargetCamera {
  113513. /**
  113514. * Distance the follow camera should follow an object at
  113515. */
  113516. radius: number;
  113517. /**
  113518. * Minimum allowed distance of the camera to the axis of rotation
  113519. * (The camera can not get closer).
  113520. * This can help limiting how the Camera is able to move in the scene.
  113521. */
  113522. lowerRadiusLimit: Nullable<number>;
  113523. /**
  113524. * Maximum allowed distance of the camera to the axis of rotation
  113525. * (The camera can not get further).
  113526. * This can help limiting how the Camera is able to move in the scene.
  113527. */
  113528. upperRadiusLimit: Nullable<number>;
  113529. /**
  113530. * Define a rotation offset between the camera and the object it follows
  113531. */
  113532. rotationOffset: number;
  113533. /**
  113534. * Minimum allowed angle to camera position relative to target object.
  113535. * This can help limiting how the Camera is able to move in the scene.
  113536. */
  113537. lowerRotationOffsetLimit: Nullable<number>;
  113538. /**
  113539. * Maximum allowed angle to camera position relative to target object.
  113540. * This can help limiting how the Camera is able to move in the scene.
  113541. */
  113542. upperRotationOffsetLimit: Nullable<number>;
  113543. /**
  113544. * Define a height offset between the camera and the object it follows.
  113545. * It can help following an object from the top (like a car chaing a plane)
  113546. */
  113547. heightOffset: number;
  113548. /**
  113549. * Minimum allowed height of camera position relative to target object.
  113550. * This can help limiting how the Camera is able to move in the scene.
  113551. */
  113552. lowerHeightOffsetLimit: Nullable<number>;
  113553. /**
  113554. * Maximum allowed height of camera position relative to target object.
  113555. * This can help limiting how the Camera is able to move in the scene.
  113556. */
  113557. upperHeightOffsetLimit: Nullable<number>;
  113558. /**
  113559. * Define how fast the camera can accelerate to follow it s target.
  113560. */
  113561. cameraAcceleration: number;
  113562. /**
  113563. * Define the speed limit of the camera following an object.
  113564. */
  113565. maxCameraSpeed: number;
  113566. /**
  113567. * Define the target of the camera.
  113568. */
  113569. lockedTarget: Nullable<AbstractMesh>;
  113570. /**
  113571. * Defines the input associated with the camera.
  113572. */
  113573. inputs: FollowCameraInputsManager;
  113574. /**
  113575. * Instantiates the follow camera.
  113576. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113577. * @param name Define the name of the camera in the scene
  113578. * @param position Define the position of the camera
  113579. * @param scene Define the scene the camera belong to
  113580. * @param lockedTarget Define the target of the camera
  113581. */
  113582. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113583. private _follow;
  113584. /**
  113585. * Attached controls to the current camera.
  113586. * @param element Defines the element the controls should be listened from
  113587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113588. */
  113589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113590. /**
  113591. * Detach the current controls from the camera.
  113592. * The camera will stop reacting to inputs.
  113593. * @param element Defines the element to stop listening the inputs from
  113594. */
  113595. detachControl(element: HTMLElement): void;
  113596. /** @hidden */
  113597. _checkInputs(): void;
  113598. private _checkLimits;
  113599. /**
  113600. * Gets the camera class name.
  113601. * @returns the class name
  113602. */
  113603. getClassName(): string;
  113604. }
  113605. /**
  113606. * Arc Rotate version of the follow camera.
  113607. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113608. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113609. */
  113610. export class ArcFollowCamera extends TargetCamera {
  113611. /** The longitudinal angle of the camera */
  113612. alpha: number;
  113613. /** The latitudinal angle of the camera */
  113614. beta: number;
  113615. /** The radius of the camera from its target */
  113616. radius: number;
  113617. /** Define the camera target (the messh it should follow) */
  113618. target: Nullable<AbstractMesh>;
  113619. private _cartesianCoordinates;
  113620. /**
  113621. * Instantiates a new ArcFollowCamera
  113622. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113623. * @param name Define the name of the camera
  113624. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113625. * @param beta Define the rotation angle of the camera around the elevation axis
  113626. * @param radius Define the radius of the camera from its target point
  113627. * @param target Define the target of the camera
  113628. * @param scene Define the scene the camera belongs to
  113629. */
  113630. constructor(name: string,
  113631. /** The longitudinal angle of the camera */
  113632. alpha: number,
  113633. /** The latitudinal angle of the camera */
  113634. beta: number,
  113635. /** The radius of the camera from its target */
  113636. radius: number,
  113637. /** Define the camera target (the messh it should follow) */
  113638. target: Nullable<AbstractMesh>, scene: Scene);
  113639. private _follow;
  113640. /** @hidden */
  113641. _checkInputs(): void;
  113642. /**
  113643. * Returns the class name of the object.
  113644. * It is mostly used internally for serialization purposes.
  113645. */
  113646. getClassName(): string;
  113647. }
  113648. }
  113649. declare module BABYLON {
  113650. /**
  113651. * Manage the keyboard inputs to control the movement of a follow camera.
  113652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113653. */
  113654. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113655. /**
  113656. * Defines the camera the input is attached to.
  113657. */
  113658. camera: FollowCamera;
  113659. /**
  113660. * Defines the list of key codes associated with the up action (increase heightOffset)
  113661. */
  113662. keysHeightOffsetIncr: number[];
  113663. /**
  113664. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113665. */
  113666. keysHeightOffsetDecr: number[];
  113667. /**
  113668. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113669. */
  113670. keysHeightOffsetModifierAlt: boolean;
  113671. /**
  113672. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113673. */
  113674. keysHeightOffsetModifierCtrl: boolean;
  113675. /**
  113676. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113677. */
  113678. keysHeightOffsetModifierShift: boolean;
  113679. /**
  113680. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113681. */
  113682. keysRotationOffsetIncr: number[];
  113683. /**
  113684. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113685. */
  113686. keysRotationOffsetDecr: number[];
  113687. /**
  113688. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113689. */
  113690. keysRotationOffsetModifierAlt: boolean;
  113691. /**
  113692. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113693. */
  113694. keysRotationOffsetModifierCtrl: boolean;
  113695. /**
  113696. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113697. */
  113698. keysRotationOffsetModifierShift: boolean;
  113699. /**
  113700. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113701. */
  113702. keysRadiusIncr: number[];
  113703. /**
  113704. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113705. */
  113706. keysRadiusDecr: number[];
  113707. /**
  113708. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113709. */
  113710. keysRadiusModifierAlt: boolean;
  113711. /**
  113712. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113713. */
  113714. keysRadiusModifierCtrl: boolean;
  113715. /**
  113716. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113717. */
  113718. keysRadiusModifierShift: boolean;
  113719. /**
  113720. * Defines the rate of change of heightOffset.
  113721. */
  113722. heightSensibility: number;
  113723. /**
  113724. * Defines the rate of change of rotationOffset.
  113725. */
  113726. rotationSensibility: number;
  113727. /**
  113728. * Defines the rate of change of radius.
  113729. */
  113730. radiusSensibility: number;
  113731. private _keys;
  113732. private _ctrlPressed;
  113733. private _altPressed;
  113734. private _shiftPressed;
  113735. private _onCanvasBlurObserver;
  113736. private _onKeyboardObserver;
  113737. private _engine;
  113738. private _scene;
  113739. /**
  113740. * Attach the input controls to a specific dom element to get the input from.
  113741. * @param element Defines the element the controls should be listened from
  113742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113743. */
  113744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113745. /**
  113746. * Detach the current controls from the specified dom element.
  113747. * @param element Defines the element to stop listening the inputs from
  113748. */
  113749. detachControl(element: Nullable<HTMLElement>): void;
  113750. /**
  113751. * Update the current camera state depending on the inputs that have been used this frame.
  113752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113753. */
  113754. checkInputs(): void;
  113755. /**
  113756. * Gets the class name of the current input.
  113757. * @returns the class name
  113758. */
  113759. getClassName(): string;
  113760. /**
  113761. * Get the friendly name associated with the input class.
  113762. * @returns the input friendly name
  113763. */
  113764. getSimpleName(): string;
  113765. /**
  113766. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113767. * allow modification of the heightOffset value.
  113768. */
  113769. private _modifierHeightOffset;
  113770. /**
  113771. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113772. * allow modification of the rotationOffset value.
  113773. */
  113774. private _modifierRotationOffset;
  113775. /**
  113776. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113777. * allow modification of the radius value.
  113778. */
  113779. private _modifierRadius;
  113780. }
  113781. }
  113782. declare module BABYLON {
  113783. interface FreeCameraInputsManager {
  113784. /**
  113785. * @hidden
  113786. */
  113787. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113788. /**
  113789. * Add orientation input support to the input manager.
  113790. * @returns the current input manager
  113791. */
  113792. addDeviceOrientation(): FreeCameraInputsManager;
  113793. }
  113794. /**
  113795. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113796. * Screen rotation is taken into account.
  113797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113798. */
  113799. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113800. private _camera;
  113801. private _screenOrientationAngle;
  113802. private _constantTranform;
  113803. private _screenQuaternion;
  113804. private _alpha;
  113805. private _beta;
  113806. private _gamma;
  113807. /**
  113808. * Can be used to detect if a device orientation sensor is available on a device
  113809. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113810. * @returns a promise that will resolve on orientation change
  113811. */
  113812. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113813. /**
  113814. * @hidden
  113815. */
  113816. _onDeviceOrientationChangedObservable: Observable<void>;
  113817. /**
  113818. * Instantiates a new input
  113819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113820. */
  113821. constructor();
  113822. /**
  113823. * Define the camera controlled by the input.
  113824. */
  113825. get camera(): FreeCamera;
  113826. set camera(camera: FreeCamera);
  113827. /**
  113828. * Attach the input controls to a specific dom element to get the input from.
  113829. * @param element Defines the element the controls should be listened from
  113830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113831. */
  113832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113833. private _orientationChanged;
  113834. private _deviceOrientation;
  113835. /**
  113836. * Detach the current controls from the specified dom element.
  113837. * @param element Defines the element to stop listening the inputs from
  113838. */
  113839. detachControl(element: Nullable<HTMLElement>): void;
  113840. /**
  113841. * Update the current camera state depending on the inputs that have been used this frame.
  113842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113843. */
  113844. checkInputs(): void;
  113845. /**
  113846. * Gets the class name of the current intput.
  113847. * @returns the class name
  113848. */
  113849. getClassName(): string;
  113850. /**
  113851. * Get the friendly name associated with the input class.
  113852. * @returns the input friendly name
  113853. */
  113854. getSimpleName(): string;
  113855. }
  113856. }
  113857. declare module BABYLON {
  113858. /**
  113859. * Manage the gamepad inputs to control a free camera.
  113860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113861. */
  113862. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113863. /**
  113864. * Define the camera the input is attached to.
  113865. */
  113866. camera: FreeCamera;
  113867. /**
  113868. * Define the Gamepad controlling the input
  113869. */
  113870. gamepad: Nullable<Gamepad>;
  113871. /**
  113872. * Defines the gamepad rotation sensiblity.
  113873. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113874. */
  113875. gamepadAngularSensibility: number;
  113876. /**
  113877. * Defines the gamepad move sensiblity.
  113878. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113879. */
  113880. gamepadMoveSensibility: number;
  113881. private _yAxisScale;
  113882. /**
  113883. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113884. */
  113885. get invertYAxis(): boolean;
  113886. set invertYAxis(value: boolean);
  113887. private _onGamepadConnectedObserver;
  113888. private _onGamepadDisconnectedObserver;
  113889. private _cameraTransform;
  113890. private _deltaTransform;
  113891. private _vector3;
  113892. private _vector2;
  113893. /**
  113894. * Attach the input controls to a specific dom element to get the input from.
  113895. * @param element Defines the element the controls should be listened from
  113896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113897. */
  113898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113899. /**
  113900. * Detach the current controls from the specified dom element.
  113901. * @param element Defines the element to stop listening the inputs from
  113902. */
  113903. detachControl(element: Nullable<HTMLElement>): void;
  113904. /**
  113905. * Update the current camera state depending on the inputs that have been used this frame.
  113906. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113907. */
  113908. checkInputs(): void;
  113909. /**
  113910. * Gets the class name of the current intput.
  113911. * @returns the class name
  113912. */
  113913. getClassName(): string;
  113914. /**
  113915. * Get the friendly name associated with the input class.
  113916. * @returns the input friendly name
  113917. */
  113918. getSimpleName(): string;
  113919. }
  113920. }
  113921. declare module BABYLON {
  113922. /**
  113923. * Defines the potential axis of a Joystick
  113924. */
  113925. export enum JoystickAxis {
  113926. /** X axis */
  113927. X = 0,
  113928. /** Y axis */
  113929. Y = 1,
  113930. /** Z axis */
  113931. Z = 2
  113932. }
  113933. /**
  113934. * Class used to define virtual joystick (used in touch mode)
  113935. */
  113936. export class VirtualJoystick {
  113937. /**
  113938. * Gets or sets a boolean indicating that left and right values must be inverted
  113939. */
  113940. reverseLeftRight: boolean;
  113941. /**
  113942. * Gets or sets a boolean indicating that up and down values must be inverted
  113943. */
  113944. reverseUpDown: boolean;
  113945. /**
  113946. * Gets the offset value for the position (ie. the change of the position value)
  113947. */
  113948. deltaPosition: Vector3;
  113949. /**
  113950. * Gets a boolean indicating if the virtual joystick was pressed
  113951. */
  113952. pressed: boolean;
  113953. /**
  113954. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113955. */
  113956. static Canvas: Nullable<HTMLCanvasElement>;
  113957. private static _globalJoystickIndex;
  113958. private static vjCanvasContext;
  113959. private static vjCanvasWidth;
  113960. private static vjCanvasHeight;
  113961. private static halfWidth;
  113962. private _action;
  113963. private _axisTargetedByLeftAndRight;
  113964. private _axisTargetedByUpAndDown;
  113965. private _joystickSensibility;
  113966. private _inversedSensibility;
  113967. private _joystickPointerID;
  113968. private _joystickColor;
  113969. private _joystickPointerPos;
  113970. private _joystickPreviousPointerPos;
  113971. private _joystickPointerStartPos;
  113972. private _deltaJoystickVector;
  113973. private _leftJoystick;
  113974. private _touches;
  113975. private _onPointerDownHandlerRef;
  113976. private _onPointerMoveHandlerRef;
  113977. private _onPointerUpHandlerRef;
  113978. private _onResize;
  113979. /**
  113980. * Creates a new virtual joystick
  113981. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113982. */
  113983. constructor(leftJoystick?: boolean);
  113984. /**
  113985. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113986. * @param newJoystickSensibility defines the new sensibility
  113987. */
  113988. setJoystickSensibility(newJoystickSensibility: number): void;
  113989. private _onPointerDown;
  113990. private _onPointerMove;
  113991. private _onPointerUp;
  113992. /**
  113993. * Change the color of the virtual joystick
  113994. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113995. */
  113996. setJoystickColor(newColor: string): void;
  113997. /**
  113998. * Defines a callback to call when the joystick is touched
  113999. * @param action defines the callback
  114000. */
  114001. setActionOnTouch(action: () => any): void;
  114002. /**
  114003. * Defines which axis you'd like to control for left & right
  114004. * @param axis defines the axis to use
  114005. */
  114006. setAxisForLeftRight(axis: JoystickAxis): void;
  114007. /**
  114008. * Defines which axis you'd like to control for up & down
  114009. * @param axis defines the axis to use
  114010. */
  114011. setAxisForUpDown(axis: JoystickAxis): void;
  114012. private _drawVirtualJoystick;
  114013. /**
  114014. * Release internal HTML canvas
  114015. */
  114016. releaseCanvas(): void;
  114017. }
  114018. }
  114019. declare module BABYLON {
  114020. interface FreeCameraInputsManager {
  114021. /**
  114022. * Add virtual joystick input support to the input manager.
  114023. * @returns the current input manager
  114024. */
  114025. addVirtualJoystick(): FreeCameraInputsManager;
  114026. }
  114027. /**
  114028. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114030. */
  114031. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114032. /**
  114033. * Defines the camera the input is attached to.
  114034. */
  114035. camera: FreeCamera;
  114036. private _leftjoystick;
  114037. private _rightjoystick;
  114038. /**
  114039. * Gets the left stick of the virtual joystick.
  114040. * @returns The virtual Joystick
  114041. */
  114042. getLeftJoystick(): VirtualJoystick;
  114043. /**
  114044. * Gets the right stick of the virtual joystick.
  114045. * @returns The virtual Joystick
  114046. */
  114047. getRightJoystick(): VirtualJoystick;
  114048. /**
  114049. * Update the current camera state depending on the inputs that have been used this frame.
  114050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114051. */
  114052. checkInputs(): void;
  114053. /**
  114054. * Attach the input controls to a specific dom element to get the input from.
  114055. * @param element Defines the element the controls should be listened from
  114056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114057. */
  114058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114059. /**
  114060. * Detach the current controls from the specified dom element.
  114061. * @param element Defines the element to stop listening the inputs from
  114062. */
  114063. detachControl(element: Nullable<HTMLElement>): void;
  114064. /**
  114065. * Gets the class name of the current intput.
  114066. * @returns the class name
  114067. */
  114068. getClassName(): string;
  114069. /**
  114070. * Get the friendly name associated with the input class.
  114071. * @returns the input friendly name
  114072. */
  114073. getSimpleName(): string;
  114074. }
  114075. }
  114076. declare module BABYLON {
  114077. /**
  114078. * This represents a FPS type of camera controlled by touch.
  114079. * This is like a universal camera minus the Gamepad controls.
  114080. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114081. */
  114082. export class TouchCamera extends FreeCamera {
  114083. /**
  114084. * Defines the touch sensibility for rotation.
  114085. * The higher the faster.
  114086. */
  114087. get touchAngularSensibility(): number;
  114088. set touchAngularSensibility(value: number);
  114089. /**
  114090. * Defines the touch sensibility for move.
  114091. * The higher the faster.
  114092. */
  114093. get touchMoveSensibility(): number;
  114094. set touchMoveSensibility(value: number);
  114095. /**
  114096. * Instantiates a new touch camera.
  114097. * This represents a FPS type of camera controlled by touch.
  114098. * This is like a universal camera minus the Gamepad controls.
  114099. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114100. * @param name Define the name of the camera in the scene
  114101. * @param position Define the start position of the camera in the scene
  114102. * @param scene Define the scene the camera belongs to
  114103. */
  114104. constructor(name: string, position: Vector3, scene: Scene);
  114105. /**
  114106. * Gets the current object class name.
  114107. * @return the class name
  114108. */
  114109. getClassName(): string;
  114110. /** @hidden */
  114111. _setupInputs(): void;
  114112. }
  114113. }
  114114. declare module BABYLON {
  114115. /**
  114116. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114117. * being tilted forward or back and left or right.
  114118. */
  114119. export class DeviceOrientationCamera extends FreeCamera {
  114120. private _initialQuaternion;
  114121. private _quaternionCache;
  114122. private _tmpDragQuaternion;
  114123. private _disablePointerInputWhenUsingDeviceOrientation;
  114124. /**
  114125. * Creates a new device orientation camera
  114126. * @param name The name of the camera
  114127. * @param position The start position camera
  114128. * @param scene The scene the camera belongs to
  114129. */
  114130. constructor(name: string, position: Vector3, scene: Scene);
  114131. /**
  114132. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114133. */
  114134. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114135. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114136. private _dragFactor;
  114137. /**
  114138. * Enabled turning on the y axis when the orientation sensor is active
  114139. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114140. */
  114141. enableHorizontalDragging(dragFactor?: number): void;
  114142. /**
  114143. * Gets the current instance class name ("DeviceOrientationCamera").
  114144. * This helps avoiding instanceof at run time.
  114145. * @returns the class name
  114146. */
  114147. getClassName(): string;
  114148. /**
  114149. * @hidden
  114150. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114151. */
  114152. _checkInputs(): void;
  114153. /**
  114154. * Reset the camera to its default orientation on the specified axis only.
  114155. * @param axis The axis to reset
  114156. */
  114157. resetToCurrentRotation(axis?: Axis): void;
  114158. }
  114159. }
  114160. declare module BABYLON {
  114161. /**
  114162. * Defines supported buttons for XBox360 compatible gamepads
  114163. */
  114164. export enum Xbox360Button {
  114165. /** A */
  114166. A = 0,
  114167. /** B */
  114168. B = 1,
  114169. /** X */
  114170. X = 2,
  114171. /** Y */
  114172. Y = 3,
  114173. /** Start */
  114174. Start = 4,
  114175. /** Back */
  114176. Back = 5,
  114177. /** Left button */
  114178. LB = 6,
  114179. /** Right button */
  114180. RB = 7,
  114181. /** Left stick */
  114182. LeftStick = 8,
  114183. /** Right stick */
  114184. RightStick = 9
  114185. }
  114186. /** Defines values for XBox360 DPad */
  114187. export enum Xbox360Dpad {
  114188. /** Up */
  114189. Up = 0,
  114190. /** Down */
  114191. Down = 1,
  114192. /** Left */
  114193. Left = 2,
  114194. /** Right */
  114195. Right = 3
  114196. }
  114197. /**
  114198. * Defines a XBox360 gamepad
  114199. */
  114200. export class Xbox360Pad extends Gamepad {
  114201. private _leftTrigger;
  114202. private _rightTrigger;
  114203. private _onlefttriggerchanged;
  114204. private _onrighttriggerchanged;
  114205. private _onbuttondown;
  114206. private _onbuttonup;
  114207. private _ondpaddown;
  114208. private _ondpadup;
  114209. /** Observable raised when a button is pressed */
  114210. onButtonDownObservable: Observable<Xbox360Button>;
  114211. /** Observable raised when a button is released */
  114212. onButtonUpObservable: Observable<Xbox360Button>;
  114213. /** Observable raised when a pad is pressed */
  114214. onPadDownObservable: Observable<Xbox360Dpad>;
  114215. /** Observable raised when a pad is released */
  114216. onPadUpObservable: Observable<Xbox360Dpad>;
  114217. private _buttonA;
  114218. private _buttonB;
  114219. private _buttonX;
  114220. private _buttonY;
  114221. private _buttonBack;
  114222. private _buttonStart;
  114223. private _buttonLB;
  114224. private _buttonRB;
  114225. private _buttonLeftStick;
  114226. private _buttonRightStick;
  114227. private _dPadUp;
  114228. private _dPadDown;
  114229. private _dPadLeft;
  114230. private _dPadRight;
  114231. private _isXboxOnePad;
  114232. /**
  114233. * Creates a new XBox360 gamepad object
  114234. * @param id defines the id of this gamepad
  114235. * @param index defines its index
  114236. * @param gamepad defines the internal HTML gamepad object
  114237. * @param xboxOne defines if it is a XBox One gamepad
  114238. */
  114239. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114240. /**
  114241. * Defines the callback to call when left trigger is pressed
  114242. * @param callback defines the callback to use
  114243. */
  114244. onlefttriggerchanged(callback: (value: number) => void): void;
  114245. /**
  114246. * Defines the callback to call when right trigger is pressed
  114247. * @param callback defines the callback to use
  114248. */
  114249. onrighttriggerchanged(callback: (value: number) => void): void;
  114250. /**
  114251. * Gets the left trigger value
  114252. */
  114253. get leftTrigger(): number;
  114254. /**
  114255. * Sets the left trigger value
  114256. */
  114257. set leftTrigger(newValue: number);
  114258. /**
  114259. * Gets the right trigger value
  114260. */
  114261. get rightTrigger(): number;
  114262. /**
  114263. * Sets the right trigger value
  114264. */
  114265. set rightTrigger(newValue: number);
  114266. /**
  114267. * Defines the callback to call when a button is pressed
  114268. * @param callback defines the callback to use
  114269. */
  114270. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114271. /**
  114272. * Defines the callback to call when a button is released
  114273. * @param callback defines the callback to use
  114274. */
  114275. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114276. /**
  114277. * Defines the callback to call when a pad is pressed
  114278. * @param callback defines the callback to use
  114279. */
  114280. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114281. /**
  114282. * Defines the callback to call when a pad is released
  114283. * @param callback defines the callback to use
  114284. */
  114285. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114286. private _setButtonValue;
  114287. private _setDPadValue;
  114288. /**
  114289. * Gets the value of the `A` button
  114290. */
  114291. get buttonA(): number;
  114292. /**
  114293. * Sets the value of the `A` button
  114294. */
  114295. set buttonA(value: number);
  114296. /**
  114297. * Gets the value of the `B` button
  114298. */
  114299. get buttonB(): number;
  114300. /**
  114301. * Sets the value of the `B` button
  114302. */
  114303. set buttonB(value: number);
  114304. /**
  114305. * Gets the value of the `X` button
  114306. */
  114307. get buttonX(): number;
  114308. /**
  114309. * Sets the value of the `X` button
  114310. */
  114311. set buttonX(value: number);
  114312. /**
  114313. * Gets the value of the `Y` button
  114314. */
  114315. get buttonY(): number;
  114316. /**
  114317. * Sets the value of the `Y` button
  114318. */
  114319. set buttonY(value: number);
  114320. /**
  114321. * Gets the value of the `Start` button
  114322. */
  114323. get buttonStart(): number;
  114324. /**
  114325. * Sets the value of the `Start` button
  114326. */
  114327. set buttonStart(value: number);
  114328. /**
  114329. * Gets the value of the `Back` button
  114330. */
  114331. get buttonBack(): number;
  114332. /**
  114333. * Sets the value of the `Back` button
  114334. */
  114335. set buttonBack(value: number);
  114336. /**
  114337. * Gets the value of the `Left` button
  114338. */
  114339. get buttonLB(): number;
  114340. /**
  114341. * Sets the value of the `Left` button
  114342. */
  114343. set buttonLB(value: number);
  114344. /**
  114345. * Gets the value of the `Right` button
  114346. */
  114347. get buttonRB(): number;
  114348. /**
  114349. * Sets the value of the `Right` button
  114350. */
  114351. set buttonRB(value: number);
  114352. /**
  114353. * Gets the value of the Left joystick
  114354. */
  114355. get buttonLeftStick(): number;
  114356. /**
  114357. * Sets the value of the Left joystick
  114358. */
  114359. set buttonLeftStick(value: number);
  114360. /**
  114361. * Gets the value of the Right joystick
  114362. */
  114363. get buttonRightStick(): number;
  114364. /**
  114365. * Sets the value of the Right joystick
  114366. */
  114367. set buttonRightStick(value: number);
  114368. /**
  114369. * Gets the value of D-pad up
  114370. */
  114371. get dPadUp(): number;
  114372. /**
  114373. * Sets the value of D-pad up
  114374. */
  114375. set dPadUp(value: number);
  114376. /**
  114377. * Gets the value of D-pad down
  114378. */
  114379. get dPadDown(): number;
  114380. /**
  114381. * Sets the value of D-pad down
  114382. */
  114383. set dPadDown(value: number);
  114384. /**
  114385. * Gets the value of D-pad left
  114386. */
  114387. get dPadLeft(): number;
  114388. /**
  114389. * Sets the value of D-pad left
  114390. */
  114391. set dPadLeft(value: number);
  114392. /**
  114393. * Gets the value of D-pad right
  114394. */
  114395. get dPadRight(): number;
  114396. /**
  114397. * Sets the value of D-pad right
  114398. */
  114399. set dPadRight(value: number);
  114400. /**
  114401. * Force the gamepad to synchronize with device values
  114402. */
  114403. update(): void;
  114404. /**
  114405. * Disposes the gamepad
  114406. */
  114407. dispose(): void;
  114408. }
  114409. }
  114410. declare module BABYLON {
  114411. /**
  114412. * Defines supported buttons for DualShock compatible gamepads
  114413. */
  114414. export enum DualShockButton {
  114415. /** Cross */
  114416. Cross = 0,
  114417. /** Circle */
  114418. Circle = 1,
  114419. /** Square */
  114420. Square = 2,
  114421. /** Triangle */
  114422. Triangle = 3,
  114423. /** Options */
  114424. Options = 4,
  114425. /** Share */
  114426. Share = 5,
  114427. /** L1 */
  114428. L1 = 6,
  114429. /** R1 */
  114430. R1 = 7,
  114431. /** Left stick */
  114432. LeftStick = 8,
  114433. /** Right stick */
  114434. RightStick = 9
  114435. }
  114436. /** Defines values for DualShock DPad */
  114437. export enum DualShockDpad {
  114438. /** Up */
  114439. Up = 0,
  114440. /** Down */
  114441. Down = 1,
  114442. /** Left */
  114443. Left = 2,
  114444. /** Right */
  114445. Right = 3
  114446. }
  114447. /**
  114448. * Defines a DualShock gamepad
  114449. */
  114450. export class DualShockPad extends Gamepad {
  114451. private _leftTrigger;
  114452. private _rightTrigger;
  114453. private _onlefttriggerchanged;
  114454. private _onrighttriggerchanged;
  114455. private _onbuttondown;
  114456. private _onbuttonup;
  114457. private _ondpaddown;
  114458. private _ondpadup;
  114459. /** Observable raised when a button is pressed */
  114460. onButtonDownObservable: Observable<DualShockButton>;
  114461. /** Observable raised when a button is released */
  114462. onButtonUpObservable: Observable<DualShockButton>;
  114463. /** Observable raised when a pad is pressed */
  114464. onPadDownObservable: Observable<DualShockDpad>;
  114465. /** Observable raised when a pad is released */
  114466. onPadUpObservable: Observable<DualShockDpad>;
  114467. private _buttonCross;
  114468. private _buttonCircle;
  114469. private _buttonSquare;
  114470. private _buttonTriangle;
  114471. private _buttonShare;
  114472. private _buttonOptions;
  114473. private _buttonL1;
  114474. private _buttonR1;
  114475. private _buttonLeftStick;
  114476. private _buttonRightStick;
  114477. private _dPadUp;
  114478. private _dPadDown;
  114479. private _dPadLeft;
  114480. private _dPadRight;
  114481. /**
  114482. * Creates a new DualShock gamepad object
  114483. * @param id defines the id of this gamepad
  114484. * @param index defines its index
  114485. * @param gamepad defines the internal HTML gamepad object
  114486. */
  114487. constructor(id: string, index: number, gamepad: any);
  114488. /**
  114489. * Defines the callback to call when left trigger is pressed
  114490. * @param callback defines the callback to use
  114491. */
  114492. onlefttriggerchanged(callback: (value: number) => void): void;
  114493. /**
  114494. * Defines the callback to call when right trigger is pressed
  114495. * @param callback defines the callback to use
  114496. */
  114497. onrighttriggerchanged(callback: (value: number) => void): void;
  114498. /**
  114499. * Gets the left trigger value
  114500. */
  114501. get leftTrigger(): number;
  114502. /**
  114503. * Sets the left trigger value
  114504. */
  114505. set leftTrigger(newValue: number);
  114506. /**
  114507. * Gets the right trigger value
  114508. */
  114509. get rightTrigger(): number;
  114510. /**
  114511. * Sets the right trigger value
  114512. */
  114513. set rightTrigger(newValue: number);
  114514. /**
  114515. * Defines the callback to call when a button is pressed
  114516. * @param callback defines the callback to use
  114517. */
  114518. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114519. /**
  114520. * Defines the callback to call when a button is released
  114521. * @param callback defines the callback to use
  114522. */
  114523. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114524. /**
  114525. * Defines the callback to call when a pad is pressed
  114526. * @param callback defines the callback to use
  114527. */
  114528. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114529. /**
  114530. * Defines the callback to call when a pad is released
  114531. * @param callback defines the callback to use
  114532. */
  114533. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114534. private _setButtonValue;
  114535. private _setDPadValue;
  114536. /**
  114537. * Gets the value of the `Cross` button
  114538. */
  114539. get buttonCross(): number;
  114540. /**
  114541. * Sets the value of the `Cross` button
  114542. */
  114543. set buttonCross(value: number);
  114544. /**
  114545. * Gets the value of the `Circle` button
  114546. */
  114547. get buttonCircle(): number;
  114548. /**
  114549. * Sets the value of the `Circle` button
  114550. */
  114551. set buttonCircle(value: number);
  114552. /**
  114553. * Gets the value of the `Square` button
  114554. */
  114555. get buttonSquare(): number;
  114556. /**
  114557. * Sets the value of the `Square` button
  114558. */
  114559. set buttonSquare(value: number);
  114560. /**
  114561. * Gets the value of the `Triangle` button
  114562. */
  114563. get buttonTriangle(): number;
  114564. /**
  114565. * Sets the value of the `Triangle` button
  114566. */
  114567. set buttonTriangle(value: number);
  114568. /**
  114569. * Gets the value of the `Options` button
  114570. */
  114571. get buttonOptions(): number;
  114572. /**
  114573. * Sets the value of the `Options` button
  114574. */
  114575. set buttonOptions(value: number);
  114576. /**
  114577. * Gets the value of the `Share` button
  114578. */
  114579. get buttonShare(): number;
  114580. /**
  114581. * Sets the value of the `Share` button
  114582. */
  114583. set buttonShare(value: number);
  114584. /**
  114585. * Gets the value of the `L1` button
  114586. */
  114587. get buttonL1(): number;
  114588. /**
  114589. * Sets the value of the `L1` button
  114590. */
  114591. set buttonL1(value: number);
  114592. /**
  114593. * Gets the value of the `R1` button
  114594. */
  114595. get buttonR1(): number;
  114596. /**
  114597. * Sets the value of the `R1` button
  114598. */
  114599. set buttonR1(value: number);
  114600. /**
  114601. * Gets the value of the Left joystick
  114602. */
  114603. get buttonLeftStick(): number;
  114604. /**
  114605. * Sets the value of the Left joystick
  114606. */
  114607. set buttonLeftStick(value: number);
  114608. /**
  114609. * Gets the value of the Right joystick
  114610. */
  114611. get buttonRightStick(): number;
  114612. /**
  114613. * Sets the value of the Right joystick
  114614. */
  114615. set buttonRightStick(value: number);
  114616. /**
  114617. * Gets the value of D-pad up
  114618. */
  114619. get dPadUp(): number;
  114620. /**
  114621. * Sets the value of D-pad up
  114622. */
  114623. set dPadUp(value: number);
  114624. /**
  114625. * Gets the value of D-pad down
  114626. */
  114627. get dPadDown(): number;
  114628. /**
  114629. * Sets the value of D-pad down
  114630. */
  114631. set dPadDown(value: number);
  114632. /**
  114633. * Gets the value of D-pad left
  114634. */
  114635. get dPadLeft(): number;
  114636. /**
  114637. * Sets the value of D-pad left
  114638. */
  114639. set dPadLeft(value: number);
  114640. /**
  114641. * Gets the value of D-pad right
  114642. */
  114643. get dPadRight(): number;
  114644. /**
  114645. * Sets the value of D-pad right
  114646. */
  114647. set dPadRight(value: number);
  114648. /**
  114649. * Force the gamepad to synchronize with device values
  114650. */
  114651. update(): void;
  114652. /**
  114653. * Disposes the gamepad
  114654. */
  114655. dispose(): void;
  114656. }
  114657. }
  114658. declare module BABYLON {
  114659. /**
  114660. * Manager for handling gamepads
  114661. */
  114662. export class GamepadManager {
  114663. private _scene?;
  114664. private _babylonGamepads;
  114665. private _oneGamepadConnected;
  114666. /** @hidden */
  114667. _isMonitoring: boolean;
  114668. private _gamepadEventSupported;
  114669. private _gamepadSupport?;
  114670. /**
  114671. * observable to be triggered when the gamepad controller has been connected
  114672. */
  114673. onGamepadConnectedObservable: Observable<Gamepad>;
  114674. /**
  114675. * observable to be triggered when the gamepad controller has been disconnected
  114676. */
  114677. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114678. private _onGamepadConnectedEvent;
  114679. private _onGamepadDisconnectedEvent;
  114680. /**
  114681. * Initializes the gamepad manager
  114682. * @param _scene BabylonJS scene
  114683. */
  114684. constructor(_scene?: Scene | undefined);
  114685. /**
  114686. * The gamepads in the game pad manager
  114687. */
  114688. get gamepads(): Gamepad[];
  114689. /**
  114690. * Get the gamepad controllers based on type
  114691. * @param type The type of gamepad controller
  114692. * @returns Nullable gamepad
  114693. */
  114694. getGamepadByType(type?: number): Nullable<Gamepad>;
  114695. /**
  114696. * Disposes the gamepad manager
  114697. */
  114698. dispose(): void;
  114699. private _addNewGamepad;
  114700. private _startMonitoringGamepads;
  114701. private _stopMonitoringGamepads;
  114702. /** @hidden */
  114703. _checkGamepadsStatus(): void;
  114704. private _updateGamepadObjects;
  114705. }
  114706. }
  114707. declare module BABYLON {
  114708. interface Scene {
  114709. /** @hidden */
  114710. _gamepadManager: Nullable<GamepadManager>;
  114711. /**
  114712. * Gets the gamepad manager associated with the scene
  114713. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114714. */
  114715. gamepadManager: GamepadManager;
  114716. }
  114717. /**
  114718. * Interface representing a free camera inputs manager
  114719. */
  114720. interface FreeCameraInputsManager {
  114721. /**
  114722. * Adds gamepad input support to the FreeCameraInputsManager.
  114723. * @returns the FreeCameraInputsManager
  114724. */
  114725. addGamepad(): FreeCameraInputsManager;
  114726. }
  114727. /**
  114728. * Interface representing an arc rotate camera inputs manager
  114729. */
  114730. interface ArcRotateCameraInputsManager {
  114731. /**
  114732. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114733. * @returns the camera inputs manager
  114734. */
  114735. addGamepad(): ArcRotateCameraInputsManager;
  114736. }
  114737. /**
  114738. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114739. */
  114740. export class GamepadSystemSceneComponent implements ISceneComponent {
  114741. /**
  114742. * The component name helpfull to identify the component in the list of scene components.
  114743. */
  114744. readonly name: string;
  114745. /**
  114746. * The scene the component belongs to.
  114747. */
  114748. scene: Scene;
  114749. /**
  114750. * Creates a new instance of the component for the given scene
  114751. * @param scene Defines the scene to register the component in
  114752. */
  114753. constructor(scene: Scene);
  114754. /**
  114755. * Registers the component in a given scene
  114756. */
  114757. register(): void;
  114758. /**
  114759. * Rebuilds the elements related to this component in case of
  114760. * context lost for instance.
  114761. */
  114762. rebuild(): void;
  114763. /**
  114764. * Disposes the component and the associated ressources
  114765. */
  114766. dispose(): void;
  114767. private _beforeCameraUpdate;
  114768. }
  114769. }
  114770. declare module BABYLON {
  114771. /**
  114772. * 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,
  114773. * which still works and will still be found in many Playgrounds.
  114774. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114775. */
  114776. export class UniversalCamera extends TouchCamera {
  114777. /**
  114778. * Defines the gamepad rotation sensiblity.
  114779. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114780. */
  114781. get gamepadAngularSensibility(): number;
  114782. set gamepadAngularSensibility(value: number);
  114783. /**
  114784. * Defines the gamepad move sensiblity.
  114785. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114786. */
  114787. get gamepadMoveSensibility(): number;
  114788. set gamepadMoveSensibility(value: number);
  114789. /**
  114790. * 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,
  114791. * which still works and will still be found in many Playgrounds.
  114792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114793. * @param name Define the name of the camera in the scene
  114794. * @param position Define the start position of the camera in the scene
  114795. * @param scene Define the scene the camera belongs to
  114796. */
  114797. constructor(name: string, position: Vector3, scene: Scene);
  114798. /**
  114799. * Gets the current object class name.
  114800. * @return the class name
  114801. */
  114802. getClassName(): string;
  114803. }
  114804. }
  114805. declare module BABYLON {
  114806. /**
  114807. * This represents a FPS type of camera. This is only here for back compat purpose.
  114808. * Please use the UniversalCamera instead as both are identical.
  114809. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114810. */
  114811. export class GamepadCamera extends UniversalCamera {
  114812. /**
  114813. * Instantiates a new Gamepad Camera
  114814. * This represents a FPS type of camera. This is only here for back compat purpose.
  114815. * Please use the UniversalCamera instead as both are identical.
  114816. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114817. * @param name Define the name of the camera in the scene
  114818. * @param position Define the start position of the camera in the scene
  114819. * @param scene Define the scene the camera belongs to
  114820. */
  114821. constructor(name: string, position: Vector3, scene: Scene);
  114822. /**
  114823. * Gets the current object class name.
  114824. * @return the class name
  114825. */
  114826. getClassName(): string;
  114827. }
  114828. }
  114829. declare module BABYLON {
  114830. /** @hidden */
  114831. export var passPixelShader: {
  114832. name: string;
  114833. shader: string;
  114834. };
  114835. }
  114836. declare module BABYLON {
  114837. /** @hidden */
  114838. export var passCubePixelShader: {
  114839. name: string;
  114840. shader: string;
  114841. };
  114842. }
  114843. declare module BABYLON {
  114844. /**
  114845. * PassPostProcess which produces an output the same as it's input
  114846. */
  114847. export class PassPostProcess extends PostProcess {
  114848. /**
  114849. * Creates the PassPostProcess
  114850. * @param name The name of the effect.
  114851. * @param options The required width/height ratio to downsize to before computing the render pass.
  114852. * @param camera The camera to apply the render pass to.
  114853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114854. * @param engine The engine which the post process will be applied. (default: current engine)
  114855. * @param reusable If the post process can be reused on the same frame. (default: false)
  114856. * @param textureType The type of texture to be used when performing the post processing.
  114857. * @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)
  114858. */
  114859. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114860. }
  114861. /**
  114862. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114863. */
  114864. export class PassCubePostProcess extends PostProcess {
  114865. private _face;
  114866. /**
  114867. * Gets or sets the cube face to display.
  114868. * * 0 is +X
  114869. * * 1 is -X
  114870. * * 2 is +Y
  114871. * * 3 is -Y
  114872. * * 4 is +Z
  114873. * * 5 is -Z
  114874. */
  114875. get face(): number;
  114876. set face(value: number);
  114877. /**
  114878. * Creates the PassCubePostProcess
  114879. * @param name The name of the effect.
  114880. * @param options The required width/height ratio to downsize to before computing the render pass.
  114881. * @param camera The camera to apply the render pass to.
  114882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114883. * @param engine The engine which the post process will be applied. (default: current engine)
  114884. * @param reusable If the post process can be reused on the same frame. (default: false)
  114885. * @param textureType The type of texture to be used when performing the post processing.
  114886. * @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)
  114887. */
  114888. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114889. }
  114890. }
  114891. declare module BABYLON {
  114892. /** @hidden */
  114893. export var anaglyphPixelShader: {
  114894. name: string;
  114895. shader: string;
  114896. };
  114897. }
  114898. declare module BABYLON {
  114899. /**
  114900. * Postprocess used to generate anaglyphic rendering
  114901. */
  114902. export class AnaglyphPostProcess extends PostProcess {
  114903. private _passedProcess;
  114904. /**
  114905. * Creates a new AnaglyphPostProcess
  114906. * @param name defines postprocess name
  114907. * @param options defines creation options or target ratio scale
  114908. * @param rigCameras defines cameras using this postprocess
  114909. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114910. * @param engine defines hosting engine
  114911. * @param reusable defines if the postprocess will be reused multiple times per frame
  114912. */
  114913. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114914. }
  114915. }
  114916. declare module BABYLON {
  114917. /**
  114918. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114919. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114920. */
  114921. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114922. /**
  114923. * Creates a new AnaglyphArcRotateCamera
  114924. * @param name defines camera name
  114925. * @param alpha defines alpha angle (in radians)
  114926. * @param beta defines beta angle (in radians)
  114927. * @param radius defines radius
  114928. * @param target defines camera target
  114929. * @param interaxialDistance defines distance between each color axis
  114930. * @param scene defines the hosting scene
  114931. */
  114932. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114933. /**
  114934. * Gets camera class name
  114935. * @returns AnaglyphArcRotateCamera
  114936. */
  114937. getClassName(): string;
  114938. }
  114939. }
  114940. declare module BABYLON {
  114941. /**
  114942. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114943. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114944. */
  114945. export class AnaglyphFreeCamera extends FreeCamera {
  114946. /**
  114947. * Creates a new AnaglyphFreeCamera
  114948. * @param name defines camera name
  114949. * @param position defines initial position
  114950. * @param interaxialDistance defines distance between each color axis
  114951. * @param scene defines the hosting scene
  114952. */
  114953. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114954. /**
  114955. * Gets camera class name
  114956. * @returns AnaglyphFreeCamera
  114957. */
  114958. getClassName(): string;
  114959. }
  114960. }
  114961. declare module BABYLON {
  114962. /**
  114963. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114964. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114965. */
  114966. export class AnaglyphGamepadCamera extends GamepadCamera {
  114967. /**
  114968. * Creates a new AnaglyphGamepadCamera
  114969. * @param name defines camera name
  114970. * @param position defines initial position
  114971. * @param interaxialDistance defines distance between each color axis
  114972. * @param scene defines the hosting scene
  114973. */
  114974. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114975. /**
  114976. * Gets camera class name
  114977. * @returns AnaglyphGamepadCamera
  114978. */
  114979. getClassName(): string;
  114980. }
  114981. }
  114982. declare module BABYLON {
  114983. /**
  114984. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114985. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114986. */
  114987. export class AnaglyphUniversalCamera extends UniversalCamera {
  114988. /**
  114989. * Creates a new AnaglyphUniversalCamera
  114990. * @param name defines camera name
  114991. * @param position defines initial position
  114992. * @param interaxialDistance defines distance between each color axis
  114993. * @param scene defines the hosting scene
  114994. */
  114995. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114996. /**
  114997. * Gets camera class name
  114998. * @returns AnaglyphUniversalCamera
  114999. */
  115000. getClassName(): string;
  115001. }
  115002. }
  115003. declare module BABYLON {
  115004. /** @hidden */
  115005. export var stereoscopicInterlacePixelShader: {
  115006. name: string;
  115007. shader: string;
  115008. };
  115009. }
  115010. declare module BABYLON {
  115011. /**
  115012. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115013. */
  115014. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115015. private _stepSize;
  115016. private _passedProcess;
  115017. /**
  115018. * Initializes a StereoscopicInterlacePostProcessI
  115019. * @param name The name of the effect.
  115020. * @param rigCameras The rig cameras to be appled to the post process
  115021. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115022. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115024. * @param engine The engine which the post process will be applied. (default: current engine)
  115025. * @param reusable If the post process can be reused on the same frame. (default: false)
  115026. */
  115027. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115028. }
  115029. /**
  115030. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115031. */
  115032. export class StereoscopicInterlacePostProcess extends PostProcess {
  115033. private _stepSize;
  115034. private _passedProcess;
  115035. /**
  115036. * Initializes a StereoscopicInterlacePostProcess
  115037. * @param name The name of the effect.
  115038. * @param rigCameras The rig cameras to be appled to the post process
  115039. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115041. * @param engine The engine which the post process will be applied. (default: current engine)
  115042. * @param reusable If the post process can be reused on the same frame. (default: false)
  115043. */
  115044. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115045. }
  115046. }
  115047. declare module BABYLON {
  115048. /**
  115049. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115050. * @see http://doc.babylonjs.com/features/cameras
  115051. */
  115052. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115053. /**
  115054. * Creates a new StereoscopicArcRotateCamera
  115055. * @param name defines camera name
  115056. * @param alpha defines alpha angle (in radians)
  115057. * @param beta defines beta angle (in radians)
  115058. * @param radius defines radius
  115059. * @param target defines camera target
  115060. * @param interaxialDistance defines distance between each color axis
  115061. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115062. * @param scene defines the hosting scene
  115063. */
  115064. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115065. /**
  115066. * Gets camera class name
  115067. * @returns StereoscopicArcRotateCamera
  115068. */
  115069. getClassName(): string;
  115070. }
  115071. }
  115072. declare module BABYLON {
  115073. /**
  115074. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115075. * @see http://doc.babylonjs.com/features/cameras
  115076. */
  115077. export class StereoscopicFreeCamera extends FreeCamera {
  115078. /**
  115079. * Creates a new StereoscopicFreeCamera
  115080. * @param name defines camera name
  115081. * @param position defines initial position
  115082. * @param interaxialDistance defines distance between each color axis
  115083. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115084. * @param scene defines the hosting scene
  115085. */
  115086. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115087. /**
  115088. * Gets camera class name
  115089. * @returns StereoscopicFreeCamera
  115090. */
  115091. getClassName(): string;
  115092. }
  115093. }
  115094. declare module BABYLON {
  115095. /**
  115096. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115097. * @see http://doc.babylonjs.com/features/cameras
  115098. */
  115099. export class StereoscopicGamepadCamera extends GamepadCamera {
  115100. /**
  115101. * Creates a new StereoscopicGamepadCamera
  115102. * @param name defines camera name
  115103. * @param position defines initial position
  115104. * @param interaxialDistance defines distance between each color axis
  115105. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115106. * @param scene defines the hosting scene
  115107. */
  115108. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115109. /**
  115110. * Gets camera class name
  115111. * @returns StereoscopicGamepadCamera
  115112. */
  115113. getClassName(): string;
  115114. }
  115115. }
  115116. declare module BABYLON {
  115117. /**
  115118. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115119. * @see http://doc.babylonjs.com/features/cameras
  115120. */
  115121. export class StereoscopicUniversalCamera extends UniversalCamera {
  115122. /**
  115123. * Creates a new StereoscopicUniversalCamera
  115124. * @param name defines camera name
  115125. * @param position defines initial position
  115126. * @param interaxialDistance defines distance between each color axis
  115127. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115128. * @param scene defines the hosting scene
  115129. */
  115130. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115131. /**
  115132. * Gets camera class name
  115133. * @returns StereoscopicUniversalCamera
  115134. */
  115135. getClassName(): string;
  115136. }
  115137. }
  115138. declare module BABYLON {
  115139. /**
  115140. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115141. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115142. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115143. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115144. */
  115145. export class VirtualJoysticksCamera extends FreeCamera {
  115146. /**
  115147. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115148. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115149. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115150. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115151. * @param name Define the name of the camera in the scene
  115152. * @param position Define the start position of the camera in the scene
  115153. * @param scene Define the scene the camera belongs to
  115154. */
  115155. constructor(name: string, position: Vector3, scene: Scene);
  115156. /**
  115157. * Gets the current object class name.
  115158. * @return the class name
  115159. */
  115160. getClassName(): string;
  115161. }
  115162. }
  115163. declare module BABYLON {
  115164. /**
  115165. * This represents all the required metrics to create a VR camera.
  115166. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115167. */
  115168. export class VRCameraMetrics {
  115169. /**
  115170. * Define the horizontal resolution off the screen.
  115171. */
  115172. hResolution: number;
  115173. /**
  115174. * Define the vertical resolution off the screen.
  115175. */
  115176. vResolution: number;
  115177. /**
  115178. * Define the horizontal screen size.
  115179. */
  115180. hScreenSize: number;
  115181. /**
  115182. * Define the vertical screen size.
  115183. */
  115184. vScreenSize: number;
  115185. /**
  115186. * Define the vertical screen center position.
  115187. */
  115188. vScreenCenter: number;
  115189. /**
  115190. * Define the distance of the eyes to the screen.
  115191. */
  115192. eyeToScreenDistance: number;
  115193. /**
  115194. * Define the distance between both lenses
  115195. */
  115196. lensSeparationDistance: number;
  115197. /**
  115198. * Define the distance between both viewer's eyes.
  115199. */
  115200. interpupillaryDistance: number;
  115201. /**
  115202. * Define the distortion factor of the VR postprocess.
  115203. * Please, touch with care.
  115204. */
  115205. distortionK: number[];
  115206. /**
  115207. * Define the chromatic aberration correction factors for the VR post process.
  115208. */
  115209. chromaAbCorrection: number[];
  115210. /**
  115211. * Define the scale factor of the post process.
  115212. * The smaller the better but the slower.
  115213. */
  115214. postProcessScaleFactor: number;
  115215. /**
  115216. * Define an offset for the lens center.
  115217. */
  115218. lensCenterOffset: number;
  115219. /**
  115220. * Define if the current vr camera should compensate the distortion of the lense or not.
  115221. */
  115222. compensateDistortion: boolean;
  115223. /**
  115224. * Defines if multiview should be enabled when rendering (Default: false)
  115225. */
  115226. multiviewEnabled: boolean;
  115227. /**
  115228. * Gets the rendering aspect ratio based on the provided resolutions.
  115229. */
  115230. get aspectRatio(): number;
  115231. /**
  115232. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115233. */
  115234. get aspectRatioFov(): number;
  115235. /**
  115236. * @hidden
  115237. */
  115238. get leftHMatrix(): Matrix;
  115239. /**
  115240. * @hidden
  115241. */
  115242. get rightHMatrix(): Matrix;
  115243. /**
  115244. * @hidden
  115245. */
  115246. get leftPreViewMatrix(): Matrix;
  115247. /**
  115248. * @hidden
  115249. */
  115250. get rightPreViewMatrix(): Matrix;
  115251. /**
  115252. * Get the default VRMetrics based on the most generic setup.
  115253. * @returns the default vr metrics
  115254. */
  115255. static GetDefault(): VRCameraMetrics;
  115256. }
  115257. }
  115258. declare module BABYLON {
  115259. /** @hidden */
  115260. export var vrDistortionCorrectionPixelShader: {
  115261. name: string;
  115262. shader: string;
  115263. };
  115264. }
  115265. declare module BABYLON {
  115266. /**
  115267. * VRDistortionCorrectionPostProcess used for mobile VR
  115268. */
  115269. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115270. private _isRightEye;
  115271. private _distortionFactors;
  115272. private _postProcessScaleFactor;
  115273. private _lensCenterOffset;
  115274. private _scaleIn;
  115275. private _scaleFactor;
  115276. private _lensCenter;
  115277. /**
  115278. * Initializes the VRDistortionCorrectionPostProcess
  115279. * @param name The name of the effect.
  115280. * @param camera The camera to apply the render pass to.
  115281. * @param isRightEye If this is for the right eye distortion
  115282. * @param vrMetrics All the required metrics for the VR camera
  115283. */
  115284. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115285. }
  115286. }
  115287. declare module BABYLON {
  115288. /**
  115289. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115290. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115291. */
  115292. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115293. /**
  115294. * Creates a new VRDeviceOrientationArcRotateCamera
  115295. * @param name defines camera name
  115296. * @param alpha defines the camera rotation along the logitudinal axis
  115297. * @param beta defines the camera rotation along the latitudinal axis
  115298. * @param radius defines the camera distance from its target
  115299. * @param target defines the camera target
  115300. * @param scene defines the scene the camera belongs to
  115301. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115302. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115303. */
  115304. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115305. /**
  115306. * Gets camera class name
  115307. * @returns VRDeviceOrientationArcRotateCamera
  115308. */
  115309. getClassName(): string;
  115310. }
  115311. }
  115312. declare module BABYLON {
  115313. /**
  115314. * Camera used to simulate VR rendering (based on FreeCamera)
  115315. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115316. */
  115317. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115318. /**
  115319. * Creates a new VRDeviceOrientationFreeCamera
  115320. * @param name defines camera name
  115321. * @param position defines the start position of the camera
  115322. * @param scene defines the scene the camera belongs to
  115323. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115324. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115325. */
  115326. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115327. /**
  115328. * Gets camera class name
  115329. * @returns VRDeviceOrientationFreeCamera
  115330. */
  115331. getClassName(): string;
  115332. }
  115333. }
  115334. declare module BABYLON {
  115335. /**
  115336. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115337. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115338. */
  115339. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115340. /**
  115341. * Creates a new VRDeviceOrientationGamepadCamera
  115342. * @param name defines camera name
  115343. * @param position defines the start position of the camera
  115344. * @param scene defines the scene the camera belongs to
  115345. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115346. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115347. */
  115348. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115349. /**
  115350. * Gets camera class name
  115351. * @returns VRDeviceOrientationGamepadCamera
  115352. */
  115353. getClassName(): string;
  115354. }
  115355. }
  115356. declare module BABYLON {
  115357. /** @hidden */
  115358. export var imageProcessingPixelShader: {
  115359. name: string;
  115360. shader: string;
  115361. };
  115362. }
  115363. declare module BABYLON {
  115364. /**
  115365. * ImageProcessingPostProcess
  115366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115367. */
  115368. export class ImageProcessingPostProcess extends PostProcess {
  115369. /**
  115370. * Default configuration related to image processing available in the PBR Material.
  115371. */
  115372. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115373. /**
  115374. * Gets the image processing configuration used either in this material.
  115375. */
  115376. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115377. /**
  115378. * Sets the Default image processing configuration used either in the this material.
  115379. *
  115380. * If sets to null, the scene one is in use.
  115381. */
  115382. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115383. /**
  115384. * Keep track of the image processing observer to allow dispose and replace.
  115385. */
  115386. private _imageProcessingObserver;
  115387. /**
  115388. * Attaches a new image processing configuration to the PBR Material.
  115389. * @param configuration
  115390. */
  115391. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115392. /**
  115393. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115394. */
  115395. get colorCurves(): Nullable<ColorCurves>;
  115396. /**
  115397. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115398. */
  115399. set colorCurves(value: Nullable<ColorCurves>);
  115400. /**
  115401. * Gets wether the color curves effect is enabled.
  115402. */
  115403. get colorCurvesEnabled(): boolean;
  115404. /**
  115405. * Sets wether the color curves effect is enabled.
  115406. */
  115407. set colorCurvesEnabled(value: boolean);
  115408. /**
  115409. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115410. */
  115411. get colorGradingTexture(): Nullable<BaseTexture>;
  115412. /**
  115413. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115414. */
  115415. set colorGradingTexture(value: Nullable<BaseTexture>);
  115416. /**
  115417. * Gets wether the color grading effect is enabled.
  115418. */
  115419. get colorGradingEnabled(): boolean;
  115420. /**
  115421. * Gets wether the color grading effect is enabled.
  115422. */
  115423. set colorGradingEnabled(value: boolean);
  115424. /**
  115425. * Gets exposure used in the effect.
  115426. */
  115427. get exposure(): number;
  115428. /**
  115429. * Sets exposure used in the effect.
  115430. */
  115431. set exposure(value: number);
  115432. /**
  115433. * Gets wether tonemapping is enabled or not.
  115434. */
  115435. get toneMappingEnabled(): boolean;
  115436. /**
  115437. * Sets wether tonemapping is enabled or not
  115438. */
  115439. set toneMappingEnabled(value: boolean);
  115440. /**
  115441. * Gets the type of tone mapping effect.
  115442. */
  115443. get toneMappingType(): number;
  115444. /**
  115445. * Sets the type of tone mapping effect.
  115446. */
  115447. set toneMappingType(value: number);
  115448. /**
  115449. * Gets contrast used in the effect.
  115450. */
  115451. get contrast(): number;
  115452. /**
  115453. * Sets contrast used in the effect.
  115454. */
  115455. set contrast(value: number);
  115456. /**
  115457. * Gets Vignette stretch size.
  115458. */
  115459. get vignetteStretch(): number;
  115460. /**
  115461. * Sets Vignette stretch size.
  115462. */
  115463. set vignetteStretch(value: number);
  115464. /**
  115465. * Gets Vignette centre X Offset.
  115466. */
  115467. get vignetteCentreX(): number;
  115468. /**
  115469. * Sets Vignette centre X Offset.
  115470. */
  115471. set vignetteCentreX(value: number);
  115472. /**
  115473. * Gets Vignette centre Y Offset.
  115474. */
  115475. get vignetteCentreY(): number;
  115476. /**
  115477. * Sets Vignette centre Y Offset.
  115478. */
  115479. set vignetteCentreY(value: number);
  115480. /**
  115481. * Gets Vignette weight or intensity of the vignette effect.
  115482. */
  115483. get vignetteWeight(): number;
  115484. /**
  115485. * Sets Vignette weight or intensity of the vignette effect.
  115486. */
  115487. set vignetteWeight(value: number);
  115488. /**
  115489. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115490. * if vignetteEnabled is set to true.
  115491. */
  115492. get vignetteColor(): Color4;
  115493. /**
  115494. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115495. * if vignetteEnabled is set to true.
  115496. */
  115497. set vignetteColor(value: Color4);
  115498. /**
  115499. * Gets Camera field of view used by the Vignette effect.
  115500. */
  115501. get vignetteCameraFov(): number;
  115502. /**
  115503. * Sets Camera field of view used by the Vignette effect.
  115504. */
  115505. set vignetteCameraFov(value: number);
  115506. /**
  115507. * Gets the vignette blend mode allowing different kind of effect.
  115508. */
  115509. get vignetteBlendMode(): number;
  115510. /**
  115511. * Sets the vignette blend mode allowing different kind of effect.
  115512. */
  115513. set vignetteBlendMode(value: number);
  115514. /**
  115515. * Gets wether the vignette effect is enabled.
  115516. */
  115517. get vignetteEnabled(): boolean;
  115518. /**
  115519. * Sets wether the vignette effect is enabled.
  115520. */
  115521. set vignetteEnabled(value: boolean);
  115522. private _fromLinearSpace;
  115523. /**
  115524. * Gets wether the input of the processing is in Gamma or Linear Space.
  115525. */
  115526. get fromLinearSpace(): boolean;
  115527. /**
  115528. * Sets wether the input of the processing is in Gamma or Linear Space.
  115529. */
  115530. set fromLinearSpace(value: boolean);
  115531. /**
  115532. * Defines cache preventing GC.
  115533. */
  115534. private _defines;
  115535. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115536. /**
  115537. * "ImageProcessingPostProcess"
  115538. * @returns "ImageProcessingPostProcess"
  115539. */
  115540. getClassName(): string;
  115541. protected _updateParameters(): void;
  115542. dispose(camera?: Camera): void;
  115543. }
  115544. }
  115545. declare module BABYLON {
  115546. /**
  115547. * Class containing static functions to help procedurally build meshes
  115548. */
  115549. export class GroundBuilder {
  115550. /**
  115551. * Creates a ground mesh
  115552. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115553. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115555. * @param name defines the name of the mesh
  115556. * @param options defines the options used to create the mesh
  115557. * @param scene defines the hosting scene
  115558. * @returns the ground mesh
  115559. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115560. */
  115561. static CreateGround(name: string, options: {
  115562. width?: number;
  115563. height?: number;
  115564. subdivisions?: number;
  115565. subdivisionsX?: number;
  115566. subdivisionsY?: number;
  115567. updatable?: boolean;
  115568. }, scene: any): Mesh;
  115569. /**
  115570. * Creates a tiled ground mesh
  115571. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115572. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115573. * * 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
  115574. * * 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
  115575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115576. * @param name defines the name of the mesh
  115577. * @param options defines the options used to create the mesh
  115578. * @param scene defines the hosting scene
  115579. * @returns the tiled ground mesh
  115580. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115581. */
  115582. static CreateTiledGround(name: string, options: {
  115583. xmin: number;
  115584. zmin: number;
  115585. xmax: number;
  115586. zmax: number;
  115587. subdivisions?: {
  115588. w: number;
  115589. h: number;
  115590. };
  115591. precision?: {
  115592. w: number;
  115593. h: number;
  115594. };
  115595. updatable?: boolean;
  115596. }, scene?: Nullable<Scene>): Mesh;
  115597. /**
  115598. * Creates a ground mesh from a height map
  115599. * * The parameter `url` sets the URL of the height map image resource.
  115600. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115601. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115602. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115603. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115604. * * 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.
  115605. * * 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).
  115606. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115608. * @param name defines the name of the mesh
  115609. * @param url defines the url to the height map
  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/babylon101/height_map
  115614. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115615. */
  115616. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115617. width?: number;
  115618. height?: number;
  115619. subdivisions?: number;
  115620. minHeight?: number;
  115621. maxHeight?: number;
  115622. colorFilter?: Color3;
  115623. alphaFilter?: number;
  115624. updatable?: boolean;
  115625. onReady?: (mesh: GroundMesh) => void;
  115626. }, scene?: Nullable<Scene>): GroundMesh;
  115627. }
  115628. }
  115629. declare module BABYLON {
  115630. /**
  115631. * Class containing static functions to help procedurally build meshes
  115632. */
  115633. export class TorusBuilder {
  115634. /**
  115635. * Creates a torus mesh
  115636. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115637. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115638. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115642. * @param name defines the name of the mesh
  115643. * @param options defines the options used to create the mesh
  115644. * @param scene defines the hosting scene
  115645. * @returns the torus mesh
  115646. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115647. */
  115648. static CreateTorus(name: string, options: {
  115649. diameter?: number;
  115650. thickness?: number;
  115651. tessellation?: number;
  115652. updatable?: boolean;
  115653. sideOrientation?: number;
  115654. frontUVs?: Vector4;
  115655. backUVs?: Vector4;
  115656. }, scene: any): Mesh;
  115657. }
  115658. }
  115659. declare module BABYLON {
  115660. /**
  115661. * Class containing static functions to help procedurally build meshes
  115662. */
  115663. export class CylinderBuilder {
  115664. /**
  115665. * Creates a cylinder or a cone mesh
  115666. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115667. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115668. * * 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.
  115669. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115670. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115671. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115672. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115673. * * 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).
  115674. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115675. * * 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).
  115676. * * 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
  115677. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115678. * * 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
  115679. * * 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.
  115680. * * If `enclose` is false, a ring surface is one element.
  115681. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115682. * * 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
  115683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115686. * @param name defines the name of the mesh
  115687. * @param options defines the options used to create the mesh
  115688. * @param scene defines the hosting scene
  115689. * @returns the cylinder mesh
  115690. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115691. */
  115692. static CreateCylinder(name: string, options: {
  115693. height?: number;
  115694. diameterTop?: number;
  115695. diameterBottom?: number;
  115696. diameter?: number;
  115697. tessellation?: number;
  115698. subdivisions?: number;
  115699. arc?: number;
  115700. faceColors?: Color4[];
  115701. faceUV?: Vector4[];
  115702. updatable?: boolean;
  115703. hasRings?: boolean;
  115704. enclose?: boolean;
  115705. cap?: number;
  115706. sideOrientation?: number;
  115707. frontUVs?: Vector4;
  115708. backUVs?: Vector4;
  115709. }, scene: any): Mesh;
  115710. }
  115711. }
  115712. declare module BABYLON {
  115713. /**
  115714. * States of the webXR experience
  115715. */
  115716. export enum WebXRState {
  115717. /**
  115718. * Transitioning to being in XR mode
  115719. */
  115720. ENTERING_XR = 0,
  115721. /**
  115722. * Transitioning to non XR mode
  115723. */
  115724. EXITING_XR = 1,
  115725. /**
  115726. * In XR mode and presenting
  115727. */
  115728. IN_XR = 2,
  115729. /**
  115730. * Not entered XR mode
  115731. */
  115732. NOT_IN_XR = 3
  115733. }
  115734. /**
  115735. * Abstraction of the XR render target
  115736. */
  115737. export interface WebXRRenderTarget extends IDisposable {
  115738. /**
  115739. * xrpresent context of the canvas which can be used to display/mirror xr content
  115740. */
  115741. canvasContext: WebGLRenderingContext;
  115742. /**
  115743. * xr layer for the canvas
  115744. */
  115745. xrLayer: Nullable<XRWebGLLayer>;
  115746. /**
  115747. * Initializes the xr layer for the session
  115748. * @param xrSession xr session
  115749. * @returns a promise that will resolve once the XR Layer has been created
  115750. */
  115751. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115752. }
  115753. }
  115754. declare module BABYLON {
  115755. /**
  115756. * COnfiguration object for WebXR output canvas
  115757. */
  115758. export class WebXRManagedOutputCanvasOptions {
  115759. /**
  115760. * Options for this XR Layer output
  115761. */
  115762. canvasOptions?: XRWebGLLayerOptions;
  115763. /**
  115764. * CSS styling for a newly created canvas (if not provided)
  115765. */
  115766. newCanvasCssStyle?: string;
  115767. /**
  115768. * An optional canvas in case you wish to create it yourself and provide it here.
  115769. * If not provided, a new canvas will be created
  115770. */
  115771. canvasElement?: HTMLCanvasElement;
  115772. /**
  115773. * Get the default values of the configuration object
  115774. * @returns default values of this configuration object
  115775. */
  115776. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115777. }
  115778. /**
  115779. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115780. */
  115781. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115782. private _options;
  115783. private _engine;
  115784. private _canvas;
  115785. /**
  115786. * Rendering context of the canvas which can be used to display/mirror xr content
  115787. */
  115788. canvasContext: WebGLRenderingContext;
  115789. /**
  115790. * xr layer for the canvas
  115791. */
  115792. xrLayer: Nullable<XRWebGLLayer>;
  115793. /**
  115794. * Initializes the xr layer for the session
  115795. * @param xrSession xr session
  115796. * @returns a promise that will resolve once the XR Layer has been created
  115797. */
  115798. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115799. /**
  115800. * Initializes the canvas to be added/removed upon entering/exiting xr
  115801. * @param _xrSessionManager The XR Session manager
  115802. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115803. */
  115804. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115805. /**
  115806. * Disposes of the object
  115807. */
  115808. dispose(): void;
  115809. private _setManagedOutputCanvas;
  115810. private _addCanvas;
  115811. private _removeCanvas;
  115812. }
  115813. }
  115814. declare module BABYLON {
  115815. /**
  115816. * Manages an XRSession to work with Babylon's engine
  115817. * @see https://doc.babylonjs.com/how_to/webxr
  115818. */
  115819. export class WebXRSessionManager implements IDisposable {
  115820. /** The scene which the session should be created for */
  115821. scene: Scene;
  115822. /**
  115823. * Fires every time a new xrFrame arrives which can be used to update the camera
  115824. */
  115825. onXRFrameObservable: Observable<XRFrame>;
  115826. /**
  115827. * Fires when the xr session is ended either by the device or manually done
  115828. */
  115829. onXRSessionEnded: Observable<any>;
  115830. /**
  115831. * Fires when the xr session is ended either by the device or manually done
  115832. */
  115833. onXRSessionInit: Observable<XRSession>;
  115834. /**
  115835. * Fires when the reference space changed
  115836. */
  115837. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115838. /**
  115839. * Underlying xr session
  115840. */
  115841. session: XRSession;
  115842. /**
  115843. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115844. * or get the offset the player is currently at.
  115845. */
  115846. viewerReferenceSpace: XRReferenceSpace;
  115847. private _referenceSpace;
  115848. /**
  115849. * The current reference space used in this session. This reference space can constantly change!
  115850. * It is mainly used to offset the camera's position.
  115851. */
  115852. get referenceSpace(): XRReferenceSpace;
  115853. /**
  115854. * Set a new reference space and triggers the observable
  115855. */
  115856. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115857. /**
  115858. * The base reference space from which the session started. good if you want to reset your
  115859. * reference space
  115860. */
  115861. baseReferenceSpace: XRReferenceSpace;
  115862. /**
  115863. * Used just in case of a failure to initialize an immersive session.
  115864. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115865. */
  115866. defaultHeightCompensation: number;
  115867. /**
  115868. * Current XR frame
  115869. */
  115870. currentFrame: Nullable<XRFrame>;
  115871. /** WebXR timestamp updated every frame */
  115872. currentTimestamp: number;
  115873. private _xrNavigator;
  115874. private baseLayer;
  115875. private _rttProvider;
  115876. private _sessionEnded;
  115877. /**
  115878. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115879. * @param scene The scene which the session should be created for
  115880. */
  115881. constructor(
  115882. /** The scene which the session should be created for */
  115883. scene: Scene);
  115884. /**
  115885. * Initializes the manager
  115886. * After initialization enterXR can be called to start an XR session
  115887. * @returns Promise which resolves after it is initialized
  115888. */
  115889. initializeAsync(): Promise<void>;
  115890. /**
  115891. * Initializes an xr session
  115892. * @param xrSessionMode mode to initialize
  115893. * @param xrSessionInit defines optional and required values to pass to the session builder
  115894. * @returns a promise which will resolve once the session has been initialized
  115895. */
  115896. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115897. /**
  115898. * Sets the reference space on the xr session
  115899. * @param referenceSpaceType space to set
  115900. * @returns a promise that will resolve once the reference space has been set
  115901. */
  115902. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115903. /**
  115904. * Resets the reference space to the one started the session
  115905. */
  115906. resetReferenceSpace(): void;
  115907. /**
  115908. * Updates the render state of the session
  115909. * @param state state to set
  115910. * @returns a promise that resolves once the render state has been updated
  115911. */
  115912. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115913. /**
  115914. * Starts rendering to the xr layer
  115915. */
  115916. runXRRenderLoop(): void;
  115917. /**
  115918. * Gets the correct render target texture to be rendered this frame for this eye
  115919. * @param eye the eye for which to get the render target
  115920. * @returns the render target for the specified eye
  115921. */
  115922. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115923. /**
  115924. * Stops the xrSession and restores the renderloop
  115925. * @returns Promise which resolves after it exits XR
  115926. */
  115927. exitXRAsync(): Promise<void>;
  115928. /**
  115929. * Checks if a session would be supported for the creation options specified
  115930. * @param sessionMode session mode to check if supported eg. immersive-vr
  115931. * @returns A Promise that resolves to true if supported and false if not
  115932. */
  115933. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115934. /**
  115935. * Creates a WebXRRenderTarget object for the XR session
  115936. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115937. * @param options optional options to provide when creating a new render target
  115938. * @returns a WebXR render target to which the session can render
  115939. */
  115940. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115941. /**
  115942. * @hidden
  115943. * Converts the render layer of xrSession to a render target
  115944. * @param session session to create render target for
  115945. * @param scene scene the new render target should be created for
  115946. * @param baseLayer the webgl layer to create the render target for
  115947. */
  115948. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115949. /**
  115950. * Disposes of the session manager
  115951. */
  115952. dispose(): void;
  115953. /**
  115954. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115955. * @param sessionMode defines the session to test
  115956. * @returns a promise with boolean as final value
  115957. */
  115958. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115959. }
  115960. }
  115961. declare module BABYLON {
  115962. /**
  115963. * WebXR Camera which holds the views for the xrSession
  115964. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115965. */
  115966. export class WebXRCamera extends FreeCamera {
  115967. private _xrSessionManager;
  115968. private _firstFrame;
  115969. private _referenceQuaternion;
  115970. private _referencedPosition;
  115971. private _xrInvPositionCache;
  115972. private _xrInvQuaternionCache;
  115973. /**
  115974. * Should position compensation execute on first frame.
  115975. * This is used when copying the position from a native (non XR) camera
  115976. */
  115977. compensateOnFirstFrame: boolean;
  115978. /**
  115979. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115980. * @param name the name of the camera
  115981. * @param scene the scene to add the camera to
  115982. * @param _xrSessionManager a constructed xr session manager
  115983. */
  115984. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115985. /**
  115986. * Return the user's height, unrelated to the current ground.
  115987. * This will be the y position of this camera, when ground level is 0.
  115988. */
  115989. get realWorldHeight(): number;
  115990. /** @hidden */
  115991. _updateForDualEyeDebugging(): void;
  115992. /**
  115993. * Sets this camera's transformation based on a non-vr camera
  115994. * @param otherCamera the non-vr camera to copy the transformation from
  115995. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115996. */
  115997. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  115998. private _updateFromXRSession;
  115999. private _updateNumberOfRigCameras;
  116000. private _updateReferenceSpace;
  116001. private _updateReferenceSpaceOffset;
  116002. }
  116003. }
  116004. declare module BABYLON {
  116005. /**
  116006. * Defining the interface required for a (webxr) feature
  116007. */
  116008. export interface IWebXRFeature extends IDisposable {
  116009. /**
  116010. * Is this feature attached
  116011. */
  116012. attached: boolean;
  116013. /**
  116014. * Should auto-attach be disabled?
  116015. */
  116016. disableAutoAttach: boolean;
  116017. /**
  116018. * Attach the feature to the session
  116019. * Will usually be called by the features manager
  116020. *
  116021. * @param force should attachment be forced (even when already attached)
  116022. * @returns true if successful.
  116023. */
  116024. attach(force?: boolean): boolean;
  116025. /**
  116026. * Detach the feature from the session
  116027. * Will usually be called by the features manager
  116028. *
  116029. * @returns true if successful.
  116030. */
  116031. detach(): boolean;
  116032. }
  116033. /**
  116034. * A list of the currently available features without referencing them
  116035. */
  116036. export class WebXRFeatureName {
  116037. /**
  116038. * The name of the hit test feature
  116039. */
  116040. static HIT_TEST: string;
  116041. /**
  116042. * The name of the anchor system feature
  116043. */
  116044. static ANCHOR_SYSTEM: string;
  116045. /**
  116046. * The name of the background remover feature
  116047. */
  116048. static BACKGROUND_REMOVER: string;
  116049. /**
  116050. * The name of the pointer selection feature
  116051. */
  116052. static POINTER_SELECTION: string;
  116053. /**
  116054. * The name of the teleportation feature
  116055. */
  116056. static TELEPORTATION: string;
  116057. /**
  116058. * The name of the plane detection feature
  116059. */
  116060. static PLANE_DETECTION: string;
  116061. /**
  116062. * physics impostors for xr controllers feature
  116063. */
  116064. static PHYSICS_CONTROLLERS: string;
  116065. }
  116066. /**
  116067. * Defining the constructor of a feature. Used to register the modules.
  116068. */
  116069. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116070. /**
  116071. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116072. * It is mainly used in AR sessions.
  116073. *
  116074. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116075. */
  116076. export class WebXRFeaturesManager implements IDisposable {
  116077. private _xrSessionManager;
  116078. private static readonly _AvailableFeatures;
  116079. /**
  116080. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116081. * Mainly used internally.
  116082. *
  116083. * @param featureName the name of the feature to register
  116084. * @param constructorFunction the function used to construct the module
  116085. * @param version the (babylon) version of the module
  116086. * @param stable is that a stable version of this module
  116087. */
  116088. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116089. /**
  116090. * Returns a constructor of a specific feature.
  116091. *
  116092. * @param featureName the name of the feature to construct
  116093. * @param version the version of the feature to load
  116094. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116095. * @param options optional options provided to the module.
  116096. * @returns a function that, when called, will return a new instance of this feature
  116097. */
  116098. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116099. /**
  116100. * Return the latest unstable version of this feature
  116101. * @param featureName the name of the feature to search
  116102. * @returns the version number. if not found will return -1
  116103. */
  116104. static GetLatestVersionOfFeature(featureName: string): number;
  116105. /**
  116106. * Return the latest stable version of this feature
  116107. * @param featureName the name of the feature to search
  116108. * @returns the version number. if not found will return -1
  116109. */
  116110. static GetStableVersionOfFeature(featureName: string): number;
  116111. /**
  116112. * Can be used to return the list of features currently registered
  116113. *
  116114. * @returns an Array of available features
  116115. */
  116116. static GetAvailableFeatures(): string[];
  116117. /**
  116118. * Gets the versions available for a specific feature
  116119. * @param featureName the name of the feature
  116120. * @returns an array with the available versions
  116121. */
  116122. static GetAvailableVersions(featureName: string): string[];
  116123. private _features;
  116124. /**
  116125. * constructs a new features manages.
  116126. *
  116127. * @param _xrSessionManager an instance of WebXRSessionManager
  116128. */
  116129. constructor(_xrSessionManager: WebXRSessionManager);
  116130. /**
  116131. * 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.
  116132. * 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.
  116133. *
  116134. * @param featureName the name of the feature to load or the class of the feature
  116135. * @param version optional version to load. if not provided the latest version will be enabled
  116136. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116137. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116138. * @returns a new constructed feature or throws an error if feature not found.
  116139. */
  116140. enableFeature(featureName: string | {
  116141. Name: string;
  116142. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116143. /**
  116144. * Used to disable an already-enabled feature
  116145. * The feature will be disposed and will be recreated once enabled.
  116146. * @param featureName the feature to disable
  116147. * @returns true if disable was successful
  116148. */
  116149. disableFeature(featureName: string | {
  116150. Name: string;
  116151. }): boolean;
  116152. /**
  116153. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116154. * Can be used during a session to start a feature
  116155. * @param featureName the name of feature to attach
  116156. */
  116157. attachFeature(featureName: string): void;
  116158. /**
  116159. * Can be used inside a session or when the session ends to detach a specific feature
  116160. * @param featureName the name of the feature to detach
  116161. */
  116162. detachFeature(featureName: string): void;
  116163. /**
  116164. * Get the list of enabled features
  116165. * @returns an array of enabled features
  116166. */
  116167. getEnabledFeatures(): string[];
  116168. /**
  116169. * get the implementation of an enabled feature.
  116170. * @param featureName the name of the feature to load
  116171. * @returns the feature class, if found
  116172. */
  116173. getEnabledFeature(featureName: string): IWebXRFeature;
  116174. /**
  116175. * dispose this features manager
  116176. */
  116177. dispose(): void;
  116178. }
  116179. }
  116180. declare module BABYLON {
  116181. /**
  116182. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  116183. * @see https://doc.babylonjs.com/how_to/webxr
  116184. */
  116185. export class WebXRExperienceHelper implements IDisposable {
  116186. private scene;
  116187. /**
  116188. * Camera used to render xr content
  116189. */
  116190. camera: WebXRCamera;
  116191. /**
  116192. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116193. */
  116194. state: WebXRState;
  116195. private _setState;
  116196. /**
  116197. * Fires when the state of the experience helper has changed
  116198. */
  116199. onStateChangedObservable: Observable<WebXRState>;
  116200. /**
  116201. * Observers registered here will be triggered after the camera's initial transformation is set
  116202. * This can be used to set a different ground level or an extra rotation.
  116203. *
  116204. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116205. * to the position set after this observable is done executing.
  116206. */
  116207. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116208. /** Session manager used to keep track of xr session */
  116209. sessionManager: WebXRSessionManager;
  116210. /** A features manager for this xr session */
  116211. featuresManager: WebXRFeaturesManager;
  116212. private _nonVRCamera;
  116213. private _originalSceneAutoClear;
  116214. private _supported;
  116215. /**
  116216. * Creates the experience helper
  116217. * @param scene the scene to attach the experience helper to
  116218. * @returns a promise for the experience helper
  116219. */
  116220. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116221. /**
  116222. * Creates a WebXRExperienceHelper
  116223. * @param scene The scene the helper should be created in
  116224. */
  116225. private constructor();
  116226. /**
  116227. * Exits XR mode and returns the scene to its original state
  116228. * @returns promise that resolves after xr mode has exited
  116229. */
  116230. exitXRAsync(): Promise<void>;
  116231. /**
  116232. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116233. * @param sessionMode options for the XR session
  116234. * @param referenceSpaceType frame of reference of the XR session
  116235. * @param renderTarget the output canvas that will be used to enter XR mode
  116236. * @returns promise that resolves after xr mode has entered
  116237. */
  116238. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116239. /**
  116240. * Disposes of the experience helper
  116241. */
  116242. dispose(): void;
  116243. private _nonXRToXRCamera;
  116244. }
  116245. }
  116246. declare module BABYLON {
  116247. /**
  116248. * X-Y values for axes in WebXR
  116249. */
  116250. export interface IWebXRMotionControllerAxesValue {
  116251. /**
  116252. * The value of the x axis
  116253. */
  116254. x: number;
  116255. /**
  116256. * The value of the y-axis
  116257. */
  116258. y: number;
  116259. }
  116260. /**
  116261. * changed / previous values for the values of this component
  116262. */
  116263. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116264. /**
  116265. * current (this frame) value
  116266. */
  116267. current: T;
  116268. /**
  116269. * previous (last change) value
  116270. */
  116271. previous: T;
  116272. }
  116273. /**
  116274. * Represents changes in the component between current frame and last values recorded
  116275. */
  116276. export interface IWebXRMotionControllerComponentChanges {
  116277. /**
  116278. * will be populated with previous and current values if touched changed
  116279. */
  116280. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116281. /**
  116282. * will be populated with previous and current values if pressed changed
  116283. */
  116284. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116285. /**
  116286. * will be populated with previous and current values if value changed
  116287. */
  116288. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116289. /**
  116290. * will be populated with previous and current values if axes changed
  116291. */
  116292. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116293. }
  116294. /**
  116295. * This class represents a single component (for example button or thumbstick) of a motion controller
  116296. */
  116297. export class WebXRControllerComponent implements IDisposable {
  116298. /**
  116299. * the id of this component
  116300. */
  116301. id: string;
  116302. /**
  116303. * the type of the component
  116304. */
  116305. type: MotionControllerComponentType;
  116306. private _buttonIndex;
  116307. private _axesIndices;
  116308. /**
  116309. * Thumbstick component type
  116310. */
  116311. static THUMBSTICK: MotionControllerComponentType;
  116312. /**
  116313. * Touchpad component type
  116314. */
  116315. static TOUCHPAD: MotionControllerComponentType;
  116316. /**
  116317. * trigger component type
  116318. */
  116319. static TRIGGER: MotionControllerComponentType;
  116320. /**
  116321. * squeeze component type
  116322. */
  116323. static SQUEEZE: MotionControllerComponentType;
  116324. /**
  116325. * button component type
  116326. */
  116327. static BUTTON: MotionControllerComponentType;
  116328. /**
  116329. * Observers registered here will be triggered when the state of a button changes
  116330. * State change is either pressed / touched / value
  116331. */
  116332. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116333. /**
  116334. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116335. * the axes data changes
  116336. */
  116337. onAxisValueChangedObservable: Observable<{
  116338. x: number;
  116339. y: number;
  116340. }>;
  116341. private _currentValue;
  116342. private _touched;
  116343. private _pressed;
  116344. private _axes;
  116345. private _changes;
  116346. private _hasChanges;
  116347. /**
  116348. * Return whether or not the component changed the last frame
  116349. */
  116350. get hasChanges(): boolean;
  116351. /**
  116352. * Creates a new component for a motion controller.
  116353. * It is created by the motion controller itself
  116354. *
  116355. * @param id the id of this component
  116356. * @param type the type of the component
  116357. * @param _buttonIndex index in the buttons array of the gamepad
  116358. * @param _axesIndices indices of the values in the axes array of the gamepad
  116359. */
  116360. constructor(
  116361. /**
  116362. * the id of this component
  116363. */
  116364. id: string,
  116365. /**
  116366. * the type of the component
  116367. */
  116368. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116369. /**
  116370. * Get the current value of this component
  116371. */
  116372. get value(): number;
  116373. /**
  116374. * is the button currently pressed
  116375. */
  116376. get pressed(): boolean;
  116377. /**
  116378. * is the button currently touched
  116379. */
  116380. get touched(): boolean;
  116381. /**
  116382. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116383. */
  116384. get axes(): IWebXRMotionControllerAxesValue;
  116385. /**
  116386. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116387. */
  116388. get changes(): IWebXRMotionControllerComponentChanges;
  116389. /**
  116390. * Is this component a button (hence - pressable)
  116391. * @returns true if can be pressed
  116392. */
  116393. isButton(): boolean;
  116394. /**
  116395. * Are there axes correlating to this component
  116396. * @return true is axes data is available
  116397. */
  116398. isAxes(): boolean;
  116399. /**
  116400. * update this component using the gamepad object it is in. Called on every frame
  116401. * @param nativeController the native gamepad controller object
  116402. */
  116403. update(nativeController: IMinimalMotionControllerObject): void;
  116404. /**
  116405. * Dispose this component
  116406. */
  116407. dispose(): void;
  116408. }
  116409. }
  116410. declare module BABYLON {
  116411. /**
  116412. * Class used to represent data loading progression
  116413. */
  116414. export class SceneLoaderProgressEvent {
  116415. /** defines if data length to load can be evaluated */
  116416. readonly lengthComputable: boolean;
  116417. /** defines the loaded data length */
  116418. readonly loaded: number;
  116419. /** defines the data length to load */
  116420. readonly total: number;
  116421. /**
  116422. * Create a new progress event
  116423. * @param lengthComputable defines if data length to load can be evaluated
  116424. * @param loaded defines the loaded data length
  116425. * @param total defines the data length to load
  116426. */
  116427. constructor(
  116428. /** defines if data length to load can be evaluated */
  116429. lengthComputable: boolean,
  116430. /** defines the loaded data length */
  116431. loaded: number,
  116432. /** defines the data length to load */
  116433. total: number);
  116434. /**
  116435. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116436. * @param event defines the source event
  116437. * @returns a new SceneLoaderProgressEvent
  116438. */
  116439. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116440. }
  116441. /**
  116442. * Interface used by SceneLoader plugins to define supported file extensions
  116443. */
  116444. export interface ISceneLoaderPluginExtensions {
  116445. /**
  116446. * Defines the list of supported extensions
  116447. */
  116448. [extension: string]: {
  116449. isBinary: boolean;
  116450. };
  116451. }
  116452. /**
  116453. * Interface used by SceneLoader plugin factory
  116454. */
  116455. export interface ISceneLoaderPluginFactory {
  116456. /**
  116457. * Defines the name of the factory
  116458. */
  116459. name: string;
  116460. /**
  116461. * Function called to create a new plugin
  116462. * @return the new plugin
  116463. */
  116464. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116465. /**
  116466. * The callback that returns true if the data can be directly loaded.
  116467. * @param data string containing the file data
  116468. * @returns if the data can be loaded directly
  116469. */
  116470. canDirectLoad?(data: string): boolean;
  116471. }
  116472. /**
  116473. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116474. */
  116475. export interface ISceneLoaderPluginBase {
  116476. /**
  116477. * The friendly name of this plugin.
  116478. */
  116479. name: string;
  116480. /**
  116481. * The file extensions supported by this plugin.
  116482. */
  116483. extensions: string | ISceneLoaderPluginExtensions;
  116484. /**
  116485. * The callback called when loading from a url.
  116486. * @param scene scene loading this url
  116487. * @param url url to load
  116488. * @param onSuccess callback called when the file successfully loads
  116489. * @param onProgress callback called while file is loading (if the server supports this mode)
  116490. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116491. * @param onError callback called when the file fails to load
  116492. * @returns a file request object
  116493. */
  116494. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116495. /**
  116496. * The callback called when loading from a file object.
  116497. * @param scene scene loading this file
  116498. * @param file defines the file to load
  116499. * @param onSuccess defines the callback to call when data is loaded
  116500. * @param onProgress defines the callback to call during loading process
  116501. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116502. * @param onError defines the callback to call when an error occurs
  116503. * @returns a file request object
  116504. */
  116505. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116506. /**
  116507. * The callback that returns true if the data can be directly loaded.
  116508. * @param data string containing the file data
  116509. * @returns if the data can be loaded directly
  116510. */
  116511. canDirectLoad?(data: string): boolean;
  116512. /**
  116513. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116514. * @param scene scene loading this data
  116515. * @param data string containing the data
  116516. * @returns data to pass to the plugin
  116517. */
  116518. directLoad?(scene: Scene, data: string): any;
  116519. /**
  116520. * The callback that allows custom handling of the root url based on the response url.
  116521. * @param rootUrl the original root url
  116522. * @param responseURL the response url if available
  116523. * @returns the new root url
  116524. */
  116525. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116526. }
  116527. /**
  116528. * Interface used to define a SceneLoader plugin
  116529. */
  116530. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116531. /**
  116532. * Import meshes into a scene.
  116533. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116534. * @param scene The scene to import into
  116535. * @param data The data to import
  116536. * @param rootUrl The root url for scene and resources
  116537. * @param meshes The meshes array to import into
  116538. * @param particleSystems The particle systems array to import into
  116539. * @param skeletons The skeletons array to import into
  116540. * @param onError The callback when import fails
  116541. * @returns True if successful or false otherwise
  116542. */
  116543. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116544. /**
  116545. * Load into a scene.
  116546. * @param scene The scene to load into
  116547. * @param data The data to import
  116548. * @param rootUrl The root url for scene and resources
  116549. * @param onError The callback when import fails
  116550. * @returns True if successful or false otherwise
  116551. */
  116552. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116553. /**
  116554. * Load into an asset container.
  116555. * @param scene The scene to load into
  116556. * @param data The data to import
  116557. * @param rootUrl The root url for scene and resources
  116558. * @param onError The callback when import fails
  116559. * @returns The loaded asset container
  116560. */
  116561. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116562. }
  116563. /**
  116564. * Interface used to define an async SceneLoader plugin
  116565. */
  116566. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116567. /**
  116568. * Import meshes into a scene.
  116569. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116570. * @param scene The scene to import into
  116571. * @param data The data to import
  116572. * @param rootUrl The root url for scene and resources
  116573. * @param onProgress The callback when the load progresses
  116574. * @param fileName Defines the name of the file to load
  116575. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116576. */
  116577. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116578. meshes: AbstractMesh[];
  116579. particleSystems: IParticleSystem[];
  116580. skeletons: Skeleton[];
  116581. animationGroups: AnimationGroup[];
  116582. }>;
  116583. /**
  116584. * Load into a scene.
  116585. * @param scene The scene to load into
  116586. * @param data The data to import
  116587. * @param rootUrl The root url for scene and resources
  116588. * @param onProgress The callback when the load progresses
  116589. * @param fileName Defines the name of the file to load
  116590. * @returns Nothing
  116591. */
  116592. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116593. /**
  116594. * Load into an asset container.
  116595. * @param scene The scene to load into
  116596. * @param data The data to import
  116597. * @param rootUrl The root url for scene and resources
  116598. * @param onProgress The callback when the load progresses
  116599. * @param fileName Defines the name of the file to load
  116600. * @returns The loaded asset container
  116601. */
  116602. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116603. }
  116604. /**
  116605. * Mode that determines how to handle old animation groups before loading new ones.
  116606. */
  116607. export enum SceneLoaderAnimationGroupLoadingMode {
  116608. /**
  116609. * Reset all old animations to initial state then dispose them.
  116610. */
  116611. Clean = 0,
  116612. /**
  116613. * Stop all old animations.
  116614. */
  116615. Stop = 1,
  116616. /**
  116617. * Restart old animations from first frame.
  116618. */
  116619. Sync = 2,
  116620. /**
  116621. * Old animations remains untouched.
  116622. */
  116623. NoSync = 3
  116624. }
  116625. /**
  116626. * Class used to load scene from various file formats using registered plugins
  116627. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116628. */
  116629. export class SceneLoader {
  116630. /**
  116631. * No logging while loading
  116632. */
  116633. static readonly NO_LOGGING: number;
  116634. /**
  116635. * Minimal logging while loading
  116636. */
  116637. static readonly MINIMAL_LOGGING: number;
  116638. /**
  116639. * Summary logging while loading
  116640. */
  116641. static readonly SUMMARY_LOGGING: number;
  116642. /**
  116643. * Detailled logging while loading
  116644. */
  116645. static readonly DETAILED_LOGGING: number;
  116646. /**
  116647. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116648. */
  116649. static get ForceFullSceneLoadingForIncremental(): boolean;
  116650. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116651. /**
  116652. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116653. */
  116654. static get ShowLoadingScreen(): boolean;
  116655. static set ShowLoadingScreen(value: boolean);
  116656. /**
  116657. * Defines the current logging level (while loading the scene)
  116658. * @ignorenaming
  116659. */
  116660. static get loggingLevel(): number;
  116661. static set loggingLevel(value: number);
  116662. /**
  116663. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116664. */
  116665. static get CleanBoneMatrixWeights(): boolean;
  116666. static set CleanBoneMatrixWeights(value: boolean);
  116667. /**
  116668. * Event raised when a plugin is used to load a scene
  116669. */
  116670. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116671. private static _registeredPlugins;
  116672. private static _getDefaultPlugin;
  116673. private static _getPluginForExtension;
  116674. private static _getPluginForDirectLoad;
  116675. private static _getPluginForFilename;
  116676. private static _getDirectLoad;
  116677. private static _loadData;
  116678. private static _getFileInfo;
  116679. /**
  116680. * Gets a plugin that can load the given extension
  116681. * @param extension defines the extension to load
  116682. * @returns a plugin or null if none works
  116683. */
  116684. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116685. /**
  116686. * Gets a boolean indicating that the given extension can be loaded
  116687. * @param extension defines the extension to load
  116688. * @returns true if the extension is supported
  116689. */
  116690. static IsPluginForExtensionAvailable(extension: string): boolean;
  116691. /**
  116692. * Adds a new plugin to the list of registered plugins
  116693. * @param plugin defines the plugin to add
  116694. */
  116695. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116696. /**
  116697. * Import meshes into a scene
  116698. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116699. * @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)
  116700. * @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)
  116701. * @param scene the instance of BABYLON.Scene to append to
  116702. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116703. * @param onProgress a callback with a progress event for each file being loaded
  116704. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116705. * @param pluginExtension the extension used to determine the plugin
  116706. * @returns The loaded plugin
  116707. */
  116708. 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>;
  116709. /**
  116710. * Import meshes into a scene
  116711. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116712. * @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)
  116713. * @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)
  116714. * @param scene the instance of BABYLON.Scene to append to
  116715. * @param onProgress a callback with a progress event for each file being loaded
  116716. * @param pluginExtension the extension used to determine the plugin
  116717. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116718. */
  116719. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116720. meshes: AbstractMesh[];
  116721. particleSystems: IParticleSystem[];
  116722. skeletons: Skeleton[];
  116723. animationGroups: AnimationGroup[];
  116724. }>;
  116725. /**
  116726. * Load a scene
  116727. * @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)
  116728. * @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)
  116729. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116730. * @param onSuccess a callback with the scene when import succeeds
  116731. * @param onProgress a callback with a progress event for each file being loaded
  116732. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116733. * @param pluginExtension the extension used to determine the plugin
  116734. * @returns The loaded plugin
  116735. */
  116736. 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>;
  116737. /**
  116738. * Load a scene
  116739. * @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)
  116740. * @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)
  116741. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116742. * @param onProgress a callback with a progress event for each file being loaded
  116743. * @param pluginExtension the extension used to determine the plugin
  116744. * @returns The loaded scene
  116745. */
  116746. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116747. /**
  116748. * Append a scene
  116749. * @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)
  116750. * @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)
  116751. * @param scene is the instance of BABYLON.Scene to append to
  116752. * @param onSuccess a callback with the scene when import succeeds
  116753. * @param onProgress a callback with a progress event for each file being loaded
  116754. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116755. * @param pluginExtension the extension used to determine the plugin
  116756. * @returns The loaded plugin
  116757. */
  116758. 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>;
  116759. /**
  116760. * Append a scene
  116761. * @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)
  116762. * @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)
  116763. * @param scene is the instance of BABYLON.Scene to append to
  116764. * @param onProgress a callback with a progress event for each file being loaded
  116765. * @param pluginExtension the extension used to determine the plugin
  116766. * @returns The given scene
  116767. */
  116768. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116769. /**
  116770. * Load a scene into an asset container
  116771. * @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)
  116772. * @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)
  116773. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116774. * @param onSuccess a callback with the scene when import succeeds
  116775. * @param onProgress a callback with a progress event for each file being loaded
  116776. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116777. * @param pluginExtension the extension used to determine the plugin
  116778. * @returns The loaded plugin
  116779. */
  116780. 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>;
  116781. /**
  116782. * Load a scene into an asset container
  116783. * @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)
  116784. * @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)
  116785. * @param scene is the instance of Scene to append to
  116786. * @param onProgress a callback with a progress event for each file being loaded
  116787. * @param pluginExtension the extension used to determine the plugin
  116788. * @returns The loaded asset container
  116789. */
  116790. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116791. /**
  116792. * Import animations from a file into a scene
  116793. * @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)
  116794. * @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)
  116795. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116796. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116797. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116798. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116799. * @param onSuccess a callback with the scene when import succeeds
  116800. * @param onProgress a callback with a progress event for each file being loaded
  116801. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116802. */
  116803. 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;
  116804. /**
  116805. * Import animations from a file into a scene
  116806. * @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)
  116807. * @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)
  116808. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116809. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116810. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116811. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116812. * @param onSuccess a callback with the scene when import succeeds
  116813. * @param onProgress a callback with a progress event for each file being loaded
  116814. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116815. * @returns the updated scene with imported animations
  116816. */
  116817. 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>;
  116818. }
  116819. }
  116820. declare module BABYLON {
  116821. /**
  116822. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116823. */
  116824. export type MotionControllerHandness = "none" | "left" | "right";
  116825. /**
  116826. * The type of components available in motion controllers.
  116827. * This is not the name of the component.
  116828. */
  116829. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116830. /**
  116831. * The state of a controller component
  116832. */
  116833. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116834. /**
  116835. * The schema of motion controller layout.
  116836. * No object will be initialized using this interface
  116837. * This is used just to define the profile.
  116838. */
  116839. export interface IMotionControllerLayout {
  116840. /**
  116841. * Defines the main button component id
  116842. */
  116843. selectComponentId: string;
  116844. /**
  116845. * Available components (unsorted)
  116846. */
  116847. components: {
  116848. /**
  116849. * A map of component Ids
  116850. */
  116851. [componentId: string]: {
  116852. /**
  116853. * The type of input the component outputs
  116854. */
  116855. type: MotionControllerComponentType;
  116856. /**
  116857. * The indices of this component in the gamepad object
  116858. */
  116859. gamepadIndices: {
  116860. /**
  116861. * Index of button
  116862. */
  116863. button?: number;
  116864. /**
  116865. * If available, index of x-axis
  116866. */
  116867. xAxis?: number;
  116868. /**
  116869. * If available, index of y-axis
  116870. */
  116871. yAxis?: number;
  116872. };
  116873. /**
  116874. * The mesh's root node name
  116875. */
  116876. rootNodeName: string;
  116877. /**
  116878. * Animation definitions for this model
  116879. */
  116880. visualResponses: {
  116881. [stateKey: string]: {
  116882. /**
  116883. * What property will be animated
  116884. */
  116885. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116886. /**
  116887. * What states influence this visual reponse
  116888. */
  116889. states: MotionControllerComponentStateType[];
  116890. /**
  116891. * Type of animation - movement or visibility
  116892. */
  116893. valueNodeProperty: "transform" | "visibility";
  116894. /**
  116895. * Base node name to move. Its position will be calculated according to the min and max nodes
  116896. */
  116897. valueNodeName?: string;
  116898. /**
  116899. * Minimum movement node
  116900. */
  116901. minNodeName?: string;
  116902. /**
  116903. * Max movement node
  116904. */
  116905. maxNodeName?: string;
  116906. };
  116907. };
  116908. /**
  116909. * If touch enabled, what is the name of node to display user feedback
  116910. */
  116911. touchPointNodeName?: string;
  116912. };
  116913. };
  116914. /**
  116915. * Is it xr standard mapping or not
  116916. */
  116917. gamepadMapping: "" | "xr-standard";
  116918. /**
  116919. * Base root node of this entire model
  116920. */
  116921. rootNodeName: string;
  116922. /**
  116923. * Path to load the assets. Usually relative to the base path
  116924. */
  116925. assetPath: string;
  116926. }
  116927. /**
  116928. * A definition for the layout map in the input profile
  116929. */
  116930. export interface IMotionControllerLayoutMap {
  116931. /**
  116932. * Layouts with handness type as a key
  116933. */
  116934. [handness: string]: IMotionControllerLayout;
  116935. }
  116936. /**
  116937. * The XR Input profile schema
  116938. * Profiles can be found here:
  116939. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116940. */
  116941. export interface IMotionControllerProfile {
  116942. /**
  116943. * The id of this profile
  116944. * correlates to the profile(s) in the xrInput.profiles array
  116945. */
  116946. profileId: string;
  116947. /**
  116948. * fallback profiles for this profileId
  116949. */
  116950. fallbackProfileIds: string[];
  116951. /**
  116952. * The layout map, with handness as key
  116953. */
  116954. layouts: IMotionControllerLayoutMap;
  116955. }
  116956. /**
  116957. * A helper-interface for the 3 meshes needed for controller button animation
  116958. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116959. */
  116960. export interface IMotionControllerButtonMeshMap {
  116961. /**
  116962. * The mesh that will be changed when value changes
  116963. */
  116964. valueMesh: AbstractMesh;
  116965. /**
  116966. * the mesh that defines the pressed value mesh position.
  116967. * This is used to find the max-position of this button
  116968. */
  116969. pressedMesh: AbstractMesh;
  116970. /**
  116971. * the mesh that defines the unpressed value mesh position.
  116972. * This is used to find the min (or initial) position of this button
  116973. */
  116974. unpressedMesh: AbstractMesh;
  116975. }
  116976. /**
  116977. * A helper-interface for the 3 meshes needed for controller axis animation.
  116978. * This will be expanded when touchpad animations are fully supported
  116979. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116980. */
  116981. export interface IMotionControllerMeshMap {
  116982. /**
  116983. * The mesh that will be changed when axis value changes
  116984. */
  116985. valueMesh: AbstractMesh;
  116986. /**
  116987. * the mesh that defines the minimum value mesh position.
  116988. */
  116989. minMesh?: AbstractMesh;
  116990. /**
  116991. * the mesh that defines the maximum value mesh position.
  116992. */
  116993. maxMesh?: AbstractMesh;
  116994. }
  116995. /**
  116996. * The elements needed for change-detection of the gamepad objects in motion controllers
  116997. */
  116998. export interface IMinimalMotionControllerObject {
  116999. /**
  117000. * An array of available buttons
  117001. */
  117002. buttons: Array<{
  117003. /**
  117004. * Value of the button/trigger
  117005. */
  117006. value: number;
  117007. /**
  117008. * If the button/trigger is currently touched
  117009. */
  117010. touched: boolean;
  117011. /**
  117012. * If the button/trigger is currently pressed
  117013. */
  117014. pressed: boolean;
  117015. }>;
  117016. /**
  117017. * Available axes of this controller
  117018. */
  117019. axes: number[];
  117020. }
  117021. /**
  117022. * An Abstract Motion controller
  117023. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117024. * Each component has an observable to check for changes in value and state
  117025. */
  117026. export abstract class WebXRAbstractMotionController implements IDisposable {
  117027. protected scene: Scene;
  117028. protected layout: IMotionControllerLayout;
  117029. /**
  117030. * The gamepad object correlating to this controller
  117031. */
  117032. gamepadObject: IMinimalMotionControllerObject;
  117033. /**
  117034. * handness (left/right/none) of this controller
  117035. */
  117036. handness: MotionControllerHandness;
  117037. /**
  117038. * The profile id of this motion controller
  117039. */
  117040. abstract profileId: string;
  117041. /**
  117042. * A map of components (WebXRControllerComponent) in this motion controller
  117043. * Components have a ComponentType and can also have both button and axis definitions
  117044. */
  117045. readonly components: {
  117046. [id: string]: WebXRControllerComponent;
  117047. };
  117048. /**
  117049. * Observers registered here will be triggered when the model of this controller is done loading
  117050. */
  117051. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117052. /**
  117053. * The root mesh of the model. It is null if the model was not yet initialized
  117054. */
  117055. rootMesh: Nullable<AbstractMesh>;
  117056. /**
  117057. * Disable the model's animation. Can be set at any time.
  117058. */
  117059. disableAnimation: boolean;
  117060. private _modelReady;
  117061. /**
  117062. * constructs a new abstract motion controller
  117063. * @param scene the scene to which the model of the controller will be added
  117064. * @param layout The profile layout to load
  117065. * @param gamepadObject The gamepad object correlating to this controller
  117066. * @param handness handness (left/right/none) of this controller
  117067. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117068. */
  117069. constructor(scene: Scene, layout: IMotionControllerLayout,
  117070. /**
  117071. * The gamepad object correlating to this controller
  117072. */
  117073. gamepadObject: IMinimalMotionControllerObject,
  117074. /**
  117075. * handness (left/right/none) of this controller
  117076. */
  117077. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117078. private _initComponent;
  117079. /**
  117080. * Update this model using the current XRFrame
  117081. * @param xrFrame the current xr frame to use and update the model
  117082. */
  117083. updateFromXRFrame(xrFrame: XRFrame): void;
  117084. /**
  117085. * Get the list of components available in this motion controller
  117086. * @returns an array of strings correlating to available components
  117087. */
  117088. getComponentIds(): string[];
  117089. /**
  117090. * Get the main (Select) component of this controller as defined in the layout
  117091. * @returns the main component of this controller
  117092. */
  117093. getMainComponent(): WebXRControllerComponent;
  117094. /**
  117095. * get a component based an its component id as defined in layout.components
  117096. * @param id the id of the component
  117097. * @returns the component correlates to the id or undefined if not found
  117098. */
  117099. getComponent(id: string): WebXRControllerComponent;
  117100. /**
  117101. * Get the first component of specific type
  117102. * @param type type of component to find
  117103. * @return a controller component or null if not found
  117104. */
  117105. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117106. /**
  117107. * Returns all components of specific type
  117108. * @param type the type to search for
  117109. * @return an array of components with this type
  117110. */
  117111. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117112. /**
  117113. * Loads the model correlating to this controller
  117114. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117115. * @returns A promise fulfilled with the result of the model loading
  117116. */
  117117. loadModel(): Promise<boolean>;
  117118. /**
  117119. * Update the model itself with the current frame data
  117120. * @param xrFrame the frame to use for updating the model mesh
  117121. */
  117122. protected updateModel(xrFrame: XRFrame): void;
  117123. /**
  117124. * Moves the axis on the controller mesh based on its current state
  117125. * @param axis the index of the axis
  117126. * @param axisValue the value of the axis which determines the meshes new position
  117127. * @hidden
  117128. */
  117129. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117130. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117131. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117132. private _getGenericFilenameAndPath;
  117133. private _getGenericParentMesh;
  117134. /**
  117135. * Get the filename and path for this controller's model
  117136. * @returns a map of filename and path
  117137. */
  117138. protected abstract _getFilenameAndPath(): {
  117139. filename: string;
  117140. path: string;
  117141. };
  117142. /**
  117143. * This function will be called after the model was successfully loaded and can be used
  117144. * for mesh transformations before it is available for the user
  117145. * @param meshes the loaded meshes
  117146. */
  117147. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117148. /**
  117149. * Set the root mesh for this controller. Important for the WebXR controller class
  117150. * @param meshes the loaded meshes
  117151. */
  117152. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117153. /**
  117154. * A function executed each frame that updates the mesh (if needed)
  117155. * @param xrFrame the current xrFrame
  117156. */
  117157. protected abstract _updateModel(xrFrame: XRFrame): void;
  117158. /**
  117159. * This function is called before the mesh is loaded. It checks for loading constraints.
  117160. * For example, this function can check if the GLB loader is available
  117161. * If this function returns false, the generic controller will be loaded instead
  117162. * @returns Is the client ready to load the mesh
  117163. */
  117164. protected abstract _getModelLoadingConstraints(): boolean;
  117165. /**
  117166. * Dispose this controller, the model mesh and all its components
  117167. */
  117168. dispose(): void;
  117169. }
  117170. }
  117171. declare module BABYLON {
  117172. /**
  117173. * A generic trigger-only motion controller for WebXR
  117174. */
  117175. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117176. /**
  117177. * Static version of the profile id of this controller
  117178. */
  117179. static ProfileId: string;
  117180. profileId: string;
  117181. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117182. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117183. protected _updateModel(): void;
  117184. protected _getFilenameAndPath(): {
  117185. filename: string;
  117186. path: string;
  117187. };
  117188. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117189. protected _getModelLoadingConstraints(): boolean;
  117190. }
  117191. }
  117192. declare module BABYLON {
  117193. /**
  117194. * Class containing static functions to help procedurally build meshes
  117195. */
  117196. export class SphereBuilder {
  117197. /**
  117198. * Creates a sphere mesh
  117199. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117200. * * 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`)
  117201. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117202. * * 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
  117203. * * 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)
  117204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117207. * @param name defines the name of the mesh
  117208. * @param options defines the options used to create the mesh
  117209. * @param scene defines the hosting scene
  117210. * @returns the sphere mesh
  117211. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117212. */
  117213. static CreateSphere(name: string, options: {
  117214. segments?: number;
  117215. diameter?: number;
  117216. diameterX?: number;
  117217. diameterY?: number;
  117218. diameterZ?: number;
  117219. arc?: number;
  117220. slice?: number;
  117221. sideOrientation?: number;
  117222. frontUVs?: Vector4;
  117223. backUVs?: Vector4;
  117224. updatable?: boolean;
  117225. }, scene?: Nullable<Scene>): Mesh;
  117226. }
  117227. }
  117228. declare module BABYLON {
  117229. /**
  117230. * A profiled motion controller has its profile loaded from an online repository.
  117231. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117232. */
  117233. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117234. private _repositoryUrl;
  117235. /**
  117236. * The profile ID of this controller. Will be populated when the controller initializes.
  117237. */
  117238. profileId: string;
  117239. private _buttonMeshMapping;
  117240. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117241. protected _getFilenameAndPath(): {
  117242. filename: string;
  117243. path: string;
  117244. };
  117245. private _touchDots;
  117246. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117247. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117248. protected _updateModel(_xrFrame: XRFrame): void;
  117249. protected _getModelLoadingConstraints(): boolean;
  117250. dispose(): void;
  117251. }
  117252. }
  117253. declare module BABYLON {
  117254. /**
  117255. * A construction function type to create a new controller based on an xrInput object
  117256. */
  117257. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117258. /**
  117259. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117260. *
  117261. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117262. * it should be replaced with auto-loaded controllers.
  117263. *
  117264. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117265. */
  117266. export class WebXRMotionControllerManager {
  117267. /**
  117268. * The base URL of the online controller repository. Can be changed at any time.
  117269. */
  117270. static BaseRepositoryUrl: string;
  117271. /**
  117272. * Use the online repository, or use only locally-defined controllers
  117273. */
  117274. static UseOnlineRepository: boolean;
  117275. /**
  117276. * Which repository gets priority - local or online
  117277. */
  117278. static PrioritizeOnlineRepository: boolean;
  117279. private static _AvailableControllers;
  117280. private static _Fallbacks;
  117281. /**
  117282. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117283. *
  117284. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117285. *
  117286. * @param type the profile type to register
  117287. * @param constructFunction the function to be called when loading this profile
  117288. */
  117289. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117290. /**
  117291. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117292. * The order of search:
  117293. *
  117294. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117295. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117296. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117297. * 4) return the generic trigger controller if none were found
  117298. *
  117299. * @param xrInput the xrInput to which a new controller is initialized
  117300. * @param scene the scene to which the model will be added
  117301. * @param forceProfile force a certain profile for this controller
  117302. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117303. */
  117304. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117305. private static _LoadProfilesFromAvailableControllers;
  117306. private static _ProfilesList;
  117307. private static _ProfileLoadingPromises;
  117308. private static _LoadProfileFromRepository;
  117309. /**
  117310. * Clear the cache used for profile loading and reload when requested again
  117311. */
  117312. static ClearProfilesCache(): void;
  117313. /**
  117314. * Will update the list of profiles available in the repository
  117315. * @return a promise that resolves to a map of profiles available online
  117316. */
  117317. static UpdateProfilesList(): Promise<{
  117318. [profile: string]: string;
  117319. }>;
  117320. /**
  117321. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117322. * @param profileId the profile to which a fallback needs to be found
  117323. * @return an array with corresponding fallback profiles
  117324. */
  117325. static FindFallbackWithProfileId(profileId: string): string[];
  117326. /**
  117327. * Register a fallback to a specific profile.
  117328. * @param profileId the profileId that will receive the fallbacks
  117329. * @param fallbacks A list of fallback profiles
  117330. */
  117331. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117332. /**
  117333. * Register the default fallbacks.
  117334. * This function is called automatically when this file is imported.
  117335. */
  117336. static DefaultFallbacks(): void;
  117337. }
  117338. }
  117339. declare module BABYLON {
  117340. /**
  117341. * Configuration options for the WebXR controller creation
  117342. */
  117343. export interface IWebXRControllerOptions {
  117344. /**
  117345. * Force a specific controller type for this controller.
  117346. * This can be used when creating your own profile or when testing different controllers
  117347. */
  117348. forceControllerProfile?: string;
  117349. /**
  117350. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117351. */
  117352. doNotLoadControllerMesh?: boolean;
  117353. /**
  117354. * Should the controller mesh be animated when a user interacts with it
  117355. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117356. */
  117357. disableMotionControllerAnimation?: boolean;
  117358. }
  117359. /**
  117360. * Represents an XR controller
  117361. */
  117362. export class WebXRInputSource {
  117363. private _scene;
  117364. /** The underlying input source for the controller */
  117365. inputSource: XRInputSource;
  117366. private _options;
  117367. /**
  117368. * 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
  117369. */
  117370. grip?: AbstractMesh;
  117371. /**
  117372. * Pointer which can be used to select objects or attach a visible laser to
  117373. */
  117374. pointer: AbstractMesh;
  117375. /**
  117376. * If available, this is the gamepad object related to this controller.
  117377. * Using this object it is possible to get click events and trackpad changes of the
  117378. * webxr controller that is currently being used.
  117379. */
  117380. motionController?: WebXRAbstractMotionController;
  117381. /**
  117382. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117383. */
  117384. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117385. /**
  117386. * Will be triggered when the mesh associated with the motion controller is done loading.
  117387. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117388. * A shortened version of controller -> motion controller -> on mesh loaded.
  117389. */
  117390. onMeshLoadedObservable: Observable<AbstractMesh>;
  117391. /**
  117392. * Event that fires when the controller is removed/disposed.
  117393. * The object provided as event data is this controller, after associated assets were disposed.
  117394. * uniqueId is still available.
  117395. */
  117396. onDisposeObservable: Observable<WebXRInputSource>;
  117397. private _tmpQuaternion;
  117398. private _tmpVector;
  117399. private _uniqueId;
  117400. /**
  117401. * Creates the controller
  117402. * @see https://doc.babylonjs.com/how_to/webxr
  117403. * @param _scene the scene which the controller should be associated to
  117404. * @param inputSource the underlying input source for the controller
  117405. * @param _options options for this controller creation
  117406. */
  117407. constructor(_scene: Scene,
  117408. /** The underlying input source for the controller */
  117409. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117410. /**
  117411. * Get this controllers unique id
  117412. */
  117413. get uniqueId(): string;
  117414. /**
  117415. * Updates the controller pose based on the given XRFrame
  117416. * @param xrFrame xr frame to update the pose with
  117417. * @param referenceSpace reference space to use
  117418. */
  117419. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117420. /**
  117421. * Gets a world space ray coming from the pointer or grip
  117422. * @param result the resulting ray
  117423. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117424. */
  117425. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117426. /**
  117427. * Disposes of the object
  117428. */
  117429. dispose(): void;
  117430. }
  117431. }
  117432. declare module BABYLON {
  117433. /**
  117434. * The schema for initialization options of the XR Input class
  117435. */
  117436. export interface IWebXRInputOptions {
  117437. /**
  117438. * If set to true no model will be automatically loaded
  117439. */
  117440. doNotLoadControllerMeshes?: boolean;
  117441. /**
  117442. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117443. * If not found, the xr input profile data will be used.
  117444. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117445. */
  117446. forceInputProfile?: string;
  117447. /**
  117448. * Do not send a request to the controlle repository to load the profile.
  117449. *
  117450. * Instead, use the controllers available in babylon itself.
  117451. */
  117452. disableOnlineControllerRepository?: boolean;
  117453. /**
  117454. * A custom URL for the controllers repository
  117455. */
  117456. customControllersRepositoryURL?: string;
  117457. /**
  117458. * Should the controller model's components not move according to the user input
  117459. */
  117460. disableControllerAnimation?: boolean;
  117461. }
  117462. /**
  117463. * XR input used to track XR inputs such as controllers/rays
  117464. */
  117465. export class WebXRInput implements IDisposable {
  117466. /**
  117467. * the xr session manager for this session
  117468. */
  117469. xrSessionManager: WebXRSessionManager;
  117470. /**
  117471. * the WebXR camera for this session. Mainly used for teleportation
  117472. */
  117473. xrCamera: WebXRCamera;
  117474. private readonly options;
  117475. /**
  117476. * XR controllers being tracked
  117477. */
  117478. controllers: Array<WebXRInputSource>;
  117479. private _frameObserver;
  117480. private _sessionEndedObserver;
  117481. private _sessionInitObserver;
  117482. /**
  117483. * Event when a controller has been connected/added
  117484. */
  117485. onControllerAddedObservable: Observable<WebXRInputSource>;
  117486. /**
  117487. * Event when a controller has been removed/disconnected
  117488. */
  117489. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117490. /**
  117491. * Initializes the WebXRInput
  117492. * @param xrSessionManager the xr session manager for this session
  117493. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117494. * @param options = initialization options for this xr input
  117495. */
  117496. constructor(
  117497. /**
  117498. * the xr session manager for this session
  117499. */
  117500. xrSessionManager: WebXRSessionManager,
  117501. /**
  117502. * the WebXR camera for this session. Mainly used for teleportation
  117503. */
  117504. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117505. private _onInputSourcesChange;
  117506. private _addAndRemoveControllers;
  117507. /**
  117508. * Disposes of the object
  117509. */
  117510. dispose(): void;
  117511. }
  117512. }
  117513. declare module BABYLON {
  117514. /**
  117515. * This is the base class for all WebXR features.
  117516. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117517. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117518. */
  117519. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117520. protected _xrSessionManager: WebXRSessionManager;
  117521. /**
  117522. * Construct a new (abstract) webxr feature
  117523. * @param _xrSessionManager the xr session manager for this feature
  117524. */
  117525. constructor(_xrSessionManager: WebXRSessionManager);
  117526. private _attached;
  117527. private _removeOnDetach;
  117528. /**
  117529. * Is this feature attached
  117530. */
  117531. get attached(): boolean;
  117532. /**
  117533. * Should auto-attach be disabled?
  117534. */
  117535. disableAutoAttach: boolean;
  117536. /**
  117537. * attach this feature
  117538. *
  117539. * @param force should attachment be forced (even when already attached)
  117540. * @returns true if successful, false is failed or already attached
  117541. */
  117542. attach(force?: boolean): boolean;
  117543. /**
  117544. * detach this feature.
  117545. *
  117546. * @returns true if successful, false if failed or already detached
  117547. */
  117548. detach(): boolean;
  117549. /**
  117550. * Dispose this feature and all of the resources attached
  117551. */
  117552. dispose(): void;
  117553. /**
  117554. * Code in this function will be executed on each xrFrame received from the browser.
  117555. * This function will not execute after the feature is detached.
  117556. * @param _xrFrame the current frame
  117557. */
  117558. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117559. /**
  117560. * This is used to register callbacks that will automatically be removed when detach is called.
  117561. * @param observable the observable to which the observer will be attached
  117562. * @param callback the callback to register
  117563. */
  117564. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117565. }
  117566. }
  117567. declare module BABYLON {
  117568. /**
  117569. * Renders a layer on top of an existing scene
  117570. */
  117571. export class UtilityLayerRenderer implements IDisposable {
  117572. /** the original scene that will be rendered on top of */
  117573. originalScene: Scene;
  117574. private _pointerCaptures;
  117575. private _lastPointerEvents;
  117576. private static _DefaultUtilityLayer;
  117577. private static _DefaultKeepDepthUtilityLayer;
  117578. private _sharedGizmoLight;
  117579. private _renderCamera;
  117580. /**
  117581. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117582. * @returns the camera that is used when rendering the utility layer
  117583. */
  117584. getRenderCamera(): Camera;
  117585. /**
  117586. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117587. * @param cam the camera that should be used when rendering the utility layer
  117588. */
  117589. setRenderCamera(cam: Nullable<Camera>): void;
  117590. /**
  117591. * @hidden
  117592. * Light which used by gizmos to get light shading
  117593. */
  117594. _getSharedGizmoLight(): HemisphericLight;
  117595. /**
  117596. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117597. */
  117598. pickUtilitySceneFirst: boolean;
  117599. /**
  117600. * 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)
  117601. */
  117602. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117603. /**
  117604. * 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)
  117605. */
  117606. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117607. /**
  117608. * The scene that is rendered on top of the original scene
  117609. */
  117610. utilityLayerScene: Scene;
  117611. /**
  117612. * If the utility layer should automatically be rendered on top of existing scene
  117613. */
  117614. shouldRender: boolean;
  117615. /**
  117616. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117617. */
  117618. onlyCheckPointerDownEvents: boolean;
  117619. /**
  117620. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117621. */
  117622. processAllEvents: boolean;
  117623. /**
  117624. * Observable raised when the pointer move from the utility layer scene to the main scene
  117625. */
  117626. onPointerOutObservable: Observable<number>;
  117627. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117628. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117629. private _afterRenderObserver;
  117630. private _sceneDisposeObserver;
  117631. private _originalPointerObserver;
  117632. /**
  117633. * Instantiates a UtilityLayerRenderer
  117634. * @param originalScene the original scene that will be rendered on top of
  117635. * @param handleEvents boolean indicating if the utility layer should handle events
  117636. */
  117637. constructor(
  117638. /** the original scene that will be rendered on top of */
  117639. originalScene: Scene, handleEvents?: boolean);
  117640. private _notifyObservers;
  117641. /**
  117642. * Renders the utility layers scene on top of the original scene
  117643. */
  117644. render(): void;
  117645. /**
  117646. * Disposes of the renderer
  117647. */
  117648. dispose(): void;
  117649. private _updateCamera;
  117650. }
  117651. }
  117652. declare module BABYLON {
  117653. /**
  117654. * Options interface for the pointer selection module
  117655. */
  117656. export interface IWebXRControllerPointerSelectionOptions {
  117657. /**
  117658. * the xr input to use with this pointer selection
  117659. */
  117660. xrInput: WebXRInput;
  117661. /**
  117662. * Different button type to use instead of the main component
  117663. */
  117664. overrideButtonId?: string;
  117665. /**
  117666. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117667. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117668. * 3000 means 3 seconds between pointing at something and selecting it
  117669. */
  117670. timeToSelect?: number;
  117671. /**
  117672. * 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)
  117673. * If not disabled, the last picked point will be used to execute a pointer up event
  117674. * If disabled, pointer up event will be triggered right after the pointer down event.
  117675. * Used in screen and gaze target ray mode only
  117676. */
  117677. disablePointerUpOnTouchOut: boolean;
  117678. /**
  117679. * For gaze mode (time to select instead of press)
  117680. */
  117681. forceGazeMode: boolean;
  117682. /**
  117683. * 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
  117684. * to start a new countdown to the pointer down event.
  117685. * Defaults to 1.
  117686. */
  117687. gazeModePointerMovedFactor?: number;
  117688. /**
  117689. * Should meshes created here be added to a utility layer or the main scene
  117690. */
  117691. useUtilityLayer?: boolean;
  117692. /**
  117693. * if provided, this scene will be used to render meshes.
  117694. */
  117695. customUtilityLayerScene?: Scene;
  117696. }
  117697. /**
  117698. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117699. */
  117700. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117701. private readonly _options;
  117702. /**
  117703. * The module's name
  117704. */
  117705. static readonly Name: string;
  117706. /**
  117707. * The (Babylon) version of this module.
  117708. * This is an integer representing the implementation version.
  117709. * This number does not correspond to the webxr specs version
  117710. */
  117711. static readonly Version: number;
  117712. /**
  117713. * This color will be set to the laser pointer when selection is triggered
  117714. */
  117715. laserPointerPickedColor: Color3;
  117716. /**
  117717. * This color will be applied to the selection ring when selection is triggered
  117718. */
  117719. selectionMeshPickedColor: Color3;
  117720. /**
  117721. * default color of the selection ring
  117722. */
  117723. selectionMeshDefaultColor: Color3;
  117724. /**
  117725. * Default color of the laser pointer
  117726. */
  117727. lasterPointerDefaultColor: Color3;
  117728. /**
  117729. * Should the laser pointer be displayed
  117730. */
  117731. displayLaserPointer: boolean;
  117732. /**
  117733. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117734. */
  117735. displaySelectionMesh: boolean;
  117736. /**
  117737. * Disable lighting on the laser pointer (so it will always be visible)
  117738. */
  117739. disablePointerLighting: boolean;
  117740. /**
  117741. * Disable lighting on the selection mesh (so it will always be visible)
  117742. */
  117743. disableSelectionMeshLighting: boolean;
  117744. private static _idCounter;
  117745. private _tmpRay;
  117746. private _controllers;
  117747. private _scene;
  117748. /**
  117749. * constructs a new background remover module
  117750. * @param _xrSessionManager the session manager for this module
  117751. * @param _options read-only options to be used in this module
  117752. */
  117753. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117754. /**
  117755. * attach this feature
  117756. * Will usually be called by the features manager
  117757. *
  117758. * @returns true if successful.
  117759. */
  117760. attach(): boolean;
  117761. /**
  117762. * detach this feature.
  117763. * Will usually be called by the features manager
  117764. *
  117765. * @returns true if successful.
  117766. */
  117767. detach(): boolean;
  117768. /**
  117769. * Get the xr controller that correlates to the pointer id in the pointer event
  117770. *
  117771. * @param id the pointer id to search for
  117772. * @returns the controller that correlates to this id or null if not found
  117773. */
  117774. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117775. protected _onXRFrame(_xrFrame: XRFrame): void;
  117776. private _attachController;
  117777. private _attachScreenRayMode;
  117778. private _attachGazeMode;
  117779. private _tmpVectorForPickCompare;
  117780. private _pickingMoved;
  117781. private _attachTrackedPointerRayMode;
  117782. private _detachController;
  117783. private _generateNewMeshPair;
  117784. private _convertNormalToDirectionOfRay;
  117785. private _updatePointerDistance;
  117786. }
  117787. }
  117788. declare module BABYLON {
  117789. /**
  117790. * Button which can be used to enter a different mode of XR
  117791. */
  117792. export class WebXREnterExitUIButton {
  117793. /** button element */
  117794. element: HTMLElement;
  117795. /** XR initialization options for the button */
  117796. sessionMode: XRSessionMode;
  117797. /** Reference space type */
  117798. referenceSpaceType: XRReferenceSpaceType;
  117799. /**
  117800. * Creates a WebXREnterExitUIButton
  117801. * @param element button element
  117802. * @param sessionMode XR initialization session mode
  117803. * @param referenceSpaceType the type of reference space to be used
  117804. */
  117805. constructor(
  117806. /** button element */
  117807. element: HTMLElement,
  117808. /** XR initialization options for the button */
  117809. sessionMode: XRSessionMode,
  117810. /** Reference space type */
  117811. referenceSpaceType: XRReferenceSpaceType);
  117812. /**
  117813. * Overwritable function which can be used to update the button's visuals when the state changes
  117814. * @param activeButton the current active button in the UI
  117815. */
  117816. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117817. }
  117818. /**
  117819. * Options to create the webXR UI
  117820. */
  117821. export class WebXREnterExitUIOptions {
  117822. /**
  117823. * Context to enter xr with
  117824. */
  117825. renderTarget?: Nullable<WebXRRenderTarget>;
  117826. /**
  117827. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117828. */
  117829. customButtons?: Array<WebXREnterExitUIButton>;
  117830. /**
  117831. * A session mode to use when creating the default button.
  117832. * Default is immersive-vr
  117833. */
  117834. sessionMode?: XRSessionMode;
  117835. /**
  117836. * A reference space type to use when creating the default button.
  117837. * Default is local-floor
  117838. */
  117839. referenceSpaceType?: XRReferenceSpaceType;
  117840. }
  117841. /**
  117842. * UI to allow the user to enter/exit XR mode
  117843. */
  117844. export class WebXREnterExitUI implements IDisposable {
  117845. private scene;
  117846. /** version of the options passed to this UI */
  117847. options: WebXREnterExitUIOptions;
  117848. private _overlay;
  117849. private _buttons;
  117850. private _activeButton;
  117851. /**
  117852. * Fired every time the active button is changed.
  117853. *
  117854. * When xr is entered via a button that launches xr that button will be the callback parameter
  117855. *
  117856. * When exiting xr the callback parameter will be null)
  117857. */
  117858. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117859. /**
  117860. * Creates UI to allow the user to enter/exit XR mode
  117861. * @param scene the scene to add the ui to
  117862. * @param helper the xr experience helper to enter/exit xr with
  117863. * @param options options to configure the UI
  117864. * @returns the created ui
  117865. */
  117866. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117867. /**
  117868. *
  117869. * @param scene babylon scene object to use
  117870. * @param options (read-only) version of the options passed to this UI
  117871. */
  117872. private constructor();
  117873. private _updateButtons;
  117874. /**
  117875. * Disposes of the object
  117876. */
  117877. dispose(): void;
  117878. }
  117879. }
  117880. declare module BABYLON {
  117881. /**
  117882. * Class containing static functions to help procedurally build meshes
  117883. */
  117884. export class LinesBuilder {
  117885. /**
  117886. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117887. * * 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
  117888. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117889. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117890. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117891. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117892. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117893. * * 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
  117894. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117897. * @param name defines the name of the new line system
  117898. * @param options defines the options used to create the line system
  117899. * @param scene defines the hosting scene
  117900. * @returns a new line system mesh
  117901. */
  117902. static CreateLineSystem(name: string, options: {
  117903. lines: Vector3[][];
  117904. updatable?: boolean;
  117905. instance?: Nullable<LinesMesh>;
  117906. colors?: Nullable<Color4[][]>;
  117907. useVertexAlpha?: boolean;
  117908. }, scene: Nullable<Scene>): LinesMesh;
  117909. /**
  117910. * Creates a line mesh
  117911. * 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
  117912. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117913. * * The parameter `points` is an array successive Vector3
  117914. * * 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
  117915. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117916. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117917. * * When updating an instance, remember that only point positions can change, not the number of points
  117918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117920. * @param name defines the name of the new line system
  117921. * @param options defines the options used to create the line system
  117922. * @param scene defines the hosting scene
  117923. * @returns a new line mesh
  117924. */
  117925. static CreateLines(name: string, options: {
  117926. points: Vector3[];
  117927. updatable?: boolean;
  117928. instance?: Nullable<LinesMesh>;
  117929. colors?: Color4[];
  117930. useVertexAlpha?: boolean;
  117931. }, scene?: Nullable<Scene>): LinesMesh;
  117932. /**
  117933. * Creates a dashed line mesh
  117934. * * 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
  117935. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117936. * * The parameter `points` is an array successive Vector3
  117937. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117938. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117939. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117940. * * 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
  117941. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117942. * * When updating an instance, remember that only point positions can change, not the number of points
  117943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117944. * @param name defines the name of the mesh
  117945. * @param options defines the options used to create the mesh
  117946. * @param scene defines the hosting scene
  117947. * @returns the dashed line mesh
  117948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117949. */
  117950. static CreateDashedLines(name: string, options: {
  117951. points: Vector3[];
  117952. dashSize?: number;
  117953. gapSize?: number;
  117954. dashNb?: number;
  117955. updatable?: boolean;
  117956. instance?: LinesMesh;
  117957. useVertexAlpha?: boolean;
  117958. }, scene?: Nullable<Scene>): LinesMesh;
  117959. }
  117960. }
  117961. declare module BABYLON {
  117962. /**
  117963. * The options container for the teleportation module
  117964. */
  117965. export interface IWebXRTeleportationOptions {
  117966. /**
  117967. * Babylon XR Input class for controller
  117968. */
  117969. xrInput: WebXRInput;
  117970. /**
  117971. * A list of meshes to use as floor meshes.
  117972. * Meshes can be added and removed after initializing the feature using the
  117973. * addFloorMesh and removeFloorMesh functions
  117974. * If empty, rotation will still work
  117975. */
  117976. floorMeshes?: AbstractMesh[];
  117977. /**
  117978. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  117979. * If you want to support rotation, make sure your mesh has a direction indicator.
  117980. *
  117981. * When left untouched, the default mesh will be initialized.
  117982. */
  117983. teleportationTargetMesh?: AbstractMesh;
  117984. /**
  117985. * Values to configure the default target mesh
  117986. */
  117987. defaultTargetMeshOptions?: {
  117988. /**
  117989. * Fill color of the teleportation area
  117990. */
  117991. teleportationFillColor?: string;
  117992. /**
  117993. * Border color for the teleportation area
  117994. */
  117995. teleportationBorderColor?: string;
  117996. /**
  117997. * Disable the mesh's animation sequence
  117998. */
  117999. disableAnimation?: boolean;
  118000. /**
  118001. * Disable lighting on the material or the ring and arrow
  118002. */
  118003. disableLighting?: boolean;
  118004. /**
  118005. * Override the default material of the torus and arrow
  118006. */
  118007. torusArrowMaterial?: Material;
  118008. };
  118009. /**
  118010. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  118011. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  118012. */
  118013. useMainComponentOnly?: boolean;
  118014. /**
  118015. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  118016. */
  118017. timeToTeleport?: number;
  118018. /**
  118019. * Should meshes created here be added to a utility layer or the main scene
  118020. */
  118021. useUtilityLayer?: boolean;
  118022. /**
  118023. * if provided, this scene will be used to render meshes.
  118024. */
  118025. customUtilityLayerScene?: Scene;
  118026. }
  118027. /**
  118028. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  118029. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  118030. * the input of the attached controllers.
  118031. */
  118032. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118033. private _options;
  118034. /**
  118035. * The module's name
  118036. */
  118037. static readonly Name: string;
  118038. /**
  118039. * The (Babylon) version of this module.
  118040. * This is an integer representing the implementation version.
  118041. * This number does not correspond to the webxr specs version
  118042. */
  118043. static readonly Version: number;
  118044. /**
  118045. * Is rotation enabled when moving forward?
  118046. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118047. */
  118048. rotationEnabled: boolean;
  118049. /**
  118050. * Should the module support parabolic ray on top of direct ray
  118051. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118052. * Very helpful when moving between floors / different heights
  118053. */
  118054. parabolicRayEnabled: boolean;
  118055. /**
  118056. * The distance from the user to the inspection point in the direction of the controller
  118057. * A higher number will allow the user to move further
  118058. * defaults to 5 (meters, in xr units)
  118059. */
  118060. parabolicCheckRadius: number;
  118061. /**
  118062. * How much rotation should be applied when rotating right and left
  118063. */
  118064. rotationAngle: number;
  118065. /**
  118066. * Is movement backwards enabled
  118067. */
  118068. backwardsMovementEnabled: boolean;
  118069. /**
  118070. * Distance to travel when moving backwards
  118071. */
  118072. backwardsTeleportationDistance: number;
  118073. /**
  118074. * Add a new mesh to the floor meshes array
  118075. * @param mesh the mesh to use as floor mesh
  118076. */
  118077. addFloorMesh(mesh: AbstractMesh): void;
  118078. /**
  118079. * Remove a mesh from the floor meshes array
  118080. * @param mesh the mesh to remove
  118081. */
  118082. removeFloorMesh(mesh: AbstractMesh): void;
  118083. /**
  118084. * Remove a mesh from the floor meshes array using its name
  118085. * @param name the mesh name to remove
  118086. */
  118087. removeFloorMeshByName(name: string): void;
  118088. private _tmpRay;
  118089. private _tmpVector;
  118090. private _floorMeshes;
  118091. private _controllers;
  118092. /**
  118093. * constructs a new anchor system
  118094. * @param _xrSessionManager an instance of WebXRSessionManager
  118095. * @param _options configuration object for this feature
  118096. */
  118097. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118098. private _selectionFeature;
  118099. /**
  118100. * This function sets a selection feature that will be disabled when
  118101. * the forward ray is shown and will be reattached when hidden.
  118102. * This is used to remove the selection rays when moving.
  118103. * @param selectionFeature the feature to disable when forward movement is enabled
  118104. */
  118105. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118106. attach(): boolean;
  118107. detach(): boolean;
  118108. dispose(): void;
  118109. protected _onXRFrame(_xrFrame: XRFrame): void;
  118110. private _currentTeleportationControllerId;
  118111. private _attachController;
  118112. private _teleportForward;
  118113. private _detachController;
  118114. private createDefaultTargetMesh;
  118115. private setTargetMeshVisibility;
  118116. private setTargetMeshPosition;
  118117. private _quadraticBezierCurve;
  118118. private _showParabolicPath;
  118119. }
  118120. }
  118121. declare module BABYLON {
  118122. /**
  118123. * Options for the default xr helper
  118124. */
  118125. export class WebXRDefaultExperienceOptions {
  118126. /**
  118127. * Floor meshes that will be used for teleporting
  118128. */
  118129. floorMeshes?: Array<AbstractMesh>;
  118130. /**
  118131. * Enable or disable default UI to enter XR
  118132. */
  118133. disableDefaultUI?: boolean;
  118134. /**
  118135. * optional configuration for the output canvas
  118136. */
  118137. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118138. /**
  118139. * optional UI options. This can be used among other to change session mode and reference space type
  118140. */
  118141. uiOptions?: WebXREnterExitUIOptions;
  118142. /**
  118143. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118144. */
  118145. inputOptions?: IWebXRInputOptions;
  118146. /**
  118147. * Should teleportation not initialize. defaults to false.
  118148. */
  118149. disableTeleportation?: boolean;
  118150. /**
  118151. * If set to true, the first frame will not be used to reset position
  118152. * The first frame is mainly used when copying transformation from the old camera
  118153. * Mainly used in AR
  118154. */
  118155. ignoreNativeCameraTransformation?: boolean;
  118156. /**
  118157. * When loading teleportation and pointer select, use stable versions instead of latest.
  118158. */
  118159. useStablePlugins?: boolean;
  118160. }
  118161. /**
  118162. * Default experience which provides a similar setup to the previous webVRExperience
  118163. */
  118164. export class WebXRDefaultExperience {
  118165. /**
  118166. * Base experience
  118167. */
  118168. baseExperience: WebXRExperienceHelper;
  118169. /**
  118170. * Input experience extension
  118171. */
  118172. input: WebXRInput;
  118173. /**
  118174. * Enables laser pointer and selection
  118175. */
  118176. pointerSelection: WebXRControllerPointerSelection;
  118177. /**
  118178. * Enables teleportation
  118179. */
  118180. teleportation: WebXRMotionControllerTeleportation;
  118181. /**
  118182. * Enables ui for entering/exiting xr
  118183. */
  118184. enterExitUI: WebXREnterExitUI;
  118185. /**
  118186. * Default target xr should render to
  118187. */
  118188. renderTarget: WebXRRenderTarget;
  118189. /**
  118190. * Creates the default xr experience
  118191. * @param scene scene
  118192. * @param options options for basic configuration
  118193. * @returns resulting WebXRDefaultExperience
  118194. */
  118195. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118196. private constructor();
  118197. /**
  118198. * DIsposes of the experience helper
  118199. */
  118200. dispose(): void;
  118201. }
  118202. }
  118203. declare module BABYLON {
  118204. /**
  118205. * Options to modify the vr teleportation behavior.
  118206. */
  118207. export interface VRTeleportationOptions {
  118208. /**
  118209. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118210. */
  118211. floorMeshName?: string;
  118212. /**
  118213. * A list of meshes to be used as the teleportation floor. (default: empty)
  118214. */
  118215. floorMeshes?: Mesh[];
  118216. /**
  118217. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118218. */
  118219. teleportationMode?: number;
  118220. /**
  118221. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118222. */
  118223. teleportationTime?: number;
  118224. /**
  118225. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118226. */
  118227. teleportationSpeed?: number;
  118228. /**
  118229. * The easing function used in the animation or null for Linear. (default CircleEase)
  118230. */
  118231. easingFunction?: EasingFunction;
  118232. }
  118233. /**
  118234. * Options to modify the vr experience helper's behavior.
  118235. */
  118236. export interface VRExperienceHelperOptions extends WebVROptions {
  118237. /**
  118238. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118239. */
  118240. createDeviceOrientationCamera?: boolean;
  118241. /**
  118242. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118243. */
  118244. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118245. /**
  118246. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118247. */
  118248. laserToggle?: boolean;
  118249. /**
  118250. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118251. */
  118252. floorMeshes?: Mesh[];
  118253. /**
  118254. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118255. */
  118256. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118257. /**
  118258. * Defines if WebXR should be used instead of WebVR (if available)
  118259. */
  118260. useXR?: boolean;
  118261. }
  118262. /**
  118263. * Event containing information after VR has been entered
  118264. */
  118265. export class OnAfterEnteringVRObservableEvent {
  118266. /**
  118267. * If entering vr was successful
  118268. */
  118269. success: boolean;
  118270. }
  118271. /**
  118272. * Helps to quickly add VR support to an existing scene.
  118273. * See http://doc.babylonjs.com/how_to/webvr_helper
  118274. */
  118275. export class VRExperienceHelper {
  118276. /** Options to modify the vr experience helper's behavior. */
  118277. webVROptions: VRExperienceHelperOptions;
  118278. private _scene;
  118279. private _position;
  118280. private _btnVR;
  118281. private _btnVRDisplayed;
  118282. private _webVRsupported;
  118283. private _webVRready;
  118284. private _webVRrequesting;
  118285. private _webVRpresenting;
  118286. private _hasEnteredVR;
  118287. private _fullscreenVRpresenting;
  118288. private _inputElement;
  118289. private _webVRCamera;
  118290. private _vrDeviceOrientationCamera;
  118291. private _deviceOrientationCamera;
  118292. private _existingCamera;
  118293. private _onKeyDown;
  118294. private _onVrDisplayPresentChange;
  118295. private _onVRDisplayChanged;
  118296. private _onVRRequestPresentStart;
  118297. private _onVRRequestPresentComplete;
  118298. /**
  118299. * 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)
  118300. */
  118301. enableGazeEvenWhenNoPointerLock: boolean;
  118302. /**
  118303. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118304. */
  118305. exitVROnDoubleTap: boolean;
  118306. /**
  118307. * Observable raised right before entering VR.
  118308. */
  118309. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118310. /**
  118311. * Observable raised when entering VR has completed.
  118312. */
  118313. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118314. /**
  118315. * Observable raised when exiting VR.
  118316. */
  118317. onExitingVRObservable: Observable<VRExperienceHelper>;
  118318. /**
  118319. * Observable raised when controller mesh is loaded.
  118320. */
  118321. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118322. /** Return this.onEnteringVRObservable
  118323. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118324. */
  118325. get onEnteringVR(): Observable<VRExperienceHelper>;
  118326. /** Return this.onExitingVRObservable
  118327. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118328. */
  118329. get onExitingVR(): Observable<VRExperienceHelper>;
  118330. /** Return this.onControllerMeshLoadedObservable
  118331. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118332. */
  118333. get onControllerMeshLoaded(): Observable<WebVRController>;
  118334. private _rayLength;
  118335. private _useCustomVRButton;
  118336. private _teleportationRequested;
  118337. private _teleportActive;
  118338. private _floorMeshName;
  118339. private _floorMeshesCollection;
  118340. private _teleportationMode;
  118341. private _teleportationTime;
  118342. private _teleportationSpeed;
  118343. private _teleportationEasing;
  118344. private _rotationAllowed;
  118345. private _teleportBackwardsVector;
  118346. private _teleportationTarget;
  118347. private _isDefaultTeleportationTarget;
  118348. private _postProcessMove;
  118349. private _teleportationFillColor;
  118350. private _teleportationBorderColor;
  118351. private _rotationAngle;
  118352. private _haloCenter;
  118353. private _cameraGazer;
  118354. private _padSensibilityUp;
  118355. private _padSensibilityDown;
  118356. private _leftController;
  118357. private _rightController;
  118358. private _gazeColor;
  118359. private _laserColor;
  118360. private _pickedLaserColor;
  118361. private _pickedGazeColor;
  118362. /**
  118363. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118364. */
  118365. onNewMeshSelected: Observable<AbstractMesh>;
  118366. /**
  118367. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118368. * This observable will provide the mesh and the controller used to select the mesh
  118369. */
  118370. onMeshSelectedWithController: Observable<{
  118371. mesh: AbstractMesh;
  118372. controller: WebVRController;
  118373. }>;
  118374. /**
  118375. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118376. */
  118377. onNewMeshPicked: Observable<PickingInfo>;
  118378. private _circleEase;
  118379. /**
  118380. * Observable raised before camera teleportation
  118381. */
  118382. onBeforeCameraTeleport: Observable<Vector3>;
  118383. /**
  118384. * Observable raised after camera teleportation
  118385. */
  118386. onAfterCameraTeleport: Observable<Vector3>;
  118387. /**
  118388. * Observable raised when current selected mesh gets unselected
  118389. */
  118390. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118391. private _raySelectionPredicate;
  118392. /**
  118393. * To be optionaly changed by user to define custom ray selection
  118394. */
  118395. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118396. /**
  118397. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118398. */
  118399. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118400. /**
  118401. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118402. */
  118403. teleportationEnabled: boolean;
  118404. private _defaultHeight;
  118405. private _teleportationInitialized;
  118406. private _interactionsEnabled;
  118407. private _interactionsRequested;
  118408. private _displayGaze;
  118409. private _displayLaserPointer;
  118410. /**
  118411. * The mesh used to display where the user is going to teleport.
  118412. */
  118413. get teleportationTarget(): Mesh;
  118414. /**
  118415. * Sets the mesh to be used to display where the user is going to teleport.
  118416. */
  118417. set teleportationTarget(value: Mesh);
  118418. /**
  118419. * 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
  118420. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118421. * See http://doc.babylonjs.com/resources/baking_transformations
  118422. */
  118423. get gazeTrackerMesh(): Mesh;
  118424. set gazeTrackerMesh(value: Mesh);
  118425. /**
  118426. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118427. */
  118428. updateGazeTrackerScale: boolean;
  118429. /**
  118430. * If the gaze trackers color should be updated when selecting meshes
  118431. */
  118432. updateGazeTrackerColor: boolean;
  118433. /**
  118434. * If the controller laser color should be updated when selecting meshes
  118435. */
  118436. updateControllerLaserColor: boolean;
  118437. /**
  118438. * The gaze tracking mesh corresponding to the left controller
  118439. */
  118440. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118441. /**
  118442. * The gaze tracking mesh corresponding to the right controller
  118443. */
  118444. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118445. /**
  118446. * If the ray of the gaze should be displayed.
  118447. */
  118448. get displayGaze(): boolean;
  118449. /**
  118450. * Sets if the ray of the gaze should be displayed.
  118451. */
  118452. set displayGaze(value: boolean);
  118453. /**
  118454. * If the ray of the LaserPointer should be displayed.
  118455. */
  118456. get displayLaserPointer(): boolean;
  118457. /**
  118458. * Sets if the ray of the LaserPointer should be displayed.
  118459. */
  118460. set displayLaserPointer(value: boolean);
  118461. /**
  118462. * The deviceOrientationCamera used as the camera when not in VR.
  118463. */
  118464. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118465. /**
  118466. * Based on the current WebVR support, returns the current VR camera used.
  118467. */
  118468. get currentVRCamera(): Nullable<Camera>;
  118469. /**
  118470. * The webVRCamera which is used when in VR.
  118471. */
  118472. get webVRCamera(): WebVRFreeCamera;
  118473. /**
  118474. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118475. */
  118476. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118477. /**
  118478. * The html button that is used to trigger entering into VR.
  118479. */
  118480. get vrButton(): Nullable<HTMLButtonElement>;
  118481. private get _teleportationRequestInitiated();
  118482. /**
  118483. * Defines whether or not Pointer lock should be requested when switching to
  118484. * full screen.
  118485. */
  118486. requestPointerLockOnFullScreen: boolean;
  118487. /**
  118488. * If asking to force XR, this will be populated with the default xr experience
  118489. */
  118490. xr: WebXRDefaultExperience;
  118491. /**
  118492. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118493. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118494. */
  118495. xrTestDone: boolean;
  118496. /**
  118497. * Instantiates a VRExperienceHelper.
  118498. * Helps to quickly add VR support to an existing scene.
  118499. * @param scene The scene the VRExperienceHelper belongs to.
  118500. * @param webVROptions Options to modify the vr experience helper's behavior.
  118501. */
  118502. constructor(scene: Scene,
  118503. /** Options to modify the vr experience helper's behavior. */
  118504. webVROptions?: VRExperienceHelperOptions);
  118505. private completeVRInit;
  118506. private _onDefaultMeshLoaded;
  118507. private _onResize;
  118508. private _onFullscreenChange;
  118509. /**
  118510. * Gets a value indicating if we are currently in VR mode.
  118511. */
  118512. get isInVRMode(): boolean;
  118513. private onVrDisplayPresentChange;
  118514. private onVRDisplayChanged;
  118515. private moveButtonToBottomRight;
  118516. private displayVRButton;
  118517. private updateButtonVisibility;
  118518. private _cachedAngularSensibility;
  118519. /**
  118520. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118521. * Otherwise, will use the fullscreen API.
  118522. */
  118523. enterVR(): void;
  118524. /**
  118525. * Attempt to exit VR, or fullscreen.
  118526. */
  118527. exitVR(): void;
  118528. /**
  118529. * The position of the vr experience helper.
  118530. */
  118531. get position(): Vector3;
  118532. /**
  118533. * Sets the position of the vr experience helper.
  118534. */
  118535. set position(value: Vector3);
  118536. /**
  118537. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118538. */
  118539. enableInteractions(): void;
  118540. private get _noControllerIsActive();
  118541. private beforeRender;
  118542. private _isTeleportationFloor;
  118543. /**
  118544. * Adds a floor mesh to be used for teleportation.
  118545. * @param floorMesh the mesh to be used for teleportation.
  118546. */
  118547. addFloorMesh(floorMesh: Mesh): void;
  118548. /**
  118549. * Removes a floor mesh from being used for teleportation.
  118550. * @param floorMesh the mesh to be removed.
  118551. */
  118552. removeFloorMesh(floorMesh: Mesh): void;
  118553. /**
  118554. * Enables interactions and teleportation using the VR controllers and gaze.
  118555. * @param vrTeleportationOptions options to modify teleportation behavior.
  118556. */
  118557. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118558. private _onNewGamepadConnected;
  118559. private _tryEnableInteractionOnController;
  118560. private _onNewGamepadDisconnected;
  118561. private _enableInteractionOnController;
  118562. private _checkTeleportWithRay;
  118563. private _checkRotate;
  118564. private _checkTeleportBackwards;
  118565. private _enableTeleportationOnController;
  118566. private _createTeleportationCircles;
  118567. private _displayTeleportationTarget;
  118568. private _hideTeleportationTarget;
  118569. private _rotateCamera;
  118570. private _moveTeleportationSelectorTo;
  118571. private _workingVector;
  118572. private _workingQuaternion;
  118573. private _workingMatrix;
  118574. /**
  118575. * Time Constant Teleportation Mode
  118576. */
  118577. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118578. /**
  118579. * Speed Constant Teleportation Mode
  118580. */
  118581. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118582. /**
  118583. * Teleports the users feet to the desired location
  118584. * @param location The location where the user's feet should be placed
  118585. */
  118586. teleportCamera(location: Vector3): void;
  118587. private _convertNormalToDirectionOfRay;
  118588. private _castRayAndSelectObject;
  118589. private _notifySelectedMeshUnselected;
  118590. /**
  118591. * Permanently set new colors for the laser pointer
  118592. * @param color the new laser color
  118593. * @param pickedColor the new laser color when picked mesh detected
  118594. */
  118595. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118596. /**
  118597. * Set lighting enabled / disabled on the laser pointer of both controllers
  118598. * @param enabled should the lighting be enabled on the laser pointer
  118599. */
  118600. setLaserLightingState(enabled?: boolean): void;
  118601. /**
  118602. * Permanently set new colors for the gaze pointer
  118603. * @param color the new gaze color
  118604. * @param pickedColor the new gaze color when picked mesh detected
  118605. */
  118606. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118607. /**
  118608. * Sets the color of the laser ray from the vr controllers.
  118609. * @param color new color for the ray.
  118610. */
  118611. changeLaserColor(color: Color3): void;
  118612. /**
  118613. * Sets the color of the ray from the vr headsets gaze.
  118614. * @param color new color for the ray.
  118615. */
  118616. changeGazeColor(color: Color3): void;
  118617. /**
  118618. * Exits VR and disposes of the vr experience helper
  118619. */
  118620. dispose(): void;
  118621. /**
  118622. * Gets the name of the VRExperienceHelper class
  118623. * @returns "VRExperienceHelper"
  118624. */
  118625. getClassName(): string;
  118626. }
  118627. }
  118628. declare module BABYLON {
  118629. /**
  118630. * Contains an array of blocks representing the octree
  118631. */
  118632. export interface IOctreeContainer<T> {
  118633. /**
  118634. * Blocks within the octree
  118635. */
  118636. blocks: Array<OctreeBlock<T>>;
  118637. }
  118638. /**
  118639. * Class used to store a cell in an octree
  118640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118641. */
  118642. export class OctreeBlock<T> {
  118643. /**
  118644. * Gets the content of the current block
  118645. */
  118646. entries: T[];
  118647. /**
  118648. * Gets the list of block children
  118649. */
  118650. blocks: Array<OctreeBlock<T>>;
  118651. private _depth;
  118652. private _maxDepth;
  118653. private _capacity;
  118654. private _minPoint;
  118655. private _maxPoint;
  118656. private _boundingVectors;
  118657. private _creationFunc;
  118658. /**
  118659. * Creates a new block
  118660. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118661. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118662. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118663. * @param depth defines the current depth of this block in the octree
  118664. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118665. * @param creationFunc defines a callback to call when an element is added to the block
  118666. */
  118667. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118668. /**
  118669. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118670. */
  118671. get capacity(): number;
  118672. /**
  118673. * Gets the minimum vector (in world space) of the block's bounding box
  118674. */
  118675. get minPoint(): Vector3;
  118676. /**
  118677. * Gets the maximum vector (in world space) of the block's bounding box
  118678. */
  118679. get maxPoint(): Vector3;
  118680. /**
  118681. * Add a new element to this block
  118682. * @param entry defines the element to add
  118683. */
  118684. addEntry(entry: T): void;
  118685. /**
  118686. * Remove an element from this block
  118687. * @param entry defines the element to remove
  118688. */
  118689. removeEntry(entry: T): void;
  118690. /**
  118691. * Add an array of elements to this block
  118692. * @param entries defines the array of elements to add
  118693. */
  118694. addEntries(entries: T[]): void;
  118695. /**
  118696. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118697. * @param frustumPlanes defines the frustum planes to test
  118698. * @param selection defines the array to store current content if selection is positive
  118699. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118700. */
  118701. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118702. /**
  118703. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118704. * @param sphereCenter defines the bounding sphere center
  118705. * @param sphereRadius defines the bounding sphere radius
  118706. * @param selection defines the array to store current content if selection is positive
  118707. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118708. */
  118709. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118710. /**
  118711. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118712. * @param ray defines the ray to test with
  118713. * @param selection defines the array to store current content if selection is positive
  118714. */
  118715. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118716. /**
  118717. * Subdivide the content into child blocks (this block will then be empty)
  118718. */
  118719. createInnerBlocks(): void;
  118720. /**
  118721. * @hidden
  118722. */
  118723. 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;
  118724. }
  118725. }
  118726. declare module BABYLON {
  118727. /**
  118728. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118729. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118730. */
  118731. export class Octree<T> {
  118732. /** 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.) */
  118733. maxDepth: number;
  118734. /**
  118735. * Blocks within the octree containing objects
  118736. */
  118737. blocks: Array<OctreeBlock<T>>;
  118738. /**
  118739. * Content stored in the octree
  118740. */
  118741. dynamicContent: T[];
  118742. private _maxBlockCapacity;
  118743. private _selectionContent;
  118744. private _creationFunc;
  118745. /**
  118746. * Creates a octree
  118747. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118748. * @param creationFunc function to be used to instatiate the octree
  118749. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118750. * @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.)
  118751. */
  118752. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118753. /** 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.) */
  118754. maxDepth?: number);
  118755. /**
  118756. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118757. * @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);
  118758. * @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);
  118759. * @param entries meshes to be added to the octree blocks
  118760. */
  118761. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118762. /**
  118763. * Adds a mesh to the octree
  118764. * @param entry Mesh to add to the octree
  118765. */
  118766. addMesh(entry: T): void;
  118767. /**
  118768. * Remove an element from the octree
  118769. * @param entry defines the element to remove
  118770. */
  118771. removeMesh(entry: T): void;
  118772. /**
  118773. * Selects an array of meshes within the frustum
  118774. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118775. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118776. * @returns array of meshes within the frustum
  118777. */
  118778. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118779. /**
  118780. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118781. * @param sphereCenter defines the bounding sphere center
  118782. * @param sphereRadius defines the bounding sphere radius
  118783. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118784. * @returns an array of objects that intersect the sphere
  118785. */
  118786. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118787. /**
  118788. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118789. * @param ray defines the ray to test with
  118790. * @returns array of intersected objects
  118791. */
  118792. intersectsRay(ray: Ray): SmartArray<T>;
  118793. /**
  118794. * Adds a mesh into the octree block if it intersects the block
  118795. */
  118796. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118797. /**
  118798. * Adds a submesh into the octree block if it intersects the block
  118799. */
  118800. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118801. }
  118802. }
  118803. declare module BABYLON {
  118804. interface Scene {
  118805. /**
  118806. * @hidden
  118807. * Backing Filed
  118808. */
  118809. _selectionOctree: Octree<AbstractMesh>;
  118810. /**
  118811. * Gets the octree used to boost mesh selection (picking)
  118812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118813. */
  118814. selectionOctree: Octree<AbstractMesh>;
  118815. /**
  118816. * Creates or updates the octree used to boost selection (picking)
  118817. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118818. * @param maxCapacity defines the maximum capacity per leaf
  118819. * @param maxDepth defines the maximum depth of the octree
  118820. * @returns an octree of AbstractMesh
  118821. */
  118822. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118823. }
  118824. interface AbstractMesh {
  118825. /**
  118826. * @hidden
  118827. * Backing Field
  118828. */
  118829. _submeshesOctree: Octree<SubMesh>;
  118830. /**
  118831. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118832. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118833. * @param maxCapacity defines the maximum size of each block (64 by default)
  118834. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118835. * @returns the new octree
  118836. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118838. */
  118839. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118840. }
  118841. /**
  118842. * Defines the octree scene component responsible to manage any octrees
  118843. * in a given scene.
  118844. */
  118845. export class OctreeSceneComponent {
  118846. /**
  118847. * The component name help to identify the component in the list of scene components.
  118848. */
  118849. readonly name: string;
  118850. /**
  118851. * The scene the component belongs to.
  118852. */
  118853. scene: Scene;
  118854. /**
  118855. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118856. */
  118857. readonly checksIsEnabled: boolean;
  118858. /**
  118859. * Creates a new instance of the component for the given scene
  118860. * @param scene Defines the scene to register the component in
  118861. */
  118862. constructor(scene: Scene);
  118863. /**
  118864. * Registers the component in a given scene
  118865. */
  118866. register(): void;
  118867. /**
  118868. * Return the list of active meshes
  118869. * @returns the list of active meshes
  118870. */
  118871. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118872. /**
  118873. * Return the list of active sub meshes
  118874. * @param mesh The mesh to get the candidates sub meshes from
  118875. * @returns the list of active sub meshes
  118876. */
  118877. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118878. private _tempRay;
  118879. /**
  118880. * Return the list of sub meshes intersecting with a given local ray
  118881. * @param mesh defines the mesh to find the submesh for
  118882. * @param localRay defines the ray in local space
  118883. * @returns the list of intersecting sub meshes
  118884. */
  118885. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118886. /**
  118887. * Return the list of sub meshes colliding with a collider
  118888. * @param mesh defines the mesh to find the submesh for
  118889. * @param collider defines the collider to evaluate the collision against
  118890. * @returns the list of colliding sub meshes
  118891. */
  118892. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118893. /**
  118894. * Rebuilds the elements related to this component in case of
  118895. * context lost for instance.
  118896. */
  118897. rebuild(): void;
  118898. /**
  118899. * Disposes the component and the associated ressources.
  118900. */
  118901. dispose(): void;
  118902. }
  118903. }
  118904. declare module BABYLON {
  118905. /**
  118906. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118907. */
  118908. export class Gizmo implements IDisposable {
  118909. /** The utility layer the gizmo will be added to */
  118910. gizmoLayer: UtilityLayerRenderer;
  118911. /**
  118912. * The root mesh of the gizmo
  118913. */
  118914. _rootMesh: Mesh;
  118915. private _attachedMesh;
  118916. /**
  118917. * Ratio for the scale of the gizmo (Default: 1)
  118918. */
  118919. scaleRatio: number;
  118920. /**
  118921. * If a custom mesh has been set (Default: false)
  118922. */
  118923. protected _customMeshSet: boolean;
  118924. /**
  118925. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118926. * * When set, interactions will be enabled
  118927. */
  118928. get attachedMesh(): Nullable<AbstractMesh>;
  118929. set attachedMesh(value: Nullable<AbstractMesh>);
  118930. /**
  118931. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118932. * @param mesh The mesh to replace the default mesh of the gizmo
  118933. */
  118934. setCustomMesh(mesh: Mesh): void;
  118935. /**
  118936. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118937. */
  118938. updateGizmoRotationToMatchAttachedMesh: boolean;
  118939. /**
  118940. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118941. */
  118942. updateGizmoPositionToMatchAttachedMesh: boolean;
  118943. /**
  118944. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118945. */
  118946. updateScale: boolean;
  118947. protected _interactionsEnabled: boolean;
  118948. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118949. private _beforeRenderObserver;
  118950. private _tempVector;
  118951. /**
  118952. * Creates a gizmo
  118953. * @param gizmoLayer The utility layer the gizmo will be added to
  118954. */
  118955. constructor(
  118956. /** The utility layer the gizmo will be added to */
  118957. gizmoLayer?: UtilityLayerRenderer);
  118958. /**
  118959. * Updates the gizmo to match the attached mesh's position/rotation
  118960. */
  118961. protected _update(): void;
  118962. /**
  118963. * Disposes of the gizmo
  118964. */
  118965. dispose(): void;
  118966. }
  118967. }
  118968. declare module BABYLON {
  118969. /**
  118970. * Single plane drag gizmo
  118971. */
  118972. export class PlaneDragGizmo extends Gizmo {
  118973. /**
  118974. * Drag behavior responsible for the gizmos dragging interactions
  118975. */
  118976. dragBehavior: PointerDragBehavior;
  118977. private _pointerObserver;
  118978. /**
  118979. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118980. */
  118981. snapDistance: number;
  118982. /**
  118983. * Event that fires each time the gizmo snaps to a new location.
  118984. * * snapDistance is the the change in distance
  118985. */
  118986. onSnapObservable: Observable<{
  118987. snapDistance: number;
  118988. }>;
  118989. private _plane;
  118990. private _coloredMaterial;
  118991. private _hoverMaterial;
  118992. private _isEnabled;
  118993. private _parent;
  118994. /** @hidden */
  118995. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  118996. /** @hidden */
  118997. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118998. /**
  118999. * Creates a PlaneDragGizmo
  119000. * @param gizmoLayer The utility layer the gizmo will be added to
  119001. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119002. * @param color The color of the gizmo
  119003. */
  119004. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119005. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119006. /**
  119007. * If the gizmo is enabled
  119008. */
  119009. set isEnabled(value: boolean);
  119010. get isEnabled(): boolean;
  119011. /**
  119012. * Disposes of the gizmo
  119013. */
  119014. dispose(): void;
  119015. }
  119016. }
  119017. declare module BABYLON {
  119018. /**
  119019. * Gizmo that enables dragging a mesh along 3 axis
  119020. */
  119021. export class PositionGizmo extends Gizmo {
  119022. /**
  119023. * Internal gizmo used for interactions on the x axis
  119024. */
  119025. xGizmo: AxisDragGizmo;
  119026. /**
  119027. * Internal gizmo used for interactions on the y axis
  119028. */
  119029. yGizmo: AxisDragGizmo;
  119030. /**
  119031. * Internal gizmo used for interactions on the z axis
  119032. */
  119033. zGizmo: AxisDragGizmo;
  119034. /**
  119035. * Internal gizmo used for interactions on the yz plane
  119036. */
  119037. xPlaneGizmo: PlaneDragGizmo;
  119038. /**
  119039. * Internal gizmo used for interactions on the xz plane
  119040. */
  119041. yPlaneGizmo: PlaneDragGizmo;
  119042. /**
  119043. * Internal gizmo used for interactions on the xy plane
  119044. */
  119045. zPlaneGizmo: PlaneDragGizmo;
  119046. /**
  119047. * private variables
  119048. */
  119049. private _meshAttached;
  119050. private _updateGizmoRotationToMatchAttachedMesh;
  119051. private _snapDistance;
  119052. private _scaleRatio;
  119053. /** Fires an event when any of it's sub gizmos are dragged */
  119054. onDragStartObservable: Observable<unknown>;
  119055. /** Fires an event when any of it's sub gizmos are released from dragging */
  119056. onDragEndObservable: Observable<unknown>;
  119057. /**
  119058. * If set to true, planar drag is enabled
  119059. */
  119060. private _planarGizmoEnabled;
  119061. get attachedMesh(): Nullable<AbstractMesh>;
  119062. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119063. /**
  119064. * Creates a PositionGizmo
  119065. * @param gizmoLayer The utility layer the gizmo will be added to
  119066. */
  119067. constructor(gizmoLayer?: UtilityLayerRenderer);
  119068. /**
  119069. * If the planar drag gizmo is enabled
  119070. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119071. */
  119072. set planarGizmoEnabled(value: boolean);
  119073. get planarGizmoEnabled(): boolean;
  119074. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119075. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119076. /**
  119077. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119078. */
  119079. set snapDistance(value: number);
  119080. get snapDistance(): number;
  119081. /**
  119082. * Ratio for the scale of the gizmo (Default: 1)
  119083. */
  119084. set scaleRatio(value: number);
  119085. get scaleRatio(): number;
  119086. /**
  119087. * Disposes of the gizmo
  119088. */
  119089. dispose(): void;
  119090. /**
  119091. * CustomMeshes are not supported by this gizmo
  119092. * @param mesh The mesh to replace the default mesh of the gizmo
  119093. */
  119094. setCustomMesh(mesh: Mesh): void;
  119095. }
  119096. }
  119097. declare module BABYLON {
  119098. /**
  119099. * Single axis drag gizmo
  119100. */
  119101. export class AxisDragGizmo extends Gizmo {
  119102. /**
  119103. * Drag behavior responsible for the gizmos dragging interactions
  119104. */
  119105. dragBehavior: PointerDragBehavior;
  119106. private _pointerObserver;
  119107. /**
  119108. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119109. */
  119110. snapDistance: number;
  119111. /**
  119112. * Event that fires each time the gizmo snaps to a new location.
  119113. * * snapDistance is the the change in distance
  119114. */
  119115. onSnapObservable: Observable<{
  119116. snapDistance: number;
  119117. }>;
  119118. private _isEnabled;
  119119. private _parent;
  119120. private _arrow;
  119121. private _coloredMaterial;
  119122. private _hoverMaterial;
  119123. /** @hidden */
  119124. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119125. /** @hidden */
  119126. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119127. /**
  119128. * Creates an AxisDragGizmo
  119129. * @param gizmoLayer The utility layer the gizmo will be added to
  119130. * @param dragAxis The axis which the gizmo will be able to drag on
  119131. * @param color The color of the gizmo
  119132. */
  119133. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119134. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119135. /**
  119136. * If the gizmo is enabled
  119137. */
  119138. set isEnabled(value: boolean);
  119139. get isEnabled(): boolean;
  119140. /**
  119141. * Disposes of the gizmo
  119142. */
  119143. dispose(): void;
  119144. }
  119145. }
  119146. declare module BABYLON.Debug {
  119147. /**
  119148. * The Axes viewer will show 3 axes in a specific point in space
  119149. */
  119150. export class AxesViewer {
  119151. private _xAxis;
  119152. private _yAxis;
  119153. private _zAxis;
  119154. private _scaleLinesFactor;
  119155. private _instanced;
  119156. /**
  119157. * Gets the hosting scene
  119158. */
  119159. scene: Scene;
  119160. /**
  119161. * Gets or sets a number used to scale line length
  119162. */
  119163. scaleLines: number;
  119164. /** Gets the node hierarchy used to render x-axis */
  119165. get xAxis(): TransformNode;
  119166. /** Gets the node hierarchy used to render y-axis */
  119167. get yAxis(): TransformNode;
  119168. /** Gets the node hierarchy used to render z-axis */
  119169. get zAxis(): TransformNode;
  119170. /**
  119171. * Creates a new AxesViewer
  119172. * @param scene defines the hosting scene
  119173. * @param scaleLines defines a number used to scale line length (1 by default)
  119174. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119175. * @param xAxis defines the node hierarchy used to render the x-axis
  119176. * @param yAxis defines the node hierarchy used to render the y-axis
  119177. * @param zAxis defines the node hierarchy used to render the z-axis
  119178. */
  119179. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119180. /**
  119181. * Force the viewer to update
  119182. * @param position defines the position of the viewer
  119183. * @param xaxis defines the x axis of the viewer
  119184. * @param yaxis defines the y axis of the viewer
  119185. * @param zaxis defines the z axis of the viewer
  119186. */
  119187. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119188. /**
  119189. * Creates an instance of this axes viewer.
  119190. * @returns a new axes viewer with instanced meshes
  119191. */
  119192. createInstance(): AxesViewer;
  119193. /** Releases resources */
  119194. dispose(): void;
  119195. private static _SetRenderingGroupId;
  119196. }
  119197. }
  119198. declare module BABYLON.Debug {
  119199. /**
  119200. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119201. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119202. */
  119203. export class BoneAxesViewer extends AxesViewer {
  119204. /**
  119205. * Gets or sets the target mesh where to display the axes viewer
  119206. */
  119207. mesh: Nullable<Mesh>;
  119208. /**
  119209. * Gets or sets the target bone where to display the axes viewer
  119210. */
  119211. bone: Nullable<Bone>;
  119212. /** Gets current position */
  119213. pos: Vector3;
  119214. /** Gets direction of X axis */
  119215. xaxis: Vector3;
  119216. /** Gets direction of Y axis */
  119217. yaxis: Vector3;
  119218. /** Gets direction of Z axis */
  119219. zaxis: Vector3;
  119220. /**
  119221. * Creates a new BoneAxesViewer
  119222. * @param scene defines the hosting scene
  119223. * @param bone defines the target bone
  119224. * @param mesh defines the target mesh
  119225. * @param scaleLines defines a scaling factor for line length (1 by default)
  119226. */
  119227. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119228. /**
  119229. * Force the viewer to update
  119230. */
  119231. update(): void;
  119232. /** Releases resources */
  119233. dispose(): void;
  119234. }
  119235. }
  119236. declare module BABYLON {
  119237. /**
  119238. * Interface used to define scene explorer extensibility option
  119239. */
  119240. export interface IExplorerExtensibilityOption {
  119241. /**
  119242. * Define the option label
  119243. */
  119244. label: string;
  119245. /**
  119246. * Defines the action to execute on click
  119247. */
  119248. action: (entity: any) => void;
  119249. }
  119250. /**
  119251. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119252. */
  119253. export interface IExplorerExtensibilityGroup {
  119254. /**
  119255. * Defines a predicate to test if a given type mut be extended
  119256. */
  119257. predicate: (entity: any) => boolean;
  119258. /**
  119259. * Gets the list of options added to a type
  119260. */
  119261. entries: IExplorerExtensibilityOption[];
  119262. }
  119263. /**
  119264. * Interface used to define the options to use to create the Inspector
  119265. */
  119266. export interface IInspectorOptions {
  119267. /**
  119268. * Display in overlay mode (default: false)
  119269. */
  119270. overlay?: boolean;
  119271. /**
  119272. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119273. */
  119274. globalRoot?: HTMLElement;
  119275. /**
  119276. * Display the Scene explorer
  119277. */
  119278. showExplorer?: boolean;
  119279. /**
  119280. * Display the property inspector
  119281. */
  119282. showInspector?: boolean;
  119283. /**
  119284. * Display in embed mode (both panes on the right)
  119285. */
  119286. embedMode?: boolean;
  119287. /**
  119288. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119289. */
  119290. handleResize?: boolean;
  119291. /**
  119292. * Allow the panes to popup (default: true)
  119293. */
  119294. enablePopup?: boolean;
  119295. /**
  119296. * Allow the panes to be closed by users (default: true)
  119297. */
  119298. enableClose?: boolean;
  119299. /**
  119300. * Optional list of extensibility entries
  119301. */
  119302. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119303. /**
  119304. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119305. */
  119306. inspectorURL?: string;
  119307. /**
  119308. * Optional initial tab (default to DebugLayerTab.Properties)
  119309. */
  119310. initialTab?: DebugLayerTab;
  119311. }
  119312. interface Scene {
  119313. /**
  119314. * @hidden
  119315. * Backing field
  119316. */
  119317. _debugLayer: DebugLayer;
  119318. /**
  119319. * Gets the debug layer (aka Inspector) associated with the scene
  119320. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119321. */
  119322. debugLayer: DebugLayer;
  119323. }
  119324. /**
  119325. * Enum of inspector action tab
  119326. */
  119327. export enum DebugLayerTab {
  119328. /**
  119329. * Properties tag (default)
  119330. */
  119331. Properties = 0,
  119332. /**
  119333. * Debug tab
  119334. */
  119335. Debug = 1,
  119336. /**
  119337. * Statistics tab
  119338. */
  119339. Statistics = 2,
  119340. /**
  119341. * Tools tab
  119342. */
  119343. Tools = 3,
  119344. /**
  119345. * Settings tab
  119346. */
  119347. Settings = 4
  119348. }
  119349. /**
  119350. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119351. * what is happening in your scene
  119352. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119353. */
  119354. export class DebugLayer {
  119355. /**
  119356. * Define the url to get the inspector script from.
  119357. * By default it uses the babylonjs CDN.
  119358. * @ignoreNaming
  119359. */
  119360. static InspectorURL: string;
  119361. private _scene;
  119362. private BJSINSPECTOR;
  119363. private _onPropertyChangedObservable?;
  119364. /**
  119365. * Observable triggered when a property is changed through the inspector.
  119366. */
  119367. get onPropertyChangedObservable(): any;
  119368. /**
  119369. * Instantiates a new debug layer.
  119370. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119371. * what is happening in your scene
  119372. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119373. * @param scene Defines the scene to inspect
  119374. */
  119375. constructor(scene: Scene);
  119376. /** Creates the inspector window. */
  119377. private _createInspector;
  119378. /**
  119379. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119380. * @param entity defines the entity to select
  119381. * @param lineContainerTitle defines the specific block to highlight
  119382. */
  119383. select(entity: any, lineContainerTitle?: string): void;
  119384. /** Get the inspector from bundle or global */
  119385. private _getGlobalInspector;
  119386. /**
  119387. * Get if the inspector is visible or not.
  119388. * @returns true if visible otherwise, false
  119389. */
  119390. isVisible(): boolean;
  119391. /**
  119392. * Hide the inspector and close its window.
  119393. */
  119394. hide(): void;
  119395. /**
  119396. * Launch the debugLayer.
  119397. * @param config Define the configuration of the inspector
  119398. * @return a promise fulfilled when the debug layer is visible
  119399. */
  119400. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119401. }
  119402. }
  119403. declare module BABYLON {
  119404. /**
  119405. * Class containing static functions to help procedurally build meshes
  119406. */
  119407. export class BoxBuilder {
  119408. /**
  119409. * Creates a box mesh
  119410. * * The parameter `size` sets the size (float) of each box side (default 1)
  119411. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119412. * * 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)
  119413. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119417. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119418. * @param name defines the name of the mesh
  119419. * @param options defines the options used to create the mesh
  119420. * @param scene defines the hosting scene
  119421. * @returns the box mesh
  119422. */
  119423. static CreateBox(name: string, options: {
  119424. size?: number;
  119425. width?: number;
  119426. height?: number;
  119427. depth?: number;
  119428. faceUV?: Vector4[];
  119429. faceColors?: Color4[];
  119430. sideOrientation?: number;
  119431. frontUVs?: Vector4;
  119432. backUVs?: Vector4;
  119433. wrap?: boolean;
  119434. topBaseAt?: number;
  119435. bottomBaseAt?: number;
  119436. updatable?: boolean;
  119437. }, scene?: Nullable<Scene>): Mesh;
  119438. }
  119439. }
  119440. declare module BABYLON.Debug {
  119441. /**
  119442. * Used to show the physics impostor around the specific mesh
  119443. */
  119444. export class PhysicsViewer {
  119445. /** @hidden */
  119446. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119447. /** @hidden */
  119448. protected _meshes: Array<Nullable<AbstractMesh>>;
  119449. /** @hidden */
  119450. protected _scene: Nullable<Scene>;
  119451. /** @hidden */
  119452. protected _numMeshes: number;
  119453. /** @hidden */
  119454. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119455. private _renderFunction;
  119456. private _utilityLayer;
  119457. private _debugBoxMesh;
  119458. private _debugSphereMesh;
  119459. private _debugCylinderMesh;
  119460. private _debugMaterial;
  119461. private _debugMeshMeshes;
  119462. /**
  119463. * Creates a new PhysicsViewer
  119464. * @param scene defines the hosting scene
  119465. */
  119466. constructor(scene: Scene);
  119467. /** @hidden */
  119468. protected _updateDebugMeshes(): void;
  119469. /**
  119470. * Renders a specified physic impostor
  119471. * @param impostor defines the impostor to render
  119472. * @param targetMesh defines the mesh represented by the impostor
  119473. * @returns the new debug mesh used to render the impostor
  119474. */
  119475. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119476. /**
  119477. * Hides a specified physic impostor
  119478. * @param impostor defines the impostor to hide
  119479. */
  119480. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119481. private _getDebugMaterial;
  119482. private _getDebugBoxMesh;
  119483. private _getDebugSphereMesh;
  119484. private _getDebugCylinderMesh;
  119485. private _getDebugMeshMesh;
  119486. private _getDebugMesh;
  119487. /** Releases all resources */
  119488. dispose(): void;
  119489. }
  119490. }
  119491. declare module BABYLON {
  119492. /**
  119493. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119494. * in order to better appreciate the issue one might have.
  119495. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119496. */
  119497. export class RayHelper {
  119498. /**
  119499. * Defines the ray we are currently tryin to visualize.
  119500. */
  119501. ray: Nullable<Ray>;
  119502. private _renderPoints;
  119503. private _renderLine;
  119504. private _renderFunction;
  119505. private _scene;
  119506. private _updateToMeshFunction;
  119507. private _attachedToMesh;
  119508. private _meshSpaceDirection;
  119509. private _meshSpaceOrigin;
  119510. /**
  119511. * Helper function to create a colored helper in a scene in one line.
  119512. * @param ray Defines the ray we are currently tryin to visualize
  119513. * @param scene Defines the scene the ray is used in
  119514. * @param color Defines the color we want to see the ray in
  119515. * @returns The newly created ray helper.
  119516. */
  119517. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119518. /**
  119519. * Instantiate a new ray helper.
  119520. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119521. * in order to better appreciate the issue one might have.
  119522. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119523. * @param ray Defines the ray we are currently tryin to visualize
  119524. */
  119525. constructor(ray: Ray);
  119526. /**
  119527. * Shows the ray we are willing to debug.
  119528. * @param scene Defines the scene the ray needs to be rendered in
  119529. * @param color Defines the color the ray needs to be rendered in
  119530. */
  119531. show(scene: Scene, color?: Color3): void;
  119532. /**
  119533. * Hides the ray we are debugging.
  119534. */
  119535. hide(): void;
  119536. private _render;
  119537. /**
  119538. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119539. * @param mesh Defines the mesh we want the helper attached to
  119540. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119541. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119542. * @param length Defines the length of the ray
  119543. */
  119544. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119545. /**
  119546. * Detach the ray helper from the mesh it has previously been attached to.
  119547. */
  119548. detachFromMesh(): void;
  119549. private _updateToMesh;
  119550. /**
  119551. * Dispose the helper and release its associated resources.
  119552. */
  119553. dispose(): void;
  119554. }
  119555. }
  119556. declare module BABYLON.Debug {
  119557. /**
  119558. * Class used to render a debug view of a given skeleton
  119559. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119560. */
  119561. export class SkeletonViewer {
  119562. /** defines the skeleton to render */
  119563. skeleton: Skeleton;
  119564. /** defines the mesh attached to the skeleton */
  119565. mesh: AbstractMesh;
  119566. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119567. autoUpdateBonesMatrices: boolean;
  119568. /** defines the rendering group id to use with the viewer */
  119569. renderingGroupId: number;
  119570. /** Gets or sets the color used to render the skeleton */
  119571. color: Color3;
  119572. private _scene;
  119573. private _debugLines;
  119574. private _debugMesh;
  119575. private _isEnabled;
  119576. private _renderFunction;
  119577. private _utilityLayer;
  119578. /**
  119579. * Returns the mesh used to render the bones
  119580. */
  119581. get debugMesh(): Nullable<LinesMesh>;
  119582. /**
  119583. * Creates a new SkeletonViewer
  119584. * @param skeleton defines the skeleton to render
  119585. * @param mesh defines the mesh attached to the skeleton
  119586. * @param scene defines the hosting scene
  119587. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119588. * @param renderingGroupId defines the rendering group id to use with the viewer
  119589. */
  119590. constructor(
  119591. /** defines the skeleton to render */
  119592. skeleton: Skeleton,
  119593. /** defines the mesh attached to the skeleton */
  119594. mesh: AbstractMesh, scene: Scene,
  119595. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119596. autoUpdateBonesMatrices?: boolean,
  119597. /** defines the rendering group id to use with the viewer */
  119598. renderingGroupId?: number);
  119599. /** Gets or sets a boolean indicating if the viewer is enabled */
  119600. set isEnabled(value: boolean);
  119601. get isEnabled(): boolean;
  119602. private _getBonePosition;
  119603. private _getLinesForBonesWithLength;
  119604. private _getLinesForBonesNoLength;
  119605. /** Update the viewer to sync with current skeleton state */
  119606. update(): void;
  119607. /** Release associated resources */
  119608. dispose(): void;
  119609. }
  119610. }
  119611. declare module BABYLON {
  119612. /**
  119613. * Options to create the null engine
  119614. */
  119615. export class NullEngineOptions {
  119616. /**
  119617. * Render width (Default: 512)
  119618. */
  119619. renderWidth: number;
  119620. /**
  119621. * Render height (Default: 256)
  119622. */
  119623. renderHeight: number;
  119624. /**
  119625. * Texture size (Default: 512)
  119626. */
  119627. textureSize: number;
  119628. /**
  119629. * If delta time between frames should be constant
  119630. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119631. */
  119632. deterministicLockstep: boolean;
  119633. /**
  119634. * Maximum about of steps between frames (Default: 4)
  119635. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119636. */
  119637. lockstepMaxSteps: number;
  119638. }
  119639. /**
  119640. * The null engine class provides support for headless version of babylon.js.
  119641. * This can be used in server side scenario or for testing purposes
  119642. */
  119643. export class NullEngine extends Engine {
  119644. private _options;
  119645. /**
  119646. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119648. * @returns true if engine is in deterministic lock step mode
  119649. */
  119650. isDeterministicLockStep(): boolean;
  119651. /**
  119652. * Gets the max steps when engine is running in deterministic lock step
  119653. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119654. * @returns the max steps
  119655. */
  119656. getLockstepMaxSteps(): number;
  119657. /**
  119658. * Gets the current hardware scaling level.
  119659. * By default the hardware scaling level is computed from the window device ratio.
  119660. * 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.
  119661. * @returns a number indicating the current hardware scaling level
  119662. */
  119663. getHardwareScalingLevel(): number;
  119664. constructor(options?: NullEngineOptions);
  119665. /**
  119666. * Creates a vertex buffer
  119667. * @param vertices the data for the vertex buffer
  119668. * @returns the new WebGL static buffer
  119669. */
  119670. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119671. /**
  119672. * Creates a new index buffer
  119673. * @param indices defines the content of the index buffer
  119674. * @param updatable defines if the index buffer must be updatable
  119675. * @returns a new webGL buffer
  119676. */
  119677. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119678. /**
  119679. * Clear the current render buffer or the current render target (if any is set up)
  119680. * @param color defines the color to use
  119681. * @param backBuffer defines if the back buffer must be cleared
  119682. * @param depth defines if the depth buffer must be cleared
  119683. * @param stencil defines if the stencil buffer must be cleared
  119684. */
  119685. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119686. /**
  119687. * Gets the current render width
  119688. * @param useScreen defines if screen size must be used (or the current render target if any)
  119689. * @returns a number defining the current render width
  119690. */
  119691. getRenderWidth(useScreen?: boolean): number;
  119692. /**
  119693. * Gets the current render height
  119694. * @param useScreen defines if screen size must be used (or the current render target if any)
  119695. * @returns a number defining the current render height
  119696. */
  119697. getRenderHeight(useScreen?: boolean): number;
  119698. /**
  119699. * Set the WebGL's viewport
  119700. * @param viewport defines the viewport element to be used
  119701. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119702. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119703. */
  119704. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119705. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119706. /**
  119707. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119708. * @param pipelineContext defines the pipeline context to use
  119709. * @param uniformsNames defines the list of uniform names
  119710. * @returns an array of webGL uniform locations
  119711. */
  119712. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119713. /**
  119714. * Gets the lsit of active attributes for a given webGL program
  119715. * @param pipelineContext defines the pipeline context to use
  119716. * @param attributesNames defines the list of attribute names to get
  119717. * @returns an array of indices indicating the offset of each attribute
  119718. */
  119719. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119720. /**
  119721. * Binds an effect to the webGL context
  119722. * @param effect defines the effect to bind
  119723. */
  119724. bindSamplers(effect: Effect): void;
  119725. /**
  119726. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119727. * @param effect defines the effect to activate
  119728. */
  119729. enableEffect(effect: Effect): void;
  119730. /**
  119731. * Set various states to the webGL context
  119732. * @param culling defines backface culling state
  119733. * @param zOffset defines the value to apply to zOffset (0 by default)
  119734. * @param force defines if states must be applied even if cache is up to date
  119735. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119736. */
  119737. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119738. /**
  119739. * Set the value of an uniform to an array of int32
  119740. * @param uniform defines the webGL uniform location where to store the value
  119741. * @param array defines the array of int32 to store
  119742. */
  119743. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119744. /**
  119745. * Set the value of an uniform to an array of int32 (stored as vec2)
  119746. * @param uniform defines the webGL uniform location where to store the value
  119747. * @param array defines the array of int32 to store
  119748. */
  119749. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119750. /**
  119751. * Set the value of an uniform to an array of int32 (stored as vec3)
  119752. * @param uniform defines the webGL uniform location where to store the value
  119753. * @param array defines the array of int32 to store
  119754. */
  119755. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119756. /**
  119757. * Set the value of an uniform to an array of int32 (stored as vec4)
  119758. * @param uniform defines the webGL uniform location where to store the value
  119759. * @param array defines the array of int32 to store
  119760. */
  119761. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119762. /**
  119763. * Set the value of an uniform to an array of float32
  119764. * @param uniform defines the webGL uniform location where to store the value
  119765. * @param array defines the array of float32 to store
  119766. */
  119767. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119768. /**
  119769. * Set the value of an uniform to an array of float32 (stored as vec2)
  119770. * @param uniform defines the webGL uniform location where to store the value
  119771. * @param array defines the array of float32 to store
  119772. */
  119773. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119774. /**
  119775. * Set the value of an uniform to an array of float32 (stored as vec3)
  119776. * @param uniform defines the webGL uniform location where to store the value
  119777. * @param array defines the array of float32 to store
  119778. */
  119779. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119780. /**
  119781. * Set the value of an uniform to an array of float32 (stored as vec4)
  119782. * @param uniform defines the webGL uniform location where to store the value
  119783. * @param array defines the array of float32 to store
  119784. */
  119785. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119786. /**
  119787. * Set the value of an uniform to an array of number
  119788. * @param uniform defines the webGL uniform location where to store the value
  119789. * @param array defines the array of number to store
  119790. */
  119791. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119792. /**
  119793. * Set the value of an uniform to an array of number (stored as vec2)
  119794. * @param uniform defines the webGL uniform location where to store the value
  119795. * @param array defines the array of number to store
  119796. */
  119797. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119798. /**
  119799. * Set the value of an uniform to an array of number (stored as vec3)
  119800. * @param uniform defines the webGL uniform location where to store the value
  119801. * @param array defines the array of number to store
  119802. */
  119803. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119804. /**
  119805. * Set the value of an uniform to an array of number (stored as vec4)
  119806. * @param uniform defines the webGL uniform location where to store the value
  119807. * @param array defines the array of number to store
  119808. */
  119809. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119810. /**
  119811. * Set the value of an uniform to an array of float32 (stored as matrices)
  119812. * @param uniform defines the webGL uniform location where to store the value
  119813. * @param matrices defines the array of float32 to store
  119814. */
  119815. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119816. /**
  119817. * Set the value of an uniform to a matrix (3x3)
  119818. * @param uniform defines the webGL uniform location where to store the value
  119819. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119820. */
  119821. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119822. /**
  119823. * Set the value of an uniform to a matrix (2x2)
  119824. * @param uniform defines the webGL uniform location where to store the value
  119825. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119826. */
  119827. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119828. /**
  119829. * Set the value of an uniform to a number (float)
  119830. * @param uniform defines the webGL uniform location where to store the value
  119831. * @param value defines the float number to store
  119832. */
  119833. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119834. /**
  119835. * Set the value of an uniform to a vec2
  119836. * @param uniform defines the webGL uniform location where to store the value
  119837. * @param x defines the 1st component of the value
  119838. * @param y defines the 2nd component of the value
  119839. */
  119840. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119841. /**
  119842. * Set the value of an uniform to a vec3
  119843. * @param uniform defines the webGL uniform location where to store the value
  119844. * @param x defines the 1st component of the value
  119845. * @param y defines the 2nd component of the value
  119846. * @param z defines the 3rd component of the value
  119847. */
  119848. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119849. /**
  119850. * Set the value of an uniform to a boolean
  119851. * @param uniform defines the webGL uniform location where to store the value
  119852. * @param bool defines the boolean to store
  119853. */
  119854. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119855. /**
  119856. * Set the value of an uniform to a vec4
  119857. * @param uniform defines the webGL uniform location where to store the value
  119858. * @param x defines the 1st component of the value
  119859. * @param y defines the 2nd component of the value
  119860. * @param z defines the 3rd component of the value
  119861. * @param w defines the 4th component of the value
  119862. */
  119863. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119864. /**
  119865. * Sets the current alpha mode
  119866. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119867. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119868. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119869. */
  119870. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119871. /**
  119872. * Bind webGl buffers directly to the webGL context
  119873. * @param vertexBuffers defines the vertex buffer to bind
  119874. * @param indexBuffer defines the index buffer to bind
  119875. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119876. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119877. * @param effect defines the effect associated with the vertex buffer
  119878. */
  119879. bindBuffers(vertexBuffers: {
  119880. [key: string]: VertexBuffer;
  119881. }, indexBuffer: DataBuffer, effect: Effect): void;
  119882. /**
  119883. * Force the entire cache to be cleared
  119884. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119885. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119886. */
  119887. wipeCaches(bruteForce?: boolean): void;
  119888. /**
  119889. * Send a draw order
  119890. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119891. * @param indexStart defines the starting index
  119892. * @param indexCount defines the number of index to draw
  119893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119894. */
  119895. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119896. /**
  119897. * Draw a list of indexed primitives
  119898. * @param fillMode defines the primitive to use
  119899. * @param indexStart defines the starting index
  119900. * @param indexCount defines the number of index to draw
  119901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119902. */
  119903. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119904. /**
  119905. * Draw a list of unindexed primitives
  119906. * @param fillMode defines the primitive to use
  119907. * @param verticesStart defines the index of first vertex to draw
  119908. * @param verticesCount defines the count of vertices to draw
  119909. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119910. */
  119911. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119912. /** @hidden */
  119913. _createTexture(): WebGLTexture;
  119914. /** @hidden */
  119915. _releaseTexture(texture: InternalTexture): void;
  119916. /**
  119917. * Usually called from Texture.ts.
  119918. * Passed information to create a WebGLTexture
  119919. * @param urlArg defines a value which contains one of the following:
  119920. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119921. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119922. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119923. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119924. * @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)
  119925. * @param scene needed for loading to the correct scene
  119926. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119927. * @param onLoad optional callback to be called upon successful completion
  119928. * @param onError optional callback to be called upon failure
  119929. * @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
  119930. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119931. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119932. * @param forcedExtension defines the extension to use to pick the right loader
  119933. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119934. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119935. */
  119936. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  119937. /**
  119938. * Creates a new render target texture
  119939. * @param size defines the size of the texture
  119940. * @param options defines the options used to create the texture
  119941. * @returns a new render target texture stored in an InternalTexture
  119942. */
  119943. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119944. /**
  119945. * Update the sampling mode of a given texture
  119946. * @param samplingMode defines the required sampling mode
  119947. * @param texture defines the texture to update
  119948. */
  119949. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119950. /**
  119951. * Binds the frame buffer to the specified texture.
  119952. * @param texture The texture to render to or null for the default canvas
  119953. * @param faceIndex The face of the texture to render to in case of cube texture
  119954. * @param requiredWidth The width of the target to render to
  119955. * @param requiredHeight The height of the target to render to
  119956. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119957. * @param lodLevel defines le lod level to bind to the frame buffer
  119958. */
  119959. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119960. /**
  119961. * Unbind the current render target texture from the webGL context
  119962. * @param texture defines the render target texture to unbind
  119963. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119964. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119965. */
  119966. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119967. /**
  119968. * Creates a dynamic vertex buffer
  119969. * @param vertices the data for the dynamic vertex buffer
  119970. * @returns the new WebGL dynamic buffer
  119971. */
  119972. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119973. /**
  119974. * Update the content of a dynamic texture
  119975. * @param texture defines the texture to update
  119976. * @param canvas defines the canvas containing the source
  119977. * @param invertY defines if data must be stored with Y axis inverted
  119978. * @param premulAlpha defines if alpha is stored as premultiplied
  119979. * @param format defines the format of the data
  119980. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119981. */
  119982. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119983. /**
  119984. * Gets a boolean indicating if all created effects are ready
  119985. * @returns true if all effects are ready
  119986. */
  119987. areAllEffectsReady(): boolean;
  119988. /**
  119989. * @hidden
  119990. * Get the current error code of the webGL context
  119991. * @returns the error code
  119992. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119993. */
  119994. getError(): number;
  119995. /** @hidden */
  119996. _getUnpackAlignement(): number;
  119997. /** @hidden */
  119998. _unpackFlipY(value: boolean): void;
  119999. /**
  120000. * Update a dynamic index buffer
  120001. * @param indexBuffer defines the target index buffer
  120002. * @param indices defines the data to update
  120003. * @param offset defines the offset in the target index buffer where update should start
  120004. */
  120005. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120006. /**
  120007. * Updates a dynamic vertex buffer.
  120008. * @param vertexBuffer the vertex buffer to update
  120009. * @param vertices the data used to update the vertex buffer
  120010. * @param byteOffset the byte offset of the data (optional)
  120011. * @param byteLength the byte length of the data (optional)
  120012. */
  120013. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120014. /** @hidden */
  120015. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120016. /** @hidden */
  120017. _bindTexture(channel: number, texture: InternalTexture): void;
  120018. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120019. /**
  120020. * 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
  120021. */
  120022. releaseEffects(): void;
  120023. displayLoadingUI(): void;
  120024. hideLoadingUI(): void;
  120025. /** @hidden */
  120026. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120027. /** @hidden */
  120028. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120029. /** @hidden */
  120030. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120031. /** @hidden */
  120032. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120033. }
  120034. }
  120035. declare module BABYLON {
  120036. /**
  120037. * @hidden
  120038. **/
  120039. export class _TimeToken {
  120040. _startTimeQuery: Nullable<WebGLQuery>;
  120041. _endTimeQuery: Nullable<WebGLQuery>;
  120042. _timeElapsedQuery: Nullable<WebGLQuery>;
  120043. _timeElapsedQueryEnded: boolean;
  120044. }
  120045. }
  120046. declare module BABYLON {
  120047. /** @hidden */
  120048. export class _OcclusionDataStorage {
  120049. /** @hidden */
  120050. occlusionInternalRetryCounter: number;
  120051. /** @hidden */
  120052. isOcclusionQueryInProgress: boolean;
  120053. /** @hidden */
  120054. isOccluded: boolean;
  120055. /** @hidden */
  120056. occlusionRetryCount: number;
  120057. /** @hidden */
  120058. occlusionType: number;
  120059. /** @hidden */
  120060. occlusionQueryAlgorithmType: number;
  120061. }
  120062. interface Engine {
  120063. /**
  120064. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120065. * @return the new query
  120066. */
  120067. createQuery(): WebGLQuery;
  120068. /**
  120069. * Delete and release a webGL query
  120070. * @param query defines the query to delete
  120071. * @return the current engine
  120072. */
  120073. deleteQuery(query: WebGLQuery): Engine;
  120074. /**
  120075. * Check if a given query has resolved and got its value
  120076. * @param query defines the query to check
  120077. * @returns true if the query got its value
  120078. */
  120079. isQueryResultAvailable(query: WebGLQuery): boolean;
  120080. /**
  120081. * Gets the value of a given query
  120082. * @param query defines the query to check
  120083. * @returns the value of the query
  120084. */
  120085. getQueryResult(query: WebGLQuery): number;
  120086. /**
  120087. * Initiates an occlusion query
  120088. * @param algorithmType defines the algorithm to use
  120089. * @param query defines the query to use
  120090. * @returns the current engine
  120091. * @see http://doc.babylonjs.com/features/occlusionquery
  120092. */
  120093. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120094. /**
  120095. * Ends an occlusion query
  120096. * @see http://doc.babylonjs.com/features/occlusionquery
  120097. * @param algorithmType defines the algorithm to use
  120098. * @returns the current engine
  120099. */
  120100. endOcclusionQuery(algorithmType: number): Engine;
  120101. /**
  120102. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120103. * Please note that only one query can be issued at a time
  120104. * @returns a time token used to track the time span
  120105. */
  120106. startTimeQuery(): Nullable<_TimeToken>;
  120107. /**
  120108. * Ends a time query
  120109. * @param token defines the token used to measure the time span
  120110. * @returns the time spent (in ns)
  120111. */
  120112. endTimeQuery(token: _TimeToken): int;
  120113. /** @hidden */
  120114. _currentNonTimestampToken: Nullable<_TimeToken>;
  120115. /** @hidden */
  120116. _createTimeQuery(): WebGLQuery;
  120117. /** @hidden */
  120118. _deleteTimeQuery(query: WebGLQuery): void;
  120119. /** @hidden */
  120120. _getGlAlgorithmType(algorithmType: number): number;
  120121. /** @hidden */
  120122. _getTimeQueryResult(query: WebGLQuery): any;
  120123. /** @hidden */
  120124. _getTimeQueryAvailability(query: WebGLQuery): any;
  120125. }
  120126. interface AbstractMesh {
  120127. /**
  120128. * Backing filed
  120129. * @hidden
  120130. */
  120131. __occlusionDataStorage: _OcclusionDataStorage;
  120132. /**
  120133. * Access property
  120134. * @hidden
  120135. */
  120136. _occlusionDataStorage: _OcclusionDataStorage;
  120137. /**
  120138. * 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.
  120139. * The default value is -1 which means don't break the query and wait till the result
  120140. * @see http://doc.babylonjs.com/features/occlusionquery
  120141. */
  120142. occlusionRetryCount: number;
  120143. /**
  120144. * 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:
  120145. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120146. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120147. * * 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.
  120148. * @see http://doc.babylonjs.com/features/occlusionquery
  120149. */
  120150. occlusionType: number;
  120151. /**
  120152. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120153. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120154. * * 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.
  120155. * @see http://doc.babylonjs.com/features/occlusionquery
  120156. */
  120157. occlusionQueryAlgorithmType: number;
  120158. /**
  120159. * 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
  120160. * @see http://doc.babylonjs.com/features/occlusionquery
  120161. */
  120162. isOccluded: boolean;
  120163. /**
  120164. * Flag to check the progress status of the query
  120165. * @see http://doc.babylonjs.com/features/occlusionquery
  120166. */
  120167. isOcclusionQueryInProgress: boolean;
  120168. }
  120169. }
  120170. declare module BABYLON {
  120171. /** @hidden */
  120172. export var _forceTransformFeedbackToBundle: boolean;
  120173. interface Engine {
  120174. /**
  120175. * Creates a webGL transform feedback object
  120176. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120177. * @returns the webGL transform feedback object
  120178. */
  120179. createTransformFeedback(): WebGLTransformFeedback;
  120180. /**
  120181. * Delete a webGL transform feedback object
  120182. * @param value defines the webGL transform feedback object to delete
  120183. */
  120184. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120185. /**
  120186. * Bind a webGL transform feedback object to the webgl context
  120187. * @param value defines the webGL transform feedback object to bind
  120188. */
  120189. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120190. /**
  120191. * Begins a transform feedback operation
  120192. * @param usePoints defines if points or triangles must be used
  120193. */
  120194. beginTransformFeedback(usePoints: boolean): void;
  120195. /**
  120196. * Ends a transform feedback operation
  120197. */
  120198. endTransformFeedback(): void;
  120199. /**
  120200. * Specify the varyings to use with transform feedback
  120201. * @param program defines the associated webGL program
  120202. * @param value defines the list of strings representing the varying names
  120203. */
  120204. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120205. /**
  120206. * Bind a webGL buffer for a transform feedback operation
  120207. * @param value defines the webGL buffer to bind
  120208. */
  120209. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120210. }
  120211. }
  120212. declare module BABYLON {
  120213. /**
  120214. * Creation options of the multi render target texture.
  120215. */
  120216. export interface IMultiRenderTargetOptions {
  120217. /**
  120218. * Define if the texture needs to create mip maps after render.
  120219. */
  120220. generateMipMaps?: boolean;
  120221. /**
  120222. * Define the types of all the draw buffers we want to create
  120223. */
  120224. types?: number[];
  120225. /**
  120226. * Define the sampling modes of all the draw buffers we want to create
  120227. */
  120228. samplingModes?: number[];
  120229. /**
  120230. * Define if a depth buffer is required
  120231. */
  120232. generateDepthBuffer?: boolean;
  120233. /**
  120234. * Define if a stencil buffer is required
  120235. */
  120236. generateStencilBuffer?: boolean;
  120237. /**
  120238. * Define if a depth texture is required instead of a depth buffer
  120239. */
  120240. generateDepthTexture?: boolean;
  120241. /**
  120242. * Define the number of desired draw buffers
  120243. */
  120244. textureCount?: number;
  120245. /**
  120246. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120247. */
  120248. doNotChangeAspectRatio?: boolean;
  120249. /**
  120250. * Define the default type of the buffers we are creating
  120251. */
  120252. defaultType?: number;
  120253. }
  120254. /**
  120255. * A multi render target, like a render target provides the ability to render to a texture.
  120256. * Unlike the render target, it can render to several draw buffers in one draw.
  120257. * This is specially interesting in deferred rendering or for any effects requiring more than
  120258. * just one color from a single pass.
  120259. */
  120260. export class MultiRenderTarget extends RenderTargetTexture {
  120261. private _internalTextures;
  120262. private _textures;
  120263. private _multiRenderTargetOptions;
  120264. /**
  120265. * Get if draw buffers are currently supported by the used hardware and browser.
  120266. */
  120267. get isSupported(): boolean;
  120268. /**
  120269. * Get the list of textures generated by the multi render target.
  120270. */
  120271. get textures(): Texture[];
  120272. /**
  120273. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120274. */
  120275. get depthTexture(): Texture;
  120276. /**
  120277. * Set the wrapping mode on U of all the textures we are rendering to.
  120278. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120279. */
  120280. set wrapU(wrap: number);
  120281. /**
  120282. * Set the wrapping mode on V of all the textures we are rendering to.
  120283. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120284. */
  120285. set wrapV(wrap: number);
  120286. /**
  120287. * Instantiate a new multi render target texture.
  120288. * A multi render target, like a render target provides the ability to render to a texture.
  120289. * Unlike the render target, it can render to several draw buffers in one draw.
  120290. * This is specially interesting in deferred rendering or for any effects requiring more than
  120291. * just one color from a single pass.
  120292. * @param name Define the name of the texture
  120293. * @param size Define the size of the buffers to render to
  120294. * @param count Define the number of target we are rendering into
  120295. * @param scene Define the scene the texture belongs to
  120296. * @param options Define the options used to create the multi render target
  120297. */
  120298. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120299. /** @hidden */
  120300. _rebuild(): void;
  120301. private _createInternalTextures;
  120302. private _createTextures;
  120303. /**
  120304. * Define the number of samples used if MSAA is enabled.
  120305. */
  120306. get samples(): number;
  120307. set samples(value: number);
  120308. /**
  120309. * Resize all the textures in the multi render target.
  120310. * Be carrefull as it will recreate all the data in the new texture.
  120311. * @param size Define the new size
  120312. */
  120313. resize(size: any): void;
  120314. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120315. /**
  120316. * Dispose the render targets and their associated resources
  120317. */
  120318. dispose(): void;
  120319. /**
  120320. * Release all the underlying texture used as draw buffers.
  120321. */
  120322. releaseInternalTextures(): void;
  120323. }
  120324. }
  120325. declare module BABYLON {
  120326. interface ThinEngine {
  120327. /**
  120328. * Unbind a list of render target textures from the webGL context
  120329. * This is used only when drawBuffer extension or webGL2 are active
  120330. * @param textures defines the render target textures to unbind
  120331. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120332. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120333. */
  120334. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120335. /**
  120336. * Create a multi render target texture
  120337. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120338. * @param size defines the size of the texture
  120339. * @param options defines the creation options
  120340. * @returns the cube texture as an InternalTexture
  120341. */
  120342. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120343. /**
  120344. * Update the sample count for a given multiple render target texture
  120345. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120346. * @param textures defines the textures to update
  120347. * @param samples defines the sample count to set
  120348. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120349. */
  120350. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120351. }
  120352. }
  120353. declare module BABYLON {
  120354. /**
  120355. * Class used to define an additional view for the engine
  120356. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120357. */
  120358. export class EngineView {
  120359. /** Defines the canvas where to render the view */
  120360. target: HTMLCanvasElement;
  120361. /** Defines an optional camera used to render the view (will use active camera else) */
  120362. camera?: Camera;
  120363. }
  120364. interface Engine {
  120365. /**
  120366. * Gets or sets the HTML element to use for attaching events
  120367. */
  120368. inputElement: Nullable<HTMLElement>;
  120369. /**
  120370. * Gets the current engine view
  120371. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120372. */
  120373. activeView: Nullable<EngineView>;
  120374. /** Gets or sets the list of views */
  120375. views: EngineView[];
  120376. /**
  120377. * Register a new child canvas
  120378. * @param canvas defines the canvas to register
  120379. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120380. * @returns the associated view
  120381. */
  120382. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120383. /**
  120384. * Remove a registered child canvas
  120385. * @param canvas defines the canvas to remove
  120386. * @returns the current engine
  120387. */
  120388. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120389. }
  120390. }
  120391. declare module BABYLON {
  120392. /**
  120393. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120394. */
  120395. export interface CubeMapInfo {
  120396. /**
  120397. * The pixel array for the front face.
  120398. * This is stored in format, left to right, up to down format.
  120399. */
  120400. front: Nullable<ArrayBufferView>;
  120401. /**
  120402. * The pixel array for the back face.
  120403. * This is stored in format, left to right, up to down format.
  120404. */
  120405. back: Nullable<ArrayBufferView>;
  120406. /**
  120407. * The pixel array for the left face.
  120408. * This is stored in format, left to right, up to down format.
  120409. */
  120410. left: Nullable<ArrayBufferView>;
  120411. /**
  120412. * The pixel array for the right face.
  120413. * This is stored in format, left to right, up to down format.
  120414. */
  120415. right: Nullable<ArrayBufferView>;
  120416. /**
  120417. * The pixel array for the up face.
  120418. * This is stored in format, left to right, up to down format.
  120419. */
  120420. up: Nullable<ArrayBufferView>;
  120421. /**
  120422. * The pixel array for the down face.
  120423. * This is stored in format, left to right, up to down format.
  120424. */
  120425. down: Nullable<ArrayBufferView>;
  120426. /**
  120427. * The size of the cubemap stored.
  120428. *
  120429. * Each faces will be size * size pixels.
  120430. */
  120431. size: number;
  120432. /**
  120433. * The format of the texture.
  120434. *
  120435. * RGBA, RGB.
  120436. */
  120437. format: number;
  120438. /**
  120439. * The type of the texture data.
  120440. *
  120441. * UNSIGNED_INT, FLOAT.
  120442. */
  120443. type: number;
  120444. /**
  120445. * Specifies whether the texture is in gamma space.
  120446. */
  120447. gammaSpace: boolean;
  120448. }
  120449. /**
  120450. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120451. */
  120452. export class PanoramaToCubeMapTools {
  120453. private static FACE_FRONT;
  120454. private static FACE_BACK;
  120455. private static FACE_RIGHT;
  120456. private static FACE_LEFT;
  120457. private static FACE_DOWN;
  120458. private static FACE_UP;
  120459. /**
  120460. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120461. *
  120462. * @param float32Array The source data.
  120463. * @param inputWidth The width of the input panorama.
  120464. * @param inputHeight The height of the input panorama.
  120465. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120466. * @return The cubemap data
  120467. */
  120468. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120469. private static CreateCubemapTexture;
  120470. private static CalcProjectionSpherical;
  120471. }
  120472. }
  120473. declare module BABYLON {
  120474. /**
  120475. * Helper class dealing with the extraction of spherical polynomial dataArray
  120476. * from a cube map.
  120477. */
  120478. export class CubeMapToSphericalPolynomialTools {
  120479. private static FileFaces;
  120480. /**
  120481. * Converts a texture to the according Spherical Polynomial data.
  120482. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120483. *
  120484. * @param texture The texture to extract the information from.
  120485. * @return The Spherical Polynomial data.
  120486. */
  120487. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120488. /**
  120489. * Converts a cubemap to the according Spherical Polynomial data.
  120490. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120491. *
  120492. * @param cubeInfo The Cube map to extract the information from.
  120493. * @return The Spherical Polynomial data.
  120494. */
  120495. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120496. }
  120497. }
  120498. declare module BABYLON {
  120499. interface BaseTexture {
  120500. /**
  120501. * Get the polynomial representation of the texture data.
  120502. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120503. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120504. */
  120505. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120506. }
  120507. }
  120508. declare module BABYLON {
  120509. /** @hidden */
  120510. export var rgbdEncodePixelShader: {
  120511. name: string;
  120512. shader: string;
  120513. };
  120514. }
  120515. declare module BABYLON {
  120516. /** @hidden */
  120517. export var rgbdDecodePixelShader: {
  120518. name: string;
  120519. shader: string;
  120520. };
  120521. }
  120522. declare module BABYLON {
  120523. /**
  120524. * Raw texture data and descriptor sufficient for WebGL texture upload
  120525. */
  120526. export interface EnvironmentTextureInfo {
  120527. /**
  120528. * Version of the environment map
  120529. */
  120530. version: number;
  120531. /**
  120532. * Width of image
  120533. */
  120534. width: number;
  120535. /**
  120536. * Irradiance information stored in the file.
  120537. */
  120538. irradiance: any;
  120539. /**
  120540. * Specular information stored in the file.
  120541. */
  120542. specular: any;
  120543. }
  120544. /**
  120545. * Defines One Image in the file. It requires only the position in the file
  120546. * as well as the length.
  120547. */
  120548. interface BufferImageData {
  120549. /**
  120550. * Length of the image data.
  120551. */
  120552. length: number;
  120553. /**
  120554. * Position of the data from the null terminator delimiting the end of the JSON.
  120555. */
  120556. position: number;
  120557. }
  120558. /**
  120559. * Defines the specular data enclosed in the file.
  120560. * This corresponds to the version 1 of the data.
  120561. */
  120562. export interface EnvironmentTextureSpecularInfoV1 {
  120563. /**
  120564. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120565. */
  120566. specularDataPosition?: number;
  120567. /**
  120568. * This contains all the images data needed to reconstruct the cubemap.
  120569. */
  120570. mipmaps: Array<BufferImageData>;
  120571. /**
  120572. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120573. */
  120574. lodGenerationScale: number;
  120575. }
  120576. /**
  120577. * Sets of helpers addressing the serialization and deserialization of environment texture
  120578. * stored in a BabylonJS env file.
  120579. * Those files are usually stored as .env files.
  120580. */
  120581. export class EnvironmentTextureTools {
  120582. /**
  120583. * Magic number identifying the env file.
  120584. */
  120585. private static _MagicBytes;
  120586. /**
  120587. * Gets the environment info from an env file.
  120588. * @param data The array buffer containing the .env bytes.
  120589. * @returns the environment file info (the json header) if successfully parsed.
  120590. */
  120591. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120592. /**
  120593. * Creates an environment texture from a loaded cube texture.
  120594. * @param texture defines the cube texture to convert in env file
  120595. * @return a promise containing the environment data if succesfull.
  120596. */
  120597. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120598. /**
  120599. * Creates a JSON representation of the spherical data.
  120600. * @param texture defines the texture containing the polynomials
  120601. * @return the JSON representation of the spherical info
  120602. */
  120603. private static _CreateEnvTextureIrradiance;
  120604. /**
  120605. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120606. * @param data the image data
  120607. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120608. * @return the views described by info providing access to the underlying buffer
  120609. */
  120610. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120611. /**
  120612. * Uploads the texture info contained in the env file to the GPU.
  120613. * @param texture defines the internal texture to upload to
  120614. * @param data defines the data to load
  120615. * @param info defines the texture info retrieved through the GetEnvInfo method
  120616. * @returns a promise
  120617. */
  120618. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120619. private static _OnImageReadyAsync;
  120620. /**
  120621. * Uploads the levels of image data to the GPU.
  120622. * @param texture defines the internal texture to upload to
  120623. * @param imageData defines the array buffer views of image data [mipmap][face]
  120624. * @returns a promise
  120625. */
  120626. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120627. /**
  120628. * Uploads spherical polynomials information to the texture.
  120629. * @param texture defines the texture we are trying to upload the information to
  120630. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120631. */
  120632. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120633. /** @hidden */
  120634. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120635. }
  120636. }
  120637. declare module BABYLON {
  120638. /**
  120639. * Contains position and normal vectors for a vertex
  120640. */
  120641. export class PositionNormalVertex {
  120642. /** the position of the vertex (defaut: 0,0,0) */
  120643. position: Vector3;
  120644. /** the normal of the vertex (defaut: 0,1,0) */
  120645. normal: Vector3;
  120646. /**
  120647. * Creates a PositionNormalVertex
  120648. * @param position the position of the vertex (defaut: 0,0,0)
  120649. * @param normal the normal of the vertex (defaut: 0,1,0)
  120650. */
  120651. constructor(
  120652. /** the position of the vertex (defaut: 0,0,0) */
  120653. position?: Vector3,
  120654. /** the normal of the vertex (defaut: 0,1,0) */
  120655. normal?: Vector3);
  120656. /**
  120657. * Clones the PositionNormalVertex
  120658. * @returns the cloned PositionNormalVertex
  120659. */
  120660. clone(): PositionNormalVertex;
  120661. }
  120662. /**
  120663. * Contains position, normal and uv vectors for a vertex
  120664. */
  120665. export class PositionNormalTextureVertex {
  120666. /** the position of the vertex (defaut: 0,0,0) */
  120667. position: Vector3;
  120668. /** the normal of the vertex (defaut: 0,1,0) */
  120669. normal: Vector3;
  120670. /** the uv of the vertex (default: 0,0) */
  120671. uv: Vector2;
  120672. /**
  120673. * Creates a PositionNormalTextureVertex
  120674. * @param position the position of the vertex (defaut: 0,0,0)
  120675. * @param normal the normal of the vertex (defaut: 0,1,0)
  120676. * @param uv the uv of the vertex (default: 0,0)
  120677. */
  120678. constructor(
  120679. /** the position of the vertex (defaut: 0,0,0) */
  120680. position?: Vector3,
  120681. /** the normal of the vertex (defaut: 0,1,0) */
  120682. normal?: Vector3,
  120683. /** the uv of the vertex (default: 0,0) */
  120684. uv?: Vector2);
  120685. /**
  120686. * Clones the PositionNormalTextureVertex
  120687. * @returns the cloned PositionNormalTextureVertex
  120688. */
  120689. clone(): PositionNormalTextureVertex;
  120690. }
  120691. }
  120692. declare module BABYLON {
  120693. /** @hidden */
  120694. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120695. private _genericAttributeLocation;
  120696. private _varyingLocationCount;
  120697. private _varyingLocationMap;
  120698. private _replacements;
  120699. private _textureCount;
  120700. private _uniforms;
  120701. lineProcessor(line: string): string;
  120702. attributeProcessor(attribute: string): string;
  120703. varyingProcessor(varying: string, isFragment: boolean): string;
  120704. uniformProcessor(uniform: string): string;
  120705. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120706. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120707. }
  120708. }
  120709. declare module BABYLON {
  120710. /**
  120711. * Container for accessors for natively-stored mesh data buffers.
  120712. */
  120713. class NativeDataBuffer extends DataBuffer {
  120714. /**
  120715. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120716. */
  120717. nativeIndexBuffer?: any;
  120718. /**
  120719. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120720. */
  120721. nativeVertexBuffer?: any;
  120722. }
  120723. /** @hidden */
  120724. class NativeTexture extends InternalTexture {
  120725. getInternalTexture(): InternalTexture;
  120726. getViewCount(): number;
  120727. }
  120728. /** @hidden */
  120729. export class NativeEngine extends Engine {
  120730. private readonly _native;
  120731. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120732. private readonly INVALID_HANDLE;
  120733. getHardwareScalingLevel(): number;
  120734. constructor();
  120735. /**
  120736. * Can be used to override the current requestAnimationFrame requester.
  120737. * @hidden
  120738. */
  120739. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120740. /**
  120741. * Override default engine behavior.
  120742. * @param color
  120743. * @param backBuffer
  120744. * @param depth
  120745. * @param stencil
  120746. */
  120747. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120748. /**
  120749. * Gets host document
  120750. * @returns the host document object
  120751. */
  120752. getHostDocument(): Nullable<Document>;
  120753. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120754. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120755. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120756. recordVertexArrayObject(vertexBuffers: {
  120757. [key: string]: VertexBuffer;
  120758. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120759. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120760. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120761. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120762. /**
  120763. * Draw a list of indexed primitives
  120764. * @param fillMode defines the primitive to use
  120765. * @param indexStart defines the starting index
  120766. * @param indexCount defines the number of index to draw
  120767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120768. */
  120769. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120770. /**
  120771. * Draw a list of unindexed primitives
  120772. * @param fillMode defines the primitive to use
  120773. * @param verticesStart defines the index of first vertex to draw
  120774. * @param verticesCount defines the count of vertices to draw
  120775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120776. */
  120777. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120778. createPipelineContext(): IPipelineContext;
  120779. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120780. /** @hidden */
  120781. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120782. /** @hidden */
  120783. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120784. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120785. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120786. protected _setProgram(program: WebGLProgram): void;
  120787. _releaseEffect(effect: Effect): void;
  120788. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120789. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120790. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120791. bindSamplers(effect: Effect): void;
  120792. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120793. getRenderWidth(useScreen?: boolean): number;
  120794. getRenderHeight(useScreen?: boolean): number;
  120795. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120796. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120797. /**
  120798. * Set the z offset to apply to current rendering
  120799. * @param value defines the offset to apply
  120800. */
  120801. setZOffset(value: number): void;
  120802. /**
  120803. * Gets the current value of the zOffset
  120804. * @returns the current zOffset state
  120805. */
  120806. getZOffset(): number;
  120807. /**
  120808. * Enable or disable depth buffering
  120809. * @param enable defines the state to set
  120810. */
  120811. setDepthBuffer(enable: boolean): void;
  120812. /**
  120813. * Gets a boolean indicating if depth writing is enabled
  120814. * @returns the current depth writing state
  120815. */
  120816. getDepthWrite(): boolean;
  120817. /**
  120818. * Enable or disable depth writing
  120819. * @param enable defines the state to set
  120820. */
  120821. setDepthWrite(enable: boolean): void;
  120822. /**
  120823. * Enable or disable color writing
  120824. * @param enable defines the state to set
  120825. */
  120826. setColorWrite(enable: boolean): void;
  120827. /**
  120828. * Gets a boolean indicating if color writing is enabled
  120829. * @returns the current color writing state
  120830. */
  120831. getColorWrite(): boolean;
  120832. /**
  120833. * Sets alpha constants used by some alpha blending modes
  120834. * @param r defines the red component
  120835. * @param g defines the green component
  120836. * @param b defines the blue component
  120837. * @param a defines the alpha component
  120838. */
  120839. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120840. /**
  120841. * Sets the current alpha mode
  120842. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120843. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120844. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120845. */
  120846. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120847. /**
  120848. * Gets the current alpha mode
  120849. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120850. * @returns the current alpha mode
  120851. */
  120852. getAlphaMode(): number;
  120853. setInt(uniform: WebGLUniformLocation, int: number): void;
  120854. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120855. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120856. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120857. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120858. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120859. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120860. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120861. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120862. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120863. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120864. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120865. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120866. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120867. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120868. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120869. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120870. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120871. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120872. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120873. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120874. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120875. wipeCaches(bruteForce?: boolean): void;
  120876. _createTexture(): WebGLTexture;
  120877. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120878. /**
  120879. * Usually called from BABYLON.Texture.ts.
  120880. * Passed information to create a WebGLTexture
  120881. * @param urlArg defines a value which contains one of the following:
  120882. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120883. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120884. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120885. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120886. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120887. * @param scene needed for loading to the correct scene
  120888. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120889. * @param onLoad optional callback to be called upon successful completion
  120890. * @param onError optional callback to be called upon failure
  120891. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120892. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120893. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120894. * @param forcedExtension defines the extension to use to pick the right loader
  120895. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120896. */
  120897. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  120898. /**
  120899. * Creates a cube texture
  120900. * @param rootUrl defines the url where the files to load is located
  120901. * @param scene defines the current scene
  120902. * @param files defines the list of files to load (1 per face)
  120903. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120904. * @param onLoad defines an optional callback raised when the texture is loaded
  120905. * @param onError defines an optional callback raised if there is an issue to load the texture
  120906. * @param format defines the format of the data
  120907. * @param forcedExtension defines the extension to use to pick the right loader
  120908. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120909. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120910. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120911. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120912. * @returns the cube texture as an InternalTexture
  120913. */
  120914. 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;
  120915. private _getSamplingFilter;
  120916. private static _GetNativeTextureFormat;
  120917. createRenderTargetTexture(size: number | {
  120918. width: number;
  120919. height: number;
  120920. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120921. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120922. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120923. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120924. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120925. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120926. /**
  120927. * Updates a dynamic vertex buffer.
  120928. * @param vertexBuffer the vertex buffer to update
  120929. * @param data the data used to update the vertex buffer
  120930. * @param byteOffset the byte offset of the data (optional)
  120931. * @param byteLength the byte length of the data (optional)
  120932. */
  120933. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120934. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120935. private _updateAnisotropicLevel;
  120936. private _getAddressMode;
  120937. /** @hidden */
  120938. _bindTexture(channel: number, texture: InternalTexture): void;
  120939. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120940. releaseEffects(): void;
  120941. /** @hidden */
  120942. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120943. /** @hidden */
  120944. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120945. /** @hidden */
  120946. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120947. /** @hidden */
  120948. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120949. }
  120950. }
  120951. declare module BABYLON {
  120952. /**
  120953. * Gather the list of clipboard event types as constants.
  120954. */
  120955. export class ClipboardEventTypes {
  120956. /**
  120957. * The clipboard event is fired when a copy command is active (pressed).
  120958. */
  120959. static readonly COPY: number;
  120960. /**
  120961. * The clipboard event is fired when a cut command is active (pressed).
  120962. */
  120963. static readonly CUT: number;
  120964. /**
  120965. * The clipboard event is fired when a paste command is active (pressed).
  120966. */
  120967. static readonly PASTE: number;
  120968. }
  120969. /**
  120970. * This class is used to store clipboard related info for the onClipboardObservable event.
  120971. */
  120972. export class ClipboardInfo {
  120973. /**
  120974. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120975. */
  120976. type: number;
  120977. /**
  120978. * Defines the related dom event
  120979. */
  120980. event: ClipboardEvent;
  120981. /**
  120982. *Creates an instance of ClipboardInfo.
  120983. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120984. * @param event Defines the related dom event
  120985. */
  120986. constructor(
  120987. /**
  120988. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120989. */
  120990. type: number,
  120991. /**
  120992. * Defines the related dom event
  120993. */
  120994. event: ClipboardEvent);
  120995. /**
  120996. * Get the clipboard event's type from the keycode.
  120997. * @param keyCode Defines the keyCode for the current keyboard event.
  120998. * @return {number}
  120999. */
  121000. static GetTypeFromCharacter(keyCode: number): number;
  121001. }
  121002. }
  121003. declare module BABYLON {
  121004. /**
  121005. * Google Daydream controller
  121006. */
  121007. export class DaydreamController extends WebVRController {
  121008. /**
  121009. * Base Url for the controller model.
  121010. */
  121011. static MODEL_BASE_URL: string;
  121012. /**
  121013. * File name for the controller model.
  121014. */
  121015. static MODEL_FILENAME: string;
  121016. /**
  121017. * Gamepad Id prefix used to identify Daydream Controller.
  121018. */
  121019. static readonly GAMEPAD_ID_PREFIX: string;
  121020. /**
  121021. * Creates a new DaydreamController from a gamepad
  121022. * @param vrGamepad the gamepad that the controller should be created from
  121023. */
  121024. constructor(vrGamepad: any);
  121025. /**
  121026. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121027. * @param scene scene in which to add meshes
  121028. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121029. */
  121030. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121031. /**
  121032. * Called once for each button that changed state since the last frame
  121033. * @param buttonIdx Which button index changed
  121034. * @param state New state of the button
  121035. * @param changes Which properties on the state changed since last frame
  121036. */
  121037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121038. }
  121039. }
  121040. declare module BABYLON {
  121041. /**
  121042. * Gear VR Controller
  121043. */
  121044. export class GearVRController extends WebVRController {
  121045. /**
  121046. * Base Url for the controller model.
  121047. */
  121048. static MODEL_BASE_URL: string;
  121049. /**
  121050. * File name for the controller model.
  121051. */
  121052. static MODEL_FILENAME: string;
  121053. /**
  121054. * Gamepad Id prefix used to identify this controller.
  121055. */
  121056. static readonly GAMEPAD_ID_PREFIX: string;
  121057. private readonly _buttonIndexToObservableNameMap;
  121058. /**
  121059. * Creates a new GearVRController from a gamepad
  121060. * @param vrGamepad the gamepad that the controller should be created from
  121061. */
  121062. constructor(vrGamepad: any);
  121063. /**
  121064. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121065. * @param scene scene in which to add meshes
  121066. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121067. */
  121068. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121069. /**
  121070. * Called once for each button that changed state since the last frame
  121071. * @param buttonIdx Which button index changed
  121072. * @param state New state of the button
  121073. * @param changes Which properties on the state changed since last frame
  121074. */
  121075. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121076. }
  121077. }
  121078. declare module BABYLON {
  121079. /**
  121080. * Generic Controller
  121081. */
  121082. export class GenericController extends WebVRController {
  121083. /**
  121084. * Base Url for the controller model.
  121085. */
  121086. static readonly MODEL_BASE_URL: string;
  121087. /**
  121088. * File name for the controller model.
  121089. */
  121090. static readonly MODEL_FILENAME: string;
  121091. /**
  121092. * Creates a new GenericController from a gamepad
  121093. * @param vrGamepad the gamepad that the controller should be created from
  121094. */
  121095. constructor(vrGamepad: any);
  121096. /**
  121097. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121098. * @param scene scene in which to add meshes
  121099. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121100. */
  121101. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121102. /**
  121103. * Called once for each button that changed state since the last frame
  121104. * @param buttonIdx Which button index changed
  121105. * @param state New state of the button
  121106. * @param changes Which properties on the state changed since last frame
  121107. */
  121108. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121109. }
  121110. }
  121111. declare module BABYLON {
  121112. /**
  121113. * Oculus Touch Controller
  121114. */
  121115. export class OculusTouchController extends WebVRController {
  121116. /**
  121117. * Base Url for the controller model.
  121118. */
  121119. static MODEL_BASE_URL: string;
  121120. /**
  121121. * File name for the left controller model.
  121122. */
  121123. static MODEL_LEFT_FILENAME: string;
  121124. /**
  121125. * File name for the right controller model.
  121126. */
  121127. static MODEL_RIGHT_FILENAME: string;
  121128. /**
  121129. * Base Url for the Quest controller model.
  121130. */
  121131. static QUEST_MODEL_BASE_URL: string;
  121132. /**
  121133. * @hidden
  121134. * If the controllers are running on a device that needs the updated Quest controller models
  121135. */
  121136. static _IsQuest: boolean;
  121137. /**
  121138. * Fired when the secondary trigger on this controller is modified
  121139. */
  121140. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121141. /**
  121142. * Fired when the thumb rest on this controller is modified
  121143. */
  121144. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121145. /**
  121146. * Creates a new OculusTouchController from a gamepad
  121147. * @param vrGamepad the gamepad that the controller should be created from
  121148. */
  121149. constructor(vrGamepad: any);
  121150. /**
  121151. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121152. * @param scene scene in which to add meshes
  121153. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121154. */
  121155. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121156. /**
  121157. * Fired when the A button on this controller is modified
  121158. */
  121159. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121160. /**
  121161. * Fired when the B button on this controller is modified
  121162. */
  121163. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121164. /**
  121165. * Fired when the X button on this controller is modified
  121166. */
  121167. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121168. /**
  121169. * Fired when the Y button on this controller is modified
  121170. */
  121171. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121172. /**
  121173. * Called once for each button that changed state since the last frame
  121174. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121175. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121176. * 2) secondary trigger (same)
  121177. * 3) A (right) X (left), touch, pressed = value
  121178. * 4) B / Y
  121179. * 5) thumb rest
  121180. * @param buttonIdx Which button index changed
  121181. * @param state New state of the button
  121182. * @param changes Which properties on the state changed since last frame
  121183. */
  121184. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121185. }
  121186. }
  121187. declare module BABYLON {
  121188. /**
  121189. * Vive Controller
  121190. */
  121191. export class ViveController extends WebVRController {
  121192. /**
  121193. * Base Url for the controller model.
  121194. */
  121195. static MODEL_BASE_URL: string;
  121196. /**
  121197. * File name for the controller model.
  121198. */
  121199. static MODEL_FILENAME: string;
  121200. /**
  121201. * Creates a new ViveController from a gamepad
  121202. * @param vrGamepad the gamepad that the controller should be created from
  121203. */
  121204. constructor(vrGamepad: any);
  121205. /**
  121206. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121207. * @param scene scene in which to add meshes
  121208. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121209. */
  121210. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121211. /**
  121212. * Fired when the left button on this controller is modified
  121213. */
  121214. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121215. /**
  121216. * Fired when the right button on this controller is modified
  121217. */
  121218. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121219. /**
  121220. * Fired when the menu button on this controller is modified
  121221. */
  121222. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121223. /**
  121224. * Called once for each button that changed state since the last frame
  121225. * Vive mapping:
  121226. * 0: touchpad
  121227. * 1: trigger
  121228. * 2: left AND right buttons
  121229. * 3: menu button
  121230. * @param buttonIdx Which button index changed
  121231. * @param state New state of the button
  121232. * @param changes Which properties on the state changed since last frame
  121233. */
  121234. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121235. }
  121236. }
  121237. declare module BABYLON {
  121238. /**
  121239. * Defines the WindowsMotionController object that the state of the windows motion controller
  121240. */
  121241. export class WindowsMotionController extends WebVRController {
  121242. /**
  121243. * The base url used to load the left and right controller models
  121244. */
  121245. static MODEL_BASE_URL: string;
  121246. /**
  121247. * The name of the left controller model file
  121248. */
  121249. static MODEL_LEFT_FILENAME: string;
  121250. /**
  121251. * The name of the right controller model file
  121252. */
  121253. static MODEL_RIGHT_FILENAME: string;
  121254. /**
  121255. * The controller name prefix for this controller type
  121256. */
  121257. static readonly GAMEPAD_ID_PREFIX: string;
  121258. /**
  121259. * The controller id pattern for this controller type
  121260. */
  121261. private static readonly GAMEPAD_ID_PATTERN;
  121262. private _loadedMeshInfo;
  121263. protected readonly _mapping: {
  121264. buttons: string[];
  121265. buttonMeshNames: {
  121266. 'trigger': string;
  121267. 'menu': string;
  121268. 'grip': string;
  121269. 'thumbstick': string;
  121270. 'trackpad': string;
  121271. };
  121272. buttonObservableNames: {
  121273. 'trigger': string;
  121274. 'menu': string;
  121275. 'grip': string;
  121276. 'thumbstick': string;
  121277. 'trackpad': string;
  121278. };
  121279. axisMeshNames: string[];
  121280. pointingPoseMeshName: string;
  121281. };
  121282. /**
  121283. * Fired when the trackpad on this controller is clicked
  121284. */
  121285. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121286. /**
  121287. * Fired when the trackpad on this controller is modified
  121288. */
  121289. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121290. /**
  121291. * The current x and y values of this controller's trackpad
  121292. */
  121293. trackpad: StickValues;
  121294. /**
  121295. * Creates a new WindowsMotionController from a gamepad
  121296. * @param vrGamepad the gamepad that the controller should be created from
  121297. */
  121298. constructor(vrGamepad: any);
  121299. /**
  121300. * Fired when the trigger on this controller is modified
  121301. */
  121302. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121303. /**
  121304. * Fired when the menu button on this controller is modified
  121305. */
  121306. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121307. /**
  121308. * Fired when the grip button on this controller is modified
  121309. */
  121310. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121311. /**
  121312. * Fired when the thumbstick button on this controller is modified
  121313. */
  121314. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121315. /**
  121316. * Fired when the touchpad button on this controller is modified
  121317. */
  121318. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121319. /**
  121320. * Fired when the touchpad values on this controller are modified
  121321. */
  121322. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121323. protected _updateTrackpad(): void;
  121324. /**
  121325. * Called once per frame by the engine.
  121326. */
  121327. update(): void;
  121328. /**
  121329. * Called once for each button that changed state since the last frame
  121330. * @param buttonIdx Which button index changed
  121331. * @param state New state of the button
  121332. * @param changes Which properties on the state changed since last frame
  121333. */
  121334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121335. /**
  121336. * Moves the buttons on the controller mesh based on their current state
  121337. * @param buttonName the name of the button to move
  121338. * @param buttonValue the value of the button which determines the buttons new position
  121339. */
  121340. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121341. /**
  121342. * Moves the axis on the controller mesh based on its current state
  121343. * @param axis the index of the axis
  121344. * @param axisValue the value of the axis which determines the meshes new position
  121345. * @hidden
  121346. */
  121347. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121348. /**
  121349. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121350. * @param scene scene in which to add meshes
  121351. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121352. */
  121353. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121354. /**
  121355. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121356. * can be transformed by button presses and axes values, based on this._mapping.
  121357. *
  121358. * @param scene scene in which the meshes exist
  121359. * @param meshes list of meshes that make up the controller model to process
  121360. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121361. */
  121362. private processModel;
  121363. private createMeshInfo;
  121364. /**
  121365. * Gets the ray of the controller in the direction the controller is pointing
  121366. * @param length the length the resulting ray should be
  121367. * @returns a ray in the direction the controller is pointing
  121368. */
  121369. getForwardRay(length?: number): Ray;
  121370. /**
  121371. * Disposes of the controller
  121372. */
  121373. dispose(): void;
  121374. }
  121375. /**
  121376. * This class represents a new windows motion controller in XR.
  121377. */
  121378. export class XRWindowsMotionController extends WindowsMotionController {
  121379. /**
  121380. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121381. */
  121382. protected readonly _mapping: {
  121383. buttons: string[];
  121384. buttonMeshNames: {
  121385. 'trigger': string;
  121386. 'menu': string;
  121387. 'grip': string;
  121388. 'thumbstick': string;
  121389. 'trackpad': string;
  121390. };
  121391. buttonObservableNames: {
  121392. 'trigger': string;
  121393. 'menu': string;
  121394. 'grip': string;
  121395. 'thumbstick': string;
  121396. 'trackpad': string;
  121397. };
  121398. axisMeshNames: string[];
  121399. pointingPoseMeshName: string;
  121400. };
  121401. /**
  121402. * Construct a new XR-Based windows motion controller
  121403. *
  121404. * @param gamepadInfo the gamepad object from the browser
  121405. */
  121406. constructor(gamepadInfo: any);
  121407. /**
  121408. * holds the thumbstick values (X,Y)
  121409. */
  121410. thumbstickValues: StickValues;
  121411. /**
  121412. * Fired when the thumbstick on this controller is clicked
  121413. */
  121414. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121415. /**
  121416. * Fired when the thumbstick on this controller is modified
  121417. */
  121418. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121419. /**
  121420. * Fired when the touchpad button on this controller is modified
  121421. */
  121422. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121423. /**
  121424. * Fired when the touchpad values on this controller are modified
  121425. */
  121426. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121427. /**
  121428. * Fired when the thumbstick button on this controller is modified
  121429. * here to prevent breaking changes
  121430. */
  121431. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121432. /**
  121433. * updating the thumbstick(!) and not the trackpad.
  121434. * This is named this way due to the difference between WebVR and XR and to avoid
  121435. * changing the parent class.
  121436. */
  121437. protected _updateTrackpad(): void;
  121438. /**
  121439. * Disposes the class with joy
  121440. */
  121441. dispose(): void;
  121442. }
  121443. }
  121444. declare module BABYLON {
  121445. /**
  121446. * Class containing static functions to help procedurally build meshes
  121447. */
  121448. export class PolyhedronBuilder {
  121449. /**
  121450. * Creates a polyhedron mesh
  121451. * * 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
  121452. * * The parameter `size` (positive float, default 1) sets the polygon size
  121453. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121454. * * 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`
  121455. * * 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
  121456. * * 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)`)
  121457. * * 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
  121458. * * 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
  121459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121462. * @param name defines the name of the mesh
  121463. * @param options defines the options used to create the mesh
  121464. * @param scene defines the hosting scene
  121465. * @returns the polyhedron mesh
  121466. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121467. */
  121468. static CreatePolyhedron(name: string, options: {
  121469. type?: number;
  121470. size?: number;
  121471. sizeX?: number;
  121472. sizeY?: number;
  121473. sizeZ?: number;
  121474. custom?: any;
  121475. faceUV?: Vector4[];
  121476. faceColors?: Color4[];
  121477. flat?: boolean;
  121478. updatable?: boolean;
  121479. sideOrientation?: number;
  121480. frontUVs?: Vector4;
  121481. backUVs?: Vector4;
  121482. }, scene?: Nullable<Scene>): Mesh;
  121483. }
  121484. }
  121485. declare module BABYLON {
  121486. /**
  121487. * Gizmo that enables scaling a mesh along 3 axis
  121488. */
  121489. export class ScaleGizmo extends Gizmo {
  121490. /**
  121491. * Internal gizmo used for interactions on the x axis
  121492. */
  121493. xGizmo: AxisScaleGizmo;
  121494. /**
  121495. * Internal gizmo used for interactions on the y axis
  121496. */
  121497. yGizmo: AxisScaleGizmo;
  121498. /**
  121499. * Internal gizmo used for interactions on the z axis
  121500. */
  121501. zGizmo: AxisScaleGizmo;
  121502. /**
  121503. * Internal gizmo used to scale all axis equally
  121504. */
  121505. uniformScaleGizmo: AxisScaleGizmo;
  121506. private _meshAttached;
  121507. private _updateGizmoRotationToMatchAttachedMesh;
  121508. private _snapDistance;
  121509. private _scaleRatio;
  121510. private _uniformScalingMesh;
  121511. private _octahedron;
  121512. private _sensitivity;
  121513. /** Fires an event when any of it's sub gizmos are dragged */
  121514. onDragStartObservable: Observable<unknown>;
  121515. /** Fires an event when any of it's sub gizmos are released from dragging */
  121516. onDragEndObservable: Observable<unknown>;
  121517. get attachedMesh(): Nullable<AbstractMesh>;
  121518. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121519. /**
  121520. * Creates a ScaleGizmo
  121521. * @param gizmoLayer The utility layer the gizmo will be added to
  121522. */
  121523. constructor(gizmoLayer?: UtilityLayerRenderer);
  121524. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121525. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121526. /**
  121527. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121528. */
  121529. set snapDistance(value: number);
  121530. get snapDistance(): number;
  121531. /**
  121532. * Ratio for the scale of the gizmo (Default: 1)
  121533. */
  121534. set scaleRatio(value: number);
  121535. get scaleRatio(): number;
  121536. /**
  121537. * Sensitivity factor for dragging (Default: 1)
  121538. */
  121539. set sensitivity(value: number);
  121540. get sensitivity(): number;
  121541. /**
  121542. * Disposes of the gizmo
  121543. */
  121544. dispose(): void;
  121545. }
  121546. }
  121547. declare module BABYLON {
  121548. /**
  121549. * Single axis scale gizmo
  121550. */
  121551. export class AxisScaleGizmo extends Gizmo {
  121552. /**
  121553. * Drag behavior responsible for the gizmos dragging interactions
  121554. */
  121555. dragBehavior: PointerDragBehavior;
  121556. private _pointerObserver;
  121557. /**
  121558. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121559. */
  121560. snapDistance: number;
  121561. /**
  121562. * Event that fires each time the gizmo snaps to a new location.
  121563. * * snapDistance is the the change in distance
  121564. */
  121565. onSnapObservable: Observable<{
  121566. snapDistance: number;
  121567. }>;
  121568. /**
  121569. * If the scaling operation should be done on all axis (default: false)
  121570. */
  121571. uniformScaling: boolean;
  121572. /**
  121573. * Custom sensitivity value for the drag strength
  121574. */
  121575. sensitivity: number;
  121576. private _isEnabled;
  121577. private _parent;
  121578. private _arrow;
  121579. private _coloredMaterial;
  121580. private _hoverMaterial;
  121581. /**
  121582. * Creates an AxisScaleGizmo
  121583. * @param gizmoLayer The utility layer the gizmo will be added to
  121584. * @param dragAxis The axis which the gizmo will be able to scale on
  121585. * @param color The color of the gizmo
  121586. */
  121587. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121588. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121589. /**
  121590. * If the gizmo is enabled
  121591. */
  121592. set isEnabled(value: boolean);
  121593. get isEnabled(): boolean;
  121594. /**
  121595. * Disposes of the gizmo
  121596. */
  121597. dispose(): void;
  121598. /**
  121599. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121600. * @param mesh The mesh to replace the default mesh of the gizmo
  121601. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121602. */
  121603. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121604. }
  121605. }
  121606. declare module BABYLON {
  121607. /**
  121608. * Bounding box gizmo
  121609. */
  121610. export class BoundingBoxGizmo extends Gizmo {
  121611. private _lineBoundingBox;
  121612. private _rotateSpheresParent;
  121613. private _scaleBoxesParent;
  121614. private _boundingDimensions;
  121615. private _renderObserver;
  121616. private _pointerObserver;
  121617. private _scaleDragSpeed;
  121618. private _tmpQuaternion;
  121619. private _tmpVector;
  121620. private _tmpRotationMatrix;
  121621. /**
  121622. * 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)
  121623. */
  121624. ignoreChildren: boolean;
  121625. /**
  121626. * 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)
  121627. */
  121628. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121629. /**
  121630. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121631. */
  121632. rotationSphereSize: number;
  121633. /**
  121634. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121635. */
  121636. scaleBoxSize: number;
  121637. /**
  121638. * 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)
  121639. */
  121640. fixedDragMeshScreenSize: boolean;
  121641. /**
  121642. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121643. */
  121644. fixedDragMeshScreenSizeDistanceFactor: number;
  121645. /**
  121646. * Fired when a rotation sphere or scale box is dragged
  121647. */
  121648. onDragStartObservable: Observable<{}>;
  121649. /**
  121650. * Fired when a scale box is dragged
  121651. */
  121652. onScaleBoxDragObservable: Observable<{}>;
  121653. /**
  121654. * Fired when a scale box drag is ended
  121655. */
  121656. onScaleBoxDragEndObservable: Observable<{}>;
  121657. /**
  121658. * Fired when a rotation sphere is dragged
  121659. */
  121660. onRotationSphereDragObservable: Observable<{}>;
  121661. /**
  121662. * Fired when a rotation sphere drag is ended
  121663. */
  121664. onRotationSphereDragEndObservable: Observable<{}>;
  121665. /**
  121666. * 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)
  121667. */
  121668. scalePivot: Nullable<Vector3>;
  121669. /**
  121670. * Mesh used as a pivot to rotate the attached mesh
  121671. */
  121672. private _anchorMesh;
  121673. private _existingMeshScale;
  121674. private _dragMesh;
  121675. private pointerDragBehavior;
  121676. private coloredMaterial;
  121677. private hoverColoredMaterial;
  121678. /**
  121679. * Sets the color of the bounding box gizmo
  121680. * @param color the color to set
  121681. */
  121682. setColor(color: Color3): void;
  121683. /**
  121684. * Creates an BoundingBoxGizmo
  121685. * @param gizmoLayer The utility layer the gizmo will be added to
  121686. * @param color The color of the gizmo
  121687. */
  121688. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121689. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121690. private _selectNode;
  121691. /**
  121692. * Updates the bounding box information for the Gizmo
  121693. */
  121694. updateBoundingBox(): void;
  121695. private _updateRotationSpheres;
  121696. private _updateScaleBoxes;
  121697. /**
  121698. * Enables rotation on the specified axis and disables rotation on the others
  121699. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121700. */
  121701. setEnabledRotationAxis(axis: string): void;
  121702. /**
  121703. * Enables/disables scaling
  121704. * @param enable if scaling should be enabled
  121705. */
  121706. setEnabledScaling(enable: boolean): void;
  121707. private _updateDummy;
  121708. /**
  121709. * Enables a pointer drag behavior on the bounding box of the gizmo
  121710. */
  121711. enableDragBehavior(): void;
  121712. /**
  121713. * Disposes of the gizmo
  121714. */
  121715. dispose(): void;
  121716. /**
  121717. * 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)
  121718. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121719. * @returns the bounding box mesh with the passed in mesh as a child
  121720. */
  121721. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121722. /**
  121723. * CustomMeshes are not supported by this gizmo
  121724. * @param mesh The mesh to replace the default mesh of the gizmo
  121725. */
  121726. setCustomMesh(mesh: Mesh): void;
  121727. }
  121728. }
  121729. declare module BABYLON {
  121730. /**
  121731. * Single plane rotation gizmo
  121732. */
  121733. export class PlaneRotationGizmo extends Gizmo {
  121734. /**
  121735. * Drag behavior responsible for the gizmos dragging interactions
  121736. */
  121737. dragBehavior: PointerDragBehavior;
  121738. private _pointerObserver;
  121739. /**
  121740. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121741. */
  121742. snapDistance: number;
  121743. /**
  121744. * Event that fires each time the gizmo snaps to a new location.
  121745. * * snapDistance is the the change in distance
  121746. */
  121747. onSnapObservable: Observable<{
  121748. snapDistance: number;
  121749. }>;
  121750. private _isEnabled;
  121751. private _parent;
  121752. /**
  121753. * Creates a PlaneRotationGizmo
  121754. * @param gizmoLayer The utility layer the gizmo will be added to
  121755. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121756. * @param color The color of the gizmo
  121757. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121758. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121759. */
  121760. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121761. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121762. /**
  121763. * If the gizmo is enabled
  121764. */
  121765. set isEnabled(value: boolean);
  121766. get isEnabled(): boolean;
  121767. /**
  121768. * Disposes of the gizmo
  121769. */
  121770. dispose(): void;
  121771. }
  121772. }
  121773. declare module BABYLON {
  121774. /**
  121775. * Gizmo that enables rotating a mesh along 3 axis
  121776. */
  121777. export class RotationGizmo extends Gizmo {
  121778. /**
  121779. * Internal gizmo used for interactions on the x axis
  121780. */
  121781. xGizmo: PlaneRotationGizmo;
  121782. /**
  121783. * Internal gizmo used for interactions on the y axis
  121784. */
  121785. yGizmo: PlaneRotationGizmo;
  121786. /**
  121787. * Internal gizmo used for interactions on the z axis
  121788. */
  121789. zGizmo: PlaneRotationGizmo;
  121790. /** Fires an event when any of it's sub gizmos are dragged */
  121791. onDragStartObservable: Observable<unknown>;
  121792. /** Fires an event when any of it's sub gizmos are released from dragging */
  121793. onDragEndObservable: Observable<unknown>;
  121794. private _meshAttached;
  121795. get attachedMesh(): Nullable<AbstractMesh>;
  121796. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121797. /**
  121798. * Creates a RotationGizmo
  121799. * @param gizmoLayer The utility layer the gizmo will be added to
  121800. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121801. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121802. */
  121803. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121804. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121805. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121806. /**
  121807. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121808. */
  121809. set snapDistance(value: number);
  121810. get snapDistance(): number;
  121811. /**
  121812. * Ratio for the scale of the gizmo (Default: 1)
  121813. */
  121814. set scaleRatio(value: number);
  121815. get scaleRatio(): number;
  121816. /**
  121817. * Disposes of the gizmo
  121818. */
  121819. dispose(): void;
  121820. /**
  121821. * CustomMeshes are not supported by this gizmo
  121822. * @param mesh The mesh to replace the default mesh of the gizmo
  121823. */
  121824. setCustomMesh(mesh: Mesh): void;
  121825. }
  121826. }
  121827. declare module BABYLON {
  121828. /**
  121829. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121830. */
  121831. export class GizmoManager implements IDisposable {
  121832. private scene;
  121833. /**
  121834. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121835. */
  121836. gizmos: {
  121837. positionGizmo: Nullable<PositionGizmo>;
  121838. rotationGizmo: Nullable<RotationGizmo>;
  121839. scaleGizmo: Nullable<ScaleGizmo>;
  121840. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121841. };
  121842. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121843. clearGizmoOnEmptyPointerEvent: boolean;
  121844. /** Fires an event when the manager is attached to a mesh */
  121845. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121846. private _gizmosEnabled;
  121847. private _pointerObserver;
  121848. private _attachedMesh;
  121849. private _boundingBoxColor;
  121850. private _defaultUtilityLayer;
  121851. private _defaultKeepDepthUtilityLayer;
  121852. /**
  121853. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121854. */
  121855. boundingBoxDragBehavior: SixDofDragBehavior;
  121856. /**
  121857. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121858. */
  121859. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121860. /**
  121861. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121862. */
  121863. usePointerToAttachGizmos: boolean;
  121864. /**
  121865. * Utility layer that the bounding box gizmo belongs to
  121866. */
  121867. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121868. /**
  121869. * Utility layer that all gizmos besides bounding box belong to
  121870. */
  121871. get utilityLayer(): UtilityLayerRenderer;
  121872. /**
  121873. * Instatiates a gizmo manager
  121874. * @param scene the scene to overlay the gizmos on top of
  121875. */
  121876. constructor(scene: Scene);
  121877. /**
  121878. * Attaches a set of gizmos to the specified mesh
  121879. * @param mesh The mesh the gizmo's should be attached to
  121880. */
  121881. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121882. /**
  121883. * If the position gizmo is enabled
  121884. */
  121885. set positionGizmoEnabled(value: boolean);
  121886. get positionGizmoEnabled(): boolean;
  121887. /**
  121888. * If the rotation gizmo is enabled
  121889. */
  121890. set rotationGizmoEnabled(value: boolean);
  121891. get rotationGizmoEnabled(): boolean;
  121892. /**
  121893. * If the scale gizmo is enabled
  121894. */
  121895. set scaleGizmoEnabled(value: boolean);
  121896. get scaleGizmoEnabled(): boolean;
  121897. /**
  121898. * If the boundingBox gizmo is enabled
  121899. */
  121900. set boundingBoxGizmoEnabled(value: boolean);
  121901. get boundingBoxGizmoEnabled(): boolean;
  121902. /**
  121903. * Disposes of the gizmo manager
  121904. */
  121905. dispose(): void;
  121906. }
  121907. }
  121908. declare module BABYLON {
  121909. /**
  121910. * A directional light is defined by a direction (what a surprise!).
  121911. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121912. * 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.
  121913. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121914. */
  121915. export class DirectionalLight extends ShadowLight {
  121916. private _shadowFrustumSize;
  121917. /**
  121918. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121919. */
  121920. get shadowFrustumSize(): number;
  121921. /**
  121922. * Specifies a fix frustum size for the shadow generation.
  121923. */
  121924. set shadowFrustumSize(value: number);
  121925. private _shadowOrthoScale;
  121926. /**
  121927. * Gets the shadow projection scale against the optimal computed one.
  121928. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121929. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121930. */
  121931. get shadowOrthoScale(): number;
  121932. /**
  121933. * Sets the shadow projection scale against the optimal computed one.
  121934. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121935. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121936. */
  121937. set shadowOrthoScale(value: number);
  121938. /**
  121939. * Automatically compute the projection matrix to best fit (including all the casters)
  121940. * on each frame.
  121941. */
  121942. autoUpdateExtends: boolean;
  121943. /**
  121944. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121945. * on each frame. autoUpdateExtends must be set to true for this to work
  121946. */
  121947. autoCalcShadowZBounds: boolean;
  121948. private _orthoLeft;
  121949. private _orthoRight;
  121950. private _orthoTop;
  121951. private _orthoBottom;
  121952. /**
  121953. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121954. * The directional light is emitted from everywhere in the given direction.
  121955. * It can cast shadows.
  121956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121957. * @param name The friendly name of the light
  121958. * @param direction The direction of the light
  121959. * @param scene The scene the light belongs to
  121960. */
  121961. constructor(name: string, direction: Vector3, scene: Scene);
  121962. /**
  121963. * Returns the string "DirectionalLight".
  121964. * @return The class name
  121965. */
  121966. getClassName(): string;
  121967. /**
  121968. * Returns the integer 1.
  121969. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121970. */
  121971. getTypeID(): number;
  121972. /**
  121973. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121974. * Returns the DirectionalLight Shadow projection matrix.
  121975. */
  121976. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121977. /**
  121978. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121979. * Returns the DirectionalLight Shadow projection matrix.
  121980. */
  121981. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121982. /**
  121983. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121984. * Returns the DirectionalLight Shadow projection matrix.
  121985. */
  121986. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121987. protected _buildUniformLayout(): void;
  121988. /**
  121989. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121990. * @param effect The effect to update
  121991. * @param lightIndex The index of the light in the effect to update
  121992. * @returns The directional light
  121993. */
  121994. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121995. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  121996. /**
  121997. * Gets the minZ used for shadow according to both the scene and the light.
  121998. *
  121999. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122000. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122001. * @param activeCamera The camera we are returning the min for
  122002. * @returns the depth min z
  122003. */
  122004. getDepthMinZ(activeCamera: Camera): number;
  122005. /**
  122006. * Gets the maxZ used for shadow according to both the scene and the light.
  122007. *
  122008. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122009. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122010. * @param activeCamera The camera we are returning the max for
  122011. * @returns the depth max z
  122012. */
  122013. getDepthMaxZ(activeCamera: Camera): number;
  122014. /**
  122015. * Prepares the list of defines specific to the light type.
  122016. * @param defines the list of defines
  122017. * @param lightIndex defines the index of the light for the effect
  122018. */
  122019. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122020. }
  122021. }
  122022. declare module BABYLON {
  122023. /**
  122024. * Class containing static functions to help procedurally build meshes
  122025. */
  122026. export class HemisphereBuilder {
  122027. /**
  122028. * Creates a hemisphere mesh
  122029. * @param name defines the name of the mesh
  122030. * @param options defines the options used to create the mesh
  122031. * @param scene defines the hosting scene
  122032. * @returns the hemisphere mesh
  122033. */
  122034. static CreateHemisphere(name: string, options: {
  122035. segments?: number;
  122036. diameter?: number;
  122037. sideOrientation?: number;
  122038. }, scene: any): Mesh;
  122039. }
  122040. }
  122041. declare module BABYLON {
  122042. /**
  122043. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122044. * These values define a cone of light starting from the position, emitting toward the direction.
  122045. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122046. * and the exponent defines the speed of the decay of the light with distance (reach).
  122047. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122048. */
  122049. export class SpotLight extends ShadowLight {
  122050. private _angle;
  122051. private _innerAngle;
  122052. private _cosHalfAngle;
  122053. private _lightAngleScale;
  122054. private _lightAngleOffset;
  122055. /**
  122056. * Gets the cone angle of the spot light in Radians.
  122057. */
  122058. get angle(): number;
  122059. /**
  122060. * Sets the cone angle of the spot light in Radians.
  122061. */
  122062. set angle(value: number);
  122063. /**
  122064. * Only used in gltf falloff mode, this defines the angle where
  122065. * the directional falloff will start before cutting at angle which could be seen
  122066. * as outer angle.
  122067. */
  122068. get innerAngle(): number;
  122069. /**
  122070. * Only used in gltf falloff mode, this defines the angle where
  122071. * the directional falloff will start before cutting at angle which could be seen
  122072. * as outer angle.
  122073. */
  122074. set innerAngle(value: number);
  122075. private _shadowAngleScale;
  122076. /**
  122077. * Allows scaling the angle of the light for shadow generation only.
  122078. */
  122079. get shadowAngleScale(): number;
  122080. /**
  122081. * Allows scaling the angle of the light for shadow generation only.
  122082. */
  122083. set shadowAngleScale(value: number);
  122084. /**
  122085. * The light decay speed with the distance from the emission spot.
  122086. */
  122087. exponent: number;
  122088. private _projectionTextureMatrix;
  122089. /**
  122090. * Allows reading the projecton texture
  122091. */
  122092. get projectionTextureMatrix(): Matrix;
  122093. protected _projectionTextureLightNear: number;
  122094. /**
  122095. * Gets the near clip of the Spotlight for texture projection.
  122096. */
  122097. get projectionTextureLightNear(): number;
  122098. /**
  122099. * Sets the near clip of the Spotlight for texture projection.
  122100. */
  122101. set projectionTextureLightNear(value: number);
  122102. protected _projectionTextureLightFar: number;
  122103. /**
  122104. * Gets the far clip of the Spotlight for texture projection.
  122105. */
  122106. get projectionTextureLightFar(): number;
  122107. /**
  122108. * Sets the far clip of the Spotlight for texture projection.
  122109. */
  122110. set projectionTextureLightFar(value: number);
  122111. protected _projectionTextureUpDirection: Vector3;
  122112. /**
  122113. * Gets the Up vector of the Spotlight for texture projection.
  122114. */
  122115. get projectionTextureUpDirection(): Vector3;
  122116. /**
  122117. * Sets the Up vector of the Spotlight for texture projection.
  122118. */
  122119. set projectionTextureUpDirection(value: Vector3);
  122120. private _projectionTexture;
  122121. /**
  122122. * Gets the projection texture of the light.
  122123. */
  122124. get projectionTexture(): Nullable<BaseTexture>;
  122125. /**
  122126. * Sets the projection texture of the light.
  122127. */
  122128. set projectionTexture(value: Nullable<BaseTexture>);
  122129. private _projectionTextureViewLightDirty;
  122130. private _projectionTextureProjectionLightDirty;
  122131. private _projectionTextureDirty;
  122132. private _projectionTextureViewTargetVector;
  122133. private _projectionTextureViewLightMatrix;
  122134. private _projectionTextureProjectionLightMatrix;
  122135. private _projectionTextureScalingMatrix;
  122136. /**
  122137. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122138. * It can cast shadows.
  122139. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122140. * @param name The light friendly name
  122141. * @param position The position of the spot light in the scene
  122142. * @param direction The direction of the light in the scene
  122143. * @param angle The cone angle of the light in Radians
  122144. * @param exponent The light decay speed with the distance from the emission spot
  122145. * @param scene The scene the lights belongs to
  122146. */
  122147. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122148. /**
  122149. * Returns the string "SpotLight".
  122150. * @returns the class name
  122151. */
  122152. getClassName(): string;
  122153. /**
  122154. * Returns the integer 2.
  122155. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122156. */
  122157. getTypeID(): number;
  122158. /**
  122159. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122160. */
  122161. protected _setDirection(value: Vector3): void;
  122162. /**
  122163. * Overrides the position setter to recompute the projection texture view light Matrix.
  122164. */
  122165. protected _setPosition(value: Vector3): void;
  122166. /**
  122167. * 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.
  122168. * Returns the SpotLight.
  122169. */
  122170. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122171. protected _computeProjectionTextureViewLightMatrix(): void;
  122172. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122173. /**
  122174. * Main function for light texture projection matrix computing.
  122175. */
  122176. protected _computeProjectionTextureMatrix(): void;
  122177. protected _buildUniformLayout(): void;
  122178. private _computeAngleValues;
  122179. /**
  122180. * Sets the passed Effect "effect" with the Light textures.
  122181. * @param effect The effect to update
  122182. * @param lightIndex The index of the light in the effect to update
  122183. * @returns The light
  122184. */
  122185. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122186. /**
  122187. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122188. * @param effect The effect to update
  122189. * @param lightIndex The index of the light in the effect to update
  122190. * @returns The spot light
  122191. */
  122192. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122193. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122194. /**
  122195. * Disposes the light and the associated resources.
  122196. */
  122197. dispose(): void;
  122198. /**
  122199. * Prepares the list of defines specific to the light type.
  122200. * @param defines the list of defines
  122201. * @param lightIndex defines the index of the light for the effect
  122202. */
  122203. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122204. }
  122205. }
  122206. declare module BABYLON {
  122207. /**
  122208. * Gizmo that enables viewing a light
  122209. */
  122210. export class LightGizmo extends Gizmo {
  122211. private _lightMesh;
  122212. private _material;
  122213. private _cachedPosition;
  122214. private _cachedForward;
  122215. private _attachedMeshParent;
  122216. /**
  122217. * Creates a LightGizmo
  122218. * @param gizmoLayer The utility layer the gizmo will be added to
  122219. */
  122220. constructor(gizmoLayer?: UtilityLayerRenderer);
  122221. private _light;
  122222. /**
  122223. * The light that the gizmo is attached to
  122224. */
  122225. set light(light: Nullable<Light>);
  122226. get light(): Nullable<Light>;
  122227. /**
  122228. * Gets the material used to render the light gizmo
  122229. */
  122230. get material(): StandardMaterial;
  122231. /**
  122232. * @hidden
  122233. * Updates the gizmo to match the attached mesh's position/rotation
  122234. */
  122235. protected _update(): void;
  122236. private static _Scale;
  122237. /**
  122238. * Creates the lines for a light mesh
  122239. */
  122240. private static _CreateLightLines;
  122241. /**
  122242. * Disposes of the light gizmo
  122243. */
  122244. dispose(): void;
  122245. private static _CreateHemisphericLightMesh;
  122246. private static _CreatePointLightMesh;
  122247. private static _CreateSpotLightMesh;
  122248. private static _CreateDirectionalLightMesh;
  122249. }
  122250. }
  122251. declare module BABYLON {
  122252. /** @hidden */
  122253. export var backgroundFragmentDeclaration: {
  122254. name: string;
  122255. shader: string;
  122256. };
  122257. }
  122258. declare module BABYLON {
  122259. /** @hidden */
  122260. export var backgroundUboDeclaration: {
  122261. name: string;
  122262. shader: string;
  122263. };
  122264. }
  122265. declare module BABYLON {
  122266. /** @hidden */
  122267. export var backgroundPixelShader: {
  122268. name: string;
  122269. shader: string;
  122270. };
  122271. }
  122272. declare module BABYLON {
  122273. /** @hidden */
  122274. export var backgroundVertexDeclaration: {
  122275. name: string;
  122276. shader: string;
  122277. };
  122278. }
  122279. declare module BABYLON {
  122280. /** @hidden */
  122281. export var backgroundVertexShader: {
  122282. name: string;
  122283. shader: string;
  122284. };
  122285. }
  122286. declare module BABYLON {
  122287. /**
  122288. * Background material used to create an efficient environement around your scene.
  122289. */
  122290. export class BackgroundMaterial extends PushMaterial {
  122291. /**
  122292. * Standard reflectance value at parallel view angle.
  122293. */
  122294. static StandardReflectance0: number;
  122295. /**
  122296. * Standard reflectance value at grazing angle.
  122297. */
  122298. static StandardReflectance90: number;
  122299. protected _primaryColor: Color3;
  122300. /**
  122301. * Key light Color (multiply against the environement texture)
  122302. */
  122303. primaryColor: Color3;
  122304. protected __perceptualColor: Nullable<Color3>;
  122305. /**
  122306. * Experimental Internal Use Only.
  122307. *
  122308. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122309. * This acts as a helper to set the primary color to a more "human friendly" value.
  122310. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122311. * output color as close as possible from the chosen value.
  122312. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122313. * part of lighting setup.)
  122314. */
  122315. get _perceptualColor(): Nullable<Color3>;
  122316. set _perceptualColor(value: Nullable<Color3>);
  122317. protected _primaryColorShadowLevel: float;
  122318. /**
  122319. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122320. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122321. */
  122322. get primaryColorShadowLevel(): float;
  122323. set primaryColorShadowLevel(value: float);
  122324. protected _primaryColorHighlightLevel: float;
  122325. /**
  122326. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122327. * The primary color is used at the level chosen to define what the white area would look.
  122328. */
  122329. get primaryColorHighlightLevel(): float;
  122330. set primaryColorHighlightLevel(value: float);
  122331. protected _reflectionTexture: Nullable<BaseTexture>;
  122332. /**
  122333. * Reflection Texture used in the material.
  122334. * Should be author in a specific way for the best result (refer to the documentation).
  122335. */
  122336. reflectionTexture: Nullable<BaseTexture>;
  122337. protected _reflectionBlur: float;
  122338. /**
  122339. * Reflection Texture level of blur.
  122340. *
  122341. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122342. * texture twice.
  122343. */
  122344. reflectionBlur: float;
  122345. protected _diffuseTexture: Nullable<BaseTexture>;
  122346. /**
  122347. * Diffuse Texture used in the material.
  122348. * Should be author in a specific way for the best result (refer to the documentation).
  122349. */
  122350. diffuseTexture: Nullable<BaseTexture>;
  122351. protected _shadowLights: Nullable<IShadowLight[]>;
  122352. /**
  122353. * Specify the list of lights casting shadow on the material.
  122354. * All scene shadow lights will be included if null.
  122355. */
  122356. shadowLights: Nullable<IShadowLight[]>;
  122357. protected _shadowLevel: float;
  122358. /**
  122359. * Helps adjusting the shadow to a softer level if required.
  122360. * 0 means black shadows and 1 means no shadows.
  122361. */
  122362. shadowLevel: float;
  122363. protected _sceneCenter: Vector3;
  122364. /**
  122365. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122366. * It is usually zero but might be interesting to modify according to your setup.
  122367. */
  122368. sceneCenter: Vector3;
  122369. protected _opacityFresnel: boolean;
  122370. /**
  122371. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122372. * This helps ensuring a nice transition when the camera goes under the ground.
  122373. */
  122374. opacityFresnel: boolean;
  122375. protected _reflectionFresnel: boolean;
  122376. /**
  122377. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122378. * This helps adding a mirror texture on the ground.
  122379. */
  122380. reflectionFresnel: boolean;
  122381. protected _reflectionFalloffDistance: number;
  122382. /**
  122383. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122384. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122385. */
  122386. reflectionFalloffDistance: number;
  122387. protected _reflectionAmount: number;
  122388. /**
  122389. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122390. */
  122391. reflectionAmount: number;
  122392. protected _reflectionReflectance0: number;
  122393. /**
  122394. * This specifies the weight of the reflection at grazing angle.
  122395. */
  122396. reflectionReflectance0: number;
  122397. protected _reflectionReflectance90: number;
  122398. /**
  122399. * This specifies the weight of the reflection at a perpendicular point of view.
  122400. */
  122401. reflectionReflectance90: number;
  122402. /**
  122403. * Sets the reflection reflectance fresnel values according to the default standard
  122404. * empirically know to work well :-)
  122405. */
  122406. set reflectionStandardFresnelWeight(value: number);
  122407. protected _useRGBColor: boolean;
  122408. /**
  122409. * Helps to directly use the maps channels instead of their level.
  122410. */
  122411. useRGBColor: boolean;
  122412. protected _enableNoise: boolean;
  122413. /**
  122414. * This helps reducing the banding effect that could occur on the background.
  122415. */
  122416. enableNoise: boolean;
  122417. /**
  122418. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122419. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122420. * Recommended to be keep at 1.0 except for special cases.
  122421. */
  122422. get fovMultiplier(): number;
  122423. set fovMultiplier(value: number);
  122424. private _fovMultiplier;
  122425. /**
  122426. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122427. */
  122428. useEquirectangularFOV: boolean;
  122429. private _maxSimultaneousLights;
  122430. /**
  122431. * Number of Simultaneous lights allowed on the material.
  122432. */
  122433. maxSimultaneousLights: int;
  122434. /**
  122435. * Default configuration related to image processing available in the Background Material.
  122436. */
  122437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122438. /**
  122439. * Keep track of the image processing observer to allow dispose and replace.
  122440. */
  122441. private _imageProcessingObserver;
  122442. /**
  122443. * Attaches a new image processing configuration to the PBR Material.
  122444. * @param configuration (if null the scene configuration will be use)
  122445. */
  122446. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122447. /**
  122448. * Gets the image processing configuration used either in this material.
  122449. */
  122450. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122451. /**
  122452. * Sets the Default image processing configuration used either in the this material.
  122453. *
  122454. * If sets to null, the scene one is in use.
  122455. */
  122456. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122457. /**
  122458. * Gets wether the color curves effect is enabled.
  122459. */
  122460. get cameraColorCurvesEnabled(): boolean;
  122461. /**
  122462. * Sets wether the color curves effect is enabled.
  122463. */
  122464. set cameraColorCurvesEnabled(value: boolean);
  122465. /**
  122466. * Gets wether the color grading effect is enabled.
  122467. */
  122468. get cameraColorGradingEnabled(): boolean;
  122469. /**
  122470. * Gets wether the color grading effect is enabled.
  122471. */
  122472. set cameraColorGradingEnabled(value: boolean);
  122473. /**
  122474. * Gets wether tonemapping is enabled or not.
  122475. */
  122476. get cameraToneMappingEnabled(): boolean;
  122477. /**
  122478. * Sets wether tonemapping is enabled or not
  122479. */
  122480. set cameraToneMappingEnabled(value: boolean);
  122481. /**
  122482. * The camera exposure used on this material.
  122483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122484. * This corresponds to a photographic exposure.
  122485. */
  122486. get cameraExposure(): float;
  122487. /**
  122488. * The camera exposure used on this material.
  122489. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122490. * This corresponds to a photographic exposure.
  122491. */
  122492. set cameraExposure(value: float);
  122493. /**
  122494. * Gets The camera contrast used on this material.
  122495. */
  122496. get cameraContrast(): float;
  122497. /**
  122498. * Sets The camera contrast used on this material.
  122499. */
  122500. set cameraContrast(value: float);
  122501. /**
  122502. * Gets the Color Grading 2D Lookup Texture.
  122503. */
  122504. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122505. /**
  122506. * Sets the Color Grading 2D Lookup Texture.
  122507. */
  122508. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122509. /**
  122510. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122511. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122512. * 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;
  122513. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122514. */
  122515. get cameraColorCurves(): Nullable<ColorCurves>;
  122516. /**
  122517. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122518. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122519. * 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;
  122520. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122521. */
  122522. set cameraColorCurves(value: Nullable<ColorCurves>);
  122523. /**
  122524. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122525. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122526. */
  122527. switchToBGR: boolean;
  122528. private _renderTargets;
  122529. private _reflectionControls;
  122530. private _white;
  122531. private _primaryShadowColor;
  122532. private _primaryHighlightColor;
  122533. /**
  122534. * Instantiates a Background Material in the given scene
  122535. * @param name The friendly name of the material
  122536. * @param scene The scene to add the material to
  122537. */
  122538. constructor(name: string, scene: Scene);
  122539. /**
  122540. * Gets a boolean indicating that current material needs to register RTT
  122541. */
  122542. get hasRenderTargetTextures(): boolean;
  122543. /**
  122544. * The entire material has been created in order to prevent overdraw.
  122545. * @returns false
  122546. */
  122547. needAlphaTesting(): boolean;
  122548. /**
  122549. * The entire material has been created in order to prevent overdraw.
  122550. * @returns true if blending is enable
  122551. */
  122552. needAlphaBlending(): boolean;
  122553. /**
  122554. * Checks wether the material is ready to be rendered for a given mesh.
  122555. * @param mesh The mesh to render
  122556. * @param subMesh The submesh to check against
  122557. * @param useInstances Specify wether or not the material is used with instances
  122558. * @returns true if all the dependencies are ready (Textures, Effects...)
  122559. */
  122560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122561. /**
  122562. * Compute the primary color according to the chosen perceptual color.
  122563. */
  122564. private _computePrimaryColorFromPerceptualColor;
  122565. /**
  122566. * Compute the highlights and shadow colors according to their chosen levels.
  122567. */
  122568. private _computePrimaryColors;
  122569. /**
  122570. * Build the uniform buffer used in the material.
  122571. */
  122572. buildUniformLayout(): void;
  122573. /**
  122574. * Unbind the material.
  122575. */
  122576. unbind(): void;
  122577. /**
  122578. * Bind only the world matrix to the material.
  122579. * @param world The world matrix to bind.
  122580. */
  122581. bindOnlyWorldMatrix(world: Matrix): void;
  122582. /**
  122583. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122584. * @param world The world matrix to bind.
  122585. * @param subMesh The submesh to bind for.
  122586. */
  122587. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122588. /**
  122589. * Checks to see if a texture is used in the material.
  122590. * @param texture - Base texture to use.
  122591. * @returns - Boolean specifying if a texture is used in the material.
  122592. */
  122593. hasTexture(texture: BaseTexture): boolean;
  122594. /**
  122595. * Dispose the material.
  122596. * @param forceDisposeEffect Force disposal of the associated effect.
  122597. * @param forceDisposeTextures Force disposal of the associated textures.
  122598. */
  122599. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122600. /**
  122601. * Clones the material.
  122602. * @param name The cloned name.
  122603. * @returns The cloned material.
  122604. */
  122605. clone(name: string): BackgroundMaterial;
  122606. /**
  122607. * Serializes the current material to its JSON representation.
  122608. * @returns The JSON representation.
  122609. */
  122610. serialize(): any;
  122611. /**
  122612. * Gets the class name of the material
  122613. * @returns "BackgroundMaterial"
  122614. */
  122615. getClassName(): string;
  122616. /**
  122617. * Parse a JSON input to create back a background material.
  122618. * @param source The JSON data to parse
  122619. * @param scene The scene to create the parsed material in
  122620. * @param rootUrl The root url of the assets the material depends upon
  122621. * @returns the instantiated BackgroundMaterial.
  122622. */
  122623. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122624. }
  122625. }
  122626. declare module BABYLON {
  122627. /**
  122628. * Represents the different options available during the creation of
  122629. * a Environment helper.
  122630. *
  122631. * This can control the default ground, skybox and image processing setup of your scene.
  122632. */
  122633. export interface IEnvironmentHelperOptions {
  122634. /**
  122635. * Specifies whether or not to create a ground.
  122636. * True by default.
  122637. */
  122638. createGround: boolean;
  122639. /**
  122640. * Specifies the ground size.
  122641. * 15 by default.
  122642. */
  122643. groundSize: number;
  122644. /**
  122645. * The texture used on the ground for the main color.
  122646. * Comes from the BabylonJS CDN by default.
  122647. *
  122648. * Remarks: Can be either a texture or a url.
  122649. */
  122650. groundTexture: string | BaseTexture;
  122651. /**
  122652. * The color mixed in the ground texture by default.
  122653. * BabylonJS clearColor by default.
  122654. */
  122655. groundColor: Color3;
  122656. /**
  122657. * Specifies the ground opacity.
  122658. * 1 by default.
  122659. */
  122660. groundOpacity: number;
  122661. /**
  122662. * Enables the ground to receive shadows.
  122663. * True by default.
  122664. */
  122665. enableGroundShadow: boolean;
  122666. /**
  122667. * Helps preventing the shadow to be fully black on the ground.
  122668. * 0.5 by default.
  122669. */
  122670. groundShadowLevel: number;
  122671. /**
  122672. * Creates a mirror texture attach to the ground.
  122673. * false by default.
  122674. */
  122675. enableGroundMirror: boolean;
  122676. /**
  122677. * Specifies the ground mirror size ratio.
  122678. * 0.3 by default as the default kernel is 64.
  122679. */
  122680. groundMirrorSizeRatio: number;
  122681. /**
  122682. * Specifies the ground mirror blur kernel size.
  122683. * 64 by default.
  122684. */
  122685. groundMirrorBlurKernel: number;
  122686. /**
  122687. * Specifies the ground mirror visibility amount.
  122688. * 1 by default
  122689. */
  122690. groundMirrorAmount: number;
  122691. /**
  122692. * Specifies the ground mirror reflectance weight.
  122693. * This uses the standard weight of the background material to setup the fresnel effect
  122694. * of the mirror.
  122695. * 1 by default.
  122696. */
  122697. groundMirrorFresnelWeight: number;
  122698. /**
  122699. * Specifies the ground mirror Falloff distance.
  122700. * This can helps reducing the size of the reflection.
  122701. * 0 by Default.
  122702. */
  122703. groundMirrorFallOffDistance: number;
  122704. /**
  122705. * Specifies the ground mirror texture type.
  122706. * Unsigned Int by Default.
  122707. */
  122708. groundMirrorTextureType: number;
  122709. /**
  122710. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122711. * the shown objects.
  122712. */
  122713. groundYBias: number;
  122714. /**
  122715. * Specifies whether or not to create a skybox.
  122716. * True by default.
  122717. */
  122718. createSkybox: boolean;
  122719. /**
  122720. * Specifies the skybox size.
  122721. * 20 by default.
  122722. */
  122723. skyboxSize: number;
  122724. /**
  122725. * The texture used on the skybox for the main color.
  122726. * Comes from the BabylonJS CDN by default.
  122727. *
  122728. * Remarks: Can be either a texture or a url.
  122729. */
  122730. skyboxTexture: string | BaseTexture;
  122731. /**
  122732. * The color mixed in the skybox texture by default.
  122733. * BabylonJS clearColor by default.
  122734. */
  122735. skyboxColor: Color3;
  122736. /**
  122737. * The background rotation around the Y axis of the scene.
  122738. * This helps aligning the key lights of your scene with the background.
  122739. * 0 by default.
  122740. */
  122741. backgroundYRotation: number;
  122742. /**
  122743. * Compute automatically the size of the elements to best fit with the scene.
  122744. */
  122745. sizeAuto: boolean;
  122746. /**
  122747. * Default position of the rootMesh if autoSize is not true.
  122748. */
  122749. rootPosition: Vector3;
  122750. /**
  122751. * Sets up the image processing in the scene.
  122752. * true by default.
  122753. */
  122754. setupImageProcessing: boolean;
  122755. /**
  122756. * The texture used as your environment texture in the scene.
  122757. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122758. *
  122759. * Remarks: Can be either a texture or a url.
  122760. */
  122761. environmentTexture: string | BaseTexture;
  122762. /**
  122763. * The value of the exposure to apply to the scene.
  122764. * 0.6 by default if setupImageProcessing is true.
  122765. */
  122766. cameraExposure: number;
  122767. /**
  122768. * The value of the contrast to apply to the scene.
  122769. * 1.6 by default if setupImageProcessing is true.
  122770. */
  122771. cameraContrast: number;
  122772. /**
  122773. * Specifies whether or not tonemapping should be enabled in the scene.
  122774. * true by default if setupImageProcessing is true.
  122775. */
  122776. toneMappingEnabled: boolean;
  122777. }
  122778. /**
  122779. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122780. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122781. * It also helps with the default setup of your imageProcessing configuration.
  122782. */
  122783. export class EnvironmentHelper {
  122784. /**
  122785. * Default ground texture URL.
  122786. */
  122787. private static _groundTextureCDNUrl;
  122788. /**
  122789. * Default skybox texture URL.
  122790. */
  122791. private static _skyboxTextureCDNUrl;
  122792. /**
  122793. * Default environment texture URL.
  122794. */
  122795. private static _environmentTextureCDNUrl;
  122796. /**
  122797. * Creates the default options for the helper.
  122798. */
  122799. private static _getDefaultOptions;
  122800. private _rootMesh;
  122801. /**
  122802. * Gets the root mesh created by the helper.
  122803. */
  122804. get rootMesh(): Mesh;
  122805. private _skybox;
  122806. /**
  122807. * Gets the skybox created by the helper.
  122808. */
  122809. get skybox(): Nullable<Mesh>;
  122810. private _skyboxTexture;
  122811. /**
  122812. * Gets the skybox texture created by the helper.
  122813. */
  122814. get skyboxTexture(): Nullable<BaseTexture>;
  122815. private _skyboxMaterial;
  122816. /**
  122817. * Gets the skybox material created by the helper.
  122818. */
  122819. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122820. private _ground;
  122821. /**
  122822. * Gets the ground mesh created by the helper.
  122823. */
  122824. get ground(): Nullable<Mesh>;
  122825. private _groundTexture;
  122826. /**
  122827. * Gets the ground texture created by the helper.
  122828. */
  122829. get groundTexture(): Nullable<BaseTexture>;
  122830. private _groundMirror;
  122831. /**
  122832. * Gets the ground mirror created by the helper.
  122833. */
  122834. get groundMirror(): Nullable<MirrorTexture>;
  122835. /**
  122836. * Gets the ground mirror render list to helps pushing the meshes
  122837. * you wish in the ground reflection.
  122838. */
  122839. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122840. private _groundMaterial;
  122841. /**
  122842. * Gets the ground material created by the helper.
  122843. */
  122844. get groundMaterial(): Nullable<BackgroundMaterial>;
  122845. /**
  122846. * Stores the creation options.
  122847. */
  122848. private readonly _scene;
  122849. private _options;
  122850. /**
  122851. * This observable will be notified with any error during the creation of the environment,
  122852. * mainly texture creation errors.
  122853. */
  122854. onErrorObservable: Observable<{
  122855. message?: string;
  122856. exception?: any;
  122857. }>;
  122858. /**
  122859. * constructor
  122860. * @param options Defines the options we want to customize the helper
  122861. * @param scene The scene to add the material to
  122862. */
  122863. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122864. /**
  122865. * Updates the background according to the new options
  122866. * @param options
  122867. */
  122868. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122869. /**
  122870. * Sets the primary color of all the available elements.
  122871. * @param color the main color to affect to the ground and the background
  122872. */
  122873. setMainColor(color: Color3): void;
  122874. /**
  122875. * Setup the image processing according to the specified options.
  122876. */
  122877. private _setupImageProcessing;
  122878. /**
  122879. * Setup the environment texture according to the specified options.
  122880. */
  122881. private _setupEnvironmentTexture;
  122882. /**
  122883. * Setup the background according to the specified options.
  122884. */
  122885. private _setupBackground;
  122886. /**
  122887. * Get the scene sizes according to the setup.
  122888. */
  122889. private _getSceneSize;
  122890. /**
  122891. * Setup the ground according to the specified options.
  122892. */
  122893. private _setupGround;
  122894. /**
  122895. * Setup the ground material according to the specified options.
  122896. */
  122897. private _setupGroundMaterial;
  122898. /**
  122899. * Setup the ground diffuse texture according to the specified options.
  122900. */
  122901. private _setupGroundDiffuseTexture;
  122902. /**
  122903. * Setup the ground mirror texture according to the specified options.
  122904. */
  122905. private _setupGroundMirrorTexture;
  122906. /**
  122907. * Setup the ground to receive the mirror texture.
  122908. */
  122909. private _setupMirrorInGroundMaterial;
  122910. /**
  122911. * Setup the skybox according to the specified options.
  122912. */
  122913. private _setupSkybox;
  122914. /**
  122915. * Setup the skybox material according to the specified options.
  122916. */
  122917. private _setupSkyboxMaterial;
  122918. /**
  122919. * Setup the skybox reflection texture according to the specified options.
  122920. */
  122921. private _setupSkyboxReflectionTexture;
  122922. private _errorHandler;
  122923. /**
  122924. * Dispose all the elements created by the Helper.
  122925. */
  122926. dispose(): void;
  122927. }
  122928. }
  122929. declare module BABYLON {
  122930. /**
  122931. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122932. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122933. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122934. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122935. */
  122936. export class PhotoDome extends TransformNode {
  122937. /**
  122938. * Define the image as a Monoscopic panoramic 360 image.
  122939. */
  122940. static readonly MODE_MONOSCOPIC: number;
  122941. /**
  122942. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122943. */
  122944. static readonly MODE_TOPBOTTOM: number;
  122945. /**
  122946. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122947. */
  122948. static readonly MODE_SIDEBYSIDE: number;
  122949. private _useDirectMapping;
  122950. /**
  122951. * The texture being displayed on the sphere
  122952. */
  122953. protected _photoTexture: Texture;
  122954. /**
  122955. * Gets or sets the texture being displayed on the sphere
  122956. */
  122957. get photoTexture(): Texture;
  122958. set photoTexture(value: Texture);
  122959. /**
  122960. * Observable raised when an error occured while loading the 360 image
  122961. */
  122962. onLoadErrorObservable: Observable<string>;
  122963. /**
  122964. * The skybox material
  122965. */
  122966. protected _material: BackgroundMaterial;
  122967. /**
  122968. * The surface used for the skybox
  122969. */
  122970. protected _mesh: Mesh;
  122971. /**
  122972. * Gets the mesh used for the skybox.
  122973. */
  122974. get mesh(): Mesh;
  122975. /**
  122976. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122977. * Also see the options.resolution property.
  122978. */
  122979. get fovMultiplier(): number;
  122980. set fovMultiplier(value: number);
  122981. private _imageMode;
  122982. /**
  122983. * Gets or set the current video mode for the video. It can be:
  122984. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122985. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122986. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122987. */
  122988. get imageMode(): number;
  122989. set imageMode(value: number);
  122990. /**
  122991. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  122992. * @param name Element's name, child elements will append suffixes for their own names.
  122993. * @param urlsOfPhoto defines the url of the photo to display
  122994. * @param options defines an object containing optional or exposed sub element properties
  122995. * @param onError defines a callback called when an error occured while loading the texture
  122996. */
  122997. constructor(name: string, urlOfPhoto: string, options: {
  122998. resolution?: number;
  122999. size?: number;
  123000. useDirectMapping?: boolean;
  123001. faceForward?: boolean;
  123002. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123003. private _onBeforeCameraRenderObserver;
  123004. private _changeImageMode;
  123005. /**
  123006. * Releases resources associated with this node.
  123007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123009. */
  123010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123011. }
  123012. }
  123013. declare module BABYLON {
  123014. /**
  123015. * Class used to host RGBD texture specific utilities
  123016. */
  123017. export class RGBDTextureTools {
  123018. /**
  123019. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123020. * @param texture the texture to expand.
  123021. */
  123022. static ExpandRGBDTexture(texture: Texture): void;
  123023. }
  123024. }
  123025. declare module BABYLON {
  123026. /**
  123027. * Class used to host texture specific utilities
  123028. */
  123029. export class BRDFTextureTools {
  123030. /**
  123031. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123032. * @param scene defines the hosting scene
  123033. * @returns the environment BRDF texture
  123034. */
  123035. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123036. private static _environmentBRDFBase64Texture;
  123037. }
  123038. }
  123039. declare module BABYLON {
  123040. /**
  123041. * @hidden
  123042. */
  123043. export interface IMaterialClearCoatDefines {
  123044. CLEARCOAT: boolean;
  123045. CLEARCOAT_DEFAULTIOR: boolean;
  123046. CLEARCOAT_TEXTURE: boolean;
  123047. CLEARCOAT_TEXTUREDIRECTUV: number;
  123048. CLEARCOAT_BUMP: boolean;
  123049. CLEARCOAT_BUMPDIRECTUV: number;
  123050. CLEARCOAT_TINT: boolean;
  123051. CLEARCOAT_TINT_TEXTURE: boolean;
  123052. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123053. /** @hidden */
  123054. _areTexturesDirty: boolean;
  123055. }
  123056. /**
  123057. * Define the code related to the clear coat parameters of the pbr material.
  123058. */
  123059. export class PBRClearCoatConfiguration {
  123060. /**
  123061. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123062. * The default fits with a polyurethane material.
  123063. */
  123064. private static readonly _DefaultIndexOfRefraction;
  123065. private _isEnabled;
  123066. /**
  123067. * Defines if the clear coat is enabled in the material.
  123068. */
  123069. isEnabled: boolean;
  123070. /**
  123071. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123072. */
  123073. intensity: number;
  123074. /**
  123075. * Defines the clear coat layer roughness.
  123076. */
  123077. roughness: number;
  123078. private _indexOfRefraction;
  123079. /**
  123080. * Defines the index of refraction of the clear coat.
  123081. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123082. * The default fits with a polyurethane material.
  123083. * Changing the default value is more performance intensive.
  123084. */
  123085. indexOfRefraction: number;
  123086. private _texture;
  123087. /**
  123088. * Stores the clear coat values in a texture.
  123089. */
  123090. texture: Nullable<BaseTexture>;
  123091. private _bumpTexture;
  123092. /**
  123093. * Define the clear coat specific bump texture.
  123094. */
  123095. bumpTexture: Nullable<BaseTexture>;
  123096. private _isTintEnabled;
  123097. /**
  123098. * Defines if the clear coat tint is enabled in the material.
  123099. */
  123100. isTintEnabled: boolean;
  123101. /**
  123102. * Defines the clear coat tint of the material.
  123103. * This is only use if tint is enabled
  123104. */
  123105. tintColor: Color3;
  123106. /**
  123107. * Defines the distance at which the tint color should be found in the
  123108. * clear coat media.
  123109. * This is only use if tint is enabled
  123110. */
  123111. tintColorAtDistance: number;
  123112. /**
  123113. * Defines the clear coat layer thickness.
  123114. * This is only use if tint is enabled
  123115. */
  123116. tintThickness: number;
  123117. private _tintTexture;
  123118. /**
  123119. * Stores the clear tint values in a texture.
  123120. * rgb is tint
  123121. * a is a thickness factor
  123122. */
  123123. tintTexture: Nullable<BaseTexture>;
  123124. /** @hidden */
  123125. private _internalMarkAllSubMeshesAsTexturesDirty;
  123126. /** @hidden */
  123127. _markAllSubMeshesAsTexturesDirty(): void;
  123128. /**
  123129. * Instantiate a new istance of clear coat configuration.
  123130. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123131. */
  123132. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123133. /**
  123134. * Gets wehter the submesh is ready to be used or not.
  123135. * @param defines the list of "defines" to update.
  123136. * @param scene defines the scene the material belongs to.
  123137. * @param engine defines the engine the material belongs to.
  123138. * @param disableBumpMap defines wether the material disables bump or not.
  123139. * @returns - boolean indicating that the submesh is ready or not.
  123140. */
  123141. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123142. /**
  123143. * Checks to see if a texture is used in the material.
  123144. * @param defines the list of "defines" to update.
  123145. * @param scene defines the scene to the material belongs to.
  123146. */
  123147. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123148. /**
  123149. * Binds the material data.
  123150. * @param uniformBuffer defines the Uniform buffer to fill in.
  123151. * @param scene defines the scene the material belongs to.
  123152. * @param engine defines the engine the material belongs to.
  123153. * @param disableBumpMap defines wether the material disables bump or not.
  123154. * @param isFrozen defines wether the material is frozen or not.
  123155. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123156. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123157. */
  123158. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123159. /**
  123160. * Checks to see if a texture is used in the material.
  123161. * @param texture - Base texture to use.
  123162. * @returns - Boolean specifying if a texture is used in the material.
  123163. */
  123164. hasTexture(texture: BaseTexture): boolean;
  123165. /**
  123166. * Returns an array of the actively used textures.
  123167. * @param activeTextures Array of BaseTextures
  123168. */
  123169. getActiveTextures(activeTextures: BaseTexture[]): void;
  123170. /**
  123171. * Returns the animatable textures.
  123172. * @param animatables Array of animatable textures.
  123173. */
  123174. getAnimatables(animatables: IAnimatable[]): void;
  123175. /**
  123176. * Disposes the resources of the material.
  123177. * @param forceDisposeTextures - Forces the disposal of all textures.
  123178. */
  123179. dispose(forceDisposeTextures?: boolean): void;
  123180. /**
  123181. * Get the current class name of the texture useful for serialization or dynamic coding.
  123182. * @returns "PBRClearCoatConfiguration"
  123183. */
  123184. getClassName(): string;
  123185. /**
  123186. * Add fallbacks to the effect fallbacks list.
  123187. * @param defines defines the Base texture to use.
  123188. * @param fallbacks defines the current fallback list.
  123189. * @param currentRank defines the current fallback rank.
  123190. * @returns the new fallback rank.
  123191. */
  123192. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123193. /**
  123194. * Add the required uniforms to the current list.
  123195. * @param uniforms defines the current uniform list.
  123196. */
  123197. static AddUniforms(uniforms: string[]): void;
  123198. /**
  123199. * Add the required samplers to the current list.
  123200. * @param samplers defines the current sampler list.
  123201. */
  123202. static AddSamplers(samplers: string[]): void;
  123203. /**
  123204. * Add the required uniforms to the current buffer.
  123205. * @param uniformBuffer defines the current uniform buffer.
  123206. */
  123207. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123208. /**
  123209. * Makes a duplicate of the current configuration into another one.
  123210. * @param clearCoatConfiguration define the config where to copy the info
  123211. */
  123212. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123213. /**
  123214. * Serializes this clear coat configuration.
  123215. * @returns - An object with the serialized config.
  123216. */
  123217. serialize(): any;
  123218. /**
  123219. * Parses a anisotropy Configuration from a serialized object.
  123220. * @param source - Serialized object.
  123221. * @param scene Defines the scene we are parsing for
  123222. * @param rootUrl Defines the rootUrl to load from
  123223. */
  123224. parse(source: any, scene: Scene, rootUrl: string): void;
  123225. }
  123226. }
  123227. declare module BABYLON {
  123228. /**
  123229. * @hidden
  123230. */
  123231. export interface IMaterialAnisotropicDefines {
  123232. ANISOTROPIC: boolean;
  123233. ANISOTROPIC_TEXTURE: boolean;
  123234. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123235. MAINUV1: boolean;
  123236. _areTexturesDirty: boolean;
  123237. _needUVs: boolean;
  123238. }
  123239. /**
  123240. * Define the code related to the anisotropic parameters of the pbr material.
  123241. */
  123242. export class PBRAnisotropicConfiguration {
  123243. private _isEnabled;
  123244. /**
  123245. * Defines if the anisotropy is enabled in the material.
  123246. */
  123247. isEnabled: boolean;
  123248. /**
  123249. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123250. */
  123251. intensity: number;
  123252. /**
  123253. * Defines if the effect is along the tangents, bitangents or in between.
  123254. * By default, the effect is "strectching" the highlights along the tangents.
  123255. */
  123256. direction: Vector2;
  123257. private _texture;
  123258. /**
  123259. * Stores the anisotropy values in a texture.
  123260. * rg is direction (like normal from -1 to 1)
  123261. * b is a intensity
  123262. */
  123263. texture: Nullable<BaseTexture>;
  123264. /** @hidden */
  123265. private _internalMarkAllSubMeshesAsTexturesDirty;
  123266. /** @hidden */
  123267. _markAllSubMeshesAsTexturesDirty(): void;
  123268. /**
  123269. * Instantiate a new istance of anisotropy configuration.
  123270. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123271. */
  123272. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123273. /**
  123274. * Specifies that the submesh is ready to be used.
  123275. * @param defines the list of "defines" to update.
  123276. * @param scene defines the scene the material belongs to.
  123277. * @returns - boolean indicating that the submesh is ready or not.
  123278. */
  123279. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123280. /**
  123281. * Checks to see if a texture is used in the material.
  123282. * @param defines the list of "defines" to update.
  123283. * @param mesh the mesh we are preparing the defines for.
  123284. * @param scene defines the scene the material belongs to.
  123285. */
  123286. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123287. /**
  123288. * Binds the material data.
  123289. * @param uniformBuffer defines the Uniform buffer to fill in.
  123290. * @param scene defines the scene the material belongs to.
  123291. * @param isFrozen defines wether the material is frozen or not.
  123292. */
  123293. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123294. /**
  123295. * Checks to see if a texture is used in the material.
  123296. * @param texture - Base texture to use.
  123297. * @returns - Boolean specifying if a texture is used in the material.
  123298. */
  123299. hasTexture(texture: BaseTexture): boolean;
  123300. /**
  123301. * Returns an array of the actively used textures.
  123302. * @param activeTextures Array of BaseTextures
  123303. */
  123304. getActiveTextures(activeTextures: BaseTexture[]): void;
  123305. /**
  123306. * Returns the animatable textures.
  123307. * @param animatables Array of animatable textures.
  123308. */
  123309. getAnimatables(animatables: IAnimatable[]): void;
  123310. /**
  123311. * Disposes the resources of the material.
  123312. * @param forceDisposeTextures - Forces the disposal of all textures.
  123313. */
  123314. dispose(forceDisposeTextures?: boolean): void;
  123315. /**
  123316. * Get the current class name of the texture useful for serialization or dynamic coding.
  123317. * @returns "PBRAnisotropicConfiguration"
  123318. */
  123319. getClassName(): string;
  123320. /**
  123321. * Add fallbacks to the effect fallbacks list.
  123322. * @param defines defines the Base texture to use.
  123323. * @param fallbacks defines the current fallback list.
  123324. * @param currentRank defines the current fallback rank.
  123325. * @returns the new fallback rank.
  123326. */
  123327. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123328. /**
  123329. * Add the required uniforms to the current list.
  123330. * @param uniforms defines the current uniform list.
  123331. */
  123332. static AddUniforms(uniforms: string[]): void;
  123333. /**
  123334. * Add the required uniforms to the current buffer.
  123335. * @param uniformBuffer defines the current uniform buffer.
  123336. */
  123337. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123338. /**
  123339. * Add the required samplers to the current list.
  123340. * @param samplers defines the current sampler list.
  123341. */
  123342. static AddSamplers(samplers: string[]): void;
  123343. /**
  123344. * Makes a duplicate of the current configuration into another one.
  123345. * @param anisotropicConfiguration define the config where to copy the info
  123346. */
  123347. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123348. /**
  123349. * Serializes this anisotropy configuration.
  123350. * @returns - An object with the serialized config.
  123351. */
  123352. serialize(): any;
  123353. /**
  123354. * Parses a anisotropy Configuration from a serialized object.
  123355. * @param source - Serialized object.
  123356. * @param scene Defines the scene we are parsing for
  123357. * @param rootUrl Defines the rootUrl to load from
  123358. */
  123359. parse(source: any, scene: Scene, rootUrl: string): void;
  123360. }
  123361. }
  123362. declare module BABYLON {
  123363. /**
  123364. * @hidden
  123365. */
  123366. export interface IMaterialBRDFDefines {
  123367. BRDF_V_HEIGHT_CORRELATED: boolean;
  123368. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123369. SPHERICAL_HARMONICS: boolean;
  123370. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123371. /** @hidden */
  123372. _areMiscDirty: boolean;
  123373. }
  123374. /**
  123375. * Define the code related to the BRDF parameters of the pbr material.
  123376. */
  123377. export class PBRBRDFConfiguration {
  123378. /**
  123379. * Default value used for the energy conservation.
  123380. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123381. */
  123382. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123383. /**
  123384. * Default value used for the Smith Visibility Height Correlated mode.
  123385. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123386. */
  123387. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123388. /**
  123389. * Default value used for the IBL diffuse part.
  123390. * This can help switching back to the polynomials mode globally which is a tiny bit
  123391. * less GPU intensive at the drawback of a lower quality.
  123392. */
  123393. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123394. /**
  123395. * Default value used for activating energy conservation for the specular workflow.
  123396. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123397. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123398. */
  123399. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123400. private _useEnergyConservation;
  123401. /**
  123402. * Defines if the material uses energy conservation.
  123403. */
  123404. useEnergyConservation: boolean;
  123405. private _useSmithVisibilityHeightCorrelated;
  123406. /**
  123407. * LEGACY Mode set to false
  123408. * Defines if the material uses height smith correlated visibility term.
  123409. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123410. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123411. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123412. * Not relying on height correlated will also disable energy conservation.
  123413. */
  123414. useSmithVisibilityHeightCorrelated: boolean;
  123415. private _useSphericalHarmonics;
  123416. /**
  123417. * LEGACY Mode set to false
  123418. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123419. * diffuse part of the IBL.
  123420. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123421. * to the ground truth.
  123422. */
  123423. useSphericalHarmonics: boolean;
  123424. private _useSpecularGlossinessInputEnergyConservation;
  123425. /**
  123426. * Defines if the material uses energy conservation, when the specular workflow is active.
  123427. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123428. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123429. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123430. */
  123431. useSpecularGlossinessInputEnergyConservation: boolean;
  123432. /** @hidden */
  123433. private _internalMarkAllSubMeshesAsMiscDirty;
  123434. /** @hidden */
  123435. _markAllSubMeshesAsMiscDirty(): void;
  123436. /**
  123437. * Instantiate a new istance of clear coat configuration.
  123438. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123439. */
  123440. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123441. /**
  123442. * Checks to see if a texture is used in the material.
  123443. * @param defines the list of "defines" to update.
  123444. */
  123445. prepareDefines(defines: IMaterialBRDFDefines): void;
  123446. /**
  123447. * Get the current class name of the texture useful for serialization or dynamic coding.
  123448. * @returns "PBRClearCoatConfiguration"
  123449. */
  123450. getClassName(): string;
  123451. /**
  123452. * Makes a duplicate of the current configuration into another one.
  123453. * @param brdfConfiguration define the config where to copy the info
  123454. */
  123455. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123456. /**
  123457. * Serializes this BRDF configuration.
  123458. * @returns - An object with the serialized config.
  123459. */
  123460. serialize(): any;
  123461. /**
  123462. * Parses a anisotropy Configuration from a serialized object.
  123463. * @param source - Serialized object.
  123464. * @param scene Defines the scene we are parsing for
  123465. * @param rootUrl Defines the rootUrl to load from
  123466. */
  123467. parse(source: any, scene: Scene, rootUrl: string): void;
  123468. }
  123469. }
  123470. declare module BABYLON {
  123471. /**
  123472. * @hidden
  123473. */
  123474. export interface IMaterialSheenDefines {
  123475. SHEEN: boolean;
  123476. SHEEN_TEXTURE: boolean;
  123477. SHEEN_TEXTUREDIRECTUV: number;
  123478. SHEEN_LINKWITHALBEDO: boolean;
  123479. /** @hidden */
  123480. _areTexturesDirty: boolean;
  123481. }
  123482. /**
  123483. * Define the code related to the Sheen parameters of the pbr material.
  123484. */
  123485. export class PBRSheenConfiguration {
  123486. private _isEnabled;
  123487. /**
  123488. * Defines if the material uses sheen.
  123489. */
  123490. isEnabled: boolean;
  123491. private _linkSheenWithAlbedo;
  123492. /**
  123493. * Defines if the sheen is linked to the sheen color.
  123494. */
  123495. linkSheenWithAlbedo: boolean;
  123496. /**
  123497. * Defines the sheen intensity.
  123498. */
  123499. intensity: number;
  123500. /**
  123501. * Defines the sheen color.
  123502. */
  123503. color: Color3;
  123504. private _texture;
  123505. /**
  123506. * Stores the sheen tint values in a texture.
  123507. * rgb is tint
  123508. * a is a intensity
  123509. */
  123510. texture: Nullable<BaseTexture>;
  123511. /** @hidden */
  123512. private _internalMarkAllSubMeshesAsTexturesDirty;
  123513. /** @hidden */
  123514. _markAllSubMeshesAsTexturesDirty(): void;
  123515. /**
  123516. * Instantiate a new istance of clear coat configuration.
  123517. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123518. */
  123519. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123520. /**
  123521. * Specifies that the submesh is ready to be used.
  123522. * @param defines the list of "defines" to update.
  123523. * @param scene defines the scene the material belongs to.
  123524. * @returns - boolean indicating that the submesh is ready or not.
  123525. */
  123526. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123527. /**
  123528. * Checks to see if a texture is used in the material.
  123529. * @param defines the list of "defines" to update.
  123530. * @param scene defines the scene the material belongs to.
  123531. */
  123532. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123533. /**
  123534. * Binds the material data.
  123535. * @param uniformBuffer defines the Uniform buffer to fill in.
  123536. * @param scene defines the scene the material belongs to.
  123537. * @param isFrozen defines wether the material is frozen or not.
  123538. */
  123539. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123540. /**
  123541. * Checks to see if a texture is used in the material.
  123542. * @param texture - Base texture to use.
  123543. * @returns - Boolean specifying if a texture is used in the material.
  123544. */
  123545. hasTexture(texture: BaseTexture): boolean;
  123546. /**
  123547. * Returns an array of the actively used textures.
  123548. * @param activeTextures Array of BaseTextures
  123549. */
  123550. getActiveTextures(activeTextures: BaseTexture[]): void;
  123551. /**
  123552. * Returns the animatable textures.
  123553. * @param animatables Array of animatable textures.
  123554. */
  123555. getAnimatables(animatables: IAnimatable[]): void;
  123556. /**
  123557. * Disposes the resources of the material.
  123558. * @param forceDisposeTextures - Forces the disposal of all textures.
  123559. */
  123560. dispose(forceDisposeTextures?: boolean): void;
  123561. /**
  123562. * Get the current class name of the texture useful for serialization or dynamic coding.
  123563. * @returns "PBRSheenConfiguration"
  123564. */
  123565. getClassName(): string;
  123566. /**
  123567. * Add fallbacks to the effect fallbacks list.
  123568. * @param defines defines the Base texture to use.
  123569. * @param fallbacks defines the current fallback list.
  123570. * @param currentRank defines the current fallback rank.
  123571. * @returns the new fallback rank.
  123572. */
  123573. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123574. /**
  123575. * Add the required uniforms to the current list.
  123576. * @param uniforms defines the current uniform list.
  123577. */
  123578. static AddUniforms(uniforms: string[]): void;
  123579. /**
  123580. * Add the required uniforms to the current buffer.
  123581. * @param uniformBuffer defines the current uniform buffer.
  123582. */
  123583. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123584. /**
  123585. * Add the required samplers to the current list.
  123586. * @param samplers defines the current sampler list.
  123587. */
  123588. static AddSamplers(samplers: string[]): void;
  123589. /**
  123590. * Makes a duplicate of the current configuration into another one.
  123591. * @param sheenConfiguration define the config where to copy the info
  123592. */
  123593. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123594. /**
  123595. * Serializes this BRDF configuration.
  123596. * @returns - An object with the serialized config.
  123597. */
  123598. serialize(): any;
  123599. /**
  123600. * Parses a anisotropy Configuration from a serialized object.
  123601. * @param source - Serialized object.
  123602. * @param scene Defines the scene we are parsing for
  123603. * @param rootUrl Defines the rootUrl to load from
  123604. */
  123605. parse(source: any, scene: Scene, rootUrl: string): void;
  123606. }
  123607. }
  123608. declare module BABYLON {
  123609. /**
  123610. * @hidden
  123611. */
  123612. export interface IMaterialSubSurfaceDefines {
  123613. SUBSURFACE: boolean;
  123614. SS_REFRACTION: boolean;
  123615. SS_TRANSLUCENCY: boolean;
  123616. SS_SCATERRING: boolean;
  123617. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123618. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123619. SS_REFRACTIONMAP_3D: boolean;
  123620. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123621. SS_LODINREFRACTIONALPHA: boolean;
  123622. SS_GAMMAREFRACTION: boolean;
  123623. SS_RGBDREFRACTION: boolean;
  123624. SS_LINEARSPECULARREFRACTION: boolean;
  123625. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123626. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123627. /** @hidden */
  123628. _areTexturesDirty: boolean;
  123629. }
  123630. /**
  123631. * Define the code related to the sub surface parameters of the pbr material.
  123632. */
  123633. export class PBRSubSurfaceConfiguration {
  123634. private _isRefractionEnabled;
  123635. /**
  123636. * Defines if the refraction is enabled in the material.
  123637. */
  123638. isRefractionEnabled: boolean;
  123639. private _isTranslucencyEnabled;
  123640. /**
  123641. * Defines if the translucency is enabled in the material.
  123642. */
  123643. isTranslucencyEnabled: boolean;
  123644. private _isScatteringEnabled;
  123645. /**
  123646. * Defines the refraction intensity of the material.
  123647. * The refraction when enabled replaces the Diffuse part of the material.
  123648. * The intensity helps transitionning between diffuse and refraction.
  123649. */
  123650. refractionIntensity: number;
  123651. /**
  123652. * Defines the translucency intensity of the material.
  123653. * When translucency has been enabled, this defines how much of the "translucency"
  123654. * is addded to the diffuse part of the material.
  123655. */
  123656. translucencyIntensity: number;
  123657. /**
  123658. * Defines the scattering intensity of the material.
  123659. * When scattering has been enabled, this defines how much of the "scattered light"
  123660. * is addded to the diffuse part of the material.
  123661. */
  123662. scatteringIntensity: number;
  123663. private _thicknessTexture;
  123664. /**
  123665. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123666. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123667. * 0 would mean minimumThickness
  123668. * 1 would mean maximumThickness
  123669. * The other channels might be use as a mask to vary the different effects intensity.
  123670. */
  123671. thicknessTexture: Nullable<BaseTexture>;
  123672. private _refractionTexture;
  123673. /**
  123674. * Defines the texture to use for refraction.
  123675. */
  123676. refractionTexture: Nullable<BaseTexture>;
  123677. private _indexOfRefraction;
  123678. /**
  123679. * Defines the index of refraction used in the material.
  123680. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123681. */
  123682. indexOfRefraction: number;
  123683. private _invertRefractionY;
  123684. /**
  123685. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123686. */
  123687. invertRefractionY: boolean;
  123688. private _linkRefractionWithTransparency;
  123689. /**
  123690. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123691. * Materials half opaque for instance using refraction could benefit from this control.
  123692. */
  123693. linkRefractionWithTransparency: boolean;
  123694. /**
  123695. * Defines the minimum thickness stored in the thickness map.
  123696. * If no thickness map is defined, this value will be used to simulate thickness.
  123697. */
  123698. minimumThickness: number;
  123699. /**
  123700. * Defines the maximum thickness stored in the thickness map.
  123701. */
  123702. maximumThickness: number;
  123703. /**
  123704. * Defines the volume tint of the material.
  123705. * This is used for both translucency and scattering.
  123706. */
  123707. tintColor: Color3;
  123708. /**
  123709. * Defines the distance at which the tint color should be found in the media.
  123710. * This is used for refraction only.
  123711. */
  123712. tintColorAtDistance: number;
  123713. /**
  123714. * Defines how far each channel transmit through the media.
  123715. * It is defined as a color to simplify it selection.
  123716. */
  123717. diffusionDistance: Color3;
  123718. private _useMaskFromThicknessTexture;
  123719. /**
  123720. * Stores the intensity of the different subsurface effects in the thickness texture.
  123721. * * the green channel is the translucency intensity.
  123722. * * the blue channel is the scattering intensity.
  123723. * * the alpha channel is the refraction intensity.
  123724. */
  123725. useMaskFromThicknessTexture: boolean;
  123726. /** @hidden */
  123727. private _internalMarkAllSubMeshesAsTexturesDirty;
  123728. /** @hidden */
  123729. _markAllSubMeshesAsTexturesDirty(): void;
  123730. /**
  123731. * Instantiate a new istance of sub surface configuration.
  123732. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123733. */
  123734. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123735. /**
  123736. * Gets wehter the submesh is ready to be used or not.
  123737. * @param defines the list of "defines" to update.
  123738. * @param scene defines the scene the material belongs to.
  123739. * @returns - boolean indicating that the submesh is ready or not.
  123740. */
  123741. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123742. /**
  123743. * Checks to see if a texture is used in the material.
  123744. * @param defines the list of "defines" to update.
  123745. * @param scene defines the scene to the material belongs to.
  123746. */
  123747. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123748. /**
  123749. * Binds the material data.
  123750. * @param uniformBuffer defines the Uniform buffer to fill in.
  123751. * @param scene defines the scene the material belongs to.
  123752. * @param engine defines the engine the material belongs to.
  123753. * @param isFrozen defines wether the material is frozen or not.
  123754. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123755. */
  123756. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123757. /**
  123758. * Unbinds the material from the mesh.
  123759. * @param activeEffect defines the effect that should be unbound from.
  123760. * @returns true if unbound, otherwise false
  123761. */
  123762. unbind(activeEffect: Effect): boolean;
  123763. /**
  123764. * Returns the texture used for refraction or null if none is used.
  123765. * @param scene defines the scene the material belongs to.
  123766. * @returns - Refraction texture if present. If no refraction texture and refraction
  123767. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123768. */
  123769. private _getRefractionTexture;
  123770. /**
  123771. * Returns true if alpha blending should be disabled.
  123772. */
  123773. get disableAlphaBlending(): boolean;
  123774. /**
  123775. * Fills the list of render target textures.
  123776. * @param renderTargets the list of render targets to update
  123777. */
  123778. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123779. /**
  123780. * Checks to see if a texture is used in the material.
  123781. * @param texture - Base texture to use.
  123782. * @returns - Boolean specifying if a texture is used in the material.
  123783. */
  123784. hasTexture(texture: BaseTexture): boolean;
  123785. /**
  123786. * Gets a boolean indicating that current material needs to register RTT
  123787. * @returns true if this uses a render target otherwise false.
  123788. */
  123789. hasRenderTargetTextures(): boolean;
  123790. /**
  123791. * Returns an array of the actively used textures.
  123792. * @param activeTextures Array of BaseTextures
  123793. */
  123794. getActiveTextures(activeTextures: BaseTexture[]): void;
  123795. /**
  123796. * Returns the animatable textures.
  123797. * @param animatables Array of animatable textures.
  123798. */
  123799. getAnimatables(animatables: IAnimatable[]): void;
  123800. /**
  123801. * Disposes the resources of the material.
  123802. * @param forceDisposeTextures - Forces the disposal of all textures.
  123803. */
  123804. dispose(forceDisposeTextures?: boolean): void;
  123805. /**
  123806. * Get the current class name of the texture useful for serialization or dynamic coding.
  123807. * @returns "PBRSubSurfaceConfiguration"
  123808. */
  123809. getClassName(): string;
  123810. /**
  123811. * Add fallbacks to the effect fallbacks list.
  123812. * @param defines defines the Base texture to use.
  123813. * @param fallbacks defines the current fallback list.
  123814. * @param currentRank defines the current fallback rank.
  123815. * @returns the new fallback rank.
  123816. */
  123817. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123818. /**
  123819. * Add the required uniforms to the current list.
  123820. * @param uniforms defines the current uniform list.
  123821. */
  123822. static AddUniforms(uniforms: string[]): void;
  123823. /**
  123824. * Add the required samplers to the current list.
  123825. * @param samplers defines the current sampler list.
  123826. */
  123827. static AddSamplers(samplers: string[]): void;
  123828. /**
  123829. * Add the required uniforms to the current buffer.
  123830. * @param uniformBuffer defines the current uniform buffer.
  123831. */
  123832. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123833. /**
  123834. * Makes a duplicate of the current configuration into another one.
  123835. * @param configuration define the config where to copy the info
  123836. */
  123837. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123838. /**
  123839. * Serializes this Sub Surface configuration.
  123840. * @returns - An object with the serialized config.
  123841. */
  123842. serialize(): any;
  123843. /**
  123844. * Parses a anisotropy Configuration from a serialized object.
  123845. * @param source - Serialized object.
  123846. * @param scene Defines the scene we are parsing for
  123847. * @param rootUrl Defines the rootUrl to load from
  123848. */
  123849. parse(source: any, scene: Scene, rootUrl: string): void;
  123850. }
  123851. }
  123852. declare module BABYLON {
  123853. /** @hidden */
  123854. export var pbrFragmentDeclaration: {
  123855. name: string;
  123856. shader: string;
  123857. };
  123858. }
  123859. declare module BABYLON {
  123860. /** @hidden */
  123861. export var pbrUboDeclaration: {
  123862. name: string;
  123863. shader: string;
  123864. };
  123865. }
  123866. declare module BABYLON {
  123867. /** @hidden */
  123868. export var pbrFragmentExtraDeclaration: {
  123869. name: string;
  123870. shader: string;
  123871. };
  123872. }
  123873. declare module BABYLON {
  123874. /** @hidden */
  123875. export var pbrFragmentSamplersDeclaration: {
  123876. name: string;
  123877. shader: string;
  123878. };
  123879. }
  123880. declare module BABYLON {
  123881. /** @hidden */
  123882. export var pbrHelperFunctions: {
  123883. name: string;
  123884. shader: string;
  123885. };
  123886. }
  123887. declare module BABYLON {
  123888. /** @hidden */
  123889. export var harmonicsFunctions: {
  123890. name: string;
  123891. shader: string;
  123892. };
  123893. }
  123894. declare module BABYLON {
  123895. /** @hidden */
  123896. export var pbrDirectLightingSetupFunctions: {
  123897. name: string;
  123898. shader: string;
  123899. };
  123900. }
  123901. declare module BABYLON {
  123902. /** @hidden */
  123903. export var pbrDirectLightingFalloffFunctions: {
  123904. name: string;
  123905. shader: string;
  123906. };
  123907. }
  123908. declare module BABYLON {
  123909. /** @hidden */
  123910. export var pbrBRDFFunctions: {
  123911. name: string;
  123912. shader: string;
  123913. };
  123914. }
  123915. declare module BABYLON {
  123916. /** @hidden */
  123917. export var pbrDirectLightingFunctions: {
  123918. name: string;
  123919. shader: string;
  123920. };
  123921. }
  123922. declare module BABYLON {
  123923. /** @hidden */
  123924. export var pbrIBLFunctions: {
  123925. name: string;
  123926. shader: string;
  123927. };
  123928. }
  123929. declare module BABYLON {
  123930. /** @hidden */
  123931. export var pbrDebug: {
  123932. name: string;
  123933. shader: string;
  123934. };
  123935. }
  123936. declare module BABYLON {
  123937. /** @hidden */
  123938. export var pbrPixelShader: {
  123939. name: string;
  123940. shader: string;
  123941. };
  123942. }
  123943. declare module BABYLON {
  123944. /** @hidden */
  123945. export var pbrVertexDeclaration: {
  123946. name: string;
  123947. shader: string;
  123948. };
  123949. }
  123950. declare module BABYLON {
  123951. /** @hidden */
  123952. export var pbrVertexShader: {
  123953. name: string;
  123954. shader: string;
  123955. };
  123956. }
  123957. declare module BABYLON {
  123958. /**
  123959. * Manages the defines for the PBR Material.
  123960. * @hidden
  123961. */
  123962. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123963. PBR: boolean;
  123964. MAINUV1: boolean;
  123965. MAINUV2: boolean;
  123966. UV1: boolean;
  123967. UV2: boolean;
  123968. ALBEDO: boolean;
  123969. ALBEDODIRECTUV: number;
  123970. VERTEXCOLOR: boolean;
  123971. AMBIENT: boolean;
  123972. AMBIENTDIRECTUV: number;
  123973. AMBIENTINGRAYSCALE: boolean;
  123974. OPACITY: boolean;
  123975. VERTEXALPHA: boolean;
  123976. OPACITYDIRECTUV: number;
  123977. OPACITYRGB: boolean;
  123978. ALPHATEST: boolean;
  123979. DEPTHPREPASS: boolean;
  123980. ALPHABLEND: boolean;
  123981. ALPHAFROMALBEDO: boolean;
  123982. ALPHATESTVALUE: string;
  123983. SPECULAROVERALPHA: boolean;
  123984. RADIANCEOVERALPHA: boolean;
  123985. ALPHAFRESNEL: boolean;
  123986. LINEARALPHAFRESNEL: boolean;
  123987. PREMULTIPLYALPHA: boolean;
  123988. EMISSIVE: boolean;
  123989. EMISSIVEDIRECTUV: number;
  123990. REFLECTIVITY: boolean;
  123991. REFLECTIVITYDIRECTUV: number;
  123992. SPECULARTERM: boolean;
  123993. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  123994. MICROSURFACEAUTOMATIC: boolean;
  123995. LODBASEDMICROSFURACE: boolean;
  123996. MICROSURFACEMAP: boolean;
  123997. MICROSURFACEMAPDIRECTUV: number;
  123998. METALLICWORKFLOW: boolean;
  123999. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124000. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124001. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124002. AOSTOREINMETALMAPRED: boolean;
  124003. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124004. ENVIRONMENTBRDF: boolean;
  124005. ENVIRONMENTBRDF_RGBD: boolean;
  124006. NORMAL: boolean;
  124007. TANGENT: boolean;
  124008. BUMP: boolean;
  124009. BUMPDIRECTUV: number;
  124010. OBJECTSPACE_NORMALMAP: boolean;
  124011. PARALLAX: boolean;
  124012. PARALLAXOCCLUSION: boolean;
  124013. NORMALXYSCALE: boolean;
  124014. LIGHTMAP: boolean;
  124015. LIGHTMAPDIRECTUV: number;
  124016. USELIGHTMAPASSHADOWMAP: boolean;
  124017. GAMMALIGHTMAP: boolean;
  124018. RGBDLIGHTMAP: boolean;
  124019. REFLECTION: boolean;
  124020. REFLECTIONMAP_3D: boolean;
  124021. REFLECTIONMAP_SPHERICAL: boolean;
  124022. REFLECTIONMAP_PLANAR: boolean;
  124023. REFLECTIONMAP_CUBIC: boolean;
  124024. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124025. REFLECTIONMAP_PROJECTION: boolean;
  124026. REFLECTIONMAP_SKYBOX: boolean;
  124027. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  124028. REFLECTIONMAP_EXPLICIT: boolean;
  124029. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124030. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124031. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124032. INVERTCUBICMAP: boolean;
  124033. USESPHERICALFROMREFLECTIONMAP: boolean;
  124034. USEIRRADIANCEMAP: boolean;
  124035. SPHERICAL_HARMONICS: boolean;
  124036. USESPHERICALINVERTEX: boolean;
  124037. REFLECTIONMAP_OPPOSITEZ: boolean;
  124038. LODINREFLECTIONALPHA: boolean;
  124039. GAMMAREFLECTION: boolean;
  124040. RGBDREFLECTION: boolean;
  124041. LINEARSPECULARREFLECTION: boolean;
  124042. RADIANCEOCCLUSION: boolean;
  124043. HORIZONOCCLUSION: boolean;
  124044. INSTANCES: boolean;
  124045. NUM_BONE_INFLUENCERS: number;
  124046. BonesPerMesh: number;
  124047. BONETEXTURE: boolean;
  124048. NONUNIFORMSCALING: boolean;
  124049. MORPHTARGETS: boolean;
  124050. MORPHTARGETS_NORMAL: boolean;
  124051. MORPHTARGETS_TANGENT: boolean;
  124052. MORPHTARGETS_UV: boolean;
  124053. NUM_MORPH_INFLUENCERS: number;
  124054. IMAGEPROCESSING: boolean;
  124055. VIGNETTE: boolean;
  124056. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124057. VIGNETTEBLENDMODEOPAQUE: boolean;
  124058. TONEMAPPING: boolean;
  124059. TONEMAPPING_ACES: boolean;
  124060. CONTRAST: boolean;
  124061. COLORCURVES: boolean;
  124062. COLORGRADING: boolean;
  124063. COLORGRADING3D: boolean;
  124064. SAMPLER3DGREENDEPTH: boolean;
  124065. SAMPLER3DBGRMAP: boolean;
  124066. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124067. EXPOSURE: boolean;
  124068. MULTIVIEW: boolean;
  124069. USEPHYSICALLIGHTFALLOFF: boolean;
  124070. USEGLTFLIGHTFALLOFF: boolean;
  124071. TWOSIDEDLIGHTING: boolean;
  124072. SHADOWFLOAT: boolean;
  124073. CLIPPLANE: boolean;
  124074. CLIPPLANE2: boolean;
  124075. CLIPPLANE3: boolean;
  124076. CLIPPLANE4: boolean;
  124077. CLIPPLANE5: boolean;
  124078. CLIPPLANE6: boolean;
  124079. POINTSIZE: boolean;
  124080. FOG: boolean;
  124081. LOGARITHMICDEPTH: boolean;
  124082. FORCENORMALFORWARD: boolean;
  124083. SPECULARAA: boolean;
  124084. CLEARCOAT: boolean;
  124085. CLEARCOAT_DEFAULTIOR: boolean;
  124086. CLEARCOAT_TEXTURE: boolean;
  124087. CLEARCOAT_TEXTUREDIRECTUV: number;
  124088. CLEARCOAT_BUMP: boolean;
  124089. CLEARCOAT_BUMPDIRECTUV: number;
  124090. CLEARCOAT_TINT: boolean;
  124091. CLEARCOAT_TINT_TEXTURE: boolean;
  124092. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124093. ANISOTROPIC: boolean;
  124094. ANISOTROPIC_TEXTURE: boolean;
  124095. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124096. BRDF_V_HEIGHT_CORRELATED: boolean;
  124097. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124098. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124099. SHEEN: boolean;
  124100. SHEEN_TEXTURE: boolean;
  124101. SHEEN_TEXTUREDIRECTUV: number;
  124102. SHEEN_LINKWITHALBEDO: boolean;
  124103. SUBSURFACE: boolean;
  124104. SS_REFRACTION: boolean;
  124105. SS_TRANSLUCENCY: boolean;
  124106. SS_SCATERRING: boolean;
  124107. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124108. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124109. SS_REFRACTIONMAP_3D: boolean;
  124110. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124111. SS_LODINREFRACTIONALPHA: boolean;
  124112. SS_GAMMAREFRACTION: boolean;
  124113. SS_RGBDREFRACTION: boolean;
  124114. SS_LINEARSPECULARREFRACTION: boolean;
  124115. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124116. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124117. UNLIT: boolean;
  124118. DEBUGMODE: number;
  124119. /**
  124120. * Initializes the PBR Material defines.
  124121. */
  124122. constructor();
  124123. /**
  124124. * Resets the PBR Material defines.
  124125. */
  124126. reset(): void;
  124127. }
  124128. /**
  124129. * The Physically based material base class of BJS.
  124130. *
  124131. * This offers the main features of a standard PBR material.
  124132. * For more information, please refer to the documentation :
  124133. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124134. */
  124135. export abstract class PBRBaseMaterial extends PushMaterial {
  124136. /**
  124137. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124138. */
  124139. static readonly PBRMATERIAL_OPAQUE: number;
  124140. /**
  124141. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124142. */
  124143. static readonly PBRMATERIAL_ALPHATEST: number;
  124144. /**
  124145. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124146. */
  124147. static readonly PBRMATERIAL_ALPHABLEND: number;
  124148. /**
  124149. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124150. * They are also discarded below the alpha cutoff threshold to improve performances.
  124151. */
  124152. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124153. /**
  124154. * Defines the default value of how much AO map is occluding the analytical lights
  124155. * (point spot...).
  124156. */
  124157. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124158. /**
  124159. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124160. */
  124161. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124162. /**
  124163. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124164. * to enhance interoperability with other engines.
  124165. */
  124166. static readonly LIGHTFALLOFF_GLTF: number;
  124167. /**
  124168. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124169. * to enhance interoperability with other materials.
  124170. */
  124171. static readonly LIGHTFALLOFF_STANDARD: number;
  124172. /**
  124173. * Intensity of the direct lights e.g. the four lights available in your scene.
  124174. * This impacts both the direct diffuse and specular highlights.
  124175. */
  124176. protected _directIntensity: number;
  124177. /**
  124178. * Intensity of the emissive part of the material.
  124179. * This helps controlling the emissive effect without modifying the emissive color.
  124180. */
  124181. protected _emissiveIntensity: number;
  124182. /**
  124183. * Intensity of the environment e.g. how much the environment will light the object
  124184. * either through harmonics for rough material or through the refelction for shiny ones.
  124185. */
  124186. protected _environmentIntensity: number;
  124187. /**
  124188. * This is a special control allowing the reduction of the specular highlights coming from the
  124189. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124190. */
  124191. protected _specularIntensity: number;
  124192. /**
  124193. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124194. */
  124195. private _lightingInfos;
  124196. /**
  124197. * Debug Control allowing disabling the bump map on this material.
  124198. */
  124199. protected _disableBumpMap: boolean;
  124200. /**
  124201. * AKA Diffuse Texture in standard nomenclature.
  124202. */
  124203. protected _albedoTexture: Nullable<BaseTexture>;
  124204. /**
  124205. * AKA Occlusion Texture in other nomenclature.
  124206. */
  124207. protected _ambientTexture: Nullable<BaseTexture>;
  124208. /**
  124209. * AKA Occlusion Texture Intensity in other nomenclature.
  124210. */
  124211. protected _ambientTextureStrength: number;
  124212. /**
  124213. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124214. * 1 means it completely occludes it
  124215. * 0 mean it has no impact
  124216. */
  124217. protected _ambientTextureImpactOnAnalyticalLights: number;
  124218. /**
  124219. * Stores the alpha values in a texture.
  124220. */
  124221. protected _opacityTexture: Nullable<BaseTexture>;
  124222. /**
  124223. * Stores the reflection values in a texture.
  124224. */
  124225. protected _reflectionTexture: Nullable<BaseTexture>;
  124226. /**
  124227. * Stores the emissive values in a texture.
  124228. */
  124229. protected _emissiveTexture: Nullable<BaseTexture>;
  124230. /**
  124231. * AKA Specular texture in other nomenclature.
  124232. */
  124233. protected _reflectivityTexture: Nullable<BaseTexture>;
  124234. /**
  124235. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124236. */
  124237. protected _metallicTexture: Nullable<BaseTexture>;
  124238. /**
  124239. * Specifies the metallic scalar of the metallic/roughness workflow.
  124240. * Can also be used to scale the metalness values of the metallic texture.
  124241. */
  124242. protected _metallic: Nullable<number>;
  124243. /**
  124244. * Specifies the roughness scalar of the metallic/roughness workflow.
  124245. * Can also be used to scale the roughness values of the metallic texture.
  124246. */
  124247. protected _roughness: Nullable<number>;
  124248. /**
  124249. * Specifies the an F0 factor to help configuring the material F0.
  124250. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124251. * to 0.5 the previously hard coded value stays the same.
  124252. * Can also be used to scale the F0 values of the metallic texture.
  124253. */
  124254. protected _metallicF0Factor: number;
  124255. /**
  124256. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124257. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124258. * your expectation as it multiplies with the texture data.
  124259. */
  124260. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124261. /**
  124262. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124263. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124264. */
  124265. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124266. /**
  124267. * Stores surface normal data used to displace a mesh in a texture.
  124268. */
  124269. protected _bumpTexture: Nullable<BaseTexture>;
  124270. /**
  124271. * Stores the pre-calculated light information of a mesh in a texture.
  124272. */
  124273. protected _lightmapTexture: Nullable<BaseTexture>;
  124274. /**
  124275. * The color of a material in ambient lighting.
  124276. */
  124277. protected _ambientColor: Color3;
  124278. /**
  124279. * AKA Diffuse Color in other nomenclature.
  124280. */
  124281. protected _albedoColor: Color3;
  124282. /**
  124283. * AKA Specular Color in other nomenclature.
  124284. */
  124285. protected _reflectivityColor: Color3;
  124286. /**
  124287. * The color applied when light is reflected from a material.
  124288. */
  124289. protected _reflectionColor: Color3;
  124290. /**
  124291. * The color applied when light is emitted from a material.
  124292. */
  124293. protected _emissiveColor: Color3;
  124294. /**
  124295. * AKA Glossiness in other nomenclature.
  124296. */
  124297. protected _microSurface: number;
  124298. /**
  124299. * Specifies that the material will use the light map as a show map.
  124300. */
  124301. protected _useLightmapAsShadowmap: boolean;
  124302. /**
  124303. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124304. * makes the reflect vector face the model (under horizon).
  124305. */
  124306. protected _useHorizonOcclusion: boolean;
  124307. /**
  124308. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124309. * too much the area relying on ambient texture to define their ambient occlusion.
  124310. */
  124311. protected _useRadianceOcclusion: boolean;
  124312. /**
  124313. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124314. */
  124315. protected _useAlphaFromAlbedoTexture: boolean;
  124316. /**
  124317. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124318. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124319. */
  124320. protected _useSpecularOverAlpha: boolean;
  124321. /**
  124322. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124323. */
  124324. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124325. /**
  124326. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124327. */
  124328. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124329. /**
  124330. * Specifies if the metallic texture contains the roughness information in its green channel.
  124331. */
  124332. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124333. /**
  124334. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124335. */
  124336. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124337. /**
  124338. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124339. */
  124340. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124341. /**
  124342. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124343. */
  124344. protected _useAmbientInGrayScale: boolean;
  124345. /**
  124346. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124347. * The material will try to infer what glossiness each pixel should be.
  124348. */
  124349. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124350. /**
  124351. * Defines the falloff type used in this material.
  124352. * It by default is Physical.
  124353. */
  124354. protected _lightFalloff: number;
  124355. /**
  124356. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124357. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124358. */
  124359. protected _useRadianceOverAlpha: boolean;
  124360. /**
  124361. * Allows using an object space normal map (instead of tangent space).
  124362. */
  124363. protected _useObjectSpaceNormalMap: boolean;
  124364. /**
  124365. * Allows using the bump map in parallax mode.
  124366. */
  124367. protected _useParallax: boolean;
  124368. /**
  124369. * Allows using the bump map in parallax occlusion mode.
  124370. */
  124371. protected _useParallaxOcclusion: boolean;
  124372. /**
  124373. * Controls the scale bias of the parallax mode.
  124374. */
  124375. protected _parallaxScaleBias: number;
  124376. /**
  124377. * If sets to true, disables all the lights affecting the material.
  124378. */
  124379. protected _disableLighting: boolean;
  124380. /**
  124381. * Number of Simultaneous lights allowed on the material.
  124382. */
  124383. protected _maxSimultaneousLights: number;
  124384. /**
  124385. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124386. */
  124387. protected _invertNormalMapX: boolean;
  124388. /**
  124389. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124390. */
  124391. protected _invertNormalMapY: boolean;
  124392. /**
  124393. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124394. */
  124395. protected _twoSidedLighting: boolean;
  124396. /**
  124397. * Defines the alpha limits in alpha test mode.
  124398. */
  124399. protected _alphaCutOff: number;
  124400. /**
  124401. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124402. */
  124403. protected _forceAlphaTest: boolean;
  124404. /**
  124405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124406. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124407. */
  124408. protected _useAlphaFresnel: boolean;
  124409. /**
  124410. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124411. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124412. */
  124413. protected _useLinearAlphaFresnel: boolean;
  124414. /**
  124415. * The transparency mode of the material.
  124416. */
  124417. protected _transparencyMode: Nullable<number>;
  124418. /**
  124419. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124420. * from cos thetav and roughness:
  124421. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124422. */
  124423. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124424. /**
  124425. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124426. */
  124427. protected _forceIrradianceInFragment: boolean;
  124428. /**
  124429. * Force normal to face away from face.
  124430. */
  124431. protected _forceNormalForward: boolean;
  124432. /**
  124433. * Enables specular anti aliasing in the PBR shader.
  124434. * It will both interacts on the Geometry for analytical and IBL lighting.
  124435. * It also prefilter the roughness map based on the bump values.
  124436. */
  124437. protected _enableSpecularAntiAliasing: boolean;
  124438. /**
  124439. * Default configuration related to image processing available in the PBR Material.
  124440. */
  124441. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124442. /**
  124443. * Keep track of the image processing observer to allow dispose and replace.
  124444. */
  124445. private _imageProcessingObserver;
  124446. /**
  124447. * Attaches a new image processing configuration to the PBR Material.
  124448. * @param configuration
  124449. */
  124450. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124451. /**
  124452. * Stores the available render targets.
  124453. */
  124454. private _renderTargets;
  124455. /**
  124456. * Sets the global ambient color for the material used in lighting calculations.
  124457. */
  124458. private _globalAmbientColor;
  124459. /**
  124460. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124461. */
  124462. private _useLogarithmicDepth;
  124463. /**
  124464. * If set to true, no lighting calculations will be applied.
  124465. */
  124466. private _unlit;
  124467. private _debugMode;
  124468. /**
  124469. * @hidden
  124470. * This is reserved for the inspector.
  124471. * Defines the material debug mode.
  124472. * It helps seeing only some components of the material while troubleshooting.
  124473. */
  124474. debugMode: number;
  124475. /**
  124476. * @hidden
  124477. * This is reserved for the inspector.
  124478. * Specify from where on screen the debug mode should start.
  124479. * The value goes from -1 (full screen) to 1 (not visible)
  124480. * It helps with side by side comparison against the final render
  124481. * This defaults to -1
  124482. */
  124483. private debugLimit;
  124484. /**
  124485. * @hidden
  124486. * This is reserved for the inspector.
  124487. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124488. * You can use the factor to better multiply the final value.
  124489. */
  124490. private debugFactor;
  124491. /**
  124492. * Defines the clear coat layer parameters for the material.
  124493. */
  124494. readonly clearCoat: PBRClearCoatConfiguration;
  124495. /**
  124496. * Defines the anisotropic parameters for the material.
  124497. */
  124498. readonly anisotropy: PBRAnisotropicConfiguration;
  124499. /**
  124500. * Defines the BRDF parameters for the material.
  124501. */
  124502. readonly brdf: PBRBRDFConfiguration;
  124503. /**
  124504. * Defines the Sheen parameters for the material.
  124505. */
  124506. readonly sheen: PBRSheenConfiguration;
  124507. /**
  124508. * Defines the SubSurface parameters for the material.
  124509. */
  124510. readonly subSurface: PBRSubSurfaceConfiguration;
  124511. /**
  124512. * Custom callback helping to override the default shader used in the material.
  124513. */
  124514. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124515. protected _rebuildInParallel: boolean;
  124516. /**
  124517. * Instantiates a new PBRMaterial instance.
  124518. *
  124519. * @param name The material name
  124520. * @param scene The scene the material will be use in.
  124521. */
  124522. constructor(name: string, scene: Scene);
  124523. /**
  124524. * Gets a boolean indicating that current material needs to register RTT
  124525. */
  124526. get hasRenderTargetTextures(): boolean;
  124527. /**
  124528. * Gets the name of the material class.
  124529. */
  124530. getClassName(): string;
  124531. /**
  124532. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124533. */
  124534. get useLogarithmicDepth(): boolean;
  124535. /**
  124536. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124537. */
  124538. set useLogarithmicDepth(value: boolean);
  124539. /**
  124540. * Gets the current transparency mode.
  124541. */
  124542. get transparencyMode(): Nullable<number>;
  124543. /**
  124544. * Sets the transparency mode of the material.
  124545. *
  124546. * | Value | Type | Description |
  124547. * | ----- | ----------------------------------- | ----------- |
  124548. * | 0 | OPAQUE | |
  124549. * | 1 | ALPHATEST | |
  124550. * | 2 | ALPHABLEND | |
  124551. * | 3 | ALPHATESTANDBLEND | |
  124552. *
  124553. */
  124554. set transparencyMode(value: Nullable<number>);
  124555. /**
  124556. * Returns true if alpha blending should be disabled.
  124557. */
  124558. private get _disableAlphaBlending();
  124559. /**
  124560. * Specifies whether or not this material should be rendered in alpha blend mode.
  124561. */
  124562. needAlphaBlending(): boolean;
  124563. /**
  124564. * Specifies if the mesh will require alpha blending.
  124565. * @param mesh - BJS mesh.
  124566. */
  124567. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124568. /**
  124569. * Specifies whether or not this material should be rendered in alpha test mode.
  124570. */
  124571. needAlphaTesting(): boolean;
  124572. /**
  124573. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124574. */
  124575. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124576. /**
  124577. * Gets the texture used for the alpha test.
  124578. */
  124579. getAlphaTestTexture(): Nullable<BaseTexture>;
  124580. /**
  124581. * Specifies that the submesh is ready to be used.
  124582. * @param mesh - BJS mesh.
  124583. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124584. * @param useInstances - Specifies that instances should be used.
  124585. * @returns - boolean indicating that the submesh is ready or not.
  124586. */
  124587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124588. /**
  124589. * Specifies if the material uses metallic roughness workflow.
  124590. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124591. */
  124592. isMetallicWorkflow(): boolean;
  124593. private _prepareEffect;
  124594. private _prepareDefines;
  124595. /**
  124596. * Force shader compilation
  124597. */
  124598. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124599. /**
  124600. * Initializes the uniform buffer layout for the shader.
  124601. */
  124602. buildUniformLayout(): void;
  124603. /**
  124604. * Unbinds the material from the mesh
  124605. */
  124606. unbind(): void;
  124607. /**
  124608. * Binds the submesh data.
  124609. * @param world - The world matrix.
  124610. * @param mesh - The BJS mesh.
  124611. * @param subMesh - A submesh of the BJS mesh.
  124612. */
  124613. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124614. /**
  124615. * Returns the animatable textures.
  124616. * @returns - Array of animatable textures.
  124617. */
  124618. getAnimatables(): IAnimatable[];
  124619. /**
  124620. * Returns the texture used for reflections.
  124621. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124622. */
  124623. private _getReflectionTexture;
  124624. /**
  124625. * Returns an array of the actively used textures.
  124626. * @returns - Array of BaseTextures
  124627. */
  124628. getActiveTextures(): BaseTexture[];
  124629. /**
  124630. * Checks to see if a texture is used in the material.
  124631. * @param texture - Base texture to use.
  124632. * @returns - Boolean specifying if a texture is used in the material.
  124633. */
  124634. hasTexture(texture: BaseTexture): boolean;
  124635. /**
  124636. * Disposes the resources of the material.
  124637. * @param forceDisposeEffect - Forces the disposal of effects.
  124638. * @param forceDisposeTextures - Forces the disposal of all textures.
  124639. */
  124640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124641. }
  124642. }
  124643. declare module BABYLON {
  124644. /**
  124645. * The Physically based material of BJS.
  124646. *
  124647. * This offers the main features of a standard PBR material.
  124648. * For more information, please refer to the documentation :
  124649. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124650. */
  124651. export class PBRMaterial extends PBRBaseMaterial {
  124652. /**
  124653. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124654. */
  124655. static readonly PBRMATERIAL_OPAQUE: number;
  124656. /**
  124657. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124658. */
  124659. static readonly PBRMATERIAL_ALPHATEST: number;
  124660. /**
  124661. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124662. */
  124663. static readonly PBRMATERIAL_ALPHABLEND: number;
  124664. /**
  124665. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124666. * They are also discarded below the alpha cutoff threshold to improve performances.
  124667. */
  124668. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124669. /**
  124670. * Defines the default value of how much AO map is occluding the analytical lights
  124671. * (point spot...).
  124672. */
  124673. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124674. /**
  124675. * Intensity of the direct lights e.g. the four lights available in your scene.
  124676. * This impacts both the direct diffuse and specular highlights.
  124677. */
  124678. directIntensity: number;
  124679. /**
  124680. * Intensity of the emissive part of the material.
  124681. * This helps controlling the emissive effect without modifying the emissive color.
  124682. */
  124683. emissiveIntensity: number;
  124684. /**
  124685. * Intensity of the environment e.g. how much the environment will light the object
  124686. * either through harmonics for rough material or through the refelction for shiny ones.
  124687. */
  124688. environmentIntensity: number;
  124689. /**
  124690. * This is a special control allowing the reduction of the specular highlights coming from the
  124691. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124692. */
  124693. specularIntensity: number;
  124694. /**
  124695. * Debug Control allowing disabling the bump map on this material.
  124696. */
  124697. disableBumpMap: boolean;
  124698. /**
  124699. * AKA Diffuse Texture in standard nomenclature.
  124700. */
  124701. albedoTexture: BaseTexture;
  124702. /**
  124703. * AKA Occlusion Texture in other nomenclature.
  124704. */
  124705. ambientTexture: BaseTexture;
  124706. /**
  124707. * AKA Occlusion Texture Intensity in other nomenclature.
  124708. */
  124709. ambientTextureStrength: number;
  124710. /**
  124711. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124712. * 1 means it completely occludes it
  124713. * 0 mean it has no impact
  124714. */
  124715. ambientTextureImpactOnAnalyticalLights: number;
  124716. /**
  124717. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124718. */
  124719. opacityTexture: BaseTexture;
  124720. /**
  124721. * Stores the reflection values in a texture.
  124722. */
  124723. reflectionTexture: Nullable<BaseTexture>;
  124724. /**
  124725. * Stores the emissive values in a texture.
  124726. */
  124727. emissiveTexture: BaseTexture;
  124728. /**
  124729. * AKA Specular texture in other nomenclature.
  124730. */
  124731. reflectivityTexture: BaseTexture;
  124732. /**
  124733. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124734. */
  124735. metallicTexture: BaseTexture;
  124736. /**
  124737. * Specifies the metallic scalar of the metallic/roughness workflow.
  124738. * Can also be used to scale the metalness values of the metallic texture.
  124739. */
  124740. metallic: Nullable<number>;
  124741. /**
  124742. * Specifies the roughness scalar of the metallic/roughness workflow.
  124743. * Can also be used to scale the roughness values of the metallic texture.
  124744. */
  124745. roughness: Nullable<number>;
  124746. /**
  124747. * Specifies the an F0 factor to help configuring the material F0.
  124748. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124749. * to 0.5 the previously hard coded value stays the same.
  124750. * Can also be used to scale the F0 values of the metallic texture.
  124751. */
  124752. metallicF0Factor: number;
  124753. /**
  124754. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124755. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124756. * your expectation as it multiplies with the texture data.
  124757. */
  124758. useMetallicF0FactorFromMetallicTexture: boolean;
  124759. /**
  124760. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124761. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124762. */
  124763. microSurfaceTexture: BaseTexture;
  124764. /**
  124765. * Stores surface normal data used to displace a mesh in a texture.
  124766. */
  124767. bumpTexture: BaseTexture;
  124768. /**
  124769. * Stores the pre-calculated light information of a mesh in a texture.
  124770. */
  124771. lightmapTexture: BaseTexture;
  124772. /**
  124773. * Stores the refracted light information in a texture.
  124774. */
  124775. get refractionTexture(): Nullable<BaseTexture>;
  124776. set refractionTexture(value: Nullable<BaseTexture>);
  124777. /**
  124778. * The color of a material in ambient lighting.
  124779. */
  124780. ambientColor: Color3;
  124781. /**
  124782. * AKA Diffuse Color in other nomenclature.
  124783. */
  124784. albedoColor: Color3;
  124785. /**
  124786. * AKA Specular Color in other nomenclature.
  124787. */
  124788. reflectivityColor: Color3;
  124789. /**
  124790. * The color reflected from the material.
  124791. */
  124792. reflectionColor: Color3;
  124793. /**
  124794. * The color emitted from the material.
  124795. */
  124796. emissiveColor: Color3;
  124797. /**
  124798. * AKA Glossiness in other nomenclature.
  124799. */
  124800. microSurface: number;
  124801. /**
  124802. * source material index of refraction (IOR)' / 'destination material IOR.
  124803. */
  124804. get indexOfRefraction(): number;
  124805. set indexOfRefraction(value: number);
  124806. /**
  124807. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124808. */
  124809. get invertRefractionY(): boolean;
  124810. set invertRefractionY(value: boolean);
  124811. /**
  124812. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124813. * Materials half opaque for instance using refraction could benefit from this control.
  124814. */
  124815. get linkRefractionWithTransparency(): boolean;
  124816. set linkRefractionWithTransparency(value: boolean);
  124817. /**
  124818. * If true, the light map contains occlusion information instead of lighting info.
  124819. */
  124820. useLightmapAsShadowmap: boolean;
  124821. /**
  124822. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124823. */
  124824. useAlphaFromAlbedoTexture: boolean;
  124825. /**
  124826. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124827. */
  124828. forceAlphaTest: boolean;
  124829. /**
  124830. * Defines the alpha limits in alpha test mode.
  124831. */
  124832. alphaCutOff: number;
  124833. /**
  124834. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124835. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124836. */
  124837. useSpecularOverAlpha: boolean;
  124838. /**
  124839. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124840. */
  124841. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124842. /**
  124843. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124844. */
  124845. useRoughnessFromMetallicTextureAlpha: boolean;
  124846. /**
  124847. * Specifies if the metallic texture contains the roughness information in its green channel.
  124848. */
  124849. useRoughnessFromMetallicTextureGreen: boolean;
  124850. /**
  124851. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124852. */
  124853. useMetallnessFromMetallicTextureBlue: boolean;
  124854. /**
  124855. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124856. */
  124857. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124858. /**
  124859. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124860. */
  124861. useAmbientInGrayScale: boolean;
  124862. /**
  124863. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124864. * The material will try to infer what glossiness each pixel should be.
  124865. */
  124866. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124867. /**
  124868. * BJS is using an harcoded light falloff based on a manually sets up range.
  124869. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124870. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124871. */
  124872. get usePhysicalLightFalloff(): boolean;
  124873. /**
  124874. * BJS is using an harcoded light falloff based on a manually sets up range.
  124875. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124876. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124877. */
  124878. set usePhysicalLightFalloff(value: boolean);
  124879. /**
  124880. * In order to support the falloff compatibility with gltf, a special mode has been added
  124881. * to reproduce the gltf light falloff.
  124882. */
  124883. get useGLTFLightFalloff(): boolean;
  124884. /**
  124885. * In order to support the falloff compatibility with gltf, a special mode has been added
  124886. * to reproduce the gltf light falloff.
  124887. */
  124888. set useGLTFLightFalloff(value: boolean);
  124889. /**
  124890. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124891. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124892. */
  124893. useRadianceOverAlpha: boolean;
  124894. /**
  124895. * Allows using an object space normal map (instead of tangent space).
  124896. */
  124897. useObjectSpaceNormalMap: boolean;
  124898. /**
  124899. * Allows using the bump map in parallax mode.
  124900. */
  124901. useParallax: boolean;
  124902. /**
  124903. * Allows using the bump map in parallax occlusion mode.
  124904. */
  124905. useParallaxOcclusion: boolean;
  124906. /**
  124907. * Controls the scale bias of the parallax mode.
  124908. */
  124909. parallaxScaleBias: number;
  124910. /**
  124911. * If sets to true, disables all the lights affecting the material.
  124912. */
  124913. disableLighting: boolean;
  124914. /**
  124915. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124916. */
  124917. forceIrradianceInFragment: boolean;
  124918. /**
  124919. * Number of Simultaneous lights allowed on the material.
  124920. */
  124921. maxSimultaneousLights: number;
  124922. /**
  124923. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124924. */
  124925. invertNormalMapX: boolean;
  124926. /**
  124927. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124928. */
  124929. invertNormalMapY: boolean;
  124930. /**
  124931. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124932. */
  124933. twoSidedLighting: boolean;
  124934. /**
  124935. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124936. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124937. */
  124938. useAlphaFresnel: boolean;
  124939. /**
  124940. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124941. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124942. */
  124943. useLinearAlphaFresnel: boolean;
  124944. /**
  124945. * Let user defines the brdf lookup texture used for IBL.
  124946. * A default 8bit version is embedded but you could point at :
  124947. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124948. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124949. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124950. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124951. */
  124952. environmentBRDFTexture: Nullable<BaseTexture>;
  124953. /**
  124954. * Force normal to face away from face.
  124955. */
  124956. forceNormalForward: boolean;
  124957. /**
  124958. * Enables specular anti aliasing in the PBR shader.
  124959. * It will both interacts on the Geometry for analytical and IBL lighting.
  124960. * It also prefilter the roughness map based on the bump values.
  124961. */
  124962. enableSpecularAntiAliasing: boolean;
  124963. /**
  124964. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124965. * makes the reflect vector face the model (under horizon).
  124966. */
  124967. useHorizonOcclusion: boolean;
  124968. /**
  124969. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124970. * too much the area relying on ambient texture to define their ambient occlusion.
  124971. */
  124972. useRadianceOcclusion: boolean;
  124973. /**
  124974. * If set to true, no lighting calculations will be applied.
  124975. */
  124976. unlit: boolean;
  124977. /**
  124978. * Gets the image processing configuration used either in this material.
  124979. */
  124980. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124981. /**
  124982. * Sets the Default image processing configuration used either in the this material.
  124983. *
  124984. * If sets to null, the scene one is in use.
  124985. */
  124986. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124987. /**
  124988. * Gets wether the color curves effect is enabled.
  124989. */
  124990. get cameraColorCurvesEnabled(): boolean;
  124991. /**
  124992. * Sets wether the color curves effect is enabled.
  124993. */
  124994. set cameraColorCurvesEnabled(value: boolean);
  124995. /**
  124996. * Gets wether the color grading effect is enabled.
  124997. */
  124998. get cameraColorGradingEnabled(): boolean;
  124999. /**
  125000. * Gets wether the color grading effect is enabled.
  125001. */
  125002. set cameraColorGradingEnabled(value: boolean);
  125003. /**
  125004. * Gets wether tonemapping is enabled or not.
  125005. */
  125006. get cameraToneMappingEnabled(): boolean;
  125007. /**
  125008. * Sets wether tonemapping is enabled or not
  125009. */
  125010. set cameraToneMappingEnabled(value: boolean);
  125011. /**
  125012. * The camera exposure used on this material.
  125013. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125014. * This corresponds to a photographic exposure.
  125015. */
  125016. get cameraExposure(): number;
  125017. /**
  125018. * The camera exposure used on this material.
  125019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125020. * This corresponds to a photographic exposure.
  125021. */
  125022. set cameraExposure(value: number);
  125023. /**
  125024. * Gets The camera contrast used on this material.
  125025. */
  125026. get cameraContrast(): number;
  125027. /**
  125028. * Sets The camera contrast used on this material.
  125029. */
  125030. set cameraContrast(value: number);
  125031. /**
  125032. * Gets the Color Grading 2D Lookup Texture.
  125033. */
  125034. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125035. /**
  125036. * Sets the Color Grading 2D Lookup Texture.
  125037. */
  125038. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125039. /**
  125040. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125041. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125042. * 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;
  125043. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125044. */
  125045. get cameraColorCurves(): Nullable<ColorCurves>;
  125046. /**
  125047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125049. * 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;
  125050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125051. */
  125052. set cameraColorCurves(value: Nullable<ColorCurves>);
  125053. /**
  125054. * Instantiates a new PBRMaterial instance.
  125055. *
  125056. * @param name The material name
  125057. * @param scene The scene the material will be use in.
  125058. */
  125059. constructor(name: string, scene: Scene);
  125060. /**
  125061. * Returns the name of this material class.
  125062. */
  125063. getClassName(): string;
  125064. /**
  125065. * Makes a duplicate of the current material.
  125066. * @param name - name to use for the new material.
  125067. */
  125068. clone(name: string): PBRMaterial;
  125069. /**
  125070. * Serializes this PBR Material.
  125071. * @returns - An object with the serialized material.
  125072. */
  125073. serialize(): any;
  125074. /**
  125075. * Parses a PBR Material from a serialized object.
  125076. * @param source - Serialized object.
  125077. * @param scene - BJS scene instance.
  125078. * @param rootUrl - url for the scene object
  125079. * @returns - PBRMaterial
  125080. */
  125081. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125082. }
  125083. }
  125084. declare module BABYLON {
  125085. /**
  125086. * Direct draw surface info
  125087. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125088. */
  125089. export interface DDSInfo {
  125090. /**
  125091. * Width of the texture
  125092. */
  125093. width: number;
  125094. /**
  125095. * Width of the texture
  125096. */
  125097. height: number;
  125098. /**
  125099. * Number of Mipmaps for the texture
  125100. * @see https://en.wikipedia.org/wiki/Mipmap
  125101. */
  125102. mipmapCount: number;
  125103. /**
  125104. * If the textures format is a known fourCC format
  125105. * @see https://www.fourcc.org/
  125106. */
  125107. isFourCC: boolean;
  125108. /**
  125109. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125110. */
  125111. isRGB: boolean;
  125112. /**
  125113. * If the texture is a lumincance format
  125114. */
  125115. isLuminance: boolean;
  125116. /**
  125117. * If this is a cube texture
  125118. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125119. */
  125120. isCube: boolean;
  125121. /**
  125122. * If the texture is a compressed format eg. FOURCC_DXT1
  125123. */
  125124. isCompressed: boolean;
  125125. /**
  125126. * The dxgiFormat of the texture
  125127. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125128. */
  125129. dxgiFormat: number;
  125130. /**
  125131. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125132. */
  125133. textureType: number;
  125134. /**
  125135. * Sphericle polynomial created for the dds texture
  125136. */
  125137. sphericalPolynomial?: SphericalPolynomial;
  125138. }
  125139. /**
  125140. * Class used to provide DDS decompression tools
  125141. */
  125142. export class DDSTools {
  125143. /**
  125144. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125145. */
  125146. static StoreLODInAlphaChannel: boolean;
  125147. /**
  125148. * Gets DDS information from an array buffer
  125149. * @param data defines the array buffer view to read data from
  125150. * @returns the DDS information
  125151. */
  125152. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125153. private static _FloatView;
  125154. private static _Int32View;
  125155. private static _ToHalfFloat;
  125156. private static _FromHalfFloat;
  125157. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125158. private static _GetHalfFloatRGBAArrayBuffer;
  125159. private static _GetFloatRGBAArrayBuffer;
  125160. private static _GetFloatAsUIntRGBAArrayBuffer;
  125161. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125162. private static _GetRGBAArrayBuffer;
  125163. private static _ExtractLongWordOrder;
  125164. private static _GetRGBArrayBuffer;
  125165. private static _GetLuminanceArrayBuffer;
  125166. /**
  125167. * Uploads DDS Levels to a Babylon Texture
  125168. * @hidden
  125169. */
  125170. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125171. }
  125172. interface ThinEngine {
  125173. /**
  125174. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125175. * @param rootUrl defines the url where the file to load is located
  125176. * @param scene defines the current scene
  125177. * @param lodScale defines scale to apply to the mip map selection
  125178. * @param lodOffset defines offset to apply to the mip map selection
  125179. * @param onLoad defines an optional callback raised when the texture is loaded
  125180. * @param onError defines an optional callback raised if there is an issue to load the texture
  125181. * @param format defines the format of the data
  125182. * @param forcedExtension defines the extension to use to pick the right loader
  125183. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125184. * @returns the cube texture as an InternalTexture
  125185. */
  125186. 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;
  125187. }
  125188. }
  125189. declare module BABYLON {
  125190. /**
  125191. * Implementation of the DDS Texture Loader.
  125192. * @hidden
  125193. */
  125194. export class _DDSTextureLoader implements IInternalTextureLoader {
  125195. /**
  125196. * Defines wether the loader supports cascade loading the different faces.
  125197. */
  125198. readonly supportCascades: boolean;
  125199. /**
  125200. * This returns if the loader support the current file information.
  125201. * @param extension defines the file extension of the file being loaded
  125202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125203. * @param fallback defines the fallback internal texture if any
  125204. * @param isBase64 defines whether the texture is encoded as a base64
  125205. * @param isBuffer defines whether the texture data are stored as a buffer
  125206. * @returns true if the loader can load the specified file
  125207. */
  125208. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125209. /**
  125210. * Transform the url before loading if required.
  125211. * @param rootUrl the url of the texture
  125212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125213. * @returns the transformed texture
  125214. */
  125215. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125216. /**
  125217. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125218. * @param rootUrl the url of the texture
  125219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125220. * @returns the fallback texture
  125221. */
  125222. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125223. /**
  125224. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125225. * @param data contains the texture data
  125226. * @param texture defines the BabylonJS internal texture
  125227. * @param createPolynomials will be true if polynomials have been requested
  125228. * @param onLoad defines the callback to trigger once the texture is ready
  125229. * @param onError defines the callback to trigger in case of error
  125230. */
  125231. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125232. /**
  125233. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125234. * @param data contains the texture data
  125235. * @param texture defines the BabylonJS internal texture
  125236. * @param callback defines the method to call once ready to upload
  125237. */
  125238. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125239. }
  125240. }
  125241. declare module BABYLON {
  125242. /**
  125243. * Implementation of the ENV Texture Loader.
  125244. * @hidden
  125245. */
  125246. export class _ENVTextureLoader implements IInternalTextureLoader {
  125247. /**
  125248. * Defines wether the loader supports cascade loading the different faces.
  125249. */
  125250. readonly supportCascades: boolean;
  125251. /**
  125252. * This returns if the loader support the current file information.
  125253. * @param extension defines the file extension of the file being loaded
  125254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125255. * @param fallback defines the fallback internal texture if any
  125256. * @param isBase64 defines whether the texture is encoded as a base64
  125257. * @param isBuffer defines whether the texture data are stored as a buffer
  125258. * @returns true if the loader can load the specified file
  125259. */
  125260. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125261. /**
  125262. * Transform the url before loading if required.
  125263. * @param rootUrl the url of the texture
  125264. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125265. * @returns the transformed texture
  125266. */
  125267. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125268. /**
  125269. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125270. * @param rootUrl the url of the texture
  125271. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125272. * @returns the fallback texture
  125273. */
  125274. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125275. /**
  125276. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125277. * @param data contains the texture data
  125278. * @param texture defines the BabylonJS internal texture
  125279. * @param createPolynomials will be true if polynomials have been requested
  125280. * @param onLoad defines the callback to trigger once the texture is ready
  125281. * @param onError defines the callback to trigger in case of error
  125282. */
  125283. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125284. /**
  125285. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125286. * @param data contains the texture data
  125287. * @param texture defines the BabylonJS internal texture
  125288. * @param callback defines the method to call once ready to upload
  125289. */
  125290. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125291. }
  125292. }
  125293. declare module BABYLON {
  125294. /**
  125295. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125296. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125297. */
  125298. export class KhronosTextureContainer {
  125299. /** contents of the KTX container file */
  125300. data: ArrayBufferView;
  125301. private static HEADER_LEN;
  125302. private static COMPRESSED_2D;
  125303. private static COMPRESSED_3D;
  125304. private static TEX_2D;
  125305. private static TEX_3D;
  125306. /**
  125307. * Gets the openGL type
  125308. */
  125309. glType: number;
  125310. /**
  125311. * Gets the openGL type size
  125312. */
  125313. glTypeSize: number;
  125314. /**
  125315. * Gets the openGL format
  125316. */
  125317. glFormat: number;
  125318. /**
  125319. * Gets the openGL internal format
  125320. */
  125321. glInternalFormat: number;
  125322. /**
  125323. * Gets the base internal format
  125324. */
  125325. glBaseInternalFormat: number;
  125326. /**
  125327. * Gets image width in pixel
  125328. */
  125329. pixelWidth: number;
  125330. /**
  125331. * Gets image height in pixel
  125332. */
  125333. pixelHeight: number;
  125334. /**
  125335. * Gets image depth in pixels
  125336. */
  125337. pixelDepth: number;
  125338. /**
  125339. * Gets the number of array elements
  125340. */
  125341. numberOfArrayElements: number;
  125342. /**
  125343. * Gets the number of faces
  125344. */
  125345. numberOfFaces: number;
  125346. /**
  125347. * Gets the number of mipmap levels
  125348. */
  125349. numberOfMipmapLevels: number;
  125350. /**
  125351. * Gets the bytes of key value data
  125352. */
  125353. bytesOfKeyValueData: number;
  125354. /**
  125355. * Gets the load type
  125356. */
  125357. loadType: number;
  125358. /**
  125359. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125360. */
  125361. isInvalid: boolean;
  125362. /**
  125363. * Creates a new KhronosTextureContainer
  125364. * @param data contents of the KTX container file
  125365. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125366. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125367. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125368. */
  125369. constructor(
  125370. /** contents of the KTX container file */
  125371. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125372. /**
  125373. * Uploads KTX content to a Babylon Texture.
  125374. * It is assumed that the texture has already been created & is currently bound
  125375. * @hidden
  125376. */
  125377. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125378. private _upload2DCompressedLevels;
  125379. }
  125380. }
  125381. declare module BABYLON {
  125382. /**
  125383. * Implementation of the KTX Texture Loader.
  125384. * @hidden
  125385. */
  125386. export class _KTXTextureLoader implements IInternalTextureLoader {
  125387. /**
  125388. * Defines wether the loader supports cascade loading the different faces.
  125389. */
  125390. readonly supportCascades: boolean;
  125391. /**
  125392. * This returns if the loader support the current file information.
  125393. * @param extension defines the file extension of the file being loaded
  125394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125395. * @param fallback defines the fallback internal texture if any
  125396. * @param isBase64 defines whether the texture is encoded as a base64
  125397. * @param isBuffer defines whether the texture data are stored as a buffer
  125398. * @returns true if the loader can load the specified file
  125399. */
  125400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125401. /**
  125402. * Transform the url before loading if required.
  125403. * @param rootUrl the url of the texture
  125404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125405. * @returns the transformed texture
  125406. */
  125407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125408. /**
  125409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125410. * @param rootUrl the url of the texture
  125411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125412. * @returns the fallback texture
  125413. */
  125414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125415. /**
  125416. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125417. * @param data contains the texture data
  125418. * @param texture defines the BabylonJS internal texture
  125419. * @param createPolynomials will be true if polynomials have been requested
  125420. * @param onLoad defines the callback to trigger once the texture is ready
  125421. * @param onError defines the callback to trigger in case of error
  125422. */
  125423. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125424. /**
  125425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125426. * @param data contains the texture data
  125427. * @param texture defines the BabylonJS internal texture
  125428. * @param callback defines the method to call once ready to upload
  125429. */
  125430. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125431. }
  125432. }
  125433. declare module BABYLON {
  125434. /** @hidden */
  125435. export var _forceSceneHelpersToBundle: boolean;
  125436. interface Scene {
  125437. /**
  125438. * Creates a default light for the scene.
  125439. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125440. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125441. */
  125442. createDefaultLight(replace?: boolean): void;
  125443. /**
  125444. * Creates a default camera for the scene.
  125445. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125446. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125447. * @param replace has default false, when true replaces the active camera in the scene
  125448. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125449. */
  125450. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125451. /**
  125452. * Creates a default camera and a default light.
  125453. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125454. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125455. * @param replace has the default false, when true replaces the active camera/light in the scene
  125456. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125457. */
  125458. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125459. /**
  125460. * Creates a new sky box
  125461. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125462. * @param environmentTexture defines the texture to use as environment texture
  125463. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125464. * @param scale defines the overall scale of the skybox
  125465. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125466. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125467. * @returns a new mesh holding the sky box
  125468. */
  125469. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125470. /**
  125471. * Creates a new environment
  125472. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125473. * @param options defines the options you can use to configure the environment
  125474. * @returns the new EnvironmentHelper
  125475. */
  125476. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125477. /**
  125478. * Creates a new VREXperienceHelper
  125479. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125480. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125481. * @returns a new VREXperienceHelper
  125482. */
  125483. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125484. /**
  125485. * Creates a new WebXRDefaultExperience
  125486. * @see http://doc.babylonjs.com/how_to/webxr
  125487. * @param options experience options
  125488. * @returns a promise for a new WebXRDefaultExperience
  125489. */
  125490. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125491. }
  125492. }
  125493. declare module BABYLON {
  125494. /**
  125495. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125496. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125497. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125498. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125499. */
  125500. export class VideoDome extends TransformNode {
  125501. /**
  125502. * Define the video source as a Monoscopic panoramic 360 video.
  125503. */
  125504. static readonly MODE_MONOSCOPIC: number;
  125505. /**
  125506. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125507. */
  125508. static readonly MODE_TOPBOTTOM: number;
  125509. /**
  125510. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125511. */
  125512. static readonly MODE_SIDEBYSIDE: number;
  125513. private _halfDome;
  125514. private _useDirectMapping;
  125515. /**
  125516. * The video texture being displayed on the sphere
  125517. */
  125518. protected _videoTexture: VideoTexture;
  125519. /**
  125520. * Gets the video texture being displayed on the sphere
  125521. */
  125522. get videoTexture(): VideoTexture;
  125523. /**
  125524. * The skybox material
  125525. */
  125526. protected _material: BackgroundMaterial;
  125527. /**
  125528. * The surface used for the skybox
  125529. */
  125530. protected _mesh: Mesh;
  125531. /**
  125532. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125533. */
  125534. private _halfDomeMask;
  125535. /**
  125536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125537. * Also see the options.resolution property.
  125538. */
  125539. get fovMultiplier(): number;
  125540. set fovMultiplier(value: number);
  125541. private _videoMode;
  125542. /**
  125543. * Gets or set the current video mode for the video. It can be:
  125544. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125545. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125546. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125547. */
  125548. get videoMode(): number;
  125549. set videoMode(value: number);
  125550. /**
  125551. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125552. *
  125553. */
  125554. get halfDome(): boolean;
  125555. /**
  125556. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125557. */
  125558. set halfDome(enabled: boolean);
  125559. /**
  125560. * Oberserver used in Stereoscopic VR Mode.
  125561. */
  125562. private _onBeforeCameraRenderObserver;
  125563. /**
  125564. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125565. * @param name Element's name, child elements will append suffixes for their own names.
  125566. * @param urlsOrVideo defines the url(s) or the video element to use
  125567. * @param options An object containing optional or exposed sub element properties
  125568. */
  125569. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125570. resolution?: number;
  125571. clickToPlay?: boolean;
  125572. autoPlay?: boolean;
  125573. loop?: boolean;
  125574. size?: number;
  125575. poster?: string;
  125576. faceForward?: boolean;
  125577. useDirectMapping?: boolean;
  125578. halfDomeMode?: boolean;
  125579. }, scene: Scene);
  125580. private _changeVideoMode;
  125581. /**
  125582. * Releases resources associated with this node.
  125583. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125584. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125585. */
  125586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125587. }
  125588. }
  125589. declare module BABYLON {
  125590. /**
  125591. * This class can be used to get instrumentation data from a Babylon engine
  125592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125593. */
  125594. export class EngineInstrumentation implements IDisposable {
  125595. /**
  125596. * Define the instrumented engine.
  125597. */
  125598. engine: Engine;
  125599. private _captureGPUFrameTime;
  125600. private _gpuFrameTimeToken;
  125601. private _gpuFrameTime;
  125602. private _captureShaderCompilationTime;
  125603. private _shaderCompilationTime;
  125604. private _onBeginFrameObserver;
  125605. private _onEndFrameObserver;
  125606. private _onBeforeShaderCompilationObserver;
  125607. private _onAfterShaderCompilationObserver;
  125608. /**
  125609. * Gets the perf counter used for GPU frame time
  125610. */
  125611. get gpuFrameTimeCounter(): PerfCounter;
  125612. /**
  125613. * Gets the GPU frame time capture status
  125614. */
  125615. get captureGPUFrameTime(): boolean;
  125616. /**
  125617. * Enable or disable the GPU frame time capture
  125618. */
  125619. set captureGPUFrameTime(value: boolean);
  125620. /**
  125621. * Gets the perf counter used for shader compilation time
  125622. */
  125623. get shaderCompilationTimeCounter(): PerfCounter;
  125624. /**
  125625. * Gets the shader compilation time capture status
  125626. */
  125627. get captureShaderCompilationTime(): boolean;
  125628. /**
  125629. * Enable or disable the shader compilation time capture
  125630. */
  125631. set captureShaderCompilationTime(value: boolean);
  125632. /**
  125633. * Instantiates a new engine instrumentation.
  125634. * This class can be used to get instrumentation data from a Babylon engine
  125635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125636. * @param engine Defines the engine to instrument
  125637. */
  125638. constructor(
  125639. /**
  125640. * Define the instrumented engine.
  125641. */
  125642. engine: Engine);
  125643. /**
  125644. * Dispose and release associated resources.
  125645. */
  125646. dispose(): void;
  125647. }
  125648. }
  125649. declare module BABYLON {
  125650. /**
  125651. * This class can be used to get instrumentation data from a Babylon engine
  125652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125653. */
  125654. export class SceneInstrumentation implements IDisposable {
  125655. /**
  125656. * Defines the scene to instrument
  125657. */
  125658. scene: Scene;
  125659. private _captureActiveMeshesEvaluationTime;
  125660. private _activeMeshesEvaluationTime;
  125661. private _captureRenderTargetsRenderTime;
  125662. private _renderTargetsRenderTime;
  125663. private _captureFrameTime;
  125664. private _frameTime;
  125665. private _captureRenderTime;
  125666. private _renderTime;
  125667. private _captureInterFrameTime;
  125668. private _interFrameTime;
  125669. private _captureParticlesRenderTime;
  125670. private _particlesRenderTime;
  125671. private _captureSpritesRenderTime;
  125672. private _spritesRenderTime;
  125673. private _capturePhysicsTime;
  125674. private _physicsTime;
  125675. private _captureAnimationsTime;
  125676. private _animationsTime;
  125677. private _captureCameraRenderTime;
  125678. private _cameraRenderTime;
  125679. private _onBeforeActiveMeshesEvaluationObserver;
  125680. private _onAfterActiveMeshesEvaluationObserver;
  125681. private _onBeforeRenderTargetsRenderObserver;
  125682. private _onAfterRenderTargetsRenderObserver;
  125683. private _onAfterRenderObserver;
  125684. private _onBeforeDrawPhaseObserver;
  125685. private _onAfterDrawPhaseObserver;
  125686. private _onBeforeAnimationsObserver;
  125687. private _onBeforeParticlesRenderingObserver;
  125688. private _onAfterParticlesRenderingObserver;
  125689. private _onBeforeSpritesRenderingObserver;
  125690. private _onAfterSpritesRenderingObserver;
  125691. private _onBeforePhysicsObserver;
  125692. private _onAfterPhysicsObserver;
  125693. private _onAfterAnimationsObserver;
  125694. private _onBeforeCameraRenderObserver;
  125695. private _onAfterCameraRenderObserver;
  125696. /**
  125697. * Gets the perf counter used for active meshes evaluation time
  125698. */
  125699. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125700. /**
  125701. * Gets the active meshes evaluation time capture status
  125702. */
  125703. get captureActiveMeshesEvaluationTime(): boolean;
  125704. /**
  125705. * Enable or disable the active meshes evaluation time capture
  125706. */
  125707. set captureActiveMeshesEvaluationTime(value: boolean);
  125708. /**
  125709. * Gets the perf counter used for render targets render time
  125710. */
  125711. get renderTargetsRenderTimeCounter(): PerfCounter;
  125712. /**
  125713. * Gets the render targets render time capture status
  125714. */
  125715. get captureRenderTargetsRenderTime(): boolean;
  125716. /**
  125717. * Enable or disable the render targets render time capture
  125718. */
  125719. set captureRenderTargetsRenderTime(value: boolean);
  125720. /**
  125721. * Gets the perf counter used for particles render time
  125722. */
  125723. get particlesRenderTimeCounter(): PerfCounter;
  125724. /**
  125725. * Gets the particles render time capture status
  125726. */
  125727. get captureParticlesRenderTime(): boolean;
  125728. /**
  125729. * Enable or disable the particles render time capture
  125730. */
  125731. set captureParticlesRenderTime(value: boolean);
  125732. /**
  125733. * Gets the perf counter used for sprites render time
  125734. */
  125735. get spritesRenderTimeCounter(): PerfCounter;
  125736. /**
  125737. * Gets the sprites render time capture status
  125738. */
  125739. get captureSpritesRenderTime(): boolean;
  125740. /**
  125741. * Enable or disable the sprites render time capture
  125742. */
  125743. set captureSpritesRenderTime(value: boolean);
  125744. /**
  125745. * Gets the perf counter used for physics time
  125746. */
  125747. get physicsTimeCounter(): PerfCounter;
  125748. /**
  125749. * Gets the physics time capture status
  125750. */
  125751. get capturePhysicsTime(): boolean;
  125752. /**
  125753. * Enable or disable the physics time capture
  125754. */
  125755. set capturePhysicsTime(value: boolean);
  125756. /**
  125757. * Gets the perf counter used for animations time
  125758. */
  125759. get animationsTimeCounter(): PerfCounter;
  125760. /**
  125761. * Gets the animations time capture status
  125762. */
  125763. get captureAnimationsTime(): boolean;
  125764. /**
  125765. * Enable or disable the animations time capture
  125766. */
  125767. set captureAnimationsTime(value: boolean);
  125768. /**
  125769. * Gets the perf counter used for frame time capture
  125770. */
  125771. get frameTimeCounter(): PerfCounter;
  125772. /**
  125773. * Gets the frame time capture status
  125774. */
  125775. get captureFrameTime(): boolean;
  125776. /**
  125777. * Enable or disable the frame time capture
  125778. */
  125779. set captureFrameTime(value: boolean);
  125780. /**
  125781. * Gets the perf counter used for inter-frames time capture
  125782. */
  125783. get interFrameTimeCounter(): PerfCounter;
  125784. /**
  125785. * Gets the inter-frames time capture status
  125786. */
  125787. get captureInterFrameTime(): boolean;
  125788. /**
  125789. * Enable or disable the inter-frames time capture
  125790. */
  125791. set captureInterFrameTime(value: boolean);
  125792. /**
  125793. * Gets the perf counter used for render time capture
  125794. */
  125795. get renderTimeCounter(): PerfCounter;
  125796. /**
  125797. * Gets the render time capture status
  125798. */
  125799. get captureRenderTime(): boolean;
  125800. /**
  125801. * Enable or disable the render time capture
  125802. */
  125803. set captureRenderTime(value: boolean);
  125804. /**
  125805. * Gets the perf counter used for camera render time capture
  125806. */
  125807. get cameraRenderTimeCounter(): PerfCounter;
  125808. /**
  125809. * Gets the camera render time capture status
  125810. */
  125811. get captureCameraRenderTime(): boolean;
  125812. /**
  125813. * Enable or disable the camera render time capture
  125814. */
  125815. set captureCameraRenderTime(value: boolean);
  125816. /**
  125817. * Gets the perf counter used for draw calls
  125818. */
  125819. get drawCallsCounter(): PerfCounter;
  125820. /**
  125821. * Instantiates a new scene instrumentation.
  125822. * This class can be used to get instrumentation data from a Babylon engine
  125823. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125824. * @param scene Defines the scene to instrument
  125825. */
  125826. constructor(
  125827. /**
  125828. * Defines the scene to instrument
  125829. */
  125830. scene: Scene);
  125831. /**
  125832. * Dispose and release associated resources.
  125833. */
  125834. dispose(): void;
  125835. }
  125836. }
  125837. declare module BABYLON {
  125838. /** @hidden */
  125839. export var glowMapGenerationPixelShader: {
  125840. name: string;
  125841. shader: string;
  125842. };
  125843. }
  125844. declare module BABYLON {
  125845. /** @hidden */
  125846. export var glowMapGenerationVertexShader: {
  125847. name: string;
  125848. shader: string;
  125849. };
  125850. }
  125851. declare module BABYLON {
  125852. /**
  125853. * Effect layer options. This helps customizing the behaviour
  125854. * of the effect layer.
  125855. */
  125856. export interface IEffectLayerOptions {
  125857. /**
  125858. * Multiplication factor apply to the canvas size to compute the render target size
  125859. * used to generated the objects (the smaller the faster).
  125860. */
  125861. mainTextureRatio: number;
  125862. /**
  125863. * Enforces a fixed size texture to ensure effect stability across devices.
  125864. */
  125865. mainTextureFixedSize?: number;
  125866. /**
  125867. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125868. */
  125869. alphaBlendingMode: number;
  125870. /**
  125871. * The camera attached to the layer.
  125872. */
  125873. camera: Nullable<Camera>;
  125874. /**
  125875. * The rendering group to draw the layer in.
  125876. */
  125877. renderingGroupId: number;
  125878. }
  125879. /**
  125880. * The effect layer Helps adding post process effect blended with the main pass.
  125881. *
  125882. * This can be for instance use to generate glow or higlight effects on the scene.
  125883. *
  125884. * The effect layer class can not be used directly and is intented to inherited from to be
  125885. * customized per effects.
  125886. */
  125887. export abstract class EffectLayer {
  125888. private _vertexBuffers;
  125889. private _indexBuffer;
  125890. private _cachedDefines;
  125891. private _effectLayerMapGenerationEffect;
  125892. private _effectLayerOptions;
  125893. private _mergeEffect;
  125894. protected _scene: Scene;
  125895. protected _engine: Engine;
  125896. protected _maxSize: number;
  125897. protected _mainTextureDesiredSize: ISize;
  125898. protected _mainTexture: RenderTargetTexture;
  125899. protected _shouldRender: boolean;
  125900. protected _postProcesses: PostProcess[];
  125901. protected _textures: BaseTexture[];
  125902. protected _emissiveTextureAndColor: {
  125903. texture: Nullable<BaseTexture>;
  125904. color: Color4;
  125905. };
  125906. /**
  125907. * The name of the layer
  125908. */
  125909. name: string;
  125910. /**
  125911. * The clear color of the texture used to generate the glow map.
  125912. */
  125913. neutralColor: Color4;
  125914. /**
  125915. * Specifies whether the highlight layer is enabled or not.
  125916. */
  125917. isEnabled: boolean;
  125918. /**
  125919. * Gets the camera attached to the layer.
  125920. */
  125921. get camera(): Nullable<Camera>;
  125922. /**
  125923. * Gets the rendering group id the layer should render in.
  125924. */
  125925. get renderingGroupId(): number;
  125926. set renderingGroupId(renderingGroupId: number);
  125927. /**
  125928. * An event triggered when the effect layer has been disposed.
  125929. */
  125930. onDisposeObservable: Observable<EffectLayer>;
  125931. /**
  125932. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125933. */
  125934. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125935. /**
  125936. * An event triggered when the generated texture is being merged in the scene.
  125937. */
  125938. onBeforeComposeObservable: Observable<EffectLayer>;
  125939. /**
  125940. * An event triggered when the mesh is rendered into the effect render target.
  125941. */
  125942. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125943. /**
  125944. * An event triggered after the mesh has been rendered into the effect render target.
  125945. */
  125946. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125947. /**
  125948. * An event triggered when the generated texture has been merged in the scene.
  125949. */
  125950. onAfterComposeObservable: Observable<EffectLayer>;
  125951. /**
  125952. * An event triggered when the efffect layer changes its size.
  125953. */
  125954. onSizeChangedObservable: Observable<EffectLayer>;
  125955. /** @hidden */
  125956. static _SceneComponentInitialization: (scene: Scene) => void;
  125957. /**
  125958. * Instantiates a new effect Layer and references it in the scene.
  125959. * @param name The name of the layer
  125960. * @param scene The scene to use the layer in
  125961. */
  125962. constructor(
  125963. /** The Friendly of the effect in the scene */
  125964. name: string, scene: Scene);
  125965. /**
  125966. * Get the effect name of the layer.
  125967. * @return The effect name
  125968. */
  125969. abstract getEffectName(): string;
  125970. /**
  125971. * Checks for the readiness of the element composing the layer.
  125972. * @param subMesh the mesh to check for
  125973. * @param useInstances specify whether or not to use instances to render the mesh
  125974. * @return true if ready otherwise, false
  125975. */
  125976. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125977. /**
  125978. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125979. * @returns true if the effect requires stencil during the main canvas render pass.
  125980. */
  125981. abstract needStencil(): boolean;
  125982. /**
  125983. * Create the merge effect. This is the shader use to blit the information back
  125984. * to the main canvas at the end of the scene rendering.
  125985. * @returns The effect containing the shader used to merge the effect on the main canvas
  125986. */
  125987. protected abstract _createMergeEffect(): Effect;
  125988. /**
  125989. * Creates the render target textures and post processes used in the effect layer.
  125990. */
  125991. protected abstract _createTextureAndPostProcesses(): void;
  125992. /**
  125993. * Implementation specific of rendering the generating effect on the main canvas.
  125994. * @param effect The effect used to render through
  125995. */
  125996. protected abstract _internalRender(effect: Effect): void;
  125997. /**
  125998. * Sets the required values for both the emissive texture and and the main color.
  125999. */
  126000. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126001. /**
  126002. * Free any resources and references associated to a mesh.
  126003. * Internal use
  126004. * @param mesh The mesh to free.
  126005. */
  126006. abstract _disposeMesh(mesh: Mesh): void;
  126007. /**
  126008. * Serializes this layer (Glow or Highlight for example)
  126009. * @returns a serialized layer object
  126010. */
  126011. abstract serialize?(): any;
  126012. /**
  126013. * Initializes the effect layer with the required options.
  126014. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126015. */
  126016. protected _init(options: Partial<IEffectLayerOptions>): void;
  126017. /**
  126018. * Generates the index buffer of the full screen quad blending to the main canvas.
  126019. */
  126020. private _generateIndexBuffer;
  126021. /**
  126022. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126023. */
  126024. private _generateVertexBuffer;
  126025. /**
  126026. * Sets the main texture desired size which is the closest power of two
  126027. * of the engine canvas size.
  126028. */
  126029. private _setMainTextureSize;
  126030. /**
  126031. * Creates the main texture for the effect layer.
  126032. */
  126033. protected _createMainTexture(): void;
  126034. /**
  126035. * Adds specific effects defines.
  126036. * @param defines The defines to add specifics to.
  126037. */
  126038. protected _addCustomEffectDefines(defines: string[]): void;
  126039. /**
  126040. * Checks for the readiness of the element composing the layer.
  126041. * @param subMesh the mesh to check for
  126042. * @param useInstances specify whether or not to use instances to render the mesh
  126043. * @param emissiveTexture the associated emissive texture used to generate the glow
  126044. * @return true if ready otherwise, false
  126045. */
  126046. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126047. /**
  126048. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126049. */
  126050. render(): void;
  126051. /**
  126052. * Determine if a given mesh will be used in the current effect.
  126053. * @param mesh mesh to test
  126054. * @returns true if the mesh will be used
  126055. */
  126056. hasMesh(mesh: AbstractMesh): boolean;
  126057. /**
  126058. * Returns true if the layer contains information to display, otherwise false.
  126059. * @returns true if the glow layer should be rendered
  126060. */
  126061. shouldRender(): boolean;
  126062. /**
  126063. * Returns true if the mesh should render, otherwise false.
  126064. * @param mesh The mesh to render
  126065. * @returns true if it should render otherwise false
  126066. */
  126067. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126068. /**
  126069. * Returns true if the mesh can be rendered, otherwise false.
  126070. * @param mesh The mesh to render
  126071. * @param material The material used on the mesh
  126072. * @returns true if it can be rendered otherwise false
  126073. */
  126074. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126075. /**
  126076. * Returns true if the mesh should render, otherwise false.
  126077. * @param mesh The mesh to render
  126078. * @returns true if it should render otherwise false
  126079. */
  126080. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126081. /**
  126082. * Renders the submesh passed in parameter to the generation map.
  126083. */
  126084. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126085. /**
  126086. * Defines whether the current material of the mesh should be use to render the effect.
  126087. * @param mesh defines the current mesh to render
  126088. */
  126089. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126090. /**
  126091. * Rebuild the required buffers.
  126092. * @hidden Internal use only.
  126093. */
  126094. _rebuild(): void;
  126095. /**
  126096. * Dispose only the render target textures and post process.
  126097. */
  126098. private _disposeTextureAndPostProcesses;
  126099. /**
  126100. * Dispose the highlight layer and free resources.
  126101. */
  126102. dispose(): void;
  126103. /**
  126104. * Gets the class name of the effect layer
  126105. * @returns the string with the class name of the effect layer
  126106. */
  126107. getClassName(): string;
  126108. /**
  126109. * Creates an effect layer from parsed effect layer data
  126110. * @param parsedEffectLayer defines effect layer data
  126111. * @param scene defines the current scene
  126112. * @param rootUrl defines the root URL containing the effect layer information
  126113. * @returns a parsed effect Layer
  126114. */
  126115. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126116. }
  126117. }
  126118. declare module BABYLON {
  126119. interface AbstractScene {
  126120. /**
  126121. * The list of effect layers (highlights/glow) added to the scene
  126122. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126123. * @see http://doc.babylonjs.com/how_to/glow_layer
  126124. */
  126125. effectLayers: Array<EffectLayer>;
  126126. /**
  126127. * Removes the given effect layer from this scene.
  126128. * @param toRemove defines the effect layer to remove
  126129. * @returns the index of the removed effect layer
  126130. */
  126131. removeEffectLayer(toRemove: EffectLayer): number;
  126132. /**
  126133. * Adds the given effect layer to this scene
  126134. * @param newEffectLayer defines the effect layer to add
  126135. */
  126136. addEffectLayer(newEffectLayer: EffectLayer): void;
  126137. }
  126138. /**
  126139. * Defines the layer scene component responsible to manage any effect layers
  126140. * in a given scene.
  126141. */
  126142. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126143. /**
  126144. * The component name helpfull to identify the component in the list of scene components.
  126145. */
  126146. readonly name: string;
  126147. /**
  126148. * The scene the component belongs to.
  126149. */
  126150. scene: Scene;
  126151. private _engine;
  126152. private _renderEffects;
  126153. private _needStencil;
  126154. private _previousStencilState;
  126155. /**
  126156. * Creates a new instance of the component for the given scene
  126157. * @param scene Defines the scene to register the component in
  126158. */
  126159. constructor(scene: Scene);
  126160. /**
  126161. * Registers the component in a given scene
  126162. */
  126163. register(): void;
  126164. /**
  126165. * Rebuilds the elements related to this component in case of
  126166. * context lost for instance.
  126167. */
  126168. rebuild(): void;
  126169. /**
  126170. * Serializes the component data to the specified json object
  126171. * @param serializationObject The object to serialize to
  126172. */
  126173. serialize(serializationObject: any): void;
  126174. /**
  126175. * Adds all the elements from the container to the scene
  126176. * @param container the container holding the elements
  126177. */
  126178. addFromContainer(container: AbstractScene): void;
  126179. /**
  126180. * Removes all the elements in the container from the scene
  126181. * @param container contains the elements to remove
  126182. * @param dispose if the removed element should be disposed (default: false)
  126183. */
  126184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126185. /**
  126186. * Disposes the component and the associated ressources.
  126187. */
  126188. dispose(): void;
  126189. private _isReadyForMesh;
  126190. private _renderMainTexture;
  126191. private _setStencil;
  126192. private _setStencilBack;
  126193. private _draw;
  126194. private _drawCamera;
  126195. private _drawRenderingGroup;
  126196. }
  126197. }
  126198. declare module BABYLON {
  126199. /** @hidden */
  126200. export var glowMapMergePixelShader: {
  126201. name: string;
  126202. shader: string;
  126203. };
  126204. }
  126205. declare module BABYLON {
  126206. /** @hidden */
  126207. export var glowMapMergeVertexShader: {
  126208. name: string;
  126209. shader: string;
  126210. };
  126211. }
  126212. declare module BABYLON {
  126213. interface AbstractScene {
  126214. /**
  126215. * Return a the first highlight layer of the scene with a given name.
  126216. * @param name The name of the highlight layer to look for.
  126217. * @return The highlight layer if found otherwise null.
  126218. */
  126219. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126220. }
  126221. /**
  126222. * Glow layer options. This helps customizing the behaviour
  126223. * of the glow layer.
  126224. */
  126225. export interface IGlowLayerOptions {
  126226. /**
  126227. * Multiplication factor apply to the canvas size to compute the render target size
  126228. * used to generated the glowing objects (the smaller the faster).
  126229. */
  126230. mainTextureRatio: number;
  126231. /**
  126232. * Enforces a fixed size texture to ensure resize independant blur.
  126233. */
  126234. mainTextureFixedSize?: number;
  126235. /**
  126236. * How big is the kernel of the blur texture.
  126237. */
  126238. blurKernelSize: number;
  126239. /**
  126240. * The camera attached to the layer.
  126241. */
  126242. camera: Nullable<Camera>;
  126243. /**
  126244. * Enable MSAA by chosing the number of samples.
  126245. */
  126246. mainTextureSamples?: number;
  126247. /**
  126248. * The rendering group to draw the layer in.
  126249. */
  126250. renderingGroupId: number;
  126251. }
  126252. /**
  126253. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126254. *
  126255. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126256. *
  126257. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126258. */
  126259. export class GlowLayer extends EffectLayer {
  126260. /**
  126261. * Effect Name of the layer.
  126262. */
  126263. static readonly EffectName: string;
  126264. /**
  126265. * The default blur kernel size used for the glow.
  126266. */
  126267. static DefaultBlurKernelSize: number;
  126268. /**
  126269. * The default texture size ratio used for the glow.
  126270. */
  126271. static DefaultTextureRatio: number;
  126272. /**
  126273. * Sets the kernel size of the blur.
  126274. */
  126275. set blurKernelSize(value: number);
  126276. /**
  126277. * Gets the kernel size of the blur.
  126278. */
  126279. get blurKernelSize(): number;
  126280. /**
  126281. * Sets the glow intensity.
  126282. */
  126283. set intensity(value: number);
  126284. /**
  126285. * Gets the glow intensity.
  126286. */
  126287. get intensity(): number;
  126288. private _options;
  126289. private _intensity;
  126290. private _horizontalBlurPostprocess1;
  126291. private _verticalBlurPostprocess1;
  126292. private _horizontalBlurPostprocess2;
  126293. private _verticalBlurPostprocess2;
  126294. private _blurTexture1;
  126295. private _blurTexture2;
  126296. private _postProcesses1;
  126297. private _postProcesses2;
  126298. private _includedOnlyMeshes;
  126299. private _excludedMeshes;
  126300. private _meshesUsingTheirOwnMaterials;
  126301. /**
  126302. * Callback used to let the user override the color selection on a per mesh basis
  126303. */
  126304. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126305. /**
  126306. * Callback used to let the user override the texture selection on a per mesh basis
  126307. */
  126308. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126309. /**
  126310. * Instantiates a new glow Layer and references it to the scene.
  126311. * @param name The name of the layer
  126312. * @param scene The scene to use the layer in
  126313. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126314. */
  126315. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126316. /**
  126317. * Get the effect name of the layer.
  126318. * @return The effect name
  126319. */
  126320. getEffectName(): string;
  126321. /**
  126322. * Create the merge effect. This is the shader use to blit the information back
  126323. * to the main canvas at the end of the scene rendering.
  126324. */
  126325. protected _createMergeEffect(): Effect;
  126326. /**
  126327. * Creates the render target textures and post processes used in the glow layer.
  126328. */
  126329. protected _createTextureAndPostProcesses(): void;
  126330. /**
  126331. * Checks for the readiness of the element composing the layer.
  126332. * @param subMesh the mesh to check for
  126333. * @param useInstances specify wether or not to use instances to render the mesh
  126334. * @param emissiveTexture the associated emissive texture used to generate the glow
  126335. * @return true if ready otherwise, false
  126336. */
  126337. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126338. /**
  126339. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126340. */
  126341. needStencil(): boolean;
  126342. /**
  126343. * Returns true if the mesh can be rendered, otherwise false.
  126344. * @param mesh The mesh to render
  126345. * @param material The material used on the mesh
  126346. * @returns true if it can be rendered otherwise false
  126347. */
  126348. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126349. /**
  126350. * Implementation specific of rendering the generating effect on the main canvas.
  126351. * @param effect The effect used to render through
  126352. */
  126353. protected _internalRender(effect: Effect): void;
  126354. /**
  126355. * Sets the required values for both the emissive texture and and the main color.
  126356. */
  126357. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126358. /**
  126359. * Returns true if the mesh should render, otherwise false.
  126360. * @param mesh The mesh to render
  126361. * @returns true if it should render otherwise false
  126362. */
  126363. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126364. /**
  126365. * Adds specific effects defines.
  126366. * @param defines The defines to add specifics to.
  126367. */
  126368. protected _addCustomEffectDefines(defines: string[]): void;
  126369. /**
  126370. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126371. * @param mesh The mesh to exclude from the glow layer
  126372. */
  126373. addExcludedMesh(mesh: Mesh): void;
  126374. /**
  126375. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126376. * @param mesh The mesh to remove
  126377. */
  126378. removeExcludedMesh(mesh: Mesh): void;
  126379. /**
  126380. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126381. * @param mesh The mesh to include in the glow layer
  126382. */
  126383. addIncludedOnlyMesh(mesh: Mesh): void;
  126384. /**
  126385. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126386. * @param mesh The mesh to remove
  126387. */
  126388. removeIncludedOnlyMesh(mesh: Mesh): void;
  126389. /**
  126390. * Determine if a given mesh will be used in the glow layer
  126391. * @param mesh The mesh to test
  126392. * @returns true if the mesh will be highlighted by the current glow layer
  126393. */
  126394. hasMesh(mesh: AbstractMesh): boolean;
  126395. /**
  126396. * Defines whether the current material of the mesh should be use to render the effect.
  126397. * @param mesh defines the current mesh to render
  126398. */
  126399. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126400. /**
  126401. * Add a mesh to be rendered through its own material and not with emissive only.
  126402. * @param mesh The mesh for which we need to use its material
  126403. */
  126404. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126405. /**
  126406. * Remove a mesh from being rendered through its own material and not with emissive only.
  126407. * @param mesh The mesh for which we need to not use its material
  126408. */
  126409. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126410. /**
  126411. * Free any resources and references associated to a mesh.
  126412. * Internal use
  126413. * @param mesh The mesh to free.
  126414. * @hidden
  126415. */
  126416. _disposeMesh(mesh: Mesh): void;
  126417. /**
  126418. * Gets the class name of the effect layer
  126419. * @returns the string with the class name of the effect layer
  126420. */
  126421. getClassName(): string;
  126422. /**
  126423. * Serializes this glow layer
  126424. * @returns a serialized glow layer object
  126425. */
  126426. serialize(): any;
  126427. /**
  126428. * Creates a Glow Layer from parsed glow layer data
  126429. * @param parsedGlowLayer defines glow layer data
  126430. * @param scene defines the current scene
  126431. * @param rootUrl defines the root URL containing the glow layer information
  126432. * @returns a parsed Glow Layer
  126433. */
  126434. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126435. }
  126436. }
  126437. declare module BABYLON {
  126438. /** @hidden */
  126439. export var glowBlurPostProcessPixelShader: {
  126440. name: string;
  126441. shader: string;
  126442. };
  126443. }
  126444. declare module BABYLON {
  126445. interface AbstractScene {
  126446. /**
  126447. * Return a the first highlight layer of the scene with a given name.
  126448. * @param name The name of the highlight layer to look for.
  126449. * @return The highlight layer if found otherwise null.
  126450. */
  126451. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126452. }
  126453. /**
  126454. * Highlight layer options. This helps customizing the behaviour
  126455. * of the highlight layer.
  126456. */
  126457. export interface IHighlightLayerOptions {
  126458. /**
  126459. * Multiplication factor apply to the canvas size to compute the render target size
  126460. * used to generated the glowing objects (the smaller the faster).
  126461. */
  126462. mainTextureRatio: number;
  126463. /**
  126464. * Enforces a fixed size texture to ensure resize independant blur.
  126465. */
  126466. mainTextureFixedSize?: number;
  126467. /**
  126468. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126469. * of the picture to blur (the smaller the faster).
  126470. */
  126471. blurTextureSizeRatio: number;
  126472. /**
  126473. * How big in texel of the blur texture is the vertical blur.
  126474. */
  126475. blurVerticalSize: number;
  126476. /**
  126477. * How big in texel of the blur texture is the horizontal blur.
  126478. */
  126479. blurHorizontalSize: number;
  126480. /**
  126481. * Alpha blending mode used to apply the blur. Default is combine.
  126482. */
  126483. alphaBlendingMode: number;
  126484. /**
  126485. * The camera attached to the layer.
  126486. */
  126487. camera: Nullable<Camera>;
  126488. /**
  126489. * Should we display highlight as a solid stroke?
  126490. */
  126491. isStroke?: boolean;
  126492. /**
  126493. * The rendering group to draw the layer in.
  126494. */
  126495. renderingGroupId: number;
  126496. }
  126497. /**
  126498. * The highlight layer Helps adding a glow effect around a mesh.
  126499. *
  126500. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126501. * glowy meshes to your scene.
  126502. *
  126503. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126504. */
  126505. export class HighlightLayer extends EffectLayer {
  126506. name: string;
  126507. /**
  126508. * Effect Name of the highlight layer.
  126509. */
  126510. static readonly EffectName: string;
  126511. /**
  126512. * The neutral color used during the preparation of the glow effect.
  126513. * This is black by default as the blend operation is a blend operation.
  126514. */
  126515. static NeutralColor: Color4;
  126516. /**
  126517. * Stencil value used for glowing meshes.
  126518. */
  126519. static GlowingMeshStencilReference: number;
  126520. /**
  126521. * Stencil value used for the other meshes in the scene.
  126522. */
  126523. static NormalMeshStencilReference: number;
  126524. /**
  126525. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126526. */
  126527. innerGlow: boolean;
  126528. /**
  126529. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126530. */
  126531. outerGlow: boolean;
  126532. /**
  126533. * Specifies the horizontal size of the blur.
  126534. */
  126535. set blurHorizontalSize(value: number);
  126536. /**
  126537. * Specifies the vertical size of the blur.
  126538. */
  126539. set blurVerticalSize(value: number);
  126540. /**
  126541. * Gets the horizontal size of the blur.
  126542. */
  126543. get blurHorizontalSize(): number;
  126544. /**
  126545. * Gets the vertical size of the blur.
  126546. */
  126547. get blurVerticalSize(): number;
  126548. /**
  126549. * An event triggered when the highlight layer is being blurred.
  126550. */
  126551. onBeforeBlurObservable: Observable<HighlightLayer>;
  126552. /**
  126553. * An event triggered when the highlight layer has been blurred.
  126554. */
  126555. onAfterBlurObservable: Observable<HighlightLayer>;
  126556. private _instanceGlowingMeshStencilReference;
  126557. private _options;
  126558. private _downSamplePostprocess;
  126559. private _horizontalBlurPostprocess;
  126560. private _verticalBlurPostprocess;
  126561. private _blurTexture;
  126562. private _meshes;
  126563. private _excludedMeshes;
  126564. /**
  126565. * Instantiates a new highlight Layer and references it to the scene..
  126566. * @param name The name of the layer
  126567. * @param scene The scene to use the layer in
  126568. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126569. */
  126570. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126571. /**
  126572. * Get the effect name of the layer.
  126573. * @return The effect name
  126574. */
  126575. getEffectName(): string;
  126576. /**
  126577. * Create the merge effect. This is the shader use to blit the information back
  126578. * to the main canvas at the end of the scene rendering.
  126579. */
  126580. protected _createMergeEffect(): Effect;
  126581. /**
  126582. * Creates the render target textures and post processes used in the highlight layer.
  126583. */
  126584. protected _createTextureAndPostProcesses(): void;
  126585. /**
  126586. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126587. */
  126588. needStencil(): boolean;
  126589. /**
  126590. * Checks for the readiness of the element composing the layer.
  126591. * @param subMesh the mesh to check for
  126592. * @param useInstances specify wether or not to use instances to render the mesh
  126593. * @param emissiveTexture the associated emissive texture used to generate the glow
  126594. * @return true if ready otherwise, false
  126595. */
  126596. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126597. /**
  126598. * Implementation specific of rendering the generating effect on the main canvas.
  126599. * @param effect The effect used to render through
  126600. */
  126601. protected _internalRender(effect: Effect): void;
  126602. /**
  126603. * Returns true if the layer contains information to display, otherwise false.
  126604. */
  126605. shouldRender(): boolean;
  126606. /**
  126607. * Returns true if the mesh should render, otherwise false.
  126608. * @param mesh The mesh to render
  126609. * @returns true if it should render otherwise false
  126610. */
  126611. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126612. /**
  126613. * Sets the required values for both the emissive texture and and the main color.
  126614. */
  126615. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126616. /**
  126617. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126618. * @param mesh The mesh to exclude from the highlight layer
  126619. */
  126620. addExcludedMesh(mesh: Mesh): void;
  126621. /**
  126622. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126623. * @param mesh The mesh to highlight
  126624. */
  126625. removeExcludedMesh(mesh: Mesh): void;
  126626. /**
  126627. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126628. * @param mesh mesh to test
  126629. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126630. */
  126631. hasMesh(mesh: AbstractMesh): boolean;
  126632. /**
  126633. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126634. * @param mesh The mesh to highlight
  126635. * @param color The color of the highlight
  126636. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126637. */
  126638. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126639. /**
  126640. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126641. * @param mesh The mesh to highlight
  126642. */
  126643. removeMesh(mesh: Mesh): void;
  126644. /**
  126645. * Force the stencil to the normal expected value for none glowing parts
  126646. */
  126647. private _defaultStencilReference;
  126648. /**
  126649. * Free any resources and references associated to a mesh.
  126650. * Internal use
  126651. * @param mesh The mesh to free.
  126652. * @hidden
  126653. */
  126654. _disposeMesh(mesh: Mesh): void;
  126655. /**
  126656. * Dispose the highlight layer and free resources.
  126657. */
  126658. dispose(): void;
  126659. /**
  126660. * Gets the class name of the effect layer
  126661. * @returns the string with the class name of the effect layer
  126662. */
  126663. getClassName(): string;
  126664. /**
  126665. * Serializes this Highlight layer
  126666. * @returns a serialized Highlight layer object
  126667. */
  126668. serialize(): any;
  126669. /**
  126670. * Creates a Highlight layer from parsed Highlight layer data
  126671. * @param parsedHightlightLayer defines the Highlight layer data
  126672. * @param scene defines the current scene
  126673. * @param rootUrl defines the root URL containing the Highlight layer information
  126674. * @returns a parsed Highlight layer
  126675. */
  126676. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126677. }
  126678. }
  126679. declare module BABYLON {
  126680. interface AbstractScene {
  126681. /**
  126682. * The list of layers (background and foreground) of the scene
  126683. */
  126684. layers: Array<Layer>;
  126685. }
  126686. /**
  126687. * Defines the layer scene component responsible to manage any layers
  126688. * in a given scene.
  126689. */
  126690. export class LayerSceneComponent implements ISceneComponent {
  126691. /**
  126692. * The component name helpfull to identify the component in the list of scene components.
  126693. */
  126694. readonly name: string;
  126695. /**
  126696. * The scene the component belongs to.
  126697. */
  126698. scene: Scene;
  126699. private _engine;
  126700. /**
  126701. * Creates a new instance of the component for the given scene
  126702. * @param scene Defines the scene to register the component in
  126703. */
  126704. constructor(scene: Scene);
  126705. /**
  126706. * Registers the component in a given scene
  126707. */
  126708. register(): void;
  126709. /**
  126710. * Rebuilds the elements related to this component in case of
  126711. * context lost for instance.
  126712. */
  126713. rebuild(): void;
  126714. /**
  126715. * Disposes the component and the associated ressources.
  126716. */
  126717. dispose(): void;
  126718. private _draw;
  126719. private _drawCameraPredicate;
  126720. private _drawCameraBackground;
  126721. private _drawCameraForeground;
  126722. private _drawRenderTargetPredicate;
  126723. private _drawRenderTargetBackground;
  126724. private _drawRenderTargetForeground;
  126725. /**
  126726. * Adds all the elements from the container to the scene
  126727. * @param container the container holding the elements
  126728. */
  126729. addFromContainer(container: AbstractScene): void;
  126730. /**
  126731. * Removes all the elements in the container from the scene
  126732. * @param container contains the elements to remove
  126733. * @param dispose if the removed element should be disposed (default: false)
  126734. */
  126735. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126736. }
  126737. }
  126738. declare module BABYLON {
  126739. /** @hidden */
  126740. export var layerPixelShader: {
  126741. name: string;
  126742. shader: string;
  126743. };
  126744. }
  126745. declare module BABYLON {
  126746. /** @hidden */
  126747. export var layerVertexShader: {
  126748. name: string;
  126749. shader: string;
  126750. };
  126751. }
  126752. declare module BABYLON {
  126753. /**
  126754. * This represents a full screen 2d layer.
  126755. * This can be useful to display a picture in the background of your scene for instance.
  126756. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126757. */
  126758. export class Layer {
  126759. /**
  126760. * Define the name of the layer.
  126761. */
  126762. name: string;
  126763. /**
  126764. * Define the texture the layer should display.
  126765. */
  126766. texture: Nullable<Texture>;
  126767. /**
  126768. * Is the layer in background or foreground.
  126769. */
  126770. isBackground: boolean;
  126771. /**
  126772. * Define the color of the layer (instead of texture).
  126773. */
  126774. color: Color4;
  126775. /**
  126776. * Define the scale of the layer in order to zoom in out of the texture.
  126777. */
  126778. scale: Vector2;
  126779. /**
  126780. * Define an offset for the layer in order to shift the texture.
  126781. */
  126782. offset: Vector2;
  126783. /**
  126784. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126785. */
  126786. alphaBlendingMode: number;
  126787. /**
  126788. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126789. * Alpha test will not mix with the background color in case of transparency.
  126790. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126791. */
  126792. alphaTest: boolean;
  126793. /**
  126794. * Define a mask to restrict the layer to only some of the scene cameras.
  126795. */
  126796. layerMask: number;
  126797. /**
  126798. * Define the list of render target the layer is visible into.
  126799. */
  126800. renderTargetTextures: RenderTargetTexture[];
  126801. /**
  126802. * Define if the layer is only used in renderTarget or if it also
  126803. * renders in the main frame buffer of the canvas.
  126804. */
  126805. renderOnlyInRenderTargetTextures: boolean;
  126806. private _scene;
  126807. private _vertexBuffers;
  126808. private _indexBuffer;
  126809. private _effect;
  126810. private _previousDefines;
  126811. /**
  126812. * An event triggered when the layer is disposed.
  126813. */
  126814. onDisposeObservable: Observable<Layer>;
  126815. private _onDisposeObserver;
  126816. /**
  126817. * Back compatibility with callback before the onDisposeObservable existed.
  126818. * The set callback will be triggered when the layer has been disposed.
  126819. */
  126820. set onDispose(callback: () => void);
  126821. /**
  126822. * An event triggered before rendering the scene
  126823. */
  126824. onBeforeRenderObservable: Observable<Layer>;
  126825. private _onBeforeRenderObserver;
  126826. /**
  126827. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126828. * The set callback will be triggered just before rendering the layer.
  126829. */
  126830. set onBeforeRender(callback: () => void);
  126831. /**
  126832. * An event triggered after rendering the scene
  126833. */
  126834. onAfterRenderObservable: Observable<Layer>;
  126835. private _onAfterRenderObserver;
  126836. /**
  126837. * Back compatibility with callback before the onAfterRenderObservable existed.
  126838. * The set callback will be triggered just after rendering the layer.
  126839. */
  126840. set onAfterRender(callback: () => void);
  126841. /**
  126842. * Instantiates a new layer.
  126843. * This represents a full screen 2d layer.
  126844. * This can be useful to display a picture in the background of your scene for instance.
  126845. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126846. * @param name Define the name of the layer in the scene
  126847. * @param imgUrl Define the url of the texture to display in the layer
  126848. * @param scene Define the scene the layer belongs to
  126849. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126850. * @param color Defines a color for the layer
  126851. */
  126852. constructor(
  126853. /**
  126854. * Define the name of the layer.
  126855. */
  126856. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126857. private _createIndexBuffer;
  126858. /** @hidden */
  126859. _rebuild(): void;
  126860. /**
  126861. * Renders the layer in the scene.
  126862. */
  126863. render(): void;
  126864. /**
  126865. * Disposes and releases the associated ressources.
  126866. */
  126867. dispose(): void;
  126868. }
  126869. }
  126870. declare module BABYLON {
  126871. /** @hidden */
  126872. export var lensFlarePixelShader: {
  126873. name: string;
  126874. shader: string;
  126875. };
  126876. }
  126877. declare module BABYLON {
  126878. /** @hidden */
  126879. export var lensFlareVertexShader: {
  126880. name: string;
  126881. shader: string;
  126882. };
  126883. }
  126884. declare module BABYLON {
  126885. /**
  126886. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126887. * It is usually composed of several `lensFlare`.
  126888. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126889. */
  126890. export class LensFlareSystem {
  126891. /**
  126892. * Define the name of the lens flare system
  126893. */
  126894. name: string;
  126895. /**
  126896. * List of lens flares used in this system.
  126897. */
  126898. lensFlares: LensFlare[];
  126899. /**
  126900. * Define a limit from the border the lens flare can be visible.
  126901. */
  126902. borderLimit: number;
  126903. /**
  126904. * Define a viewport border we do not want to see the lens flare in.
  126905. */
  126906. viewportBorder: number;
  126907. /**
  126908. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126909. */
  126910. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126911. /**
  126912. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126913. */
  126914. layerMask: number;
  126915. /**
  126916. * Define the id of the lens flare system in the scene.
  126917. * (equal to name by default)
  126918. */
  126919. id: string;
  126920. private _scene;
  126921. private _emitter;
  126922. private _vertexBuffers;
  126923. private _indexBuffer;
  126924. private _effect;
  126925. private _positionX;
  126926. private _positionY;
  126927. private _isEnabled;
  126928. /** @hidden */
  126929. static _SceneComponentInitialization: (scene: Scene) => void;
  126930. /**
  126931. * Instantiates a lens flare system.
  126932. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126933. * It is usually composed of several `lensFlare`.
  126934. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126935. * @param name Define the name of the lens flare system in the scene
  126936. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126937. * @param scene Define the scene the lens flare system belongs to
  126938. */
  126939. constructor(
  126940. /**
  126941. * Define the name of the lens flare system
  126942. */
  126943. name: string, emitter: any, scene: Scene);
  126944. /**
  126945. * Define if the lens flare system is enabled.
  126946. */
  126947. get isEnabled(): boolean;
  126948. set isEnabled(value: boolean);
  126949. /**
  126950. * Get the scene the effects belongs to.
  126951. * @returns the scene holding the lens flare system
  126952. */
  126953. getScene(): Scene;
  126954. /**
  126955. * Get the emitter of the lens flare system.
  126956. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126957. * @returns the emitter of the lens flare system
  126958. */
  126959. getEmitter(): any;
  126960. /**
  126961. * Set the emitter of the lens flare system.
  126962. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126963. * @param newEmitter Define the new emitter of the system
  126964. */
  126965. setEmitter(newEmitter: any): void;
  126966. /**
  126967. * Get the lens flare system emitter position.
  126968. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126969. * @returns the position
  126970. */
  126971. getEmitterPosition(): Vector3;
  126972. /**
  126973. * @hidden
  126974. */
  126975. computeEffectivePosition(globalViewport: Viewport): boolean;
  126976. /** @hidden */
  126977. _isVisible(): boolean;
  126978. /**
  126979. * @hidden
  126980. */
  126981. render(): boolean;
  126982. /**
  126983. * Dispose and release the lens flare with its associated resources.
  126984. */
  126985. dispose(): void;
  126986. /**
  126987. * Parse a lens flare system from a JSON repressentation
  126988. * @param parsedLensFlareSystem Define the JSON to parse
  126989. * @param scene Define the scene the parsed system should be instantiated in
  126990. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126991. * @returns the parsed system
  126992. */
  126993. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126994. /**
  126995. * Serialize the current Lens Flare System into a JSON representation.
  126996. * @returns the serialized JSON
  126997. */
  126998. serialize(): any;
  126999. }
  127000. }
  127001. declare module BABYLON {
  127002. /**
  127003. * This represents one of the lens effect in a `lensFlareSystem`.
  127004. * It controls one of the indiviual texture used in the effect.
  127005. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127006. */
  127007. export class LensFlare {
  127008. /**
  127009. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127010. */
  127011. size: number;
  127012. /**
  127013. * 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.
  127014. */
  127015. position: number;
  127016. /**
  127017. * Define the lens color.
  127018. */
  127019. color: Color3;
  127020. /**
  127021. * Define the lens texture.
  127022. */
  127023. texture: Nullable<Texture>;
  127024. /**
  127025. * Define the alpha mode to render this particular lens.
  127026. */
  127027. alphaMode: number;
  127028. private _system;
  127029. /**
  127030. * Creates a new Lens Flare.
  127031. * This represents one of the lens effect in a `lensFlareSystem`.
  127032. * It controls one of the indiviual texture used in the effect.
  127033. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127034. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127035. * @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.
  127036. * @param color Define the lens color
  127037. * @param imgUrl Define the lens texture url
  127038. * @param system Define the `lensFlareSystem` this flare is part of
  127039. * @returns The newly created Lens Flare
  127040. */
  127041. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127042. /**
  127043. * Instantiates a new Lens Flare.
  127044. * This represents one of the lens effect in a `lensFlareSystem`.
  127045. * It controls one of the indiviual texture used in the effect.
  127046. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127047. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127048. * @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.
  127049. * @param color Define the lens color
  127050. * @param imgUrl Define the lens texture url
  127051. * @param system Define the `lensFlareSystem` this flare is part of
  127052. */
  127053. constructor(
  127054. /**
  127055. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127056. */
  127057. size: number,
  127058. /**
  127059. * 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.
  127060. */
  127061. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127062. /**
  127063. * Dispose and release the lens flare with its associated resources.
  127064. */
  127065. dispose(): void;
  127066. }
  127067. }
  127068. declare module BABYLON {
  127069. interface AbstractScene {
  127070. /**
  127071. * The list of lens flare system added to the scene
  127072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127073. */
  127074. lensFlareSystems: Array<LensFlareSystem>;
  127075. /**
  127076. * Removes the given lens flare system from this scene.
  127077. * @param toRemove The lens flare system to remove
  127078. * @returns The index of the removed lens flare system
  127079. */
  127080. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127081. /**
  127082. * Adds the given lens flare system to this scene
  127083. * @param newLensFlareSystem The lens flare system to add
  127084. */
  127085. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127086. /**
  127087. * Gets a lens flare system using its name
  127088. * @param name defines the name to look for
  127089. * @returns the lens flare system or null if not found
  127090. */
  127091. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127092. /**
  127093. * Gets a lens flare system using its id
  127094. * @param id defines the id to look for
  127095. * @returns the lens flare system or null if not found
  127096. */
  127097. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127098. }
  127099. /**
  127100. * Defines the lens flare scene component responsible to manage any lens flares
  127101. * in a given scene.
  127102. */
  127103. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127104. /**
  127105. * The component name helpfull to identify the component in the list of scene components.
  127106. */
  127107. readonly name: string;
  127108. /**
  127109. * The scene the component belongs to.
  127110. */
  127111. scene: Scene;
  127112. /**
  127113. * Creates a new instance of the component for the given scene
  127114. * @param scene Defines the scene to register the component in
  127115. */
  127116. constructor(scene: Scene);
  127117. /**
  127118. * Registers the component in a given scene
  127119. */
  127120. register(): void;
  127121. /**
  127122. * Rebuilds the elements related to this component in case of
  127123. * context lost for instance.
  127124. */
  127125. rebuild(): void;
  127126. /**
  127127. * Adds all the elements from the container to the scene
  127128. * @param container the container holding the elements
  127129. */
  127130. addFromContainer(container: AbstractScene): void;
  127131. /**
  127132. * Removes all the elements in the container from the scene
  127133. * @param container contains the elements to remove
  127134. * @param dispose if the removed element should be disposed (default: false)
  127135. */
  127136. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127137. /**
  127138. * Serializes the component data to the specified json object
  127139. * @param serializationObject The object to serialize to
  127140. */
  127141. serialize(serializationObject: any): void;
  127142. /**
  127143. * Disposes the component and the associated ressources.
  127144. */
  127145. dispose(): void;
  127146. private _draw;
  127147. }
  127148. }
  127149. declare module BABYLON {
  127150. /** @hidden */
  127151. export var depthPixelShader: {
  127152. name: string;
  127153. shader: string;
  127154. };
  127155. }
  127156. declare module BABYLON {
  127157. /** @hidden */
  127158. export var depthVertexShader: {
  127159. name: string;
  127160. shader: string;
  127161. };
  127162. }
  127163. declare module BABYLON {
  127164. /**
  127165. * This represents a depth renderer in Babylon.
  127166. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127167. */
  127168. export class DepthRenderer {
  127169. private _scene;
  127170. private _depthMap;
  127171. private _effect;
  127172. private readonly _storeNonLinearDepth;
  127173. private readonly _clearColor;
  127174. /** Get if the depth renderer is using packed depth or not */
  127175. readonly isPacked: boolean;
  127176. private _cachedDefines;
  127177. private _camera;
  127178. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127179. enabled: boolean;
  127180. /**
  127181. * Specifiess that the depth renderer will only be used within
  127182. * the camera it is created for.
  127183. * This can help forcing its rendering during the camera processing.
  127184. */
  127185. useOnlyInActiveCamera: boolean;
  127186. /** @hidden */
  127187. static _SceneComponentInitialization: (scene: Scene) => void;
  127188. /**
  127189. * Instantiates a depth renderer
  127190. * @param scene The scene the renderer belongs to
  127191. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127192. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127193. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127194. */
  127195. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127196. /**
  127197. * Creates the depth rendering effect and checks if the effect is ready.
  127198. * @param subMesh The submesh to be used to render the depth map of
  127199. * @param useInstances If multiple world instances should be used
  127200. * @returns if the depth renderer is ready to render the depth map
  127201. */
  127202. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127203. /**
  127204. * Gets the texture which the depth map will be written to.
  127205. * @returns The depth map texture
  127206. */
  127207. getDepthMap(): RenderTargetTexture;
  127208. /**
  127209. * Disposes of the depth renderer.
  127210. */
  127211. dispose(): void;
  127212. }
  127213. }
  127214. declare module BABYLON {
  127215. /** @hidden */
  127216. export var minmaxReduxPixelShader: {
  127217. name: string;
  127218. shader: string;
  127219. };
  127220. }
  127221. declare module BABYLON {
  127222. /**
  127223. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127224. * and maximum values from all values of the texture.
  127225. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127226. * The source values are read from the red channel of the texture.
  127227. */
  127228. export class MinMaxReducer {
  127229. /**
  127230. * Observable triggered when the computation has been performed
  127231. */
  127232. onAfterReductionPerformed: Observable<{
  127233. min: number;
  127234. max: number;
  127235. }>;
  127236. protected _camera: Camera;
  127237. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127238. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127239. protected _postProcessManager: PostProcessManager;
  127240. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127241. protected _forceFullscreenViewport: boolean;
  127242. /**
  127243. * Creates a min/max reducer
  127244. * @param camera The camera to use for the post processes
  127245. */
  127246. constructor(camera: Camera);
  127247. /**
  127248. * Gets the texture used to read the values from.
  127249. */
  127250. get sourceTexture(): Nullable<RenderTargetTexture>;
  127251. /**
  127252. * Sets the source texture to read the values from.
  127253. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127254. * because in such textures '1' value must not be taken into account to compute the maximum
  127255. * as this value is used to clear the texture.
  127256. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127257. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127258. * @param depthRedux Indicates if the texture is a depth texture or not
  127259. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127260. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127261. */
  127262. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127263. /**
  127264. * Defines the refresh rate of the computation.
  127265. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127266. */
  127267. get refreshRate(): number;
  127268. set refreshRate(value: number);
  127269. protected _activated: boolean;
  127270. /**
  127271. * Gets the activation status of the reducer
  127272. */
  127273. get activated(): boolean;
  127274. /**
  127275. * Activates the reduction computation.
  127276. * When activated, the observers registered in onAfterReductionPerformed are
  127277. * called after the compuation is performed
  127278. */
  127279. activate(): void;
  127280. /**
  127281. * Deactivates the reduction computation.
  127282. */
  127283. deactivate(): void;
  127284. /**
  127285. * Disposes the min/max reducer
  127286. * @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.
  127287. */
  127288. dispose(disposeAll?: boolean): void;
  127289. }
  127290. }
  127291. declare module BABYLON {
  127292. /**
  127293. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127294. */
  127295. export class DepthReducer extends MinMaxReducer {
  127296. private _depthRenderer;
  127297. private _depthRendererId;
  127298. /**
  127299. * Gets the depth renderer used for the computation.
  127300. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127301. */
  127302. get depthRenderer(): Nullable<DepthRenderer>;
  127303. /**
  127304. * Creates a depth reducer
  127305. * @param camera The camera used to render the depth texture
  127306. */
  127307. constructor(camera: Camera);
  127308. /**
  127309. * Sets the depth renderer to use to generate the depth map
  127310. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127311. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127312. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127313. */
  127314. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127315. /** @hidden */
  127316. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127317. /**
  127318. * Activates the reduction computation.
  127319. * When activated, the observers registered in onAfterReductionPerformed are
  127320. * called after the compuation is performed
  127321. */
  127322. activate(): void;
  127323. /**
  127324. * Deactivates the reduction computation.
  127325. */
  127326. deactivate(): void;
  127327. /**
  127328. * Disposes the depth reducer
  127329. * @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.
  127330. */
  127331. dispose(disposeAll?: boolean): void;
  127332. }
  127333. }
  127334. declare module BABYLON {
  127335. /**
  127336. * A CSM implementation allowing casting shadows on large scenes.
  127337. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127338. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127339. */
  127340. export class CascadedShadowGenerator extends ShadowGenerator {
  127341. private static readonly frustumCornersNDCSpace;
  127342. /**
  127343. * Name of the CSM class
  127344. */
  127345. static CLASSNAME: string;
  127346. /**
  127347. * Defines the default number of cascades used by the CSM.
  127348. */
  127349. static readonly DEFAULT_CASCADES_COUNT: number;
  127350. /**
  127351. * Defines the minimum number of cascades used by the CSM.
  127352. */
  127353. static readonly MIN_CASCADES_COUNT: number;
  127354. /**
  127355. * Defines the maximum number of cascades used by the CSM.
  127356. */
  127357. static readonly MAX_CASCADES_COUNT: number;
  127358. protected _validateFilter(filter: number): number;
  127359. /**
  127360. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127361. */
  127362. penumbraDarkness: number;
  127363. private _numCascades;
  127364. /**
  127365. * Gets or set the number of cascades used by the CSM.
  127366. */
  127367. get numCascades(): number;
  127368. set numCascades(value: number);
  127369. /**
  127370. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127371. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127372. */
  127373. stabilizeCascades: boolean;
  127374. private _freezeShadowCastersBoundingInfo;
  127375. private _freezeShadowCastersBoundingInfoObservable;
  127376. /**
  127377. * Enables or disables the shadow casters bounding info computation.
  127378. * If your shadow casters don't move, you can disable this feature.
  127379. * If it is enabled, the bounding box computation is done every frame.
  127380. */
  127381. get freezeShadowCastersBoundingInfo(): boolean;
  127382. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127383. private _scbiMin;
  127384. private _scbiMax;
  127385. protected _computeShadowCastersBoundingInfo(): void;
  127386. protected _shadowCastersBoundingInfo: BoundingInfo;
  127387. /**
  127388. * Gets or sets the shadow casters bounding info.
  127389. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127390. * so that the system won't overwrite the bounds you provide
  127391. */
  127392. get shadowCastersBoundingInfo(): BoundingInfo;
  127393. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127394. protected _breaksAreDirty: boolean;
  127395. protected _minDistance: number;
  127396. protected _maxDistance: number;
  127397. /**
  127398. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127399. *
  127400. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127401. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127402. * @param min minimal distance for the breaks (default to 0.)
  127403. * @param max maximal distance for the breaks (default to 1.)
  127404. */
  127405. setMinMaxDistance(min: number, max: number): void;
  127406. /** Gets the minimal distance used in the cascade break computation */
  127407. get minDistance(): number;
  127408. /** Gets the maximal distance used in the cascade break computation */
  127409. get maxDistance(): number;
  127410. /**
  127411. * Gets the class name of that object
  127412. * @returns "CascadedShadowGenerator"
  127413. */
  127414. getClassName(): string;
  127415. private _cascadeMinExtents;
  127416. private _cascadeMaxExtents;
  127417. /**
  127418. * Gets a cascade minimum extents
  127419. * @param cascadeIndex index of the cascade
  127420. * @returns the minimum cascade extents
  127421. */
  127422. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127423. /**
  127424. * Gets a cascade maximum extents
  127425. * @param cascadeIndex index of the cascade
  127426. * @returns the maximum cascade extents
  127427. */
  127428. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127429. private _cascades;
  127430. private _currentLayer;
  127431. private _viewSpaceFrustumsZ;
  127432. private _viewMatrices;
  127433. private _projectionMatrices;
  127434. private _transformMatrices;
  127435. private _transformMatricesAsArray;
  127436. private _frustumLengths;
  127437. private _lightSizeUVCorrection;
  127438. private _depthCorrection;
  127439. private _frustumCornersWorldSpace;
  127440. private _frustumCenter;
  127441. private _shadowCameraPos;
  127442. private _shadowMaxZ;
  127443. /**
  127444. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127445. * It defaults to camera.maxZ
  127446. */
  127447. get shadowMaxZ(): number;
  127448. /**
  127449. * Sets the shadow max z distance.
  127450. */
  127451. set shadowMaxZ(value: number);
  127452. protected _debug: boolean;
  127453. /**
  127454. * Gets or sets the debug flag.
  127455. * When enabled, the cascades are materialized by different colors on the screen.
  127456. */
  127457. get debug(): boolean;
  127458. set debug(dbg: boolean);
  127459. private _depthClamp;
  127460. /**
  127461. * Gets or sets the depth clamping value.
  127462. *
  127463. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127464. * to account for the shadow casters far away.
  127465. *
  127466. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127467. */
  127468. get depthClamp(): boolean;
  127469. set depthClamp(value: boolean);
  127470. private _cascadeBlendPercentage;
  127471. /**
  127472. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127473. * It defaults to 0.1 (10% blending).
  127474. */
  127475. get cascadeBlendPercentage(): number;
  127476. set cascadeBlendPercentage(value: number);
  127477. private _lambda;
  127478. /**
  127479. * Gets or set the lambda parameter.
  127480. * This parameter is used to split the camera frustum and create the cascades.
  127481. * 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.
  127482. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127483. */
  127484. get lambda(): number;
  127485. set lambda(value: number);
  127486. /**
  127487. * Gets the view matrix corresponding to a given cascade
  127488. * @param cascadeNum cascade to retrieve the view matrix from
  127489. * @returns the cascade view matrix
  127490. */
  127491. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127492. /**
  127493. * Gets the projection matrix corresponding to a given cascade
  127494. * @param cascadeNum cascade to retrieve the projection matrix from
  127495. * @returns the cascade projection matrix
  127496. */
  127497. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127498. /**
  127499. * Gets the transformation matrix corresponding to a given cascade
  127500. * @param cascadeNum cascade to retrieve the transformation matrix from
  127501. * @returns the cascade transformation matrix
  127502. */
  127503. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127504. private _depthRenderer;
  127505. /**
  127506. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127507. *
  127508. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127509. *
  127510. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127511. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127512. * @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
  127513. */
  127514. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127515. private _depthReducer;
  127516. private _autoCalcDepthBounds;
  127517. /**
  127518. * Gets or sets the autoCalcDepthBounds property.
  127519. *
  127520. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127521. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127522. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127523. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127524. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127525. */
  127526. get autoCalcDepthBounds(): boolean;
  127527. set autoCalcDepthBounds(value: boolean);
  127528. /**
  127529. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127530. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127531. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127532. * for setting the refresh rate on the renderer yourself!
  127533. */
  127534. get autoCalcDepthBoundsRefreshRate(): number;
  127535. set autoCalcDepthBoundsRefreshRate(value: number);
  127536. /**
  127537. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127538. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127539. * you change the camera near/far planes!
  127540. */
  127541. splitFrustum(): void;
  127542. private _splitFrustum;
  127543. private _computeMatrices;
  127544. private _computeFrustumInWorldSpace;
  127545. private _computeCascadeFrustum;
  127546. /** @hidden */
  127547. static _SceneComponentInitialization: (scene: Scene) => void;
  127548. /**
  127549. * Creates a Cascaded Shadow Generator object.
  127550. * A ShadowGenerator is the required tool to use the shadows.
  127551. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127552. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127553. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127554. * @param light The directional light object generating the shadows.
  127555. * @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.
  127556. */
  127557. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127558. protected _initializeGenerator(): void;
  127559. protected _createTargetRenderTexture(): void;
  127560. protected _initializeShadowMap(): void;
  127561. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127562. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127563. /**
  127564. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127565. * @param defines Defines of the material we want to update
  127566. * @param lightIndex Index of the light in the enabled light list of the material
  127567. */
  127568. prepareDefines(defines: any, lightIndex: number): void;
  127569. /**
  127570. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127571. * defined in the generator but impacting the effect).
  127572. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127573. * @param effect The effect we are binfing the information for
  127574. */
  127575. bindShadowLight(lightIndex: string, effect: Effect): void;
  127576. /**
  127577. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127578. * (eq to view projection * shadow projection matrices)
  127579. * @returns The transform matrix used to create the shadow map
  127580. */
  127581. getTransformMatrix(): Matrix;
  127582. /**
  127583. * Disposes the ShadowGenerator.
  127584. * Returns nothing.
  127585. */
  127586. dispose(): void;
  127587. /**
  127588. * Serializes the shadow generator setup to a json object.
  127589. * @returns The serialized JSON object
  127590. */
  127591. serialize(): any;
  127592. /**
  127593. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127594. * @param parsedShadowGenerator The JSON object to parse
  127595. * @param scene The scene to create the shadow map for
  127596. * @returns The parsed shadow generator
  127597. */
  127598. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127599. }
  127600. }
  127601. declare module BABYLON {
  127602. /**
  127603. * Defines the shadow generator component responsible to manage any shadow generators
  127604. * in a given scene.
  127605. */
  127606. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127607. /**
  127608. * The component name helpfull to identify the component in the list of scene components.
  127609. */
  127610. readonly name: string;
  127611. /**
  127612. * The scene the component belongs to.
  127613. */
  127614. scene: Scene;
  127615. /**
  127616. * Creates a new instance of the component for the given scene
  127617. * @param scene Defines the scene to register the component in
  127618. */
  127619. constructor(scene: Scene);
  127620. /**
  127621. * Registers the component in a given scene
  127622. */
  127623. register(): void;
  127624. /**
  127625. * Rebuilds the elements related to this component in case of
  127626. * context lost for instance.
  127627. */
  127628. rebuild(): void;
  127629. /**
  127630. * Serializes the component data to the specified json object
  127631. * @param serializationObject The object to serialize to
  127632. */
  127633. serialize(serializationObject: any): void;
  127634. /**
  127635. * Adds all the elements from the container to the scene
  127636. * @param container the container holding the elements
  127637. */
  127638. addFromContainer(container: AbstractScene): void;
  127639. /**
  127640. * Removes all the elements in the container from the scene
  127641. * @param container contains the elements to remove
  127642. * @param dispose if the removed element should be disposed (default: false)
  127643. */
  127644. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127645. /**
  127646. * Rebuilds the elements related to this component in case of
  127647. * context lost for instance.
  127648. */
  127649. dispose(): void;
  127650. private _gatherRenderTargets;
  127651. }
  127652. }
  127653. declare module BABYLON {
  127654. /**
  127655. * A point light is a light defined by an unique point in world space.
  127656. * The light is emitted in every direction from this point.
  127657. * A good example of a point light is a standard light bulb.
  127658. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127659. */
  127660. export class PointLight extends ShadowLight {
  127661. private _shadowAngle;
  127662. /**
  127663. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127664. * This specifies what angle the shadow will use to be created.
  127665. *
  127666. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127667. */
  127668. get shadowAngle(): number;
  127669. /**
  127670. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127671. * This specifies what angle the shadow will use to be created.
  127672. *
  127673. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127674. */
  127675. set shadowAngle(value: number);
  127676. /**
  127677. * Gets the direction if it has been set.
  127678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127679. */
  127680. get direction(): Vector3;
  127681. /**
  127682. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127683. */
  127684. set direction(value: Vector3);
  127685. /**
  127686. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127687. * A PointLight emits the light in every direction.
  127688. * It can cast shadows.
  127689. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127690. * ```javascript
  127691. * var pointLight = new PointLight("pl", camera.position, scene);
  127692. * ```
  127693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127694. * @param name The light friendly name
  127695. * @param position The position of the point light in the scene
  127696. * @param scene The scene the lights belongs to
  127697. */
  127698. constructor(name: string, position: Vector3, scene: Scene);
  127699. /**
  127700. * Returns the string "PointLight"
  127701. * @returns the class name
  127702. */
  127703. getClassName(): string;
  127704. /**
  127705. * Returns the integer 0.
  127706. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127707. */
  127708. getTypeID(): number;
  127709. /**
  127710. * Specifies wether or not the shadowmap should be a cube texture.
  127711. * @returns true if the shadowmap needs to be a cube texture.
  127712. */
  127713. needCube(): boolean;
  127714. /**
  127715. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127716. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127717. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127718. */
  127719. getShadowDirection(faceIndex?: number): Vector3;
  127720. /**
  127721. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127722. * - fov = PI / 2
  127723. * - aspect ratio : 1.0
  127724. * - z-near and far equal to the active camera minZ and maxZ.
  127725. * Returns the PointLight.
  127726. */
  127727. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127728. protected _buildUniformLayout(): void;
  127729. /**
  127730. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127731. * @param effect The effect to update
  127732. * @param lightIndex The index of the light in the effect to update
  127733. * @returns The point light
  127734. */
  127735. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127736. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127737. /**
  127738. * Prepares the list of defines specific to the light type.
  127739. * @param defines the list of defines
  127740. * @param lightIndex defines the index of the light for the effect
  127741. */
  127742. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127743. }
  127744. }
  127745. declare module BABYLON {
  127746. /**
  127747. * Header information of HDR texture files.
  127748. */
  127749. export interface HDRInfo {
  127750. /**
  127751. * The height of the texture in pixels.
  127752. */
  127753. height: number;
  127754. /**
  127755. * The width of the texture in pixels.
  127756. */
  127757. width: number;
  127758. /**
  127759. * The index of the beginning of the data in the binary file.
  127760. */
  127761. dataPosition: number;
  127762. }
  127763. /**
  127764. * This groups tools to convert HDR texture to native colors array.
  127765. */
  127766. export class HDRTools {
  127767. private static Ldexp;
  127768. private static Rgbe2float;
  127769. private static readStringLine;
  127770. /**
  127771. * Reads header information from an RGBE texture stored in a native array.
  127772. * More information on this format are available here:
  127773. * https://en.wikipedia.org/wiki/RGBE_image_format
  127774. *
  127775. * @param uint8array The binary file stored in native array.
  127776. * @return The header information.
  127777. */
  127778. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127779. /**
  127780. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127781. * This RGBE texture needs to store the information as a panorama.
  127782. *
  127783. * More information on this format are available here:
  127784. * https://en.wikipedia.org/wiki/RGBE_image_format
  127785. *
  127786. * @param buffer The binary file stored in an array buffer.
  127787. * @param size The expected size of the extracted cubemap.
  127788. * @return The Cube Map information.
  127789. */
  127790. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127791. /**
  127792. * Returns the pixels data extracted from an RGBE texture.
  127793. * This pixels will be stored left to right up to down in the R G B order in one array.
  127794. *
  127795. * More information on this format are available here:
  127796. * https://en.wikipedia.org/wiki/RGBE_image_format
  127797. *
  127798. * @param uint8array The binary file stored in an array buffer.
  127799. * @param hdrInfo The header information of the file.
  127800. * @return The pixels data in RGB right to left up to down order.
  127801. */
  127802. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127803. private static RGBE_ReadPixels_RLE;
  127804. }
  127805. }
  127806. declare module BABYLON {
  127807. /**
  127808. * This represents a texture coming from an HDR input.
  127809. *
  127810. * The only supported format is currently panorama picture stored in RGBE format.
  127811. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127812. */
  127813. export class HDRCubeTexture extends BaseTexture {
  127814. private static _facesMapping;
  127815. private _generateHarmonics;
  127816. private _noMipmap;
  127817. private _textureMatrix;
  127818. private _size;
  127819. private _onLoad;
  127820. private _onError;
  127821. /**
  127822. * The texture URL.
  127823. */
  127824. url: string;
  127825. /**
  127826. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127827. */
  127828. coordinatesMode: number;
  127829. protected _isBlocking: boolean;
  127830. /**
  127831. * Sets wether or not the texture is blocking during loading.
  127832. */
  127833. set isBlocking(value: boolean);
  127834. /**
  127835. * Gets wether or not the texture is blocking during loading.
  127836. */
  127837. get isBlocking(): boolean;
  127838. protected _rotationY: number;
  127839. /**
  127840. * Sets texture matrix rotation angle around Y axis in radians.
  127841. */
  127842. set rotationY(value: number);
  127843. /**
  127844. * Gets texture matrix rotation angle around Y axis radians.
  127845. */
  127846. get rotationY(): number;
  127847. /**
  127848. * Gets or sets the center of the bounding box associated with the cube texture
  127849. * It must define where the camera used to render the texture was set
  127850. */
  127851. boundingBoxPosition: Vector3;
  127852. private _boundingBoxSize;
  127853. /**
  127854. * Gets or sets the size of the bounding box associated with the cube texture
  127855. * When defined, the cubemap will switch to local mode
  127856. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127857. * @example https://www.babylonjs-playground.com/#RNASML
  127858. */
  127859. set boundingBoxSize(value: Vector3);
  127860. get boundingBoxSize(): Vector3;
  127861. /**
  127862. * Instantiates an HDRTexture from the following parameters.
  127863. *
  127864. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127865. * @param scene The scene the texture will be used in
  127866. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127867. * @param noMipmap Forces to not generate the mipmap if true
  127868. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127869. * @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)
  127870. * @param reserved Reserved flag for internal use.
  127871. */
  127872. 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>);
  127873. /**
  127874. * Get the current class name of the texture useful for serialization or dynamic coding.
  127875. * @returns "HDRCubeTexture"
  127876. */
  127877. getClassName(): string;
  127878. /**
  127879. * Occurs when the file is raw .hdr file.
  127880. */
  127881. private loadTexture;
  127882. clone(): HDRCubeTexture;
  127883. delayLoad(): void;
  127884. /**
  127885. * Get the texture reflection matrix used to rotate/transform the reflection.
  127886. * @returns the reflection matrix
  127887. */
  127888. getReflectionTextureMatrix(): Matrix;
  127889. /**
  127890. * Set the texture reflection matrix used to rotate/transform the reflection.
  127891. * @param value Define the reflection matrix to set
  127892. */
  127893. setReflectionTextureMatrix(value: Matrix): void;
  127894. /**
  127895. * Parses a JSON representation of an HDR Texture in order to create the texture
  127896. * @param parsedTexture Define the JSON representation
  127897. * @param scene Define the scene the texture should be created in
  127898. * @param rootUrl Define the root url in case we need to load relative dependencies
  127899. * @returns the newly created texture after parsing
  127900. */
  127901. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127902. serialize(): any;
  127903. }
  127904. }
  127905. declare module BABYLON {
  127906. /**
  127907. * Class used to control physics engine
  127908. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127909. */
  127910. export class PhysicsEngine implements IPhysicsEngine {
  127911. private _physicsPlugin;
  127912. /**
  127913. * Global value used to control the smallest number supported by the simulation
  127914. */
  127915. static Epsilon: number;
  127916. private _impostors;
  127917. private _joints;
  127918. private _subTimeStep;
  127919. /**
  127920. * Gets the gravity vector used by the simulation
  127921. */
  127922. gravity: Vector3;
  127923. /**
  127924. * Factory used to create the default physics plugin.
  127925. * @returns The default physics plugin
  127926. */
  127927. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127928. /**
  127929. * Creates a new Physics Engine
  127930. * @param gravity defines the gravity vector used by the simulation
  127931. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127932. */
  127933. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127934. /**
  127935. * Sets the gravity vector used by the simulation
  127936. * @param gravity defines the gravity vector to use
  127937. */
  127938. setGravity(gravity: Vector3): void;
  127939. /**
  127940. * Set the time step of the physics engine.
  127941. * Default is 1/60.
  127942. * To slow it down, enter 1/600 for example.
  127943. * To speed it up, 1/30
  127944. * @param newTimeStep defines the new timestep to apply to this world.
  127945. */
  127946. setTimeStep(newTimeStep?: number): void;
  127947. /**
  127948. * Get the time step of the physics engine.
  127949. * @returns the current time step
  127950. */
  127951. getTimeStep(): number;
  127952. /**
  127953. * Set the sub time step of the physics engine.
  127954. * Default is 0 meaning there is no sub steps
  127955. * To increase physics resolution precision, set a small value (like 1 ms)
  127956. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127957. */
  127958. setSubTimeStep(subTimeStep?: number): void;
  127959. /**
  127960. * Get the sub time step of the physics engine.
  127961. * @returns the current sub time step
  127962. */
  127963. getSubTimeStep(): number;
  127964. /**
  127965. * Release all resources
  127966. */
  127967. dispose(): void;
  127968. /**
  127969. * Gets the name of the current physics plugin
  127970. * @returns the name of the plugin
  127971. */
  127972. getPhysicsPluginName(): string;
  127973. /**
  127974. * Adding a new impostor for the impostor tracking.
  127975. * This will be done by the impostor itself.
  127976. * @param impostor the impostor to add
  127977. */
  127978. addImpostor(impostor: PhysicsImpostor): void;
  127979. /**
  127980. * Remove an impostor from the engine.
  127981. * This impostor and its mesh will not longer be updated by the physics engine.
  127982. * @param impostor the impostor to remove
  127983. */
  127984. removeImpostor(impostor: PhysicsImpostor): void;
  127985. /**
  127986. * Add a joint to the physics engine
  127987. * @param mainImpostor defines the main impostor to which the joint is added.
  127988. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127989. * @param joint defines the joint that will connect both impostors.
  127990. */
  127991. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127992. /**
  127993. * Removes a joint from the simulation
  127994. * @param mainImpostor defines the impostor used with the joint
  127995. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127996. * @param joint defines the joint to remove
  127997. */
  127998. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127999. /**
  128000. * Called by the scene. No need to call it.
  128001. * @param delta defines the timespam between frames
  128002. */
  128003. _step(delta: number): void;
  128004. /**
  128005. * Gets the current plugin used to run the simulation
  128006. * @returns current plugin
  128007. */
  128008. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128009. /**
  128010. * Gets the list of physic impostors
  128011. * @returns an array of PhysicsImpostor
  128012. */
  128013. getImpostors(): Array<PhysicsImpostor>;
  128014. /**
  128015. * Gets the impostor for a physics enabled object
  128016. * @param object defines the object impersonated by the impostor
  128017. * @returns the PhysicsImpostor or null if not found
  128018. */
  128019. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128020. /**
  128021. * Gets the impostor for a physics body object
  128022. * @param body defines physics body used by the impostor
  128023. * @returns the PhysicsImpostor or null if not found
  128024. */
  128025. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128026. /**
  128027. * Does a raycast in the physics world
  128028. * @param from when should the ray start?
  128029. * @param to when should the ray end?
  128030. * @returns PhysicsRaycastResult
  128031. */
  128032. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128033. }
  128034. }
  128035. declare module BABYLON {
  128036. /** @hidden */
  128037. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128038. private _useDeltaForWorldStep;
  128039. world: any;
  128040. name: string;
  128041. private _physicsMaterials;
  128042. private _fixedTimeStep;
  128043. private _cannonRaycastResult;
  128044. private _raycastResult;
  128045. private _physicsBodysToRemoveAfterStep;
  128046. BJSCANNON: any;
  128047. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128048. setGravity(gravity: Vector3): void;
  128049. setTimeStep(timeStep: number): void;
  128050. getTimeStep(): number;
  128051. executeStep(delta: number): void;
  128052. private _removeMarkedPhysicsBodiesFromWorld;
  128053. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128054. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128055. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128056. private _processChildMeshes;
  128057. removePhysicsBody(impostor: PhysicsImpostor): void;
  128058. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128059. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128060. private _addMaterial;
  128061. private _checkWithEpsilon;
  128062. private _createShape;
  128063. private _createHeightmap;
  128064. private _minus90X;
  128065. private _plus90X;
  128066. private _tmpPosition;
  128067. private _tmpDeltaPosition;
  128068. private _tmpUnityRotation;
  128069. private _updatePhysicsBodyTransformation;
  128070. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128071. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128072. isSupported(): boolean;
  128073. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128074. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128075. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128076. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128077. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128078. getBodyMass(impostor: PhysicsImpostor): number;
  128079. getBodyFriction(impostor: PhysicsImpostor): number;
  128080. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128081. getBodyRestitution(impostor: PhysicsImpostor): number;
  128082. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128083. sleepBody(impostor: PhysicsImpostor): void;
  128084. wakeUpBody(impostor: PhysicsImpostor): void;
  128085. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128086. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128087. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128088. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128089. getRadius(impostor: PhysicsImpostor): number;
  128090. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128091. dispose(): void;
  128092. private _extendNamespace;
  128093. /**
  128094. * Does a raycast in the physics world
  128095. * @param from when should the ray start?
  128096. * @param to when should the ray end?
  128097. * @returns PhysicsRaycastResult
  128098. */
  128099. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128100. }
  128101. }
  128102. declare module BABYLON {
  128103. /** @hidden */
  128104. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128105. world: any;
  128106. name: string;
  128107. BJSOIMO: any;
  128108. private _raycastResult;
  128109. constructor(iterations?: number, oimoInjection?: any);
  128110. setGravity(gravity: Vector3): void;
  128111. setTimeStep(timeStep: number): void;
  128112. getTimeStep(): number;
  128113. private _tmpImpostorsArray;
  128114. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128115. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128116. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128117. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128118. private _tmpPositionVector;
  128119. removePhysicsBody(impostor: PhysicsImpostor): void;
  128120. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128122. isSupported(): boolean;
  128123. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128124. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128126. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128127. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128128. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128129. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128130. getBodyMass(impostor: PhysicsImpostor): number;
  128131. getBodyFriction(impostor: PhysicsImpostor): number;
  128132. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128133. getBodyRestitution(impostor: PhysicsImpostor): number;
  128134. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128135. sleepBody(impostor: PhysicsImpostor): void;
  128136. wakeUpBody(impostor: PhysicsImpostor): void;
  128137. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128138. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128139. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128140. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128141. getRadius(impostor: PhysicsImpostor): number;
  128142. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128143. dispose(): void;
  128144. /**
  128145. * Does a raycast in the physics world
  128146. * @param from when should the ray start?
  128147. * @param to when should the ray end?
  128148. * @returns PhysicsRaycastResult
  128149. */
  128150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128151. }
  128152. }
  128153. declare module BABYLON {
  128154. /**
  128155. * Class containing static functions to help procedurally build meshes
  128156. */
  128157. export class RibbonBuilder {
  128158. /**
  128159. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128160. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128161. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128162. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128163. * * 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
  128164. * * 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
  128165. * * 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
  128166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128169. * * 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
  128170. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128171. * * 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
  128172. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128174. * @param name defines the name of the mesh
  128175. * @param options defines the options used to create the mesh
  128176. * @param scene defines the hosting scene
  128177. * @returns the ribbon mesh
  128178. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128180. */
  128181. static CreateRibbon(name: string, options: {
  128182. pathArray: Vector3[][];
  128183. closeArray?: boolean;
  128184. closePath?: boolean;
  128185. offset?: number;
  128186. updatable?: boolean;
  128187. sideOrientation?: number;
  128188. frontUVs?: Vector4;
  128189. backUVs?: Vector4;
  128190. instance?: Mesh;
  128191. invertUV?: boolean;
  128192. uvs?: Vector2[];
  128193. colors?: Color4[];
  128194. }, scene?: Nullable<Scene>): Mesh;
  128195. }
  128196. }
  128197. declare module BABYLON {
  128198. /**
  128199. * Class containing static functions to help procedurally build meshes
  128200. */
  128201. export class ShapeBuilder {
  128202. /**
  128203. * 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.
  128204. * * 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.
  128205. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128206. * * 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.
  128207. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128208. * * 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
  128209. * * 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
  128210. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128213. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128215. * @param name defines the name of the mesh
  128216. * @param options defines the options used to create the mesh
  128217. * @param scene defines the hosting scene
  128218. * @returns the extruded shape mesh
  128219. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128221. */
  128222. static ExtrudeShape(name: string, options: {
  128223. shape: Vector3[];
  128224. path: Vector3[];
  128225. scale?: number;
  128226. rotation?: number;
  128227. cap?: number;
  128228. updatable?: boolean;
  128229. sideOrientation?: number;
  128230. frontUVs?: Vector4;
  128231. backUVs?: Vector4;
  128232. instance?: Mesh;
  128233. invertUV?: boolean;
  128234. }, scene?: Nullable<Scene>): Mesh;
  128235. /**
  128236. * Creates an custom extruded shape mesh.
  128237. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128238. * * 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.
  128239. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128240. * * 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
  128241. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128242. * * 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
  128243. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128244. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128245. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128246. * * 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
  128247. * * 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
  128248. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128253. * @param name defines the name of the mesh
  128254. * @param options defines the options used to create the mesh
  128255. * @param scene defines the hosting scene
  128256. * @returns the custom extruded shape mesh
  128257. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128258. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128260. */
  128261. static ExtrudeShapeCustom(name: string, options: {
  128262. shape: Vector3[];
  128263. path: Vector3[];
  128264. scaleFunction?: any;
  128265. rotationFunction?: any;
  128266. ribbonCloseArray?: boolean;
  128267. ribbonClosePath?: boolean;
  128268. cap?: number;
  128269. updatable?: boolean;
  128270. sideOrientation?: number;
  128271. frontUVs?: Vector4;
  128272. backUVs?: Vector4;
  128273. instance?: Mesh;
  128274. invertUV?: boolean;
  128275. }, scene?: Nullable<Scene>): Mesh;
  128276. private static _ExtrudeShapeGeneric;
  128277. }
  128278. }
  128279. declare module BABYLON {
  128280. /**
  128281. * AmmoJS Physics plugin
  128282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128283. * @see https://github.com/kripken/ammo.js/
  128284. */
  128285. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128286. private _useDeltaForWorldStep;
  128287. /**
  128288. * Reference to the Ammo library
  128289. */
  128290. bjsAMMO: any;
  128291. /**
  128292. * Created ammoJS world which physics bodies are added to
  128293. */
  128294. world: any;
  128295. /**
  128296. * Name of the plugin
  128297. */
  128298. name: string;
  128299. private _timeStep;
  128300. private _fixedTimeStep;
  128301. private _maxSteps;
  128302. private _tmpQuaternion;
  128303. private _tmpAmmoTransform;
  128304. private _tmpAmmoQuaternion;
  128305. private _tmpAmmoConcreteContactResultCallback;
  128306. private _collisionConfiguration;
  128307. private _dispatcher;
  128308. private _overlappingPairCache;
  128309. private _solver;
  128310. private _softBodySolver;
  128311. private _tmpAmmoVectorA;
  128312. private _tmpAmmoVectorB;
  128313. private _tmpAmmoVectorC;
  128314. private _tmpAmmoVectorD;
  128315. private _tmpContactCallbackResult;
  128316. private _tmpAmmoVectorRCA;
  128317. private _tmpAmmoVectorRCB;
  128318. private _raycastResult;
  128319. private static readonly DISABLE_COLLISION_FLAG;
  128320. private static readonly KINEMATIC_FLAG;
  128321. private static readonly DISABLE_DEACTIVATION_FLAG;
  128322. /**
  128323. * Initializes the ammoJS plugin
  128324. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128325. * @param ammoInjection can be used to inject your own ammo reference
  128326. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128327. */
  128328. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128329. /**
  128330. * Sets the gravity of the physics world (m/(s^2))
  128331. * @param gravity Gravity to set
  128332. */
  128333. setGravity(gravity: Vector3): void;
  128334. /**
  128335. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128336. * @param timeStep timestep to use in seconds
  128337. */
  128338. setTimeStep(timeStep: number): void;
  128339. /**
  128340. * 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)
  128341. * @param fixedTimeStep fixedTimeStep to use in seconds
  128342. */
  128343. setFixedTimeStep(fixedTimeStep: number): void;
  128344. /**
  128345. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128346. * @param maxSteps the maximum number of steps by the physics engine per frame
  128347. */
  128348. setMaxSteps(maxSteps: number): void;
  128349. /**
  128350. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128351. * @returns the current timestep in seconds
  128352. */
  128353. getTimeStep(): number;
  128354. /**
  128355. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128356. */
  128357. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128358. private _isImpostorInContact;
  128359. private _isImpostorPairInContact;
  128360. private _stepSimulation;
  128361. /**
  128362. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128363. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128364. * After the step the babylon meshes are set to the position of the physics imposters
  128365. * @param delta amount of time to step forward
  128366. * @param impostors array of imposters to update before/after the step
  128367. */
  128368. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128369. /**
  128370. * Update babylon mesh to match physics world object
  128371. * @param impostor imposter to match
  128372. */
  128373. private _afterSoftStep;
  128374. /**
  128375. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128376. * @param impostor imposter to match
  128377. */
  128378. private _ropeStep;
  128379. /**
  128380. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128381. * @param impostor imposter to match
  128382. */
  128383. private _softbodyOrClothStep;
  128384. private _tmpVector;
  128385. private _tmpMatrix;
  128386. /**
  128387. * Applies an impulse on the imposter
  128388. * @param impostor imposter to apply impulse to
  128389. * @param force amount of force to be applied to the imposter
  128390. * @param contactPoint the location to apply the impulse on the imposter
  128391. */
  128392. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128393. /**
  128394. * Applies a force on the imposter
  128395. * @param impostor imposter to apply force
  128396. * @param force amount of force to be applied to the imposter
  128397. * @param contactPoint the location to apply the force on the imposter
  128398. */
  128399. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128400. /**
  128401. * Creates a physics body using the plugin
  128402. * @param impostor the imposter to create the physics body on
  128403. */
  128404. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128405. /**
  128406. * Removes the physics body from the imposter and disposes of the body's memory
  128407. * @param impostor imposter to remove the physics body from
  128408. */
  128409. removePhysicsBody(impostor: PhysicsImpostor): void;
  128410. /**
  128411. * Generates a joint
  128412. * @param impostorJoint the imposter joint to create the joint with
  128413. */
  128414. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128415. /**
  128416. * Removes a joint
  128417. * @param impostorJoint the imposter joint to remove the joint from
  128418. */
  128419. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128420. private _addMeshVerts;
  128421. /**
  128422. * Initialise the soft body vertices to match its object's (mesh) vertices
  128423. * Softbody vertices (nodes) are in world space and to match this
  128424. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128425. * @param impostor to create the softbody for
  128426. */
  128427. private _softVertexData;
  128428. /**
  128429. * Create an impostor's soft body
  128430. * @param impostor to create the softbody for
  128431. */
  128432. private _createSoftbody;
  128433. /**
  128434. * Create cloth for an impostor
  128435. * @param impostor to create the softbody for
  128436. */
  128437. private _createCloth;
  128438. /**
  128439. * Create rope for an impostor
  128440. * @param impostor to create the softbody for
  128441. */
  128442. private _createRope;
  128443. /**
  128444. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128445. * @param impostor to create the custom physics shape for
  128446. */
  128447. private _createCustom;
  128448. private _addHullVerts;
  128449. private _createShape;
  128450. /**
  128451. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128452. * @param impostor imposter containing the physics body and babylon object
  128453. */
  128454. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128455. /**
  128456. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128457. * @param impostor imposter containing the physics body and babylon object
  128458. * @param newPosition new position
  128459. * @param newRotation new rotation
  128460. */
  128461. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128462. /**
  128463. * If this plugin is supported
  128464. * @returns true if its supported
  128465. */
  128466. isSupported(): boolean;
  128467. /**
  128468. * Sets the linear velocity of the physics body
  128469. * @param impostor imposter to set the velocity on
  128470. * @param velocity velocity to set
  128471. */
  128472. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128473. /**
  128474. * Sets the angular velocity of the physics body
  128475. * @param impostor imposter to set the velocity on
  128476. * @param velocity velocity to set
  128477. */
  128478. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128479. /**
  128480. * gets the linear velocity
  128481. * @param impostor imposter to get linear velocity from
  128482. * @returns linear velocity
  128483. */
  128484. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128485. /**
  128486. * gets the angular velocity
  128487. * @param impostor imposter to get angular velocity from
  128488. * @returns angular velocity
  128489. */
  128490. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128491. /**
  128492. * Sets the mass of physics body
  128493. * @param impostor imposter to set the mass on
  128494. * @param mass mass to set
  128495. */
  128496. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128497. /**
  128498. * Gets the mass of the physics body
  128499. * @param impostor imposter to get the mass from
  128500. * @returns mass
  128501. */
  128502. getBodyMass(impostor: PhysicsImpostor): number;
  128503. /**
  128504. * Gets friction of the impostor
  128505. * @param impostor impostor to get friction from
  128506. * @returns friction value
  128507. */
  128508. getBodyFriction(impostor: PhysicsImpostor): number;
  128509. /**
  128510. * Sets friction of the impostor
  128511. * @param impostor impostor to set friction on
  128512. * @param friction friction value
  128513. */
  128514. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128515. /**
  128516. * Gets restitution of the impostor
  128517. * @param impostor impostor to get restitution from
  128518. * @returns restitution value
  128519. */
  128520. getBodyRestitution(impostor: PhysicsImpostor): number;
  128521. /**
  128522. * Sets resitution of the impostor
  128523. * @param impostor impostor to set resitution on
  128524. * @param restitution resitution value
  128525. */
  128526. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128527. /**
  128528. * Gets pressure inside the impostor
  128529. * @param impostor impostor to get pressure from
  128530. * @returns pressure value
  128531. */
  128532. getBodyPressure(impostor: PhysicsImpostor): number;
  128533. /**
  128534. * Sets pressure inside a soft body impostor
  128535. * Cloth and rope must remain 0 pressure
  128536. * @param impostor impostor to set pressure on
  128537. * @param pressure pressure value
  128538. */
  128539. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128540. /**
  128541. * Gets stiffness of the impostor
  128542. * @param impostor impostor to get stiffness from
  128543. * @returns pressure value
  128544. */
  128545. getBodyStiffness(impostor: PhysicsImpostor): number;
  128546. /**
  128547. * Sets stiffness of the impostor
  128548. * @param impostor impostor to set stiffness on
  128549. * @param stiffness stiffness value from 0 to 1
  128550. */
  128551. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128552. /**
  128553. * Gets velocityIterations of the impostor
  128554. * @param impostor impostor to get velocity iterations from
  128555. * @returns velocityIterations value
  128556. */
  128557. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128558. /**
  128559. * Sets velocityIterations of the impostor
  128560. * @param impostor impostor to set velocity iterations on
  128561. * @param velocityIterations velocityIterations value
  128562. */
  128563. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128564. /**
  128565. * Gets positionIterations of the impostor
  128566. * @param impostor impostor to get position iterations from
  128567. * @returns positionIterations value
  128568. */
  128569. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128570. /**
  128571. * Sets positionIterations of the impostor
  128572. * @param impostor impostor to set position on
  128573. * @param positionIterations positionIterations value
  128574. */
  128575. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128576. /**
  128577. * Append an anchor to a cloth object
  128578. * @param impostor is the cloth impostor to add anchor to
  128579. * @param otherImpostor is the rigid impostor to anchor to
  128580. * @param width ratio across width from 0 to 1
  128581. * @param height ratio up height from 0 to 1
  128582. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128583. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128584. */
  128585. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128586. /**
  128587. * Append an hook to a rope object
  128588. * @param impostor is the rope impostor to add hook to
  128589. * @param otherImpostor is the rigid impostor to hook to
  128590. * @param length ratio along the rope from 0 to 1
  128591. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128592. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128593. */
  128594. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128595. /**
  128596. * Sleeps the physics body and stops it from being active
  128597. * @param impostor impostor to sleep
  128598. */
  128599. sleepBody(impostor: PhysicsImpostor): void;
  128600. /**
  128601. * Activates the physics body
  128602. * @param impostor impostor to activate
  128603. */
  128604. wakeUpBody(impostor: PhysicsImpostor): void;
  128605. /**
  128606. * Updates the distance parameters of the joint
  128607. * @param joint joint to update
  128608. * @param maxDistance maximum distance of the joint
  128609. * @param minDistance minimum distance of the joint
  128610. */
  128611. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128612. /**
  128613. * Sets a motor on the joint
  128614. * @param joint joint to set motor on
  128615. * @param speed speed of the motor
  128616. * @param maxForce maximum force of the motor
  128617. * @param motorIndex index of the motor
  128618. */
  128619. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128620. /**
  128621. * Sets the motors limit
  128622. * @param joint joint to set limit on
  128623. * @param upperLimit upper limit
  128624. * @param lowerLimit lower limit
  128625. */
  128626. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128627. /**
  128628. * Syncs the position and rotation of a mesh with the impostor
  128629. * @param mesh mesh to sync
  128630. * @param impostor impostor to update the mesh with
  128631. */
  128632. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128633. /**
  128634. * Gets the radius of the impostor
  128635. * @param impostor impostor to get radius from
  128636. * @returns the radius
  128637. */
  128638. getRadius(impostor: PhysicsImpostor): number;
  128639. /**
  128640. * Gets the box size of the impostor
  128641. * @param impostor impostor to get box size from
  128642. * @param result the resulting box size
  128643. */
  128644. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128645. /**
  128646. * Disposes of the impostor
  128647. */
  128648. dispose(): void;
  128649. /**
  128650. * Does a raycast in the physics world
  128651. * @param from when should the ray start?
  128652. * @param to when should the ray end?
  128653. * @returns PhysicsRaycastResult
  128654. */
  128655. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128656. }
  128657. }
  128658. declare module BABYLON {
  128659. interface AbstractScene {
  128660. /**
  128661. * The list of reflection probes added to the scene
  128662. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128663. */
  128664. reflectionProbes: Array<ReflectionProbe>;
  128665. /**
  128666. * Removes the given reflection probe from this scene.
  128667. * @param toRemove The reflection probe to remove
  128668. * @returns The index of the removed reflection probe
  128669. */
  128670. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128671. /**
  128672. * Adds the given reflection probe to this scene.
  128673. * @param newReflectionProbe The reflection probe to add
  128674. */
  128675. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128676. }
  128677. /**
  128678. * Class used to generate realtime reflection / refraction cube textures
  128679. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128680. */
  128681. export class ReflectionProbe {
  128682. /** defines the name of the probe */
  128683. name: string;
  128684. private _scene;
  128685. private _renderTargetTexture;
  128686. private _projectionMatrix;
  128687. private _viewMatrix;
  128688. private _target;
  128689. private _add;
  128690. private _attachedMesh;
  128691. private _invertYAxis;
  128692. /** Gets or sets probe position (center of the cube map) */
  128693. position: Vector3;
  128694. /**
  128695. * Creates a new reflection probe
  128696. * @param name defines the name of the probe
  128697. * @param size defines the texture resolution (for each face)
  128698. * @param scene defines the hosting scene
  128699. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128700. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128701. */
  128702. constructor(
  128703. /** defines the name of the probe */
  128704. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128705. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128706. get samples(): number;
  128707. set samples(value: number);
  128708. /** Gets or sets the refresh rate to use (on every frame by default) */
  128709. get refreshRate(): number;
  128710. set refreshRate(value: number);
  128711. /**
  128712. * Gets the hosting scene
  128713. * @returns a Scene
  128714. */
  128715. getScene(): Scene;
  128716. /** Gets the internal CubeTexture used to render to */
  128717. get cubeTexture(): RenderTargetTexture;
  128718. /** Gets the list of meshes to render */
  128719. get renderList(): Nullable<AbstractMesh[]>;
  128720. /**
  128721. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128722. * @param mesh defines the mesh to attach to
  128723. */
  128724. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128725. /**
  128726. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128727. * @param renderingGroupId The rendering group id corresponding to its index
  128728. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128729. */
  128730. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128731. /**
  128732. * Clean all associated resources
  128733. */
  128734. dispose(): void;
  128735. /**
  128736. * Converts the reflection probe information to a readable string for debug purpose.
  128737. * @param fullDetails Supports for multiple levels of logging within scene loading
  128738. * @returns the human readable reflection probe info
  128739. */
  128740. toString(fullDetails?: boolean): string;
  128741. /**
  128742. * Get the class name of the relfection probe.
  128743. * @returns "ReflectionProbe"
  128744. */
  128745. getClassName(): string;
  128746. /**
  128747. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128748. * @returns The JSON representation of the texture
  128749. */
  128750. serialize(): any;
  128751. /**
  128752. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128753. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128754. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128755. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128756. * @returns The parsed reflection probe if successful
  128757. */
  128758. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128759. }
  128760. }
  128761. declare module BABYLON {
  128762. /** @hidden */
  128763. export var _BabylonLoaderRegistered: boolean;
  128764. /**
  128765. * Helps setting up some configuration for the babylon file loader.
  128766. */
  128767. export class BabylonFileLoaderConfiguration {
  128768. /**
  128769. * The loader does not allow injecting custom physix engine into the plugins.
  128770. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128771. * So you could set this variable to your engine import to make it work.
  128772. */
  128773. static LoaderInjectedPhysicsEngine: any;
  128774. }
  128775. }
  128776. declare module BABYLON {
  128777. /**
  128778. * The Physically based simple base material of BJS.
  128779. *
  128780. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128781. * It is used as the base class for both the specGloss and metalRough conventions.
  128782. */
  128783. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128784. /**
  128785. * Number of Simultaneous lights allowed on the material.
  128786. */
  128787. maxSimultaneousLights: number;
  128788. /**
  128789. * If sets to true, disables all the lights affecting the material.
  128790. */
  128791. disableLighting: boolean;
  128792. /**
  128793. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128794. */
  128795. environmentTexture: BaseTexture;
  128796. /**
  128797. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128798. */
  128799. invertNormalMapX: boolean;
  128800. /**
  128801. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128802. */
  128803. invertNormalMapY: boolean;
  128804. /**
  128805. * Normal map used in the model.
  128806. */
  128807. normalTexture: BaseTexture;
  128808. /**
  128809. * Emissivie color used to self-illuminate the model.
  128810. */
  128811. emissiveColor: Color3;
  128812. /**
  128813. * Emissivie texture used to self-illuminate the model.
  128814. */
  128815. emissiveTexture: BaseTexture;
  128816. /**
  128817. * Occlusion Channel Strenght.
  128818. */
  128819. occlusionStrength: number;
  128820. /**
  128821. * Occlusion Texture of the material (adding extra occlusion effects).
  128822. */
  128823. occlusionTexture: BaseTexture;
  128824. /**
  128825. * Defines the alpha limits in alpha test mode.
  128826. */
  128827. alphaCutOff: number;
  128828. /**
  128829. * Gets the current double sided mode.
  128830. */
  128831. get doubleSided(): boolean;
  128832. /**
  128833. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128834. */
  128835. set doubleSided(value: boolean);
  128836. /**
  128837. * Stores the pre-calculated light information of a mesh in a texture.
  128838. */
  128839. lightmapTexture: BaseTexture;
  128840. /**
  128841. * If true, the light map contains occlusion information instead of lighting info.
  128842. */
  128843. useLightmapAsShadowmap: boolean;
  128844. /**
  128845. * Instantiates a new PBRMaterial instance.
  128846. *
  128847. * @param name The material name
  128848. * @param scene The scene the material will be use in.
  128849. */
  128850. constructor(name: string, scene: Scene);
  128851. getClassName(): string;
  128852. }
  128853. }
  128854. declare module BABYLON {
  128855. /**
  128856. * The PBR material of BJS following the metal roughness convention.
  128857. *
  128858. * This fits to the PBR convention in the GLTF definition:
  128859. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128860. */
  128861. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128862. /**
  128863. * The base color has two different interpretations depending on the value of metalness.
  128864. * When the material is a metal, the base color is the specific measured reflectance value
  128865. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128866. * of the material.
  128867. */
  128868. baseColor: Color3;
  128869. /**
  128870. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128871. * well as opacity information in the alpha channel.
  128872. */
  128873. baseTexture: BaseTexture;
  128874. /**
  128875. * Specifies the metallic scalar value of the material.
  128876. * Can also be used to scale the metalness values of the metallic texture.
  128877. */
  128878. metallic: number;
  128879. /**
  128880. * Specifies the roughness scalar value of the material.
  128881. * Can also be used to scale the roughness values of the metallic texture.
  128882. */
  128883. roughness: number;
  128884. /**
  128885. * Texture containing both the metallic value in the B channel and the
  128886. * roughness value in the G channel to keep better precision.
  128887. */
  128888. metallicRoughnessTexture: BaseTexture;
  128889. /**
  128890. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128891. *
  128892. * @param name The material name
  128893. * @param scene The scene the material will be use in.
  128894. */
  128895. constructor(name: string, scene: Scene);
  128896. /**
  128897. * Return the currrent class name of the material.
  128898. */
  128899. getClassName(): string;
  128900. /**
  128901. * Makes a duplicate of the current material.
  128902. * @param name - name to use for the new material.
  128903. */
  128904. clone(name: string): PBRMetallicRoughnessMaterial;
  128905. /**
  128906. * Serialize the material to a parsable JSON object.
  128907. */
  128908. serialize(): any;
  128909. /**
  128910. * Parses a JSON object correponding to the serialize function.
  128911. */
  128912. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128913. }
  128914. }
  128915. declare module BABYLON {
  128916. /**
  128917. * The PBR material of BJS following the specular glossiness convention.
  128918. *
  128919. * This fits to the PBR convention in the GLTF definition:
  128920. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128921. */
  128922. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128923. /**
  128924. * Specifies the diffuse color of the material.
  128925. */
  128926. diffuseColor: Color3;
  128927. /**
  128928. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128929. * channel.
  128930. */
  128931. diffuseTexture: BaseTexture;
  128932. /**
  128933. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128934. */
  128935. specularColor: Color3;
  128936. /**
  128937. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128938. */
  128939. glossiness: number;
  128940. /**
  128941. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128942. */
  128943. specularGlossinessTexture: BaseTexture;
  128944. /**
  128945. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128946. *
  128947. * @param name The material name
  128948. * @param scene The scene the material will be use in.
  128949. */
  128950. constructor(name: string, scene: Scene);
  128951. /**
  128952. * Return the currrent class name of the material.
  128953. */
  128954. getClassName(): string;
  128955. /**
  128956. * Makes a duplicate of the current material.
  128957. * @param name - name to use for the new material.
  128958. */
  128959. clone(name: string): PBRSpecularGlossinessMaterial;
  128960. /**
  128961. * Serialize the material to a parsable JSON object.
  128962. */
  128963. serialize(): any;
  128964. /**
  128965. * Parses a JSON object correponding to the serialize function.
  128966. */
  128967. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128968. }
  128969. }
  128970. declare module BABYLON {
  128971. /**
  128972. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128973. * It can help converting any input color in a desired output one. This can then be used to create effects
  128974. * from sepia, black and white to sixties or futuristic rendering...
  128975. *
  128976. * The only supported format is currently 3dl.
  128977. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128978. */
  128979. export class ColorGradingTexture extends BaseTexture {
  128980. /**
  128981. * The current texture matrix. (will always be identity in color grading texture)
  128982. */
  128983. private _textureMatrix;
  128984. /**
  128985. * The texture URL.
  128986. */
  128987. url: string;
  128988. /**
  128989. * Empty line regex stored for GC.
  128990. */
  128991. private static _noneEmptyLineRegex;
  128992. private _engine;
  128993. /**
  128994. * Instantiates a ColorGradingTexture from the following parameters.
  128995. *
  128996. * @param url The location of the color gradind data (currently only supporting 3dl)
  128997. * @param scene The scene the texture will be used in
  128998. */
  128999. constructor(url: string, scene: Scene);
  129000. /**
  129001. * Returns the texture matrix used in most of the material.
  129002. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129003. */
  129004. getTextureMatrix(): Matrix;
  129005. /**
  129006. * Occurs when the file being loaded is a .3dl LUT file.
  129007. */
  129008. private load3dlTexture;
  129009. /**
  129010. * Starts the loading process of the texture.
  129011. */
  129012. private loadTexture;
  129013. /**
  129014. * Clones the color gradind texture.
  129015. */
  129016. clone(): ColorGradingTexture;
  129017. /**
  129018. * Called during delayed load for textures.
  129019. */
  129020. delayLoad(): void;
  129021. /**
  129022. * Parses a color grading texture serialized by Babylon.
  129023. * @param parsedTexture The texture information being parsedTexture
  129024. * @param scene The scene to load the texture in
  129025. * @param rootUrl The root url of the data assets to load
  129026. * @return A color gradind texture
  129027. */
  129028. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129029. /**
  129030. * Serializes the LUT texture to json format.
  129031. */
  129032. serialize(): any;
  129033. }
  129034. }
  129035. declare module BABYLON {
  129036. /**
  129037. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129038. */
  129039. export class EquiRectangularCubeTexture extends BaseTexture {
  129040. /** The six faces of the cube. */
  129041. private static _FacesMapping;
  129042. private _noMipmap;
  129043. private _onLoad;
  129044. private _onError;
  129045. /** The size of the cubemap. */
  129046. private _size;
  129047. /** The buffer of the image. */
  129048. private _buffer;
  129049. /** The width of the input image. */
  129050. private _width;
  129051. /** The height of the input image. */
  129052. private _height;
  129053. /** The URL to the image. */
  129054. url: string;
  129055. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129056. coordinatesMode: number;
  129057. /**
  129058. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129059. * @param url The location of the image
  129060. * @param scene The scene the texture will be used in
  129061. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129062. * @param noMipmap Forces to not generate the mipmap if true
  129063. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129064. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129065. * @param onLoad — defines a callback called when texture is loaded
  129066. * @param onError — defines a callback called if there is an error
  129067. */
  129068. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129069. /**
  129070. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129071. */
  129072. private loadImage;
  129073. /**
  129074. * Convert the image buffer into a cubemap and create a CubeTexture.
  129075. */
  129076. private loadTexture;
  129077. /**
  129078. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129079. * @param buffer The ArrayBuffer that should be converted.
  129080. * @returns The buffer as Float32Array.
  129081. */
  129082. private getFloat32ArrayFromArrayBuffer;
  129083. /**
  129084. * Get the current class name of the texture useful for serialization or dynamic coding.
  129085. * @returns "EquiRectangularCubeTexture"
  129086. */
  129087. getClassName(): string;
  129088. /**
  129089. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129090. * @returns A clone of the current EquiRectangularCubeTexture.
  129091. */
  129092. clone(): EquiRectangularCubeTexture;
  129093. }
  129094. }
  129095. declare module BABYLON {
  129096. /**
  129097. * Based on jsTGALoader - Javascript loader for TGA file
  129098. * By Vincent Thibault
  129099. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129100. */
  129101. export class TGATools {
  129102. private static _TYPE_INDEXED;
  129103. private static _TYPE_RGB;
  129104. private static _TYPE_GREY;
  129105. private static _TYPE_RLE_INDEXED;
  129106. private static _TYPE_RLE_RGB;
  129107. private static _TYPE_RLE_GREY;
  129108. private static _ORIGIN_MASK;
  129109. private static _ORIGIN_SHIFT;
  129110. private static _ORIGIN_BL;
  129111. private static _ORIGIN_BR;
  129112. private static _ORIGIN_UL;
  129113. private static _ORIGIN_UR;
  129114. /**
  129115. * Gets the header of a TGA file
  129116. * @param data defines the TGA data
  129117. * @returns the header
  129118. */
  129119. static GetTGAHeader(data: Uint8Array): any;
  129120. /**
  129121. * Uploads TGA content to a Babylon Texture
  129122. * @hidden
  129123. */
  129124. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129125. /** @hidden */
  129126. 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;
  129127. /** @hidden */
  129128. 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;
  129129. /** @hidden */
  129130. 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;
  129131. /** @hidden */
  129132. 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;
  129133. /** @hidden */
  129134. 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;
  129135. /** @hidden */
  129136. 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;
  129137. }
  129138. }
  129139. declare module BABYLON {
  129140. /**
  129141. * Implementation of the TGA Texture Loader.
  129142. * @hidden
  129143. */
  129144. export class _TGATextureLoader implements IInternalTextureLoader {
  129145. /**
  129146. * Defines wether the loader supports cascade loading the different faces.
  129147. */
  129148. readonly supportCascades: boolean;
  129149. /**
  129150. * This returns if the loader support the current file information.
  129151. * @param extension defines the file extension of the file being loaded
  129152. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129153. * @param fallback defines the fallback internal texture if any
  129154. * @param isBase64 defines whether the texture is encoded as a base64
  129155. * @param isBuffer defines whether the texture data are stored as a buffer
  129156. * @returns true if the loader can load the specified file
  129157. */
  129158. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129159. /**
  129160. * Transform the url before loading if required.
  129161. * @param rootUrl the url of the texture
  129162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129163. * @returns the transformed texture
  129164. */
  129165. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129166. /**
  129167. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129168. * @param rootUrl the url of the texture
  129169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129170. * @returns the fallback texture
  129171. */
  129172. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129173. /**
  129174. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129175. * @param data contains the texture data
  129176. * @param texture defines the BabylonJS internal texture
  129177. * @param createPolynomials will be true if polynomials have been requested
  129178. * @param onLoad defines the callback to trigger once the texture is ready
  129179. * @param onError defines the callback to trigger in case of error
  129180. */
  129181. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129182. /**
  129183. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129184. * @param data contains the texture data
  129185. * @param texture defines the BabylonJS internal texture
  129186. * @param callback defines the method to call once ready to upload
  129187. */
  129188. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129189. }
  129190. }
  129191. declare module BABYLON {
  129192. /**
  129193. * Info about the .basis files
  129194. */
  129195. class BasisFileInfo {
  129196. /**
  129197. * If the file has alpha
  129198. */
  129199. hasAlpha: boolean;
  129200. /**
  129201. * Info about each image of the basis file
  129202. */
  129203. images: Array<{
  129204. levels: Array<{
  129205. width: number;
  129206. height: number;
  129207. transcodedPixels: ArrayBufferView;
  129208. }>;
  129209. }>;
  129210. }
  129211. /**
  129212. * Result of transcoding a basis file
  129213. */
  129214. class TranscodeResult {
  129215. /**
  129216. * Info about the .basis file
  129217. */
  129218. fileInfo: BasisFileInfo;
  129219. /**
  129220. * Format to use when loading the file
  129221. */
  129222. format: number;
  129223. }
  129224. /**
  129225. * Configuration options for the Basis transcoder
  129226. */
  129227. export class BasisTranscodeConfiguration {
  129228. /**
  129229. * Supported compression formats used to determine the supported output format of the transcoder
  129230. */
  129231. supportedCompressionFormats?: {
  129232. /**
  129233. * etc1 compression format
  129234. */
  129235. etc1?: boolean;
  129236. /**
  129237. * s3tc compression format
  129238. */
  129239. s3tc?: boolean;
  129240. /**
  129241. * pvrtc compression format
  129242. */
  129243. pvrtc?: boolean;
  129244. /**
  129245. * etc2 compression format
  129246. */
  129247. etc2?: boolean;
  129248. };
  129249. /**
  129250. * If mipmap levels should be loaded for transcoded images (Default: true)
  129251. */
  129252. loadMipmapLevels?: boolean;
  129253. /**
  129254. * Index of a single image to load (Default: all images)
  129255. */
  129256. loadSingleImage?: number;
  129257. }
  129258. /**
  129259. * Used to load .Basis files
  129260. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129261. */
  129262. export class BasisTools {
  129263. private static _IgnoreSupportedFormats;
  129264. /**
  129265. * URL to use when loading the basis transcoder
  129266. */
  129267. static JSModuleURL: string;
  129268. /**
  129269. * URL to use when loading the wasm module for the transcoder
  129270. */
  129271. static WasmModuleURL: string;
  129272. /**
  129273. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129274. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129275. * @returns internal format corresponding to the Basis format
  129276. */
  129277. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129278. private static _WorkerPromise;
  129279. private static _Worker;
  129280. private static _actionId;
  129281. private static _CreateWorkerAsync;
  129282. /**
  129283. * Transcodes a loaded image file to compressed pixel data
  129284. * @param data image data to transcode
  129285. * @param config configuration options for the transcoding
  129286. * @returns a promise resulting in the transcoded image
  129287. */
  129288. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129289. /**
  129290. * Loads a texture from the transcode result
  129291. * @param texture texture load to
  129292. * @param transcodeResult the result of transcoding the basis file to load from
  129293. */
  129294. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129295. }
  129296. }
  129297. declare module BABYLON {
  129298. /**
  129299. * Loader for .basis file format
  129300. */
  129301. export class _BasisTextureLoader implements IInternalTextureLoader {
  129302. /**
  129303. * Defines whether the loader supports cascade loading the different faces.
  129304. */
  129305. readonly supportCascades: boolean;
  129306. /**
  129307. * This returns if the loader support the current file information.
  129308. * @param extension defines the file extension of the file being loaded
  129309. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129310. * @param fallback defines the fallback internal texture if any
  129311. * @param isBase64 defines whether the texture is encoded as a base64
  129312. * @param isBuffer defines whether the texture data are stored as a buffer
  129313. * @returns true if the loader can load the specified file
  129314. */
  129315. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129316. /**
  129317. * Transform the url before loading if required.
  129318. * @param rootUrl the url of the texture
  129319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129320. * @returns the transformed texture
  129321. */
  129322. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129323. /**
  129324. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129325. * @param rootUrl the url of the texture
  129326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129327. * @returns the fallback texture
  129328. */
  129329. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129330. /**
  129331. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129332. * @param data contains the texture data
  129333. * @param texture defines the BabylonJS internal texture
  129334. * @param createPolynomials will be true if polynomials have been requested
  129335. * @param onLoad defines the callback to trigger once the texture is ready
  129336. * @param onError defines the callback to trigger in case of error
  129337. */
  129338. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129339. /**
  129340. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129341. * @param data contains the texture data
  129342. * @param texture defines the BabylonJS internal texture
  129343. * @param callback defines the method to call once ready to upload
  129344. */
  129345. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129346. }
  129347. }
  129348. declare module BABYLON {
  129349. /**
  129350. * 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.
  129351. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129352. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129353. */
  129354. export class CustomProceduralTexture extends ProceduralTexture {
  129355. private _animate;
  129356. private _time;
  129357. private _config;
  129358. private _texturePath;
  129359. /**
  129360. * Instantiates a new Custom Procedural Texture.
  129361. * 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.
  129362. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129363. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129364. * @param name Define the name of the texture
  129365. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129366. * @param size Define the size of the texture to create
  129367. * @param scene Define the scene the texture belongs to
  129368. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129369. * @param generateMipMaps Define if the texture should creates mip maps or not
  129370. */
  129371. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129372. private _loadJson;
  129373. /**
  129374. * Is the texture ready to be used ? (rendered at least once)
  129375. * @returns true if ready, otherwise, false.
  129376. */
  129377. isReady(): boolean;
  129378. /**
  129379. * Render the texture to its associated render target.
  129380. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129381. */
  129382. render(useCameraPostProcess?: boolean): void;
  129383. /**
  129384. * Update the list of dependant textures samplers in the shader.
  129385. */
  129386. updateTextures(): void;
  129387. /**
  129388. * Update the uniform values of the procedural texture in the shader.
  129389. */
  129390. updateShaderUniforms(): void;
  129391. /**
  129392. * Define if the texture animates or not.
  129393. */
  129394. get animate(): boolean;
  129395. set animate(value: boolean);
  129396. }
  129397. }
  129398. declare module BABYLON {
  129399. /** @hidden */
  129400. export var noisePixelShader: {
  129401. name: string;
  129402. shader: string;
  129403. };
  129404. }
  129405. declare module BABYLON {
  129406. /**
  129407. * Class used to generate noise procedural textures
  129408. */
  129409. export class NoiseProceduralTexture extends ProceduralTexture {
  129410. private _time;
  129411. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129412. brightness: number;
  129413. /** Defines the number of octaves to process */
  129414. octaves: number;
  129415. /** Defines the level of persistence (0.8 by default) */
  129416. persistence: number;
  129417. /** Gets or sets animation speed factor (default is 1) */
  129418. animationSpeedFactor: number;
  129419. /**
  129420. * Creates a new NoiseProceduralTexture
  129421. * @param name defines the name fo the texture
  129422. * @param size defines the size of the texture (default is 256)
  129423. * @param scene defines the hosting scene
  129424. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129425. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129426. */
  129427. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129428. private _updateShaderUniforms;
  129429. protected _getDefines(): string;
  129430. /** Generate the current state of the procedural texture */
  129431. render(useCameraPostProcess?: boolean): void;
  129432. /**
  129433. * Serializes this noise procedural texture
  129434. * @returns a serialized noise procedural texture object
  129435. */
  129436. serialize(): any;
  129437. /**
  129438. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129439. * @param parsedTexture defines parsed texture data
  129440. * @param scene defines the current scene
  129441. * @param rootUrl defines the root URL containing noise procedural texture information
  129442. * @returns a parsed NoiseProceduralTexture
  129443. */
  129444. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129445. }
  129446. }
  129447. declare module BABYLON {
  129448. /**
  129449. * Raw cube texture where the raw buffers are passed in
  129450. */
  129451. export class RawCubeTexture extends CubeTexture {
  129452. /**
  129453. * Creates a cube texture where the raw buffers are passed in.
  129454. * @param scene defines the scene the texture is attached to
  129455. * @param data defines the array of data to use to create each face
  129456. * @param size defines the size of the textures
  129457. * @param format defines the format of the data
  129458. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129459. * @param generateMipMaps defines if the engine should generate the mip levels
  129460. * @param invertY defines if data must be stored with Y axis inverted
  129461. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129462. * @param compression defines the compression used (null by default)
  129463. */
  129464. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129465. /**
  129466. * Updates the raw cube texture.
  129467. * @param data defines the data to store
  129468. * @param format defines the data format
  129469. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129470. * @param invertY defines if data must be stored with Y axis inverted
  129471. * @param compression defines the compression used (null by default)
  129472. * @param level defines which level of the texture to update
  129473. */
  129474. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129475. /**
  129476. * Updates a raw cube texture with RGBD encoded data.
  129477. * @param data defines the array of data [mipmap][face] to use to create each face
  129478. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129479. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129480. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129481. * @returns a promsie that resolves when the operation is complete
  129482. */
  129483. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129484. /**
  129485. * Clones the raw cube texture.
  129486. * @return a new cube texture
  129487. */
  129488. clone(): CubeTexture;
  129489. /** @hidden */
  129490. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129491. }
  129492. }
  129493. declare module BABYLON {
  129494. /**
  129495. * Class used to store 3D textures containing user data
  129496. */
  129497. export class RawTexture3D extends Texture {
  129498. /** Gets or sets the texture format to use */
  129499. format: number;
  129500. private _engine;
  129501. /**
  129502. * Create a new RawTexture3D
  129503. * @param data defines the data of the texture
  129504. * @param width defines the width of the texture
  129505. * @param height defines the height of the texture
  129506. * @param depth defines the depth of the texture
  129507. * @param format defines the texture format to use
  129508. * @param scene defines the hosting scene
  129509. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129510. * @param invertY defines if texture must be stored with Y axis inverted
  129511. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129512. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129513. */
  129514. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129515. /** Gets or sets the texture format to use */
  129516. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129517. /**
  129518. * Update the texture with new data
  129519. * @param data defines the data to store in the texture
  129520. */
  129521. update(data: ArrayBufferView): void;
  129522. }
  129523. }
  129524. declare module BABYLON {
  129525. /**
  129526. * Class used to store 2D array textures containing user data
  129527. */
  129528. export class RawTexture2DArray extends Texture {
  129529. /** Gets or sets the texture format to use */
  129530. format: number;
  129531. private _engine;
  129532. /**
  129533. * Create a new RawTexture2DArray
  129534. * @param data defines the data of the texture
  129535. * @param width defines the width of the texture
  129536. * @param height defines the height of the texture
  129537. * @param depth defines the number of layers of the texture
  129538. * @param format defines the texture format to use
  129539. * @param scene defines the hosting scene
  129540. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129541. * @param invertY defines if texture must be stored with Y axis inverted
  129542. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129543. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129544. */
  129545. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129546. /** Gets or sets the texture format to use */
  129547. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129548. /**
  129549. * Update the texture with new data
  129550. * @param data defines the data to store in the texture
  129551. */
  129552. update(data: ArrayBufferView): void;
  129553. }
  129554. }
  129555. declare module BABYLON {
  129556. /**
  129557. * Creates a refraction texture used by refraction channel of the standard material.
  129558. * It is like a mirror but to see through a material.
  129559. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129560. */
  129561. export class RefractionTexture extends RenderTargetTexture {
  129562. /**
  129563. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129564. * 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.
  129565. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129566. */
  129567. refractionPlane: Plane;
  129568. /**
  129569. * Define how deep under the surface we should see.
  129570. */
  129571. depth: number;
  129572. /**
  129573. * Creates a refraction texture used by refraction channel of the standard material.
  129574. * It is like a mirror but to see through a material.
  129575. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129576. * @param name Define the texture name
  129577. * @param size Define the size of the underlying texture
  129578. * @param scene Define the scene the refraction belongs to
  129579. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129580. */
  129581. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129582. /**
  129583. * Clone the refraction texture.
  129584. * @returns the cloned texture
  129585. */
  129586. clone(): RefractionTexture;
  129587. /**
  129588. * Serialize the texture to a JSON representation you could use in Parse later on
  129589. * @returns the serialized JSON representation
  129590. */
  129591. serialize(): any;
  129592. }
  129593. }
  129594. declare module BABYLON {
  129595. /**
  129596. * Defines the options related to the creation of an HtmlElementTexture
  129597. */
  129598. export interface IHtmlElementTextureOptions {
  129599. /**
  129600. * Defines wether mip maps should be created or not.
  129601. */
  129602. generateMipMaps?: boolean;
  129603. /**
  129604. * Defines the sampling mode of the texture.
  129605. */
  129606. samplingMode?: number;
  129607. /**
  129608. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129609. */
  129610. engine: Nullable<ThinEngine>;
  129611. /**
  129612. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129613. */
  129614. scene: Nullable<Scene>;
  129615. }
  129616. /**
  129617. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129618. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129619. * is automatically managed.
  129620. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129621. * in your application.
  129622. *
  129623. * As the update is not automatic, you need to call them manually.
  129624. */
  129625. export class HtmlElementTexture extends BaseTexture {
  129626. /**
  129627. * The texture URL.
  129628. */
  129629. element: HTMLVideoElement | HTMLCanvasElement;
  129630. private static readonly DefaultOptions;
  129631. private _textureMatrix;
  129632. private _engine;
  129633. private _isVideo;
  129634. private _generateMipMaps;
  129635. private _samplingMode;
  129636. /**
  129637. * Instantiates a HtmlElementTexture from the following parameters.
  129638. *
  129639. * @param name Defines the name of the texture
  129640. * @param element Defines the video or canvas the texture is filled with
  129641. * @param options Defines the other none mandatory texture creation options
  129642. */
  129643. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129644. private _createInternalTexture;
  129645. /**
  129646. * Returns the texture matrix used in most of the material.
  129647. */
  129648. getTextureMatrix(): Matrix;
  129649. /**
  129650. * Updates the content of the texture.
  129651. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129652. */
  129653. update(invertY?: Nullable<boolean>): void;
  129654. }
  129655. }
  129656. declare module BABYLON {
  129657. /**
  129658. * Defines the basic options interface of a TexturePacker Frame
  129659. */
  129660. export interface ITexturePackerFrame {
  129661. /**
  129662. * The frame ID
  129663. */
  129664. id: number;
  129665. /**
  129666. * The frames Scale
  129667. */
  129668. scale: Vector2;
  129669. /**
  129670. * The Frames offset
  129671. */
  129672. offset: Vector2;
  129673. }
  129674. /**
  129675. * This is a support class for frame Data on texture packer sets.
  129676. */
  129677. export class TexturePackerFrame implements ITexturePackerFrame {
  129678. /**
  129679. * The frame ID
  129680. */
  129681. id: number;
  129682. /**
  129683. * The frames Scale
  129684. */
  129685. scale: Vector2;
  129686. /**
  129687. * The Frames offset
  129688. */
  129689. offset: Vector2;
  129690. /**
  129691. * Initializes a texture package frame.
  129692. * @param id The numerical frame identifier
  129693. * @param scale Scalar Vector2 for UV frame
  129694. * @param offset Vector2 for the frame position in UV units.
  129695. * @returns TexturePackerFrame
  129696. */
  129697. constructor(id: number, scale: Vector2, offset: Vector2);
  129698. }
  129699. }
  129700. declare module BABYLON {
  129701. /**
  129702. * Defines the basic options interface of a TexturePacker
  129703. */
  129704. export interface ITexturePackerOptions {
  129705. /**
  129706. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129707. */
  129708. map?: string[];
  129709. /**
  129710. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129711. */
  129712. uvsIn?: string;
  129713. /**
  129714. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129715. */
  129716. uvsOut?: string;
  129717. /**
  129718. * number representing the layout style. Defaults to LAYOUT_STRIP
  129719. */
  129720. layout?: number;
  129721. /**
  129722. * number of columns if using custom column count layout(2). This defaults to 4.
  129723. */
  129724. colnum?: number;
  129725. /**
  129726. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129727. */
  129728. updateInputMeshes?: boolean;
  129729. /**
  129730. * boolean flag to dispose all the source textures. Defaults to true.
  129731. */
  129732. disposeSources?: boolean;
  129733. /**
  129734. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129735. */
  129736. fillBlanks?: boolean;
  129737. /**
  129738. * string value representing the context fill style color. Defaults to 'black'.
  129739. */
  129740. customFillColor?: string;
  129741. /**
  129742. * Width and Height Value of each Frame in the TexturePacker Sets
  129743. */
  129744. frameSize?: number;
  129745. /**
  129746. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129747. */
  129748. paddingRatio?: number;
  129749. /**
  129750. * Number that declares the fill method for the padding gutter.
  129751. */
  129752. paddingMode?: number;
  129753. /**
  129754. * If in SUBUV_COLOR padding mode what color to use.
  129755. */
  129756. paddingColor?: Color3 | Color4;
  129757. }
  129758. /**
  129759. * Defines the basic interface of a TexturePacker JSON File
  129760. */
  129761. export interface ITexturePackerJSON {
  129762. /**
  129763. * The frame ID
  129764. */
  129765. name: string;
  129766. /**
  129767. * The base64 channel data
  129768. */
  129769. sets: any;
  129770. /**
  129771. * The options of the Packer
  129772. */
  129773. options: ITexturePackerOptions;
  129774. /**
  129775. * The frame data of the Packer
  129776. */
  129777. frames: Array<number>;
  129778. }
  129779. /**
  129780. * This is a support class that generates a series of packed texture sets.
  129781. * @see https://doc.babylonjs.com/babylon101/materials
  129782. */
  129783. export class TexturePacker {
  129784. /** Packer Layout Constant 0 */
  129785. static readonly LAYOUT_STRIP: number;
  129786. /** Packer Layout Constant 1 */
  129787. static readonly LAYOUT_POWER2: number;
  129788. /** Packer Layout Constant 2 */
  129789. static readonly LAYOUT_COLNUM: number;
  129790. /** Packer Layout Constant 0 */
  129791. static readonly SUBUV_WRAP: number;
  129792. /** Packer Layout Constant 1 */
  129793. static readonly SUBUV_EXTEND: number;
  129794. /** Packer Layout Constant 2 */
  129795. static readonly SUBUV_COLOR: number;
  129796. /** The Name of the Texture Package */
  129797. name: string;
  129798. /** The scene scope of the TexturePacker */
  129799. scene: Scene;
  129800. /** The Meshes to target */
  129801. meshes: AbstractMesh[];
  129802. /** Arguments passed with the Constructor */
  129803. options: ITexturePackerOptions;
  129804. /** The promise that is started upon initialization */
  129805. promise: Nullable<Promise<TexturePacker | string>>;
  129806. /** The Container object for the channel sets that are generated */
  129807. sets: object;
  129808. /** The Container array for the frames that are generated */
  129809. frames: TexturePackerFrame[];
  129810. /** The expected number of textures the system is parsing. */
  129811. private _expecting;
  129812. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129813. private _paddingValue;
  129814. /**
  129815. * Initializes a texture package series from an array of meshes or a single mesh.
  129816. * @param name The name of the package
  129817. * @param meshes The target meshes to compose the package from
  129818. * @param options The arguments that texture packer should follow while building.
  129819. * @param scene The scene which the textures are scoped to.
  129820. * @returns TexturePacker
  129821. */
  129822. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129823. /**
  129824. * Starts the package process
  129825. * @param resolve The promises resolution function
  129826. * @returns TexturePacker
  129827. */
  129828. private _createFrames;
  129829. /**
  129830. * Calculates the Size of the Channel Sets
  129831. * @returns Vector2
  129832. */
  129833. private _calculateSize;
  129834. /**
  129835. * Calculates the UV data for the frames.
  129836. * @param baseSize the base frameSize
  129837. * @param padding the base frame padding
  129838. * @param dtSize size of the Dynamic Texture for that channel
  129839. * @param dtUnits is 1/dtSize
  129840. * @param update flag to update the input meshes
  129841. */
  129842. private _calculateMeshUVFrames;
  129843. /**
  129844. * Calculates the frames Offset.
  129845. * @param index of the frame
  129846. * @returns Vector2
  129847. */
  129848. private _getFrameOffset;
  129849. /**
  129850. * Updates a Mesh to the frame data
  129851. * @param mesh that is the target
  129852. * @param frameID or the frame index
  129853. */
  129854. private _updateMeshUV;
  129855. /**
  129856. * Updates a Meshes materials to use the texture packer channels
  129857. * @param m is the mesh to target
  129858. * @param force all channels on the packer to be set.
  129859. */
  129860. private _updateTextureReferences;
  129861. /**
  129862. * Public method to set a Mesh to a frame
  129863. * @param m that is the target
  129864. * @param frameID or the frame index
  129865. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129866. */
  129867. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129868. /**
  129869. * Starts the async promise to compile the texture packer.
  129870. * @returns Promise<void>
  129871. */
  129872. processAsync(): Promise<void>;
  129873. /**
  129874. * Disposes all textures associated with this packer
  129875. */
  129876. dispose(): void;
  129877. /**
  129878. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129879. * @param imageType is the image type to use.
  129880. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129881. */
  129882. download(imageType?: string, quality?: number): void;
  129883. /**
  129884. * Public method to load a texturePacker JSON file.
  129885. * @param data of the JSON file in string format.
  129886. */
  129887. updateFromJSON(data: string): void;
  129888. }
  129889. }
  129890. declare module BABYLON {
  129891. /**
  129892. * Enum used to define the target of a block
  129893. */
  129894. export enum NodeMaterialBlockTargets {
  129895. /** Vertex shader */
  129896. Vertex = 1,
  129897. /** Fragment shader */
  129898. Fragment = 2,
  129899. /** Neutral */
  129900. Neutral = 4,
  129901. /** Vertex and Fragment */
  129902. VertexAndFragment = 3
  129903. }
  129904. }
  129905. declare module BABYLON {
  129906. /**
  129907. * Defines the kind of connection point for node based material
  129908. */
  129909. export enum NodeMaterialBlockConnectionPointTypes {
  129910. /** Float */
  129911. Float = 1,
  129912. /** Int */
  129913. Int = 2,
  129914. /** Vector2 */
  129915. Vector2 = 4,
  129916. /** Vector3 */
  129917. Vector3 = 8,
  129918. /** Vector4 */
  129919. Vector4 = 16,
  129920. /** Color3 */
  129921. Color3 = 32,
  129922. /** Color4 */
  129923. Color4 = 64,
  129924. /** Matrix */
  129925. Matrix = 128,
  129926. /** Detect type based on connection */
  129927. AutoDetect = 1024,
  129928. /** Output type that will be defined by input type */
  129929. BasedOnInput = 2048
  129930. }
  129931. }
  129932. declare module BABYLON {
  129933. /**
  129934. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129935. */
  129936. export enum NodeMaterialBlockConnectionPointMode {
  129937. /** Value is an uniform */
  129938. Uniform = 0,
  129939. /** Value is a mesh attribute */
  129940. Attribute = 1,
  129941. /** Value is a varying between vertex and fragment shaders */
  129942. Varying = 2,
  129943. /** Mode is undefined */
  129944. Undefined = 3
  129945. }
  129946. }
  129947. declare module BABYLON {
  129948. /**
  129949. * Enum used to define system values e.g. values automatically provided by the system
  129950. */
  129951. export enum NodeMaterialSystemValues {
  129952. /** World */
  129953. World = 1,
  129954. /** View */
  129955. View = 2,
  129956. /** Projection */
  129957. Projection = 3,
  129958. /** ViewProjection */
  129959. ViewProjection = 4,
  129960. /** WorldView */
  129961. WorldView = 5,
  129962. /** WorldViewProjection */
  129963. WorldViewProjection = 6,
  129964. /** CameraPosition */
  129965. CameraPosition = 7,
  129966. /** Fog Color */
  129967. FogColor = 8,
  129968. /** Delta time */
  129969. DeltaTime = 9
  129970. }
  129971. }
  129972. declare module BABYLON {
  129973. /**
  129974. * Root class for all node material optimizers
  129975. */
  129976. export class NodeMaterialOptimizer {
  129977. /**
  129978. * Function used to optimize a NodeMaterial graph
  129979. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129980. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129981. */
  129982. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129983. }
  129984. }
  129985. declare module BABYLON {
  129986. /**
  129987. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129988. */
  129989. export class TransformBlock extends NodeMaterialBlock {
  129990. /**
  129991. * Defines the value to use to complement W value to transform it to a Vector4
  129992. */
  129993. complementW: number;
  129994. /**
  129995. * Defines the value to use to complement z value to transform it to a Vector4
  129996. */
  129997. complementZ: number;
  129998. /**
  129999. * Creates a new TransformBlock
  130000. * @param name defines the block name
  130001. */
  130002. constructor(name: string);
  130003. /**
  130004. * Gets the current class name
  130005. * @returns the class name
  130006. */
  130007. getClassName(): string;
  130008. /**
  130009. * Gets the vector input
  130010. */
  130011. get vector(): NodeMaterialConnectionPoint;
  130012. /**
  130013. * Gets the output component
  130014. */
  130015. get output(): NodeMaterialConnectionPoint;
  130016. /**
  130017. * Gets the matrix transform input
  130018. */
  130019. get transform(): NodeMaterialConnectionPoint;
  130020. protected _buildBlock(state: NodeMaterialBuildState): this;
  130021. serialize(): any;
  130022. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130023. protected _dumpPropertiesCode(): string;
  130024. }
  130025. }
  130026. declare module BABYLON {
  130027. /**
  130028. * Block used to output the vertex position
  130029. */
  130030. export class VertexOutputBlock extends NodeMaterialBlock {
  130031. /**
  130032. * Creates a new VertexOutputBlock
  130033. * @param name defines the block name
  130034. */
  130035. constructor(name: string);
  130036. /**
  130037. * Gets the current class name
  130038. * @returns the class name
  130039. */
  130040. getClassName(): string;
  130041. /**
  130042. * Gets the vector input component
  130043. */
  130044. get vector(): NodeMaterialConnectionPoint;
  130045. protected _buildBlock(state: NodeMaterialBuildState): this;
  130046. }
  130047. }
  130048. declare module BABYLON {
  130049. /**
  130050. * Block used to output the final color
  130051. */
  130052. export class FragmentOutputBlock extends NodeMaterialBlock {
  130053. /**
  130054. * Create a new FragmentOutputBlock
  130055. * @param name defines the block name
  130056. */
  130057. constructor(name: string);
  130058. /**
  130059. * Gets the current class name
  130060. * @returns the class name
  130061. */
  130062. getClassName(): string;
  130063. /**
  130064. * Gets the rgba input component
  130065. */
  130066. get rgba(): NodeMaterialConnectionPoint;
  130067. /**
  130068. * Gets the rgb input component
  130069. */
  130070. get rgb(): NodeMaterialConnectionPoint;
  130071. /**
  130072. * Gets the a input component
  130073. */
  130074. get a(): NodeMaterialConnectionPoint;
  130075. protected _buildBlock(state: NodeMaterialBuildState): this;
  130076. }
  130077. }
  130078. declare module BABYLON {
  130079. /**
  130080. * Block used to read a reflection texture from a sampler
  130081. */
  130082. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130083. private _define3DName;
  130084. private _defineCubicName;
  130085. private _defineExplicitName;
  130086. private _defineProjectionName;
  130087. private _defineLocalCubicName;
  130088. private _defineSphericalName;
  130089. private _definePlanarName;
  130090. private _defineEquirectangularName;
  130091. private _defineMirroredEquirectangularFixedName;
  130092. private _defineEquirectangularFixedName;
  130093. private _defineSkyboxName;
  130094. private _cubeSamplerName;
  130095. private _2DSamplerName;
  130096. private _positionUVWName;
  130097. private _directionWName;
  130098. private _reflectionCoordsName;
  130099. private _reflection2DCoordsName;
  130100. private _reflectionColorName;
  130101. private _reflectionMatrixName;
  130102. /**
  130103. * Gets or sets the texture associated with the node
  130104. */
  130105. texture: Nullable<BaseTexture>;
  130106. /**
  130107. * Create a new TextureBlock
  130108. * @param name defines the block name
  130109. */
  130110. constructor(name: string);
  130111. /**
  130112. * Gets the current class name
  130113. * @returns the class name
  130114. */
  130115. getClassName(): string;
  130116. /**
  130117. * Gets the world position input component
  130118. */
  130119. get position(): NodeMaterialConnectionPoint;
  130120. /**
  130121. * Gets the world position input component
  130122. */
  130123. get worldPosition(): NodeMaterialConnectionPoint;
  130124. /**
  130125. * Gets the world normal input component
  130126. */
  130127. get worldNormal(): NodeMaterialConnectionPoint;
  130128. /**
  130129. * Gets the world input component
  130130. */
  130131. get world(): NodeMaterialConnectionPoint;
  130132. /**
  130133. * Gets the camera (or eye) position component
  130134. */
  130135. get cameraPosition(): NodeMaterialConnectionPoint;
  130136. /**
  130137. * Gets the view input component
  130138. */
  130139. get view(): NodeMaterialConnectionPoint;
  130140. /**
  130141. * Gets the rgb output component
  130142. */
  130143. get rgb(): NodeMaterialConnectionPoint;
  130144. /**
  130145. * Gets the r output component
  130146. */
  130147. get r(): NodeMaterialConnectionPoint;
  130148. /**
  130149. * Gets the g output component
  130150. */
  130151. get g(): NodeMaterialConnectionPoint;
  130152. /**
  130153. * Gets the b output component
  130154. */
  130155. get b(): NodeMaterialConnectionPoint;
  130156. autoConfigure(material: NodeMaterial): void;
  130157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130158. isReady(): boolean;
  130159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130160. private _injectVertexCode;
  130161. private _writeOutput;
  130162. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130163. protected _dumpPropertiesCode(): string;
  130164. serialize(): any;
  130165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130166. }
  130167. }
  130168. declare module BABYLON {
  130169. /**
  130170. * Interface used to configure the node material editor
  130171. */
  130172. export interface INodeMaterialEditorOptions {
  130173. /** Define the URl to load node editor script */
  130174. editorURL?: string;
  130175. }
  130176. /** @hidden */
  130177. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130178. NORMAL: boolean;
  130179. TANGENT: boolean;
  130180. UV1: boolean;
  130181. /** BONES */
  130182. NUM_BONE_INFLUENCERS: number;
  130183. BonesPerMesh: number;
  130184. BONETEXTURE: boolean;
  130185. /** MORPH TARGETS */
  130186. MORPHTARGETS: boolean;
  130187. MORPHTARGETS_NORMAL: boolean;
  130188. MORPHTARGETS_TANGENT: boolean;
  130189. MORPHTARGETS_UV: boolean;
  130190. NUM_MORPH_INFLUENCERS: number;
  130191. /** IMAGE PROCESSING */
  130192. IMAGEPROCESSING: boolean;
  130193. VIGNETTE: boolean;
  130194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130195. VIGNETTEBLENDMODEOPAQUE: boolean;
  130196. TONEMAPPING: boolean;
  130197. TONEMAPPING_ACES: boolean;
  130198. CONTRAST: boolean;
  130199. EXPOSURE: boolean;
  130200. COLORCURVES: boolean;
  130201. COLORGRADING: boolean;
  130202. COLORGRADING3D: boolean;
  130203. SAMPLER3DGREENDEPTH: boolean;
  130204. SAMPLER3DBGRMAP: boolean;
  130205. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130206. /** MISC. */
  130207. BUMPDIRECTUV: number;
  130208. constructor();
  130209. setValue(name: string, value: boolean): void;
  130210. }
  130211. /**
  130212. * Class used to configure NodeMaterial
  130213. */
  130214. export interface INodeMaterialOptions {
  130215. /**
  130216. * Defines if blocks should emit comments
  130217. */
  130218. emitComments: boolean;
  130219. }
  130220. /**
  130221. * Class used to create a node based material built by assembling shader blocks
  130222. */
  130223. export class NodeMaterial extends PushMaterial {
  130224. private static _BuildIdGenerator;
  130225. private _options;
  130226. private _vertexCompilationState;
  130227. private _fragmentCompilationState;
  130228. private _sharedData;
  130229. private _buildId;
  130230. private _buildWasSuccessful;
  130231. private _cachedWorldViewMatrix;
  130232. private _cachedWorldViewProjectionMatrix;
  130233. private _optimizers;
  130234. private _animationFrame;
  130235. /** Define the Url to load node editor script */
  130236. static EditorURL: string;
  130237. /** Define the Url to load snippets */
  130238. static SnippetUrl: string;
  130239. private BJSNODEMATERIALEDITOR;
  130240. /** Get the inspector from bundle or global */
  130241. private _getGlobalNodeMaterialEditor;
  130242. /**
  130243. * Gets or sets data used by visual editor
  130244. * @see https://nme.babylonjs.com
  130245. */
  130246. editorData: any;
  130247. /**
  130248. * 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)
  130249. */
  130250. ignoreAlpha: boolean;
  130251. /**
  130252. * Defines the maximum number of lights that can be used in the material
  130253. */
  130254. maxSimultaneousLights: number;
  130255. /**
  130256. * Observable raised when the material is built
  130257. */
  130258. onBuildObservable: Observable<NodeMaterial>;
  130259. /**
  130260. * Gets or sets the root nodes of the material vertex shader
  130261. */
  130262. _vertexOutputNodes: NodeMaterialBlock[];
  130263. /**
  130264. * Gets or sets the root nodes of the material fragment (pixel) shader
  130265. */
  130266. _fragmentOutputNodes: NodeMaterialBlock[];
  130267. /** Gets or sets options to control the node material overall behavior */
  130268. get options(): INodeMaterialOptions;
  130269. set options(options: INodeMaterialOptions);
  130270. /**
  130271. * Default configuration related to image processing available in the standard Material.
  130272. */
  130273. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130274. /**
  130275. * Gets the image processing configuration used either in this material.
  130276. */
  130277. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130278. /**
  130279. * Sets the Default image processing configuration used either in the this material.
  130280. *
  130281. * If sets to null, the scene one is in use.
  130282. */
  130283. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130284. /**
  130285. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130286. */
  130287. attachedBlocks: NodeMaterialBlock[];
  130288. /**
  130289. * Create a new node based material
  130290. * @param name defines the material name
  130291. * @param scene defines the hosting scene
  130292. * @param options defines creation option
  130293. */
  130294. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130295. /**
  130296. * Gets the current class name of the material e.g. "NodeMaterial"
  130297. * @returns the class name
  130298. */
  130299. getClassName(): string;
  130300. /**
  130301. * Keep track of the image processing observer to allow dispose and replace.
  130302. */
  130303. private _imageProcessingObserver;
  130304. /**
  130305. * Attaches a new image processing configuration to the Standard Material.
  130306. * @param configuration
  130307. */
  130308. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130309. /**
  130310. * Get a block by its name
  130311. * @param name defines the name of the block to retrieve
  130312. * @returns the required block or null if not found
  130313. */
  130314. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130315. /**
  130316. * Get a block by its name
  130317. * @param predicate defines the predicate used to find the good candidate
  130318. * @returns the required block or null if not found
  130319. */
  130320. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130321. /**
  130322. * Get an input block by its name
  130323. * @param predicate defines the predicate used to find the good candidate
  130324. * @returns the required input block or null if not found
  130325. */
  130326. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130327. /**
  130328. * Gets the list of input blocks attached to this material
  130329. * @returns an array of InputBlocks
  130330. */
  130331. getInputBlocks(): InputBlock[];
  130332. /**
  130333. * Adds a new optimizer to the list of optimizers
  130334. * @param optimizer defines the optimizers to add
  130335. * @returns the current material
  130336. */
  130337. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130338. /**
  130339. * Remove an optimizer from the list of optimizers
  130340. * @param optimizer defines the optimizers to remove
  130341. * @returns the current material
  130342. */
  130343. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130344. /**
  130345. * Add a new block to the list of output nodes
  130346. * @param node defines the node to add
  130347. * @returns the current material
  130348. */
  130349. addOutputNode(node: NodeMaterialBlock): this;
  130350. /**
  130351. * Remove a block from the list of root nodes
  130352. * @param node defines the node to remove
  130353. * @returns the current material
  130354. */
  130355. removeOutputNode(node: NodeMaterialBlock): this;
  130356. private _addVertexOutputNode;
  130357. private _removeVertexOutputNode;
  130358. private _addFragmentOutputNode;
  130359. private _removeFragmentOutputNode;
  130360. /**
  130361. * Specifies if the material will require alpha blending
  130362. * @returns a boolean specifying if alpha blending is needed
  130363. */
  130364. needAlphaBlending(): boolean;
  130365. /**
  130366. * Specifies if this material should be rendered in alpha test mode
  130367. * @returns a boolean specifying if an alpha test is needed.
  130368. */
  130369. needAlphaTesting(): boolean;
  130370. private _initializeBlock;
  130371. private _resetDualBlocks;
  130372. /**
  130373. * Remove a block from the current node material
  130374. * @param block defines the block to remove
  130375. */
  130376. removeBlock(block: NodeMaterialBlock): void;
  130377. /**
  130378. * Build the material and generates the inner effect
  130379. * @param verbose defines if the build should log activity
  130380. */
  130381. build(verbose?: boolean): void;
  130382. /**
  130383. * Runs an otpimization phase to try to improve the shader code
  130384. */
  130385. optimize(): void;
  130386. private _prepareDefinesForAttributes;
  130387. /**
  130388. * Get if the submesh is ready to be used and all its information available.
  130389. * Child classes can use it to update shaders
  130390. * @param mesh defines the mesh to check
  130391. * @param subMesh defines which submesh to check
  130392. * @param useInstances specifies that instances should be used
  130393. * @returns a boolean indicating that the submesh is ready or not
  130394. */
  130395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130396. /**
  130397. * Get a string representing the shaders built by the current node graph
  130398. */
  130399. get compiledShaders(): string;
  130400. /**
  130401. * Binds the world matrix to the material
  130402. * @param world defines the world transformation matrix
  130403. */
  130404. bindOnlyWorldMatrix(world: Matrix): void;
  130405. /**
  130406. * Binds the submesh to this material by preparing the effect and shader to draw
  130407. * @param world defines the world transformation matrix
  130408. * @param mesh defines the mesh containing the submesh
  130409. * @param subMesh defines the submesh to bind the material to
  130410. */
  130411. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130412. /**
  130413. * Gets the active textures from the material
  130414. * @returns an array of textures
  130415. */
  130416. getActiveTextures(): BaseTexture[];
  130417. /**
  130418. * Gets the list of texture blocks
  130419. * @returns an array of texture blocks
  130420. */
  130421. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130422. /**
  130423. * Specifies if the material uses a texture
  130424. * @param texture defines the texture to check against the material
  130425. * @returns a boolean specifying if the material uses the texture
  130426. */
  130427. hasTexture(texture: BaseTexture): boolean;
  130428. /**
  130429. * Disposes the material
  130430. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130431. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130432. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130433. */
  130434. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130435. /** Creates the node editor window. */
  130436. private _createNodeEditor;
  130437. /**
  130438. * Launch the node material editor
  130439. * @param config Define the configuration of the editor
  130440. * @return a promise fulfilled when the node editor is visible
  130441. */
  130442. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130443. /**
  130444. * Clear the current material
  130445. */
  130446. clear(): void;
  130447. /**
  130448. * Clear the current material and set it to a default state
  130449. */
  130450. setToDefault(): void;
  130451. /**
  130452. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130453. * @param url defines the url to load from
  130454. * @returns a promise that will fullfil when the material is fully loaded
  130455. */
  130456. loadAsync(url: string): Promise<void>;
  130457. private _gatherBlocks;
  130458. /**
  130459. * Generate a string containing the code declaration required to create an equivalent of this material
  130460. * @returns a string
  130461. */
  130462. generateCode(): string;
  130463. /**
  130464. * Serializes this material in a JSON representation
  130465. * @returns the serialized material object
  130466. */
  130467. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130468. private _restoreConnections;
  130469. /**
  130470. * Clear the current graph and load a new one from a serialization object
  130471. * @param source defines the JSON representation of the material
  130472. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130473. */
  130474. loadFromSerialization(source: any, rootUrl?: string): void;
  130475. /**
  130476. * Creates a node material from parsed material data
  130477. * @param source defines the JSON representation of the material
  130478. * @param scene defines the hosting scene
  130479. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130480. * @returns a new node material
  130481. */
  130482. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130483. /**
  130484. * Creates a node material from a snippet saved in a remote file
  130485. * @param name defines the name of the material to create
  130486. * @param url defines the url to load from
  130487. * @param scene defines the hosting scene
  130488. * @returns a promise that will resolve to the new node material
  130489. */
  130490. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130491. /**
  130492. * Creates a node material from a snippet saved by the node material editor
  130493. * @param snippetId defines the snippet to load
  130494. * @param scene defines the hosting scene
  130495. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130496. * @returns a promise that will resolve to the new node material
  130497. */
  130498. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130499. /**
  130500. * Creates a new node material set to default basic configuration
  130501. * @param name defines the name of the material
  130502. * @param scene defines the hosting scene
  130503. * @returns a new NodeMaterial
  130504. */
  130505. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130506. }
  130507. }
  130508. declare module BABYLON {
  130509. /**
  130510. * Block used to read a texture from a sampler
  130511. */
  130512. export class TextureBlock extends NodeMaterialBlock {
  130513. private _defineName;
  130514. private _linearDefineName;
  130515. private _tempTextureRead;
  130516. private _samplerName;
  130517. private _transformedUVName;
  130518. private _textureTransformName;
  130519. private _textureInfoName;
  130520. private _mainUVName;
  130521. private _mainUVDefineName;
  130522. /**
  130523. * Gets or sets the texture associated with the node
  130524. */
  130525. texture: Nullable<Texture>;
  130526. /**
  130527. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130528. */
  130529. convertToGammaSpace: boolean;
  130530. /**
  130531. * Create a new TextureBlock
  130532. * @param name defines the block name
  130533. */
  130534. constructor(name: string);
  130535. /**
  130536. * Gets the current class name
  130537. * @returns the class name
  130538. */
  130539. getClassName(): string;
  130540. /**
  130541. * Gets the uv input component
  130542. */
  130543. get uv(): NodeMaterialConnectionPoint;
  130544. /**
  130545. * Gets the rgba output component
  130546. */
  130547. get rgba(): NodeMaterialConnectionPoint;
  130548. /**
  130549. * Gets the rgb output component
  130550. */
  130551. get rgb(): NodeMaterialConnectionPoint;
  130552. /**
  130553. * Gets the r output component
  130554. */
  130555. get r(): NodeMaterialConnectionPoint;
  130556. /**
  130557. * Gets the g output component
  130558. */
  130559. get g(): NodeMaterialConnectionPoint;
  130560. /**
  130561. * Gets the b output component
  130562. */
  130563. get b(): NodeMaterialConnectionPoint;
  130564. /**
  130565. * Gets the a output component
  130566. */
  130567. get a(): NodeMaterialConnectionPoint;
  130568. get target(): NodeMaterialBlockTargets;
  130569. autoConfigure(material: NodeMaterial): void;
  130570. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130572. isReady(): boolean;
  130573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130574. private get _isMixed();
  130575. private _injectVertexCode;
  130576. private _writeTextureRead;
  130577. private _writeOutput;
  130578. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130579. protected _dumpPropertiesCode(): string;
  130580. serialize(): any;
  130581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130582. }
  130583. }
  130584. declare module BABYLON {
  130585. /**
  130586. * Class used to store shared data between 2 NodeMaterialBuildState
  130587. */
  130588. export class NodeMaterialBuildStateSharedData {
  130589. /**
  130590. * Gets the list of emitted varyings
  130591. */
  130592. temps: string[];
  130593. /**
  130594. * Gets the list of emitted varyings
  130595. */
  130596. varyings: string[];
  130597. /**
  130598. * Gets the varying declaration string
  130599. */
  130600. varyingDeclaration: string;
  130601. /**
  130602. * Input blocks
  130603. */
  130604. inputBlocks: InputBlock[];
  130605. /**
  130606. * Input blocks
  130607. */
  130608. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130609. /**
  130610. * Bindable blocks (Blocks that need to set data to the effect)
  130611. */
  130612. bindableBlocks: NodeMaterialBlock[];
  130613. /**
  130614. * List of blocks that can provide a compilation fallback
  130615. */
  130616. blocksWithFallbacks: NodeMaterialBlock[];
  130617. /**
  130618. * List of blocks that can provide a define update
  130619. */
  130620. blocksWithDefines: NodeMaterialBlock[];
  130621. /**
  130622. * List of blocks that can provide a repeatable content
  130623. */
  130624. repeatableContentBlocks: NodeMaterialBlock[];
  130625. /**
  130626. * List of blocks that can provide a dynamic list of uniforms
  130627. */
  130628. dynamicUniformBlocks: NodeMaterialBlock[];
  130629. /**
  130630. * List of blocks that can block the isReady function for the material
  130631. */
  130632. blockingBlocks: NodeMaterialBlock[];
  130633. /**
  130634. * Gets the list of animated inputs
  130635. */
  130636. animatedInputs: InputBlock[];
  130637. /**
  130638. * Build Id used to avoid multiple recompilations
  130639. */
  130640. buildId: number;
  130641. /** List of emitted variables */
  130642. variableNames: {
  130643. [key: string]: number;
  130644. };
  130645. /** List of emitted defines */
  130646. defineNames: {
  130647. [key: string]: number;
  130648. };
  130649. /** Should emit comments? */
  130650. emitComments: boolean;
  130651. /** Emit build activity */
  130652. verbose: boolean;
  130653. /** Gets or sets the hosting scene */
  130654. scene: Scene;
  130655. /**
  130656. * Gets the compilation hints emitted at compilation time
  130657. */
  130658. hints: {
  130659. needWorldViewMatrix: boolean;
  130660. needWorldViewProjectionMatrix: boolean;
  130661. needAlphaBlending: boolean;
  130662. needAlphaTesting: boolean;
  130663. };
  130664. /**
  130665. * List of compilation checks
  130666. */
  130667. checks: {
  130668. emitVertex: boolean;
  130669. emitFragment: boolean;
  130670. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130671. };
  130672. /** Creates a new shared data */
  130673. constructor();
  130674. /**
  130675. * Emits console errors and exceptions if there is a failing check
  130676. */
  130677. emitErrors(): void;
  130678. }
  130679. }
  130680. declare module BABYLON {
  130681. /**
  130682. * Class used to store node based material build state
  130683. */
  130684. export class NodeMaterialBuildState {
  130685. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130686. supportUniformBuffers: boolean;
  130687. /**
  130688. * Gets the list of emitted attributes
  130689. */
  130690. attributes: string[];
  130691. /**
  130692. * Gets the list of emitted uniforms
  130693. */
  130694. uniforms: string[];
  130695. /**
  130696. * Gets the list of emitted constants
  130697. */
  130698. constants: string[];
  130699. /**
  130700. * Gets the list of emitted samplers
  130701. */
  130702. samplers: string[];
  130703. /**
  130704. * Gets the list of emitted functions
  130705. */
  130706. functions: {
  130707. [key: string]: string;
  130708. };
  130709. /**
  130710. * Gets the list of emitted extensions
  130711. */
  130712. extensions: {
  130713. [key: string]: string;
  130714. };
  130715. /**
  130716. * Gets the target of the compilation state
  130717. */
  130718. target: NodeMaterialBlockTargets;
  130719. /**
  130720. * Gets the list of emitted counters
  130721. */
  130722. counters: {
  130723. [key: string]: number;
  130724. };
  130725. /**
  130726. * Shared data between multiple NodeMaterialBuildState instances
  130727. */
  130728. sharedData: NodeMaterialBuildStateSharedData;
  130729. /** @hidden */
  130730. _vertexState: NodeMaterialBuildState;
  130731. /** @hidden */
  130732. _attributeDeclaration: string;
  130733. /** @hidden */
  130734. _uniformDeclaration: string;
  130735. /** @hidden */
  130736. _constantDeclaration: string;
  130737. /** @hidden */
  130738. _samplerDeclaration: string;
  130739. /** @hidden */
  130740. _varyingTransfer: string;
  130741. private _repeatableContentAnchorIndex;
  130742. /** @hidden */
  130743. _builtCompilationString: string;
  130744. /**
  130745. * Gets the emitted compilation strings
  130746. */
  130747. compilationString: string;
  130748. /**
  130749. * Finalize the compilation strings
  130750. * @param state defines the current compilation state
  130751. */
  130752. finalize(state: NodeMaterialBuildState): void;
  130753. /** @hidden */
  130754. get _repeatableContentAnchor(): string;
  130755. /** @hidden */
  130756. _getFreeVariableName(prefix: string): string;
  130757. /** @hidden */
  130758. _getFreeDefineName(prefix: string): string;
  130759. /** @hidden */
  130760. _excludeVariableName(name: string): void;
  130761. /** @hidden */
  130762. _emit2DSampler(name: string): void;
  130763. /** @hidden */
  130764. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130765. /** @hidden */
  130766. _emitExtension(name: string, extension: string): void;
  130767. /** @hidden */
  130768. _emitFunction(name: string, code: string, comments: string): void;
  130769. /** @hidden */
  130770. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130771. replaceStrings?: {
  130772. search: RegExp;
  130773. replace: string;
  130774. }[];
  130775. repeatKey?: string;
  130776. }): string;
  130777. /** @hidden */
  130778. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130779. repeatKey?: string;
  130780. removeAttributes?: boolean;
  130781. removeUniforms?: boolean;
  130782. removeVaryings?: boolean;
  130783. removeIfDef?: boolean;
  130784. replaceStrings?: {
  130785. search: RegExp;
  130786. replace: string;
  130787. }[];
  130788. }, storeKey?: string): void;
  130789. /** @hidden */
  130790. _registerTempVariable(name: string): boolean;
  130791. /** @hidden */
  130792. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130793. /** @hidden */
  130794. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130795. /** @hidden */
  130796. _emitFloat(value: number): string;
  130797. }
  130798. }
  130799. declare module BABYLON {
  130800. /**
  130801. * Defines a block that can be used inside a node based material
  130802. */
  130803. export class NodeMaterialBlock {
  130804. private _buildId;
  130805. private _buildTarget;
  130806. private _target;
  130807. private _isFinalMerger;
  130808. private _isInput;
  130809. protected _isUnique: boolean;
  130810. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130811. inputsAreExclusive: boolean;
  130812. /** @hidden */
  130813. _codeVariableName: string;
  130814. /** @hidden */
  130815. _inputs: NodeMaterialConnectionPoint[];
  130816. /** @hidden */
  130817. _outputs: NodeMaterialConnectionPoint[];
  130818. /** @hidden */
  130819. _preparationId: number;
  130820. /**
  130821. * Gets or sets the name of the block
  130822. */
  130823. name: string;
  130824. /**
  130825. * Gets or sets the unique id of the node
  130826. */
  130827. uniqueId: number;
  130828. /**
  130829. * Gets or sets the comments associated with this block
  130830. */
  130831. comments: string;
  130832. /**
  130833. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130834. */
  130835. get isUnique(): boolean;
  130836. /**
  130837. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130838. */
  130839. get isFinalMerger(): boolean;
  130840. /**
  130841. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130842. */
  130843. get isInput(): boolean;
  130844. /**
  130845. * Gets or sets the build Id
  130846. */
  130847. get buildId(): number;
  130848. set buildId(value: number);
  130849. /**
  130850. * Gets or sets the target of the block
  130851. */
  130852. get target(): NodeMaterialBlockTargets;
  130853. set target(value: NodeMaterialBlockTargets);
  130854. /**
  130855. * Gets the list of input points
  130856. */
  130857. get inputs(): NodeMaterialConnectionPoint[];
  130858. /** Gets the list of output points */
  130859. get outputs(): NodeMaterialConnectionPoint[];
  130860. /**
  130861. * Find an input by its name
  130862. * @param name defines the name of the input to look for
  130863. * @returns the input or null if not found
  130864. */
  130865. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130866. /**
  130867. * Find an output by its name
  130868. * @param name defines the name of the outputto look for
  130869. * @returns the output or null if not found
  130870. */
  130871. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130872. /**
  130873. * Creates a new NodeMaterialBlock
  130874. * @param name defines the block name
  130875. * @param target defines the target of that block (Vertex by default)
  130876. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130877. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130878. */
  130879. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130880. /**
  130881. * Initialize the block and prepare the context for build
  130882. * @param state defines the state that will be used for the build
  130883. */
  130884. initialize(state: NodeMaterialBuildState): void;
  130885. /**
  130886. * Bind data to effect. Will only be called for blocks with isBindable === true
  130887. * @param effect defines the effect to bind data to
  130888. * @param nodeMaterial defines the hosting NodeMaterial
  130889. * @param mesh defines the mesh that will be rendered
  130890. */
  130891. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130892. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130893. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130894. protected _writeFloat(value: number): string;
  130895. /**
  130896. * Gets the current class name e.g. "NodeMaterialBlock"
  130897. * @returns the class name
  130898. */
  130899. getClassName(): string;
  130900. /**
  130901. * Register a new input. Must be called inside a block constructor
  130902. * @param name defines the connection point name
  130903. * @param type defines the connection point type
  130904. * @param isOptional defines a boolean indicating that this input can be omitted
  130905. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130906. * @returns the current block
  130907. */
  130908. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130909. /**
  130910. * Register a new output. Must be called inside a block constructor
  130911. * @param name defines the connection point name
  130912. * @param type defines the connection point type
  130913. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130914. * @returns the current block
  130915. */
  130916. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130917. /**
  130918. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130919. * @param forOutput defines an optional connection point to check compatibility with
  130920. * @returns the first available input or null
  130921. */
  130922. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130923. /**
  130924. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130925. * @param forBlock defines an optional block to check compatibility with
  130926. * @returns the first available input or null
  130927. */
  130928. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130929. /**
  130930. * Gets the sibling of the given output
  130931. * @param current defines the current output
  130932. * @returns the next output in the list or null
  130933. */
  130934. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130935. /**
  130936. * Connect current block with another block
  130937. * @param other defines the block to connect with
  130938. * @param options define the various options to help pick the right connections
  130939. * @returns the current block
  130940. */
  130941. connectTo(other: NodeMaterialBlock, options?: {
  130942. input?: string;
  130943. output?: string;
  130944. outputSwizzle?: string;
  130945. }): this | undefined;
  130946. protected _buildBlock(state: NodeMaterialBuildState): void;
  130947. /**
  130948. * Add uniforms, samplers and uniform buffers at compilation time
  130949. * @param state defines the state to update
  130950. * @param nodeMaterial defines the node material requesting the update
  130951. * @param defines defines the material defines to update
  130952. * @param uniformBuffers defines the list of uniform buffer names
  130953. */
  130954. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130955. /**
  130956. * Add potential fallbacks if shader compilation fails
  130957. * @param mesh defines the mesh to be rendered
  130958. * @param fallbacks defines the current prioritized list of fallbacks
  130959. */
  130960. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130961. /**
  130962. * Initialize defines for shader compilation
  130963. * @param mesh defines the mesh to be rendered
  130964. * @param nodeMaterial defines the node material requesting the update
  130965. * @param defines defines the material defines to update
  130966. * @param useInstances specifies that instances should be used
  130967. */
  130968. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130969. /**
  130970. * Update defines for shader compilation
  130971. * @param mesh defines the mesh to be rendered
  130972. * @param nodeMaterial defines the node material requesting the update
  130973. * @param defines defines the material defines to update
  130974. * @param useInstances specifies that instances should be used
  130975. */
  130976. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130977. /**
  130978. * Lets the block try to connect some inputs automatically
  130979. * @param material defines the hosting NodeMaterial
  130980. */
  130981. autoConfigure(material: NodeMaterial): void;
  130982. /**
  130983. * Function called when a block is declared as repeatable content generator
  130984. * @param vertexShaderState defines the current compilation state for the vertex shader
  130985. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130986. * @param mesh defines the mesh to be rendered
  130987. * @param defines defines the material defines to update
  130988. */
  130989. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130990. /**
  130991. * Checks if the block is ready
  130992. * @param mesh defines the mesh to be rendered
  130993. * @param nodeMaterial defines the node material requesting the update
  130994. * @param defines defines the material defines to update
  130995. * @param useInstances specifies that instances should be used
  130996. * @returns true if the block is ready
  130997. */
  130998. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130999. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131000. private _processBuild;
  131001. /**
  131002. * Compile the current node and generate the shader code
  131003. * @param state defines the current compilation state (uniforms, samplers, current string)
  131004. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131005. * @returns true if already built
  131006. */
  131007. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131008. protected _inputRename(name: string): string;
  131009. protected _outputRename(name: string): string;
  131010. protected _dumpPropertiesCode(): string;
  131011. /** @hidden */
  131012. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131013. /** @hidden */
  131014. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131015. /**
  131016. * Clone the current block to a new identical block
  131017. * @param scene defines the hosting scene
  131018. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131019. * @returns a copy of the current block
  131020. */
  131021. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131022. /**
  131023. * Serializes this block in a JSON representation
  131024. * @returns the serialized block object
  131025. */
  131026. serialize(): any;
  131027. /** @hidden */
  131028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131029. /**
  131030. * Release resources
  131031. */
  131032. dispose(): void;
  131033. }
  131034. }
  131035. declare module BABYLON {
  131036. /**
  131037. * Enum defining the type of animations supported by InputBlock
  131038. */
  131039. export enum AnimatedInputBlockTypes {
  131040. /** No animation */
  131041. None = 0,
  131042. /** Time based animation. Will only work for floats */
  131043. Time = 1
  131044. }
  131045. }
  131046. declare module BABYLON {
  131047. /**
  131048. * Block used to expose an input value
  131049. */
  131050. export class InputBlock extends NodeMaterialBlock {
  131051. private _mode;
  131052. private _associatedVariableName;
  131053. private _storedValue;
  131054. private _valueCallback;
  131055. private _type;
  131056. private _animationType;
  131057. /** Gets or set a value used to limit the range of float values */
  131058. min: number;
  131059. /** Gets or set a value used to limit the range of float values */
  131060. max: number;
  131061. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131062. isBoolean: boolean;
  131063. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131064. matrixMode: number;
  131065. /** @hidden */
  131066. _systemValue: Nullable<NodeMaterialSystemValues>;
  131067. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131068. visibleInInspector: boolean;
  131069. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131070. isConstant: boolean;
  131071. /** Gets or sets the group to use to display this block in the Inspector */
  131072. groupInInspector: string;
  131073. /**
  131074. * Gets or sets the connection point type (default is float)
  131075. */
  131076. get type(): NodeMaterialBlockConnectionPointTypes;
  131077. /**
  131078. * Creates a new InputBlock
  131079. * @param name defines the block name
  131080. * @param target defines the target of that block (Vertex by default)
  131081. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131082. */
  131083. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131084. /**
  131085. * Gets the output component
  131086. */
  131087. get output(): NodeMaterialConnectionPoint;
  131088. /**
  131089. * Set the source of this connection point to a vertex attribute
  131090. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131091. * @returns the current connection point
  131092. */
  131093. setAsAttribute(attributeName?: string): InputBlock;
  131094. /**
  131095. * Set the source of this connection point to a system value
  131096. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131097. * @returns the current connection point
  131098. */
  131099. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131100. /**
  131101. * Gets or sets the value of that point.
  131102. * Please note that this value will be ignored if valueCallback is defined
  131103. */
  131104. get value(): any;
  131105. set value(value: any);
  131106. /**
  131107. * Gets or sets a callback used to get the value of that point.
  131108. * Please note that setting this value will force the connection point to ignore the value property
  131109. */
  131110. get valueCallback(): () => any;
  131111. set valueCallback(value: () => any);
  131112. /**
  131113. * Gets or sets the associated variable name in the shader
  131114. */
  131115. get associatedVariableName(): string;
  131116. set associatedVariableName(value: string);
  131117. /** Gets or sets the type of animation applied to the input */
  131118. get animationType(): AnimatedInputBlockTypes;
  131119. set animationType(value: AnimatedInputBlockTypes);
  131120. /**
  131121. * Gets a boolean indicating that this connection point not defined yet
  131122. */
  131123. get isUndefined(): boolean;
  131124. /**
  131125. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131126. * In this case the connection point name must be the name of the uniform to use.
  131127. * Can only be set on inputs
  131128. */
  131129. get isUniform(): boolean;
  131130. set isUniform(value: boolean);
  131131. /**
  131132. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131133. * In this case the connection point name must be the name of the attribute to use
  131134. * Can only be set on inputs
  131135. */
  131136. get isAttribute(): boolean;
  131137. set isAttribute(value: boolean);
  131138. /**
  131139. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131140. * Can only be set on exit points
  131141. */
  131142. get isVarying(): boolean;
  131143. set isVarying(value: boolean);
  131144. /**
  131145. * Gets a boolean indicating that the current connection point is a system value
  131146. */
  131147. get isSystemValue(): boolean;
  131148. /**
  131149. * Gets or sets the current well known value or null if not defined as a system value
  131150. */
  131151. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131152. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131153. /**
  131154. * Gets the current class name
  131155. * @returns the class name
  131156. */
  131157. getClassName(): string;
  131158. /**
  131159. * Animate the input if animationType !== None
  131160. * @param scene defines the rendering scene
  131161. */
  131162. animate(scene: Scene): void;
  131163. private _emitDefine;
  131164. initialize(state: NodeMaterialBuildState): void;
  131165. /**
  131166. * Set the input block to its default value (based on its type)
  131167. */
  131168. setDefaultValue(): void;
  131169. private _emitConstant;
  131170. private _emit;
  131171. /** @hidden */
  131172. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131173. /** @hidden */
  131174. _transmit(effect: Effect, scene: Scene): void;
  131175. protected _buildBlock(state: NodeMaterialBuildState): void;
  131176. protected _dumpPropertiesCode(): string;
  131177. serialize(): any;
  131178. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131179. }
  131180. }
  131181. declare module BABYLON {
  131182. /**
  131183. * Enum used to define the compatibility state between two connection points
  131184. */
  131185. export enum NodeMaterialConnectionPointCompatibilityStates {
  131186. /** Points are compatibles */
  131187. Compatible = 0,
  131188. /** Points are incompatible because of their types */
  131189. TypeIncompatible = 1,
  131190. /** Points are incompatible because of their targets (vertex vs fragment) */
  131191. TargetIncompatible = 2
  131192. }
  131193. /**
  131194. * Defines the direction of a connection point
  131195. */
  131196. export enum NodeMaterialConnectionPointDirection {
  131197. /** Input */
  131198. Input = 0,
  131199. /** Output */
  131200. Output = 1
  131201. }
  131202. /**
  131203. * Defines a connection point for a block
  131204. */
  131205. export class NodeMaterialConnectionPoint {
  131206. /** @hidden */
  131207. _ownerBlock: NodeMaterialBlock;
  131208. /** @hidden */
  131209. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131210. private _endpoints;
  131211. private _associatedVariableName;
  131212. private _direction;
  131213. /** @hidden */
  131214. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131215. /** @hidden */
  131216. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131217. private _type;
  131218. /** @hidden */
  131219. _enforceAssociatedVariableName: boolean;
  131220. /** Gets the direction of the point */
  131221. get direction(): NodeMaterialConnectionPointDirection;
  131222. /**
  131223. * Gets or sets the additional types supported by this connection point
  131224. */
  131225. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131226. /**
  131227. * Gets or sets the additional types excluded by this connection point
  131228. */
  131229. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131230. /**
  131231. * Observable triggered when this point is connected
  131232. */
  131233. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131234. /**
  131235. * Gets or sets the associated variable name in the shader
  131236. */
  131237. get associatedVariableName(): string;
  131238. set associatedVariableName(value: string);
  131239. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  131240. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131241. /**
  131242. * Gets or sets the connection point type (default is float)
  131243. */
  131244. get type(): NodeMaterialBlockConnectionPointTypes;
  131245. set type(value: NodeMaterialBlockConnectionPointTypes);
  131246. /**
  131247. * Gets or sets the connection point name
  131248. */
  131249. name: string;
  131250. /**
  131251. * Gets or sets a boolean indicating that this connection point can be omitted
  131252. */
  131253. isOptional: boolean;
  131254. /**
  131255. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131256. */
  131257. define: string;
  131258. /** @hidden */
  131259. _prioritizeVertex: boolean;
  131260. private _target;
  131261. /** Gets or sets the target of that connection point */
  131262. get target(): NodeMaterialBlockTargets;
  131263. set target(value: NodeMaterialBlockTargets);
  131264. /**
  131265. * Gets a boolean indicating that the current point is connected
  131266. */
  131267. get isConnected(): boolean;
  131268. /**
  131269. * Gets a boolean indicating that the current point is connected to an input block
  131270. */
  131271. get isConnectedToInputBlock(): boolean;
  131272. /**
  131273. * Gets a the connected input block (if any)
  131274. */
  131275. get connectInputBlock(): Nullable<InputBlock>;
  131276. /** Get the other side of the connection (if any) */
  131277. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131278. /** Get the block that owns this connection point */
  131279. get ownerBlock(): NodeMaterialBlock;
  131280. /** Get the block connected on the other side of this connection (if any) */
  131281. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131282. /** Get the block connected on the endpoints of this connection (if any) */
  131283. get connectedBlocks(): Array<NodeMaterialBlock>;
  131284. /** Gets the list of connected endpoints */
  131285. get endpoints(): NodeMaterialConnectionPoint[];
  131286. /** Gets a boolean indicating if that output point is connected to at least one input */
  131287. get hasEndpoints(): boolean;
  131288. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131289. get isConnectedInVertexShader(): boolean;
  131290. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131291. get isConnectedInFragmentShader(): boolean;
  131292. /**
  131293. * Creates a new connection point
  131294. * @param name defines the connection point name
  131295. * @param ownerBlock defines the block hosting this connection point
  131296. * @param direction defines the direction of the connection point
  131297. */
  131298. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131299. /**
  131300. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131301. * @returns the class name
  131302. */
  131303. getClassName(): string;
  131304. /**
  131305. * Gets a boolean indicating if the current point can be connected to another point
  131306. * @param connectionPoint defines the other connection point
  131307. * @returns a boolean
  131308. */
  131309. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131310. /**
  131311. * Gets a number indicating if the current point can be connected to another point
  131312. * @param connectionPoint defines the other connection point
  131313. * @returns a number defining the compatibility state
  131314. */
  131315. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131316. /**
  131317. * Connect this point to another connection point
  131318. * @param connectionPoint defines the other connection point
  131319. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131320. * @returns the current connection point
  131321. */
  131322. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131323. /**
  131324. * Disconnect this point from one of his endpoint
  131325. * @param endpoint defines the other connection point
  131326. * @returns the current connection point
  131327. */
  131328. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131329. /**
  131330. * Serializes this point in a JSON representation
  131331. * @returns the serialized point object
  131332. */
  131333. serialize(): any;
  131334. /**
  131335. * Release resources
  131336. */
  131337. dispose(): void;
  131338. }
  131339. }
  131340. declare module BABYLON {
  131341. /**
  131342. * Block used to add support for vertex skinning (bones)
  131343. */
  131344. export class BonesBlock extends NodeMaterialBlock {
  131345. /**
  131346. * Creates a new BonesBlock
  131347. * @param name defines the block name
  131348. */
  131349. constructor(name: string);
  131350. /**
  131351. * Initialize the block and prepare the context for build
  131352. * @param state defines the state that will be used for the build
  131353. */
  131354. initialize(state: NodeMaterialBuildState): void;
  131355. /**
  131356. * Gets the current class name
  131357. * @returns the class name
  131358. */
  131359. getClassName(): string;
  131360. /**
  131361. * Gets the matrix indices input component
  131362. */
  131363. get matricesIndices(): NodeMaterialConnectionPoint;
  131364. /**
  131365. * Gets the matrix weights input component
  131366. */
  131367. get matricesWeights(): NodeMaterialConnectionPoint;
  131368. /**
  131369. * Gets the extra matrix indices input component
  131370. */
  131371. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131372. /**
  131373. * Gets the extra matrix weights input component
  131374. */
  131375. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131376. /**
  131377. * Gets the world input component
  131378. */
  131379. get world(): NodeMaterialConnectionPoint;
  131380. /**
  131381. * Gets the output component
  131382. */
  131383. get output(): NodeMaterialConnectionPoint;
  131384. autoConfigure(material: NodeMaterial): void;
  131385. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131388. protected _buildBlock(state: NodeMaterialBuildState): this;
  131389. }
  131390. }
  131391. declare module BABYLON {
  131392. /**
  131393. * Block used to add support for instances
  131394. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131395. */
  131396. export class InstancesBlock extends NodeMaterialBlock {
  131397. /**
  131398. * Creates a new InstancesBlock
  131399. * @param name defines the block name
  131400. */
  131401. constructor(name: string);
  131402. /**
  131403. * Gets the current class name
  131404. * @returns the class name
  131405. */
  131406. getClassName(): string;
  131407. /**
  131408. * Gets the first world row input component
  131409. */
  131410. get world0(): NodeMaterialConnectionPoint;
  131411. /**
  131412. * Gets the second world row input component
  131413. */
  131414. get world1(): NodeMaterialConnectionPoint;
  131415. /**
  131416. * Gets the third world row input component
  131417. */
  131418. get world2(): NodeMaterialConnectionPoint;
  131419. /**
  131420. * Gets the forth world row input component
  131421. */
  131422. get world3(): NodeMaterialConnectionPoint;
  131423. /**
  131424. * Gets the world input component
  131425. */
  131426. get world(): NodeMaterialConnectionPoint;
  131427. /**
  131428. * Gets the output component
  131429. */
  131430. get output(): NodeMaterialConnectionPoint;
  131431. /**
  131432. * Gets the isntanceID component
  131433. */
  131434. get instanceID(): NodeMaterialConnectionPoint;
  131435. autoConfigure(material: NodeMaterial): void;
  131436. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131437. protected _buildBlock(state: NodeMaterialBuildState): this;
  131438. }
  131439. }
  131440. declare module BABYLON {
  131441. /**
  131442. * Block used to add morph targets support to vertex shader
  131443. */
  131444. export class MorphTargetsBlock extends NodeMaterialBlock {
  131445. private _repeatableContentAnchor;
  131446. /**
  131447. * Create a new MorphTargetsBlock
  131448. * @param name defines the block name
  131449. */
  131450. constructor(name: string);
  131451. /**
  131452. * Gets the current class name
  131453. * @returns the class name
  131454. */
  131455. getClassName(): string;
  131456. /**
  131457. * Gets the position input component
  131458. */
  131459. get position(): NodeMaterialConnectionPoint;
  131460. /**
  131461. * Gets the normal input component
  131462. */
  131463. get normal(): NodeMaterialConnectionPoint;
  131464. /**
  131465. * Gets the tangent input component
  131466. */
  131467. get tangent(): NodeMaterialConnectionPoint;
  131468. /**
  131469. * Gets the tangent input component
  131470. */
  131471. get uv(): NodeMaterialConnectionPoint;
  131472. /**
  131473. * Gets the position output component
  131474. */
  131475. get positionOutput(): NodeMaterialConnectionPoint;
  131476. /**
  131477. * Gets the normal output component
  131478. */
  131479. get normalOutput(): NodeMaterialConnectionPoint;
  131480. /**
  131481. * Gets the tangent output component
  131482. */
  131483. get tangentOutput(): NodeMaterialConnectionPoint;
  131484. /**
  131485. * Gets the tangent output component
  131486. */
  131487. get uvOutput(): NodeMaterialConnectionPoint;
  131488. initialize(state: NodeMaterialBuildState): void;
  131489. autoConfigure(material: NodeMaterial): void;
  131490. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131491. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131492. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131493. protected _buildBlock(state: NodeMaterialBuildState): this;
  131494. }
  131495. }
  131496. declare module BABYLON {
  131497. /**
  131498. * Block used to get data information from a light
  131499. */
  131500. export class LightInformationBlock extends NodeMaterialBlock {
  131501. private _lightDataUniformName;
  131502. private _lightColorUniformName;
  131503. private _lightTypeDefineName;
  131504. /**
  131505. * Gets or sets the light associated with this block
  131506. */
  131507. light: Nullable<Light>;
  131508. /**
  131509. * Creates a new LightInformationBlock
  131510. * @param name defines the block name
  131511. */
  131512. constructor(name: string);
  131513. /**
  131514. * Gets the current class name
  131515. * @returns the class name
  131516. */
  131517. getClassName(): string;
  131518. /**
  131519. * Gets the world position input component
  131520. */
  131521. get worldPosition(): NodeMaterialConnectionPoint;
  131522. /**
  131523. * Gets the direction output component
  131524. */
  131525. get direction(): NodeMaterialConnectionPoint;
  131526. /**
  131527. * Gets the direction output component
  131528. */
  131529. get color(): NodeMaterialConnectionPoint;
  131530. /**
  131531. * Gets the direction output component
  131532. */
  131533. get intensity(): NodeMaterialConnectionPoint;
  131534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131536. protected _buildBlock(state: NodeMaterialBuildState): this;
  131537. serialize(): any;
  131538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131539. }
  131540. }
  131541. declare module BABYLON {
  131542. /**
  131543. * Block used to add image processing support to fragment shader
  131544. */
  131545. export class ImageProcessingBlock extends NodeMaterialBlock {
  131546. /**
  131547. * Create a new ImageProcessingBlock
  131548. * @param name defines the block name
  131549. */
  131550. constructor(name: string);
  131551. /**
  131552. * Gets the current class name
  131553. * @returns the class name
  131554. */
  131555. getClassName(): string;
  131556. /**
  131557. * Gets the color input component
  131558. */
  131559. get color(): NodeMaterialConnectionPoint;
  131560. /**
  131561. * Gets the output component
  131562. */
  131563. get output(): NodeMaterialConnectionPoint;
  131564. /**
  131565. * Initialize the block and prepare the context for build
  131566. * @param state defines the state that will be used for the build
  131567. */
  131568. initialize(state: NodeMaterialBuildState): void;
  131569. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131571. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131572. protected _buildBlock(state: NodeMaterialBuildState): this;
  131573. }
  131574. }
  131575. declare module BABYLON {
  131576. /**
  131577. * Block used to pertub normals based on a normal map
  131578. */
  131579. export class PerturbNormalBlock extends NodeMaterialBlock {
  131580. private _tangentSpaceParameterName;
  131581. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131582. invertX: boolean;
  131583. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131584. invertY: boolean;
  131585. /**
  131586. * Create a new PerturbNormalBlock
  131587. * @param name defines the block name
  131588. */
  131589. constructor(name: string);
  131590. /**
  131591. * Gets the current class name
  131592. * @returns the class name
  131593. */
  131594. getClassName(): string;
  131595. /**
  131596. * Gets the world position input component
  131597. */
  131598. get worldPosition(): NodeMaterialConnectionPoint;
  131599. /**
  131600. * Gets the world normal input component
  131601. */
  131602. get worldNormal(): NodeMaterialConnectionPoint;
  131603. /**
  131604. * Gets the world tangent input component
  131605. */
  131606. get worldTangent(): NodeMaterialConnectionPoint;
  131607. /**
  131608. * Gets the uv input component
  131609. */
  131610. get uv(): NodeMaterialConnectionPoint;
  131611. /**
  131612. * Gets the normal map color input component
  131613. */
  131614. get normalMapColor(): NodeMaterialConnectionPoint;
  131615. /**
  131616. * Gets the strength input component
  131617. */
  131618. get strength(): NodeMaterialConnectionPoint;
  131619. /**
  131620. * Gets the output component
  131621. */
  131622. get output(): NodeMaterialConnectionPoint;
  131623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131624. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131625. autoConfigure(material: NodeMaterial): void;
  131626. protected _buildBlock(state: NodeMaterialBuildState): this;
  131627. protected _dumpPropertiesCode(): string;
  131628. serialize(): any;
  131629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131630. }
  131631. }
  131632. declare module BABYLON {
  131633. /**
  131634. * Block used to discard a pixel if a value is smaller than a cutoff
  131635. */
  131636. export class DiscardBlock extends NodeMaterialBlock {
  131637. /**
  131638. * Create a new DiscardBlock
  131639. * @param name defines the block name
  131640. */
  131641. constructor(name: string);
  131642. /**
  131643. * Gets the current class name
  131644. * @returns the class name
  131645. */
  131646. getClassName(): string;
  131647. /**
  131648. * Gets the color input component
  131649. */
  131650. get value(): NodeMaterialConnectionPoint;
  131651. /**
  131652. * Gets the cutoff input component
  131653. */
  131654. get cutoff(): NodeMaterialConnectionPoint;
  131655. protected _buildBlock(state: NodeMaterialBuildState): this;
  131656. }
  131657. }
  131658. declare module BABYLON {
  131659. /**
  131660. * Block used to test if the fragment shader is front facing
  131661. */
  131662. export class FrontFacingBlock extends NodeMaterialBlock {
  131663. /**
  131664. * Creates a new FrontFacingBlock
  131665. * @param name defines the block name
  131666. */
  131667. constructor(name: string);
  131668. /**
  131669. * Gets the current class name
  131670. * @returns the class name
  131671. */
  131672. getClassName(): string;
  131673. /**
  131674. * Gets the output component
  131675. */
  131676. get output(): NodeMaterialConnectionPoint;
  131677. protected _buildBlock(state: NodeMaterialBuildState): this;
  131678. }
  131679. }
  131680. declare module BABYLON {
  131681. /**
  131682. * Block used to get the derivative value on x and y of a given input
  131683. */
  131684. export class DerivativeBlock extends NodeMaterialBlock {
  131685. /**
  131686. * Create a new DerivativeBlock
  131687. * @param name defines the block name
  131688. */
  131689. constructor(name: string);
  131690. /**
  131691. * Gets the current class name
  131692. * @returns the class name
  131693. */
  131694. getClassName(): string;
  131695. /**
  131696. * Gets the input component
  131697. */
  131698. get input(): NodeMaterialConnectionPoint;
  131699. /**
  131700. * Gets the derivative output on x
  131701. */
  131702. get dx(): NodeMaterialConnectionPoint;
  131703. /**
  131704. * Gets the derivative output on y
  131705. */
  131706. get dy(): NodeMaterialConnectionPoint;
  131707. protected _buildBlock(state: NodeMaterialBuildState): this;
  131708. }
  131709. }
  131710. declare module BABYLON {
  131711. /**
  131712. * Block used to add support for scene fog
  131713. */
  131714. export class FogBlock extends NodeMaterialBlock {
  131715. private _fogDistanceName;
  131716. private _fogParameters;
  131717. /**
  131718. * Create a new FogBlock
  131719. * @param name defines the block name
  131720. */
  131721. constructor(name: string);
  131722. /**
  131723. * Gets the current class name
  131724. * @returns the class name
  131725. */
  131726. getClassName(): string;
  131727. /**
  131728. * Gets the world position input component
  131729. */
  131730. get worldPosition(): NodeMaterialConnectionPoint;
  131731. /**
  131732. * Gets the view input component
  131733. */
  131734. get view(): NodeMaterialConnectionPoint;
  131735. /**
  131736. * Gets the color input component
  131737. */
  131738. get input(): NodeMaterialConnectionPoint;
  131739. /**
  131740. * Gets the fog color input component
  131741. */
  131742. get fogColor(): NodeMaterialConnectionPoint;
  131743. /**
  131744. * Gets the output component
  131745. */
  131746. get output(): NodeMaterialConnectionPoint;
  131747. autoConfigure(material: NodeMaterial): void;
  131748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131750. protected _buildBlock(state: NodeMaterialBuildState): this;
  131751. }
  131752. }
  131753. declare module BABYLON {
  131754. /**
  131755. * Block used to add light in the fragment shader
  131756. */
  131757. export class LightBlock extends NodeMaterialBlock {
  131758. private _lightId;
  131759. /**
  131760. * Gets or sets the light associated with this block
  131761. */
  131762. light: Nullable<Light>;
  131763. /**
  131764. * Create a new LightBlock
  131765. * @param name defines the block name
  131766. */
  131767. constructor(name: string);
  131768. /**
  131769. * Gets the current class name
  131770. * @returns the class name
  131771. */
  131772. getClassName(): string;
  131773. /**
  131774. * Gets the world position input component
  131775. */
  131776. get worldPosition(): NodeMaterialConnectionPoint;
  131777. /**
  131778. * Gets the world normal input component
  131779. */
  131780. get worldNormal(): NodeMaterialConnectionPoint;
  131781. /**
  131782. * Gets the camera (or eye) position component
  131783. */
  131784. get cameraPosition(): NodeMaterialConnectionPoint;
  131785. /**
  131786. * Gets the glossiness component
  131787. */
  131788. get glossiness(): NodeMaterialConnectionPoint;
  131789. /**
  131790. * Gets the glossinness power component
  131791. */
  131792. get glossPower(): NodeMaterialConnectionPoint;
  131793. /**
  131794. * Gets the diffuse color component
  131795. */
  131796. get diffuseColor(): NodeMaterialConnectionPoint;
  131797. /**
  131798. * Gets the specular color component
  131799. */
  131800. get specularColor(): NodeMaterialConnectionPoint;
  131801. /**
  131802. * Gets the diffuse output component
  131803. */
  131804. get diffuseOutput(): NodeMaterialConnectionPoint;
  131805. /**
  131806. * Gets the specular output component
  131807. */
  131808. get specularOutput(): NodeMaterialConnectionPoint;
  131809. /**
  131810. * Gets the shadow output component
  131811. */
  131812. get shadow(): NodeMaterialConnectionPoint;
  131813. autoConfigure(material: NodeMaterial): void;
  131814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131815. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131817. private _injectVertexCode;
  131818. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131819. serialize(): any;
  131820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131821. }
  131822. }
  131823. declare module BABYLON {
  131824. /**
  131825. * Block used to multiply 2 values
  131826. */
  131827. export class MultiplyBlock extends NodeMaterialBlock {
  131828. /**
  131829. * Creates a new MultiplyBlock
  131830. * @param name defines the block name
  131831. */
  131832. constructor(name: string);
  131833. /**
  131834. * Gets the current class name
  131835. * @returns the class name
  131836. */
  131837. getClassName(): string;
  131838. /**
  131839. * Gets the left operand input component
  131840. */
  131841. get left(): NodeMaterialConnectionPoint;
  131842. /**
  131843. * Gets the right operand input component
  131844. */
  131845. get right(): NodeMaterialConnectionPoint;
  131846. /**
  131847. * Gets the output component
  131848. */
  131849. get output(): NodeMaterialConnectionPoint;
  131850. protected _buildBlock(state: NodeMaterialBuildState): this;
  131851. }
  131852. }
  131853. declare module BABYLON {
  131854. /**
  131855. * Block used to add 2 vectors
  131856. */
  131857. export class AddBlock extends NodeMaterialBlock {
  131858. /**
  131859. * Creates a new AddBlock
  131860. * @param name defines the block name
  131861. */
  131862. constructor(name: string);
  131863. /**
  131864. * Gets the current class name
  131865. * @returns the class name
  131866. */
  131867. getClassName(): string;
  131868. /**
  131869. * Gets the left operand input component
  131870. */
  131871. get left(): NodeMaterialConnectionPoint;
  131872. /**
  131873. * Gets the right operand input component
  131874. */
  131875. get right(): NodeMaterialConnectionPoint;
  131876. /**
  131877. * Gets the output component
  131878. */
  131879. get output(): NodeMaterialConnectionPoint;
  131880. protected _buildBlock(state: NodeMaterialBuildState): this;
  131881. }
  131882. }
  131883. declare module BABYLON {
  131884. /**
  131885. * Block used to scale a vector by a float
  131886. */
  131887. export class ScaleBlock extends NodeMaterialBlock {
  131888. /**
  131889. * Creates a new ScaleBlock
  131890. * @param name defines the block name
  131891. */
  131892. constructor(name: string);
  131893. /**
  131894. * Gets the current class name
  131895. * @returns the class name
  131896. */
  131897. getClassName(): string;
  131898. /**
  131899. * Gets the input component
  131900. */
  131901. get input(): NodeMaterialConnectionPoint;
  131902. /**
  131903. * Gets the factor input component
  131904. */
  131905. get factor(): NodeMaterialConnectionPoint;
  131906. /**
  131907. * Gets the output component
  131908. */
  131909. get output(): NodeMaterialConnectionPoint;
  131910. protected _buildBlock(state: NodeMaterialBuildState): this;
  131911. }
  131912. }
  131913. declare module BABYLON {
  131914. /**
  131915. * Block used to clamp a float
  131916. */
  131917. export class ClampBlock extends NodeMaterialBlock {
  131918. /** Gets or sets the minimum range */
  131919. minimum: number;
  131920. /** Gets or sets the maximum range */
  131921. maximum: number;
  131922. /**
  131923. * Creates a new ClampBlock
  131924. * @param name defines the block name
  131925. */
  131926. constructor(name: string);
  131927. /**
  131928. * Gets the current class name
  131929. * @returns the class name
  131930. */
  131931. getClassName(): string;
  131932. /**
  131933. * Gets the value input component
  131934. */
  131935. get value(): NodeMaterialConnectionPoint;
  131936. /**
  131937. * Gets the output component
  131938. */
  131939. get output(): NodeMaterialConnectionPoint;
  131940. protected _buildBlock(state: NodeMaterialBuildState): this;
  131941. protected _dumpPropertiesCode(): string;
  131942. serialize(): any;
  131943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131944. }
  131945. }
  131946. declare module BABYLON {
  131947. /**
  131948. * Block used to apply a cross product between 2 vectors
  131949. */
  131950. export class CrossBlock extends NodeMaterialBlock {
  131951. /**
  131952. * Creates a new CrossBlock
  131953. * @param name defines the block name
  131954. */
  131955. constructor(name: string);
  131956. /**
  131957. * Gets the current class name
  131958. * @returns the class name
  131959. */
  131960. getClassName(): string;
  131961. /**
  131962. * Gets the left operand input component
  131963. */
  131964. get left(): NodeMaterialConnectionPoint;
  131965. /**
  131966. * Gets the right operand input component
  131967. */
  131968. get right(): NodeMaterialConnectionPoint;
  131969. /**
  131970. * Gets the output component
  131971. */
  131972. get output(): NodeMaterialConnectionPoint;
  131973. protected _buildBlock(state: NodeMaterialBuildState): this;
  131974. }
  131975. }
  131976. declare module BABYLON {
  131977. /**
  131978. * Block used to apply a dot product between 2 vectors
  131979. */
  131980. export class DotBlock extends NodeMaterialBlock {
  131981. /**
  131982. * Creates a new DotBlock
  131983. * @param name defines the block name
  131984. */
  131985. constructor(name: string);
  131986. /**
  131987. * Gets the current class name
  131988. * @returns the class name
  131989. */
  131990. getClassName(): string;
  131991. /**
  131992. * Gets the left operand input component
  131993. */
  131994. get left(): NodeMaterialConnectionPoint;
  131995. /**
  131996. * Gets the right operand input component
  131997. */
  131998. get right(): NodeMaterialConnectionPoint;
  131999. /**
  132000. * Gets the output component
  132001. */
  132002. get output(): NodeMaterialConnectionPoint;
  132003. protected _buildBlock(state: NodeMaterialBuildState): this;
  132004. }
  132005. }
  132006. declare module BABYLON {
  132007. /**
  132008. * Block used to remap a float from a range to a new one
  132009. */
  132010. export class RemapBlock extends NodeMaterialBlock {
  132011. /**
  132012. * Gets or sets the source range
  132013. */
  132014. sourceRange: Vector2;
  132015. /**
  132016. * Gets or sets the target range
  132017. */
  132018. targetRange: Vector2;
  132019. /**
  132020. * Creates a new RemapBlock
  132021. * @param name defines the block name
  132022. */
  132023. constructor(name: string);
  132024. /**
  132025. * Gets the current class name
  132026. * @returns the class name
  132027. */
  132028. getClassName(): string;
  132029. /**
  132030. * Gets the input component
  132031. */
  132032. get input(): NodeMaterialConnectionPoint;
  132033. /**
  132034. * Gets the source min input component
  132035. */
  132036. get sourceMin(): NodeMaterialConnectionPoint;
  132037. /**
  132038. * Gets the source max input component
  132039. */
  132040. get sourceMax(): NodeMaterialConnectionPoint;
  132041. /**
  132042. * Gets the target min input component
  132043. */
  132044. get targetMin(): NodeMaterialConnectionPoint;
  132045. /**
  132046. * Gets the target max input component
  132047. */
  132048. get targetMax(): NodeMaterialConnectionPoint;
  132049. /**
  132050. * Gets the output component
  132051. */
  132052. get output(): NodeMaterialConnectionPoint;
  132053. protected _buildBlock(state: NodeMaterialBuildState): this;
  132054. protected _dumpPropertiesCode(): string;
  132055. serialize(): any;
  132056. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132057. }
  132058. }
  132059. declare module BABYLON {
  132060. /**
  132061. * Block used to normalize a vector
  132062. */
  132063. export class NormalizeBlock extends NodeMaterialBlock {
  132064. /**
  132065. * Creates a new NormalizeBlock
  132066. * @param name defines the block name
  132067. */
  132068. constructor(name: string);
  132069. /**
  132070. * Gets the current class name
  132071. * @returns the class name
  132072. */
  132073. getClassName(): string;
  132074. /**
  132075. * Gets the input component
  132076. */
  132077. get input(): NodeMaterialConnectionPoint;
  132078. /**
  132079. * Gets the output component
  132080. */
  132081. get output(): NodeMaterialConnectionPoint;
  132082. protected _buildBlock(state: NodeMaterialBuildState): this;
  132083. }
  132084. }
  132085. declare module BABYLON {
  132086. /**
  132087. * Operations supported by the Trigonometry block
  132088. */
  132089. export enum TrigonometryBlockOperations {
  132090. /** Cos */
  132091. Cos = 0,
  132092. /** Sin */
  132093. Sin = 1,
  132094. /** Abs */
  132095. Abs = 2,
  132096. /** Exp */
  132097. Exp = 3,
  132098. /** Exp2 */
  132099. Exp2 = 4,
  132100. /** Round */
  132101. Round = 5,
  132102. /** Floor */
  132103. Floor = 6,
  132104. /** Ceiling */
  132105. Ceiling = 7,
  132106. /** Square root */
  132107. Sqrt = 8,
  132108. /** Log */
  132109. Log = 9,
  132110. /** Tangent */
  132111. Tan = 10,
  132112. /** Arc tangent */
  132113. ArcTan = 11,
  132114. /** Arc cosinus */
  132115. ArcCos = 12,
  132116. /** Arc sinus */
  132117. ArcSin = 13,
  132118. /** Fraction */
  132119. Fract = 14,
  132120. /** Sign */
  132121. Sign = 15,
  132122. /** To radians (from degrees) */
  132123. Radians = 16,
  132124. /** To degrees (from radians) */
  132125. Degrees = 17
  132126. }
  132127. /**
  132128. * Block used to apply trigonometry operation to floats
  132129. */
  132130. export class TrigonometryBlock extends NodeMaterialBlock {
  132131. /**
  132132. * Gets or sets the operation applied by the block
  132133. */
  132134. operation: TrigonometryBlockOperations;
  132135. /**
  132136. * Creates a new TrigonometryBlock
  132137. * @param name defines the block name
  132138. */
  132139. constructor(name: string);
  132140. /**
  132141. * Gets the current class name
  132142. * @returns the class name
  132143. */
  132144. getClassName(): string;
  132145. /**
  132146. * Gets the input component
  132147. */
  132148. get input(): NodeMaterialConnectionPoint;
  132149. /**
  132150. * Gets the output component
  132151. */
  132152. get output(): NodeMaterialConnectionPoint;
  132153. protected _buildBlock(state: NodeMaterialBuildState): this;
  132154. serialize(): any;
  132155. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132156. protected _dumpPropertiesCode(): string;
  132157. }
  132158. }
  132159. declare module BABYLON {
  132160. /**
  132161. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132162. */
  132163. export class ColorMergerBlock extends NodeMaterialBlock {
  132164. /**
  132165. * Create a new ColorMergerBlock
  132166. * @param name defines the block name
  132167. */
  132168. constructor(name: string);
  132169. /**
  132170. * Gets the current class name
  132171. * @returns the class name
  132172. */
  132173. getClassName(): string;
  132174. /**
  132175. * Gets the rgb component (input)
  132176. */
  132177. get rgbIn(): NodeMaterialConnectionPoint;
  132178. /**
  132179. * Gets the r component (input)
  132180. */
  132181. get r(): NodeMaterialConnectionPoint;
  132182. /**
  132183. * Gets the g component (input)
  132184. */
  132185. get g(): NodeMaterialConnectionPoint;
  132186. /**
  132187. * Gets the b component (input)
  132188. */
  132189. get b(): NodeMaterialConnectionPoint;
  132190. /**
  132191. * Gets the a component (input)
  132192. */
  132193. get a(): NodeMaterialConnectionPoint;
  132194. /**
  132195. * Gets the rgba component (output)
  132196. */
  132197. get rgba(): NodeMaterialConnectionPoint;
  132198. /**
  132199. * Gets the rgb component (output)
  132200. */
  132201. get rgbOut(): NodeMaterialConnectionPoint;
  132202. /**
  132203. * Gets the rgb component (output)
  132204. * @deprecated Please use rgbOut instead.
  132205. */
  132206. get rgb(): NodeMaterialConnectionPoint;
  132207. protected _buildBlock(state: NodeMaterialBuildState): this;
  132208. }
  132209. }
  132210. declare module BABYLON {
  132211. /**
  132212. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132213. */
  132214. export class VectorMergerBlock extends NodeMaterialBlock {
  132215. /**
  132216. * Create a new VectorMergerBlock
  132217. * @param name defines the block name
  132218. */
  132219. constructor(name: string);
  132220. /**
  132221. * Gets the current class name
  132222. * @returns the class name
  132223. */
  132224. getClassName(): string;
  132225. /**
  132226. * Gets the xyz component (input)
  132227. */
  132228. get xyzIn(): NodeMaterialConnectionPoint;
  132229. /**
  132230. * Gets the xy component (input)
  132231. */
  132232. get xyIn(): NodeMaterialConnectionPoint;
  132233. /**
  132234. * Gets the x component (input)
  132235. */
  132236. get x(): NodeMaterialConnectionPoint;
  132237. /**
  132238. * Gets the y component (input)
  132239. */
  132240. get y(): NodeMaterialConnectionPoint;
  132241. /**
  132242. * Gets the z component (input)
  132243. */
  132244. get z(): NodeMaterialConnectionPoint;
  132245. /**
  132246. * Gets the w component (input)
  132247. */
  132248. get w(): NodeMaterialConnectionPoint;
  132249. /**
  132250. * Gets the xyzw component (output)
  132251. */
  132252. get xyzw(): NodeMaterialConnectionPoint;
  132253. /**
  132254. * Gets the xyz component (output)
  132255. */
  132256. get xyzOut(): NodeMaterialConnectionPoint;
  132257. /**
  132258. * Gets the xy component (output)
  132259. */
  132260. get xyOut(): NodeMaterialConnectionPoint;
  132261. /**
  132262. * Gets the xy component (output)
  132263. * @deprecated Please use xyOut instead.
  132264. */
  132265. get xy(): NodeMaterialConnectionPoint;
  132266. /**
  132267. * Gets the xyz component (output)
  132268. * @deprecated Please use xyzOut instead.
  132269. */
  132270. get xyz(): NodeMaterialConnectionPoint;
  132271. protected _buildBlock(state: NodeMaterialBuildState): this;
  132272. }
  132273. }
  132274. declare module BABYLON {
  132275. /**
  132276. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132277. */
  132278. export class ColorSplitterBlock extends NodeMaterialBlock {
  132279. /**
  132280. * Create a new ColorSplitterBlock
  132281. * @param name defines the block name
  132282. */
  132283. constructor(name: string);
  132284. /**
  132285. * Gets the current class name
  132286. * @returns the class name
  132287. */
  132288. getClassName(): string;
  132289. /**
  132290. * Gets the rgba component (input)
  132291. */
  132292. get rgba(): NodeMaterialConnectionPoint;
  132293. /**
  132294. * Gets the rgb component (input)
  132295. */
  132296. get rgbIn(): NodeMaterialConnectionPoint;
  132297. /**
  132298. * Gets the rgb component (output)
  132299. */
  132300. get rgbOut(): NodeMaterialConnectionPoint;
  132301. /**
  132302. * Gets the r component (output)
  132303. */
  132304. get r(): NodeMaterialConnectionPoint;
  132305. /**
  132306. * Gets the g component (output)
  132307. */
  132308. get g(): NodeMaterialConnectionPoint;
  132309. /**
  132310. * Gets the b component (output)
  132311. */
  132312. get b(): NodeMaterialConnectionPoint;
  132313. /**
  132314. * Gets the a component (output)
  132315. */
  132316. get a(): NodeMaterialConnectionPoint;
  132317. protected _inputRename(name: string): string;
  132318. protected _outputRename(name: string): string;
  132319. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132320. }
  132321. }
  132322. declare module BABYLON {
  132323. /**
  132324. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132325. */
  132326. export class VectorSplitterBlock extends NodeMaterialBlock {
  132327. /**
  132328. * Create a new VectorSplitterBlock
  132329. * @param name defines the block name
  132330. */
  132331. constructor(name: string);
  132332. /**
  132333. * Gets the current class name
  132334. * @returns the class name
  132335. */
  132336. getClassName(): string;
  132337. /**
  132338. * Gets the xyzw component (input)
  132339. */
  132340. get xyzw(): NodeMaterialConnectionPoint;
  132341. /**
  132342. * Gets the xyz component (input)
  132343. */
  132344. get xyzIn(): NodeMaterialConnectionPoint;
  132345. /**
  132346. * Gets the xy component (input)
  132347. */
  132348. get xyIn(): NodeMaterialConnectionPoint;
  132349. /**
  132350. * Gets the xyz component (output)
  132351. */
  132352. get xyzOut(): NodeMaterialConnectionPoint;
  132353. /**
  132354. * Gets the xy component (output)
  132355. */
  132356. get xyOut(): NodeMaterialConnectionPoint;
  132357. /**
  132358. * Gets the x component (output)
  132359. */
  132360. get x(): NodeMaterialConnectionPoint;
  132361. /**
  132362. * Gets the y component (output)
  132363. */
  132364. get y(): NodeMaterialConnectionPoint;
  132365. /**
  132366. * Gets the z component (output)
  132367. */
  132368. get z(): NodeMaterialConnectionPoint;
  132369. /**
  132370. * Gets the w component (output)
  132371. */
  132372. get w(): NodeMaterialConnectionPoint;
  132373. protected _inputRename(name: string): string;
  132374. protected _outputRename(name: string): string;
  132375. protected _buildBlock(state: NodeMaterialBuildState): this;
  132376. }
  132377. }
  132378. declare module BABYLON {
  132379. /**
  132380. * Block used to lerp between 2 values
  132381. */
  132382. export class LerpBlock extends NodeMaterialBlock {
  132383. /**
  132384. * Creates a new LerpBlock
  132385. * @param name defines the block name
  132386. */
  132387. constructor(name: string);
  132388. /**
  132389. * Gets the current class name
  132390. * @returns the class name
  132391. */
  132392. getClassName(): string;
  132393. /**
  132394. * Gets the left operand input component
  132395. */
  132396. get left(): NodeMaterialConnectionPoint;
  132397. /**
  132398. * Gets the right operand input component
  132399. */
  132400. get right(): NodeMaterialConnectionPoint;
  132401. /**
  132402. * Gets the gradient operand input component
  132403. */
  132404. get gradient(): NodeMaterialConnectionPoint;
  132405. /**
  132406. * Gets the output component
  132407. */
  132408. get output(): NodeMaterialConnectionPoint;
  132409. protected _buildBlock(state: NodeMaterialBuildState): this;
  132410. }
  132411. }
  132412. declare module BABYLON {
  132413. /**
  132414. * Block used to divide 2 vectors
  132415. */
  132416. export class DivideBlock extends NodeMaterialBlock {
  132417. /**
  132418. * Creates a new DivideBlock
  132419. * @param name defines the block name
  132420. */
  132421. constructor(name: string);
  132422. /**
  132423. * Gets the current class name
  132424. * @returns the class name
  132425. */
  132426. getClassName(): string;
  132427. /**
  132428. * Gets the left operand input component
  132429. */
  132430. get left(): NodeMaterialConnectionPoint;
  132431. /**
  132432. * Gets the right operand input component
  132433. */
  132434. get right(): NodeMaterialConnectionPoint;
  132435. /**
  132436. * Gets the output component
  132437. */
  132438. get output(): NodeMaterialConnectionPoint;
  132439. protected _buildBlock(state: NodeMaterialBuildState): this;
  132440. }
  132441. }
  132442. declare module BABYLON {
  132443. /**
  132444. * Block used to subtract 2 vectors
  132445. */
  132446. export class SubtractBlock extends NodeMaterialBlock {
  132447. /**
  132448. * Creates a new SubtractBlock
  132449. * @param name defines the block name
  132450. */
  132451. constructor(name: string);
  132452. /**
  132453. * Gets the current class name
  132454. * @returns the class name
  132455. */
  132456. getClassName(): string;
  132457. /**
  132458. * Gets the left operand input component
  132459. */
  132460. get left(): NodeMaterialConnectionPoint;
  132461. /**
  132462. * Gets the right operand input component
  132463. */
  132464. get right(): NodeMaterialConnectionPoint;
  132465. /**
  132466. * Gets the output component
  132467. */
  132468. get output(): NodeMaterialConnectionPoint;
  132469. protected _buildBlock(state: NodeMaterialBuildState): this;
  132470. }
  132471. }
  132472. declare module BABYLON {
  132473. /**
  132474. * Block used to step a value
  132475. */
  132476. export class StepBlock extends NodeMaterialBlock {
  132477. /**
  132478. * Creates a new StepBlock
  132479. * @param name defines the block name
  132480. */
  132481. constructor(name: string);
  132482. /**
  132483. * Gets the current class name
  132484. * @returns the class name
  132485. */
  132486. getClassName(): string;
  132487. /**
  132488. * Gets the value operand input component
  132489. */
  132490. get value(): NodeMaterialConnectionPoint;
  132491. /**
  132492. * Gets the edge operand input component
  132493. */
  132494. get edge(): NodeMaterialConnectionPoint;
  132495. /**
  132496. * Gets the output component
  132497. */
  132498. get output(): NodeMaterialConnectionPoint;
  132499. protected _buildBlock(state: NodeMaterialBuildState): this;
  132500. }
  132501. }
  132502. declare module BABYLON {
  132503. /**
  132504. * Block used to get the opposite (1 - x) of a value
  132505. */
  132506. export class OneMinusBlock extends NodeMaterialBlock {
  132507. /**
  132508. * Creates a new OneMinusBlock
  132509. * @param name defines the block name
  132510. */
  132511. constructor(name: string);
  132512. /**
  132513. * Gets the current class name
  132514. * @returns the class name
  132515. */
  132516. getClassName(): string;
  132517. /**
  132518. * Gets the input component
  132519. */
  132520. get input(): NodeMaterialConnectionPoint;
  132521. /**
  132522. * Gets the output component
  132523. */
  132524. get output(): NodeMaterialConnectionPoint;
  132525. protected _buildBlock(state: NodeMaterialBuildState): this;
  132526. }
  132527. }
  132528. declare module BABYLON {
  132529. /**
  132530. * Block used to get the view direction
  132531. */
  132532. export class ViewDirectionBlock extends NodeMaterialBlock {
  132533. /**
  132534. * Creates a new ViewDirectionBlock
  132535. * @param name defines the block name
  132536. */
  132537. constructor(name: string);
  132538. /**
  132539. * Gets the current class name
  132540. * @returns the class name
  132541. */
  132542. getClassName(): string;
  132543. /**
  132544. * Gets the world position component
  132545. */
  132546. get worldPosition(): NodeMaterialConnectionPoint;
  132547. /**
  132548. * Gets the camera position component
  132549. */
  132550. get cameraPosition(): NodeMaterialConnectionPoint;
  132551. /**
  132552. * Gets the output component
  132553. */
  132554. get output(): NodeMaterialConnectionPoint;
  132555. autoConfigure(material: NodeMaterial): void;
  132556. protected _buildBlock(state: NodeMaterialBuildState): this;
  132557. }
  132558. }
  132559. declare module BABYLON {
  132560. /**
  132561. * Block used to compute fresnel value
  132562. */
  132563. export class FresnelBlock extends NodeMaterialBlock {
  132564. /**
  132565. * Create a new FresnelBlock
  132566. * @param name defines the block name
  132567. */
  132568. constructor(name: string);
  132569. /**
  132570. * Gets the current class name
  132571. * @returns the class name
  132572. */
  132573. getClassName(): string;
  132574. /**
  132575. * Gets the world normal input component
  132576. */
  132577. get worldNormal(): NodeMaterialConnectionPoint;
  132578. /**
  132579. * Gets the view direction input component
  132580. */
  132581. get viewDirection(): NodeMaterialConnectionPoint;
  132582. /**
  132583. * Gets the bias input component
  132584. */
  132585. get bias(): NodeMaterialConnectionPoint;
  132586. /**
  132587. * Gets the camera (or eye) position component
  132588. */
  132589. get power(): NodeMaterialConnectionPoint;
  132590. /**
  132591. * Gets the fresnel output component
  132592. */
  132593. get fresnel(): NodeMaterialConnectionPoint;
  132594. autoConfigure(material: NodeMaterial): void;
  132595. protected _buildBlock(state: NodeMaterialBuildState): this;
  132596. }
  132597. }
  132598. declare module BABYLON {
  132599. /**
  132600. * Block used to get the max of 2 values
  132601. */
  132602. export class MaxBlock extends NodeMaterialBlock {
  132603. /**
  132604. * Creates a new MaxBlock
  132605. * @param name defines the block name
  132606. */
  132607. constructor(name: string);
  132608. /**
  132609. * Gets the current class name
  132610. * @returns the class name
  132611. */
  132612. getClassName(): string;
  132613. /**
  132614. * Gets the left operand input component
  132615. */
  132616. get left(): NodeMaterialConnectionPoint;
  132617. /**
  132618. * Gets the right operand input component
  132619. */
  132620. get right(): NodeMaterialConnectionPoint;
  132621. /**
  132622. * Gets the output component
  132623. */
  132624. get output(): NodeMaterialConnectionPoint;
  132625. protected _buildBlock(state: NodeMaterialBuildState): this;
  132626. }
  132627. }
  132628. declare module BABYLON {
  132629. /**
  132630. * Block used to get the min of 2 values
  132631. */
  132632. export class MinBlock extends NodeMaterialBlock {
  132633. /**
  132634. * Creates a new MinBlock
  132635. * @param name defines the block name
  132636. */
  132637. constructor(name: string);
  132638. /**
  132639. * Gets the current class name
  132640. * @returns the class name
  132641. */
  132642. getClassName(): string;
  132643. /**
  132644. * Gets the left operand input component
  132645. */
  132646. get left(): NodeMaterialConnectionPoint;
  132647. /**
  132648. * Gets the right operand input component
  132649. */
  132650. get right(): NodeMaterialConnectionPoint;
  132651. /**
  132652. * Gets the output component
  132653. */
  132654. get output(): NodeMaterialConnectionPoint;
  132655. protected _buildBlock(state: NodeMaterialBuildState): this;
  132656. }
  132657. }
  132658. declare module BABYLON {
  132659. /**
  132660. * Block used to get the distance between 2 values
  132661. */
  132662. export class DistanceBlock extends NodeMaterialBlock {
  132663. /**
  132664. * Creates a new DistanceBlock
  132665. * @param name defines the block name
  132666. */
  132667. constructor(name: string);
  132668. /**
  132669. * Gets the current class name
  132670. * @returns the class name
  132671. */
  132672. getClassName(): string;
  132673. /**
  132674. * Gets the left operand input component
  132675. */
  132676. get left(): NodeMaterialConnectionPoint;
  132677. /**
  132678. * Gets the right operand input component
  132679. */
  132680. get right(): NodeMaterialConnectionPoint;
  132681. /**
  132682. * Gets the output component
  132683. */
  132684. get output(): NodeMaterialConnectionPoint;
  132685. protected _buildBlock(state: NodeMaterialBuildState): this;
  132686. }
  132687. }
  132688. declare module BABYLON {
  132689. /**
  132690. * Block used to get the length of a vector
  132691. */
  132692. export class LengthBlock extends NodeMaterialBlock {
  132693. /**
  132694. * Creates a new LengthBlock
  132695. * @param name defines the block name
  132696. */
  132697. constructor(name: string);
  132698. /**
  132699. * Gets the current class name
  132700. * @returns the class name
  132701. */
  132702. getClassName(): string;
  132703. /**
  132704. * Gets the value input component
  132705. */
  132706. get value(): NodeMaterialConnectionPoint;
  132707. /**
  132708. * Gets the output component
  132709. */
  132710. get output(): NodeMaterialConnectionPoint;
  132711. protected _buildBlock(state: NodeMaterialBuildState): this;
  132712. }
  132713. }
  132714. declare module BABYLON {
  132715. /**
  132716. * Block used to get negative version of a value (i.e. x * -1)
  132717. */
  132718. export class NegateBlock extends NodeMaterialBlock {
  132719. /**
  132720. * Creates a new NegateBlock
  132721. * @param name defines the block name
  132722. */
  132723. constructor(name: string);
  132724. /**
  132725. * Gets the current class name
  132726. * @returns the class name
  132727. */
  132728. getClassName(): string;
  132729. /**
  132730. * Gets the value input component
  132731. */
  132732. get value(): NodeMaterialConnectionPoint;
  132733. /**
  132734. * Gets the output component
  132735. */
  132736. get output(): NodeMaterialConnectionPoint;
  132737. protected _buildBlock(state: NodeMaterialBuildState): this;
  132738. }
  132739. }
  132740. declare module BABYLON {
  132741. /**
  132742. * Block used to get the value of the first parameter raised to the power of the second
  132743. */
  132744. export class PowBlock extends NodeMaterialBlock {
  132745. /**
  132746. * Creates a new PowBlock
  132747. * @param name defines the block name
  132748. */
  132749. constructor(name: string);
  132750. /**
  132751. * Gets the current class name
  132752. * @returns the class name
  132753. */
  132754. getClassName(): string;
  132755. /**
  132756. * Gets the value operand input component
  132757. */
  132758. get value(): NodeMaterialConnectionPoint;
  132759. /**
  132760. * Gets the power operand input component
  132761. */
  132762. get power(): NodeMaterialConnectionPoint;
  132763. /**
  132764. * Gets the output component
  132765. */
  132766. get output(): NodeMaterialConnectionPoint;
  132767. protected _buildBlock(state: NodeMaterialBuildState): this;
  132768. }
  132769. }
  132770. declare module BABYLON {
  132771. /**
  132772. * Block used to get a random number
  132773. */
  132774. export class RandomNumberBlock extends NodeMaterialBlock {
  132775. /**
  132776. * Creates a new RandomNumberBlock
  132777. * @param name defines the block name
  132778. */
  132779. constructor(name: string);
  132780. /**
  132781. * Gets the current class name
  132782. * @returns the class name
  132783. */
  132784. getClassName(): string;
  132785. /**
  132786. * Gets the seed input component
  132787. */
  132788. get seed(): NodeMaterialConnectionPoint;
  132789. /**
  132790. * Gets the output component
  132791. */
  132792. get output(): NodeMaterialConnectionPoint;
  132793. protected _buildBlock(state: NodeMaterialBuildState): this;
  132794. }
  132795. }
  132796. declare module BABYLON {
  132797. /**
  132798. * Block used to compute arc tangent of 2 values
  132799. */
  132800. export class ArcTan2Block extends NodeMaterialBlock {
  132801. /**
  132802. * Creates a new ArcTan2Block
  132803. * @param name defines the block name
  132804. */
  132805. constructor(name: string);
  132806. /**
  132807. * Gets the current class name
  132808. * @returns the class name
  132809. */
  132810. getClassName(): string;
  132811. /**
  132812. * Gets the x operand input component
  132813. */
  132814. get x(): NodeMaterialConnectionPoint;
  132815. /**
  132816. * Gets the y operand input component
  132817. */
  132818. get y(): NodeMaterialConnectionPoint;
  132819. /**
  132820. * Gets the output component
  132821. */
  132822. get output(): NodeMaterialConnectionPoint;
  132823. protected _buildBlock(state: NodeMaterialBuildState): this;
  132824. }
  132825. }
  132826. declare module BABYLON {
  132827. /**
  132828. * Block used to smooth step a value
  132829. */
  132830. export class SmoothStepBlock extends NodeMaterialBlock {
  132831. /**
  132832. * Creates a new SmoothStepBlock
  132833. * @param name defines the block name
  132834. */
  132835. constructor(name: string);
  132836. /**
  132837. * Gets the current class name
  132838. * @returns the class name
  132839. */
  132840. getClassName(): string;
  132841. /**
  132842. * Gets the value operand input component
  132843. */
  132844. get value(): NodeMaterialConnectionPoint;
  132845. /**
  132846. * Gets the first edge operand input component
  132847. */
  132848. get edge0(): NodeMaterialConnectionPoint;
  132849. /**
  132850. * Gets the second edge operand input component
  132851. */
  132852. get edge1(): NodeMaterialConnectionPoint;
  132853. /**
  132854. * Gets the output component
  132855. */
  132856. get output(): NodeMaterialConnectionPoint;
  132857. protected _buildBlock(state: NodeMaterialBuildState): this;
  132858. }
  132859. }
  132860. declare module BABYLON {
  132861. /**
  132862. * Block used to get the reciprocal (1 / x) of a value
  132863. */
  132864. export class ReciprocalBlock extends NodeMaterialBlock {
  132865. /**
  132866. * Creates a new ReciprocalBlock
  132867. * @param name defines the block name
  132868. */
  132869. constructor(name: string);
  132870. /**
  132871. * Gets the current class name
  132872. * @returns the class name
  132873. */
  132874. getClassName(): string;
  132875. /**
  132876. * Gets the input component
  132877. */
  132878. get input(): NodeMaterialConnectionPoint;
  132879. /**
  132880. * Gets the output component
  132881. */
  132882. get output(): NodeMaterialConnectionPoint;
  132883. protected _buildBlock(state: NodeMaterialBuildState): this;
  132884. }
  132885. }
  132886. declare module BABYLON {
  132887. /**
  132888. * Block used to replace a color by another one
  132889. */
  132890. export class ReplaceColorBlock extends NodeMaterialBlock {
  132891. /**
  132892. * Creates a new ReplaceColorBlock
  132893. * @param name defines the block name
  132894. */
  132895. constructor(name: string);
  132896. /**
  132897. * Gets the current class name
  132898. * @returns the class name
  132899. */
  132900. getClassName(): string;
  132901. /**
  132902. * Gets the value input component
  132903. */
  132904. get value(): NodeMaterialConnectionPoint;
  132905. /**
  132906. * Gets the reference input component
  132907. */
  132908. get reference(): NodeMaterialConnectionPoint;
  132909. /**
  132910. * Gets the distance input component
  132911. */
  132912. get distance(): NodeMaterialConnectionPoint;
  132913. /**
  132914. * Gets the replacement input component
  132915. */
  132916. get replacement(): NodeMaterialConnectionPoint;
  132917. /**
  132918. * Gets the output component
  132919. */
  132920. get output(): NodeMaterialConnectionPoint;
  132921. protected _buildBlock(state: NodeMaterialBuildState): this;
  132922. }
  132923. }
  132924. declare module BABYLON {
  132925. /**
  132926. * Block used to posterize a value
  132927. * @see https://en.wikipedia.org/wiki/Posterization
  132928. */
  132929. export class PosterizeBlock extends NodeMaterialBlock {
  132930. /**
  132931. * Creates a new PosterizeBlock
  132932. * @param name defines the block name
  132933. */
  132934. constructor(name: string);
  132935. /**
  132936. * Gets the current class name
  132937. * @returns the class name
  132938. */
  132939. getClassName(): string;
  132940. /**
  132941. * Gets the value input component
  132942. */
  132943. get value(): NodeMaterialConnectionPoint;
  132944. /**
  132945. * Gets the steps input component
  132946. */
  132947. get steps(): NodeMaterialConnectionPoint;
  132948. /**
  132949. * Gets the output component
  132950. */
  132951. get output(): NodeMaterialConnectionPoint;
  132952. protected _buildBlock(state: NodeMaterialBuildState): this;
  132953. }
  132954. }
  132955. declare module BABYLON {
  132956. /**
  132957. * Operations supported by the Wave block
  132958. */
  132959. export enum WaveBlockKind {
  132960. /** SawTooth */
  132961. SawTooth = 0,
  132962. /** Square */
  132963. Square = 1,
  132964. /** Triangle */
  132965. Triangle = 2
  132966. }
  132967. /**
  132968. * Block used to apply wave operation to floats
  132969. */
  132970. export class WaveBlock extends NodeMaterialBlock {
  132971. /**
  132972. * Gets or sets the kibnd of wave to be applied by the block
  132973. */
  132974. kind: WaveBlockKind;
  132975. /**
  132976. * Creates a new WaveBlock
  132977. * @param name defines the block name
  132978. */
  132979. constructor(name: string);
  132980. /**
  132981. * Gets the current class name
  132982. * @returns the class name
  132983. */
  132984. getClassName(): string;
  132985. /**
  132986. * Gets the input component
  132987. */
  132988. get input(): NodeMaterialConnectionPoint;
  132989. /**
  132990. * Gets the output component
  132991. */
  132992. get output(): NodeMaterialConnectionPoint;
  132993. protected _buildBlock(state: NodeMaterialBuildState): this;
  132994. serialize(): any;
  132995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132996. }
  132997. }
  132998. declare module BABYLON {
  132999. /**
  133000. * Class used to store a color step for the GradientBlock
  133001. */
  133002. export class GradientBlockColorStep {
  133003. /**
  133004. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133005. */
  133006. step: number;
  133007. /**
  133008. * Gets or sets the color associated with this step
  133009. */
  133010. color: Color3;
  133011. /**
  133012. * Creates a new GradientBlockColorStep
  133013. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133014. * @param color defines the color associated with this step
  133015. */
  133016. constructor(
  133017. /**
  133018. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133019. */
  133020. step: number,
  133021. /**
  133022. * Gets or sets the color associated with this step
  133023. */
  133024. color: Color3);
  133025. }
  133026. /**
  133027. * Block used to return a color from a gradient based on an input value between 0 and 1
  133028. */
  133029. export class GradientBlock extends NodeMaterialBlock {
  133030. /**
  133031. * Gets or sets the list of color steps
  133032. */
  133033. colorSteps: GradientBlockColorStep[];
  133034. /**
  133035. * Creates a new GradientBlock
  133036. * @param name defines the block name
  133037. */
  133038. constructor(name: string);
  133039. /**
  133040. * Gets the current class name
  133041. * @returns the class name
  133042. */
  133043. getClassName(): string;
  133044. /**
  133045. * Gets the gradient input component
  133046. */
  133047. get gradient(): NodeMaterialConnectionPoint;
  133048. /**
  133049. * Gets the output component
  133050. */
  133051. get output(): NodeMaterialConnectionPoint;
  133052. private _writeColorConstant;
  133053. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133054. serialize(): any;
  133055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133056. protected _dumpPropertiesCode(): string;
  133057. }
  133058. }
  133059. declare module BABYLON {
  133060. /**
  133061. * Block used to normalize lerp between 2 values
  133062. */
  133063. export class NLerpBlock extends NodeMaterialBlock {
  133064. /**
  133065. * Creates a new NLerpBlock
  133066. * @param name defines the block name
  133067. */
  133068. constructor(name: string);
  133069. /**
  133070. * Gets the current class name
  133071. * @returns the class name
  133072. */
  133073. getClassName(): string;
  133074. /**
  133075. * Gets the left operand input component
  133076. */
  133077. get left(): NodeMaterialConnectionPoint;
  133078. /**
  133079. * Gets the right operand input component
  133080. */
  133081. get right(): NodeMaterialConnectionPoint;
  133082. /**
  133083. * Gets the gradient operand input component
  133084. */
  133085. get gradient(): NodeMaterialConnectionPoint;
  133086. /**
  133087. * Gets the output component
  133088. */
  133089. get output(): NodeMaterialConnectionPoint;
  133090. protected _buildBlock(state: NodeMaterialBuildState): this;
  133091. }
  133092. }
  133093. declare module BABYLON {
  133094. /**
  133095. * block used to Generate a Worley Noise 3D Noise Pattern
  133096. */
  133097. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133098. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133099. manhattanDistance: boolean;
  133100. /**
  133101. * Creates a new WorleyNoise3DBlock
  133102. * @param name defines the block name
  133103. */
  133104. constructor(name: string);
  133105. /**
  133106. * Gets the current class name
  133107. * @returns the class name
  133108. */
  133109. getClassName(): string;
  133110. /**
  133111. * Gets the seed input component
  133112. */
  133113. get seed(): NodeMaterialConnectionPoint;
  133114. /**
  133115. * Gets the jitter input component
  133116. */
  133117. get jitter(): NodeMaterialConnectionPoint;
  133118. /**
  133119. * Gets the output component
  133120. */
  133121. get output(): NodeMaterialConnectionPoint;
  133122. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133123. /**
  133124. * Exposes the properties to the UI?
  133125. */
  133126. protected _dumpPropertiesCode(): string;
  133127. /**
  133128. * Exposes the properties to the Seralize?
  133129. */
  133130. serialize(): any;
  133131. /**
  133132. * Exposes the properties to the deseralize?
  133133. */
  133134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133135. }
  133136. }
  133137. declare module BABYLON {
  133138. /**
  133139. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133140. */
  133141. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133142. /**
  133143. * Creates a new SimplexPerlin3DBlock
  133144. * @param name defines the block name
  133145. */
  133146. constructor(name: string);
  133147. /**
  133148. * Gets the current class name
  133149. * @returns the class name
  133150. */
  133151. getClassName(): string;
  133152. /**
  133153. * Gets the seed operand input component
  133154. */
  133155. get seed(): NodeMaterialConnectionPoint;
  133156. /**
  133157. * Gets the output component
  133158. */
  133159. get output(): NodeMaterialConnectionPoint;
  133160. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133161. }
  133162. }
  133163. declare module BABYLON {
  133164. /**
  133165. * Block used to blend normals
  133166. */
  133167. export class NormalBlendBlock extends NodeMaterialBlock {
  133168. /**
  133169. * Creates a new NormalBlendBlock
  133170. * @param name defines the block name
  133171. */
  133172. constructor(name: string);
  133173. /**
  133174. * Gets the current class name
  133175. * @returns the class name
  133176. */
  133177. getClassName(): string;
  133178. /**
  133179. * Gets the first input component
  133180. */
  133181. get normalMap0(): NodeMaterialConnectionPoint;
  133182. /**
  133183. * Gets the second input component
  133184. */
  133185. get normalMap1(): NodeMaterialConnectionPoint;
  133186. /**
  133187. * Gets the output component
  133188. */
  133189. get output(): NodeMaterialConnectionPoint;
  133190. protected _buildBlock(state: NodeMaterialBuildState): this;
  133191. }
  133192. }
  133193. declare module BABYLON {
  133194. /**
  133195. * Block used to rotate a 2d vector by a given angle
  133196. */
  133197. export class Rotate2dBlock extends NodeMaterialBlock {
  133198. /**
  133199. * Creates a new Rotate2dBlock
  133200. * @param name defines the block name
  133201. */
  133202. constructor(name: string);
  133203. /**
  133204. * Gets the current class name
  133205. * @returns the class name
  133206. */
  133207. getClassName(): string;
  133208. /**
  133209. * Gets the input vector
  133210. */
  133211. get input(): NodeMaterialConnectionPoint;
  133212. /**
  133213. * Gets the input angle
  133214. */
  133215. get angle(): NodeMaterialConnectionPoint;
  133216. /**
  133217. * Gets the output component
  133218. */
  133219. get output(): NodeMaterialConnectionPoint;
  133220. autoConfigure(material: NodeMaterial): void;
  133221. protected _buildBlock(state: NodeMaterialBuildState): this;
  133222. }
  133223. }
  133224. declare module BABYLON {
  133225. /**
  133226. * Block used to get the reflected vector from a direction and a normal
  133227. */
  133228. export class ReflectBlock extends NodeMaterialBlock {
  133229. /**
  133230. * Creates a new ReflectBlock
  133231. * @param name defines the block name
  133232. */
  133233. constructor(name: string);
  133234. /**
  133235. * Gets the current class name
  133236. * @returns the class name
  133237. */
  133238. getClassName(): string;
  133239. /**
  133240. * Gets the incident component
  133241. */
  133242. get incident(): NodeMaterialConnectionPoint;
  133243. /**
  133244. * Gets the normal component
  133245. */
  133246. get normal(): NodeMaterialConnectionPoint;
  133247. /**
  133248. * Gets the output component
  133249. */
  133250. get output(): NodeMaterialConnectionPoint;
  133251. protected _buildBlock(state: NodeMaterialBuildState): this;
  133252. }
  133253. }
  133254. declare module BABYLON {
  133255. /**
  133256. * Block used to get the refracted vector from a direction and a normal
  133257. */
  133258. export class RefractBlock extends NodeMaterialBlock {
  133259. /**
  133260. * Creates a new RefractBlock
  133261. * @param name defines the block name
  133262. */
  133263. constructor(name: string);
  133264. /**
  133265. * Gets the current class name
  133266. * @returns the class name
  133267. */
  133268. getClassName(): string;
  133269. /**
  133270. * Gets the incident component
  133271. */
  133272. get incident(): NodeMaterialConnectionPoint;
  133273. /**
  133274. * Gets the normal component
  133275. */
  133276. get normal(): NodeMaterialConnectionPoint;
  133277. /**
  133278. * Gets the index of refraction component
  133279. */
  133280. get ior(): NodeMaterialConnectionPoint;
  133281. /**
  133282. * Gets the output component
  133283. */
  133284. get output(): NodeMaterialConnectionPoint;
  133285. protected _buildBlock(state: NodeMaterialBuildState): this;
  133286. }
  133287. }
  133288. declare module BABYLON {
  133289. /**
  133290. * Block used to desaturate a color
  133291. */
  133292. export class DesaturateBlock extends NodeMaterialBlock {
  133293. /**
  133294. * Creates a new DesaturateBlock
  133295. * @param name defines the block name
  133296. */
  133297. constructor(name: string);
  133298. /**
  133299. * Gets the current class name
  133300. * @returns the class name
  133301. */
  133302. getClassName(): string;
  133303. /**
  133304. * Gets the color operand input component
  133305. */
  133306. get color(): NodeMaterialConnectionPoint;
  133307. /**
  133308. * Gets the level operand input component
  133309. */
  133310. get level(): NodeMaterialConnectionPoint;
  133311. /**
  133312. * Gets the output component
  133313. */
  133314. get output(): NodeMaterialConnectionPoint;
  133315. protected _buildBlock(state: NodeMaterialBuildState): this;
  133316. }
  133317. }
  133318. declare module BABYLON {
  133319. /**
  133320. * Effect Render Options
  133321. */
  133322. export interface IEffectRendererOptions {
  133323. /**
  133324. * Defines the vertices positions.
  133325. */
  133326. positions?: number[];
  133327. /**
  133328. * Defines the indices.
  133329. */
  133330. indices?: number[];
  133331. }
  133332. /**
  133333. * Helper class to render one or more effects
  133334. */
  133335. export class EffectRenderer {
  133336. private engine;
  133337. private static _DefaultOptions;
  133338. private _vertexBuffers;
  133339. private _indexBuffer;
  133340. private _ringBufferIndex;
  133341. private _ringScreenBuffer;
  133342. private _fullscreenViewport;
  133343. private _getNextFrameBuffer;
  133344. /**
  133345. * Creates an effect renderer
  133346. * @param engine the engine to use for rendering
  133347. * @param options defines the options of the effect renderer
  133348. */
  133349. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133350. /**
  133351. * Sets the current viewport in normalized coordinates 0-1
  133352. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133353. */
  133354. setViewport(viewport?: Viewport): void;
  133355. /**
  133356. * Binds the embedded attributes buffer to the effect.
  133357. * @param effect Defines the effect to bind the attributes for
  133358. */
  133359. bindBuffers(effect: Effect): void;
  133360. /**
  133361. * Sets the current effect wrapper to use during draw.
  133362. * The effect needs to be ready before calling this api.
  133363. * This also sets the default full screen position attribute.
  133364. * @param effectWrapper Defines the effect to draw with
  133365. */
  133366. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133367. /**
  133368. * Draws a full screen quad.
  133369. */
  133370. draw(): void;
  133371. /**
  133372. * renders one or more effects to a specified texture
  133373. * @param effectWrappers list of effects to renderer
  133374. * @param outputTexture texture to draw to, if null it will render to the screen
  133375. */
  133376. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133377. /**
  133378. * Disposes of the effect renderer
  133379. */
  133380. dispose(): void;
  133381. }
  133382. /**
  133383. * Options to create an EffectWrapper
  133384. */
  133385. interface EffectWrapperCreationOptions {
  133386. /**
  133387. * Engine to use to create the effect
  133388. */
  133389. engine: ThinEngine;
  133390. /**
  133391. * Fragment shader for the effect
  133392. */
  133393. fragmentShader: string;
  133394. /**
  133395. * Vertex shader for the effect
  133396. */
  133397. vertexShader?: string;
  133398. /**
  133399. * Attributes to use in the shader
  133400. */
  133401. attributeNames?: Array<string>;
  133402. /**
  133403. * Uniforms to use in the shader
  133404. */
  133405. uniformNames?: Array<string>;
  133406. /**
  133407. * Texture sampler names to use in the shader
  133408. */
  133409. samplerNames?: Array<string>;
  133410. /**
  133411. * The friendly name of the effect displayed in Spector.
  133412. */
  133413. name?: string;
  133414. }
  133415. /**
  133416. * Wraps an effect to be used for rendering
  133417. */
  133418. export class EffectWrapper {
  133419. /**
  133420. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133421. */
  133422. onApplyObservable: Observable<{}>;
  133423. /**
  133424. * The underlying effect
  133425. */
  133426. effect: Effect;
  133427. /**
  133428. * Creates an effect to be renderer
  133429. * @param creationOptions options to create the effect
  133430. */
  133431. constructor(creationOptions: EffectWrapperCreationOptions);
  133432. /**
  133433. * Disposes of the effect wrapper
  133434. */
  133435. dispose(): void;
  133436. }
  133437. }
  133438. declare module BABYLON {
  133439. /**
  133440. * Helper class to push actions to a pool of workers.
  133441. */
  133442. export class WorkerPool implements IDisposable {
  133443. private _workerInfos;
  133444. private _pendingActions;
  133445. /**
  133446. * Constructor
  133447. * @param workers Array of workers to use for actions
  133448. */
  133449. constructor(workers: Array<Worker>);
  133450. /**
  133451. * Terminates all workers and clears any pending actions.
  133452. */
  133453. dispose(): void;
  133454. /**
  133455. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133456. * pended until a worker has completed its action.
  133457. * @param action The action to perform. Call onComplete when the action is complete.
  133458. */
  133459. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133460. private _execute;
  133461. }
  133462. }
  133463. declare module BABYLON {
  133464. /**
  133465. * Configuration for Draco compression
  133466. */
  133467. export interface IDracoCompressionConfiguration {
  133468. /**
  133469. * Configuration for the decoder.
  133470. */
  133471. decoder: {
  133472. /**
  133473. * The url to the WebAssembly module.
  133474. */
  133475. wasmUrl?: string;
  133476. /**
  133477. * The url to the WebAssembly binary.
  133478. */
  133479. wasmBinaryUrl?: string;
  133480. /**
  133481. * The url to the fallback JavaScript module.
  133482. */
  133483. fallbackUrl?: string;
  133484. };
  133485. }
  133486. /**
  133487. * Draco compression (https://google.github.io/draco/)
  133488. *
  133489. * This class wraps the Draco module.
  133490. *
  133491. * **Encoder**
  133492. *
  133493. * The encoder is not currently implemented.
  133494. *
  133495. * **Decoder**
  133496. *
  133497. * 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.
  133498. *
  133499. * To update the configuration, use the following code:
  133500. * ```javascript
  133501. * DracoCompression.Configuration = {
  133502. * decoder: {
  133503. * wasmUrl: "<url to the WebAssembly library>",
  133504. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133505. * fallbackUrl: "<url to the fallback JavaScript library>",
  133506. * }
  133507. * };
  133508. * ```
  133509. *
  133510. * 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.
  133511. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133512. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133513. *
  133514. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133515. * ```javascript
  133516. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133517. * ```
  133518. *
  133519. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133520. */
  133521. export class DracoCompression implements IDisposable {
  133522. private _workerPoolPromise?;
  133523. private _decoderModulePromise?;
  133524. /**
  133525. * The configuration. Defaults to the following urls:
  133526. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133527. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133528. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133529. */
  133530. static Configuration: IDracoCompressionConfiguration;
  133531. /**
  133532. * Returns true if the decoder configuration is available.
  133533. */
  133534. static get DecoderAvailable(): boolean;
  133535. /**
  133536. * Default number of workers to create when creating the draco compression object.
  133537. */
  133538. static DefaultNumWorkers: number;
  133539. private static GetDefaultNumWorkers;
  133540. private static _Default;
  133541. /**
  133542. * Default instance for the draco compression object.
  133543. */
  133544. static get Default(): DracoCompression;
  133545. /**
  133546. * Constructor
  133547. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133548. */
  133549. constructor(numWorkers?: number);
  133550. /**
  133551. * Stop all async operations and release resources.
  133552. */
  133553. dispose(): void;
  133554. /**
  133555. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133556. * @returns a promise that resolves when ready
  133557. */
  133558. whenReadyAsync(): Promise<void>;
  133559. /**
  133560. * Decode Draco compressed mesh data to vertex data.
  133561. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133562. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133563. * @returns A promise that resolves with the decoded vertex data
  133564. */
  133565. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133566. [kind: string]: number;
  133567. }): Promise<VertexData>;
  133568. }
  133569. }
  133570. declare module BABYLON {
  133571. /**
  133572. * Class for building Constructive Solid Geometry
  133573. */
  133574. export class CSG {
  133575. private polygons;
  133576. /**
  133577. * The world matrix
  133578. */
  133579. matrix: Matrix;
  133580. /**
  133581. * Stores the position
  133582. */
  133583. position: Vector3;
  133584. /**
  133585. * Stores the rotation
  133586. */
  133587. rotation: Vector3;
  133588. /**
  133589. * Stores the rotation quaternion
  133590. */
  133591. rotationQuaternion: Nullable<Quaternion>;
  133592. /**
  133593. * Stores the scaling vector
  133594. */
  133595. scaling: Vector3;
  133596. /**
  133597. * Convert the Mesh to CSG
  133598. * @param mesh The Mesh to convert to CSG
  133599. * @returns A new CSG from the Mesh
  133600. */
  133601. static FromMesh(mesh: Mesh): CSG;
  133602. /**
  133603. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133604. * @param polygons Polygons used to construct a CSG solid
  133605. */
  133606. private static FromPolygons;
  133607. /**
  133608. * Clones, or makes a deep copy, of the CSG
  133609. * @returns A new CSG
  133610. */
  133611. clone(): CSG;
  133612. /**
  133613. * Unions this CSG with another CSG
  133614. * @param csg The CSG to union against this CSG
  133615. * @returns The unioned CSG
  133616. */
  133617. union(csg: CSG): CSG;
  133618. /**
  133619. * Unions this CSG with another CSG in place
  133620. * @param csg The CSG to union against this CSG
  133621. */
  133622. unionInPlace(csg: CSG): void;
  133623. /**
  133624. * Subtracts this CSG with another CSG
  133625. * @param csg The CSG to subtract against this CSG
  133626. * @returns A new CSG
  133627. */
  133628. subtract(csg: CSG): CSG;
  133629. /**
  133630. * Subtracts this CSG with another CSG in place
  133631. * @param csg The CSG to subtact against this CSG
  133632. */
  133633. subtractInPlace(csg: CSG): void;
  133634. /**
  133635. * Intersect this CSG with another CSG
  133636. * @param csg The CSG to intersect against this CSG
  133637. * @returns A new CSG
  133638. */
  133639. intersect(csg: CSG): CSG;
  133640. /**
  133641. * Intersects this CSG with another CSG in place
  133642. * @param csg The CSG to intersect against this CSG
  133643. */
  133644. intersectInPlace(csg: CSG): void;
  133645. /**
  133646. * Return a new CSG solid with solid and empty space switched. This solid is
  133647. * not modified.
  133648. * @returns A new CSG solid with solid and empty space switched
  133649. */
  133650. inverse(): CSG;
  133651. /**
  133652. * Inverses the CSG in place
  133653. */
  133654. inverseInPlace(): void;
  133655. /**
  133656. * This is used to keep meshes transformations so they can be restored
  133657. * when we build back a Babylon Mesh
  133658. * NB : All CSG operations are performed in world coordinates
  133659. * @param csg The CSG to copy the transform attributes from
  133660. * @returns This CSG
  133661. */
  133662. copyTransformAttributes(csg: CSG): CSG;
  133663. /**
  133664. * Build Raw mesh from CSG
  133665. * Coordinates here are in world space
  133666. * @param name The name of the mesh geometry
  133667. * @param scene The Scene
  133668. * @param keepSubMeshes Specifies if the submeshes should be kept
  133669. * @returns A new Mesh
  133670. */
  133671. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133672. /**
  133673. * Build Mesh from CSG taking material and transforms into account
  133674. * @param name The name of the Mesh
  133675. * @param material The material of the Mesh
  133676. * @param scene The Scene
  133677. * @param keepSubMeshes Specifies if submeshes should be kept
  133678. * @returns The new Mesh
  133679. */
  133680. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133681. }
  133682. }
  133683. declare module BABYLON {
  133684. /**
  133685. * Class used to create a trail following a mesh
  133686. */
  133687. export class TrailMesh extends Mesh {
  133688. private _generator;
  133689. private _autoStart;
  133690. private _running;
  133691. private _diameter;
  133692. private _length;
  133693. private _sectionPolygonPointsCount;
  133694. private _sectionVectors;
  133695. private _sectionNormalVectors;
  133696. private _beforeRenderObserver;
  133697. /**
  133698. * @constructor
  133699. * @param name The value used by scene.getMeshByName() to do a lookup.
  133700. * @param generator The mesh or transform node to generate a trail.
  133701. * @param scene The scene to add this mesh to.
  133702. * @param diameter Diameter of trailing mesh. Default is 1.
  133703. * @param length Length of trailing mesh. Default is 60.
  133704. * @param autoStart Automatically start trailing mesh. Default true.
  133705. */
  133706. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133707. /**
  133708. * "TrailMesh"
  133709. * @returns "TrailMesh"
  133710. */
  133711. getClassName(): string;
  133712. private _createMesh;
  133713. /**
  133714. * Start trailing mesh.
  133715. */
  133716. start(): void;
  133717. /**
  133718. * Stop trailing mesh.
  133719. */
  133720. stop(): void;
  133721. /**
  133722. * Update trailing mesh geometry.
  133723. */
  133724. update(): void;
  133725. /**
  133726. * Returns a new TrailMesh object.
  133727. * @param name is a string, the name given to the new mesh
  133728. * @param newGenerator use new generator object for cloned trail mesh
  133729. * @returns a new mesh
  133730. */
  133731. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133732. /**
  133733. * Serializes this trail mesh
  133734. * @param serializationObject object to write serialization to
  133735. */
  133736. serialize(serializationObject: any): void;
  133737. /**
  133738. * Parses a serialized trail mesh
  133739. * @param parsedMesh the serialized mesh
  133740. * @param scene the scene to create the trail mesh in
  133741. * @returns the created trail mesh
  133742. */
  133743. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133744. }
  133745. }
  133746. declare module BABYLON {
  133747. /**
  133748. * Class containing static functions to help procedurally build meshes
  133749. */
  133750. export class TiledBoxBuilder {
  133751. /**
  133752. * Creates a box mesh
  133753. * 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)
  133754. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133758. * @param name defines the name of the mesh
  133759. * @param options defines the options used to create the mesh
  133760. * @param scene defines the hosting scene
  133761. * @returns the box mesh
  133762. */
  133763. static CreateTiledBox(name: string, options: {
  133764. pattern?: number;
  133765. width?: number;
  133766. height?: number;
  133767. depth?: number;
  133768. tileSize?: number;
  133769. tileWidth?: number;
  133770. tileHeight?: number;
  133771. alignHorizontal?: number;
  133772. alignVertical?: number;
  133773. faceUV?: Vector4[];
  133774. faceColors?: Color4[];
  133775. sideOrientation?: number;
  133776. updatable?: boolean;
  133777. }, scene?: Nullable<Scene>): Mesh;
  133778. }
  133779. }
  133780. declare module BABYLON {
  133781. /**
  133782. * Class containing static functions to help procedurally build meshes
  133783. */
  133784. export class TorusKnotBuilder {
  133785. /**
  133786. * Creates a torus knot mesh
  133787. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133788. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133789. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133790. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133794. * @param name defines the name of the mesh
  133795. * @param options defines the options used to create the mesh
  133796. * @param scene defines the hosting scene
  133797. * @returns the torus knot mesh
  133798. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133799. */
  133800. static CreateTorusKnot(name: string, options: {
  133801. radius?: number;
  133802. tube?: number;
  133803. radialSegments?: number;
  133804. tubularSegments?: number;
  133805. p?: number;
  133806. q?: number;
  133807. updatable?: boolean;
  133808. sideOrientation?: number;
  133809. frontUVs?: Vector4;
  133810. backUVs?: Vector4;
  133811. }, scene: any): Mesh;
  133812. }
  133813. }
  133814. declare module BABYLON {
  133815. /**
  133816. * Polygon
  133817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133818. */
  133819. export class Polygon {
  133820. /**
  133821. * Creates a rectangle
  133822. * @param xmin bottom X coord
  133823. * @param ymin bottom Y coord
  133824. * @param xmax top X coord
  133825. * @param ymax top Y coord
  133826. * @returns points that make the resulting rectation
  133827. */
  133828. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133829. /**
  133830. * Creates a circle
  133831. * @param radius radius of circle
  133832. * @param cx scale in x
  133833. * @param cy scale in y
  133834. * @param numberOfSides number of sides that make up the circle
  133835. * @returns points that make the resulting circle
  133836. */
  133837. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133838. /**
  133839. * Creates a polygon from input string
  133840. * @param input Input polygon data
  133841. * @returns the parsed points
  133842. */
  133843. static Parse(input: string): Vector2[];
  133844. /**
  133845. * Starts building a polygon from x and y coordinates
  133846. * @param x x coordinate
  133847. * @param y y coordinate
  133848. * @returns the started path2
  133849. */
  133850. static StartingAt(x: number, y: number): Path2;
  133851. }
  133852. /**
  133853. * Builds a polygon
  133854. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133855. */
  133856. export class PolygonMeshBuilder {
  133857. private _points;
  133858. private _outlinepoints;
  133859. private _holes;
  133860. private _name;
  133861. private _scene;
  133862. private _epoints;
  133863. private _eholes;
  133864. private _addToepoint;
  133865. /**
  133866. * Babylon reference to the earcut plugin.
  133867. */
  133868. bjsEarcut: any;
  133869. /**
  133870. * Creates a PolygonMeshBuilder
  133871. * @param name name of the builder
  133872. * @param contours Path of the polygon
  133873. * @param scene scene to add to when creating the mesh
  133874. * @param earcutInjection can be used to inject your own earcut reference
  133875. */
  133876. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133877. /**
  133878. * Adds a whole within the polygon
  133879. * @param hole Array of points defining the hole
  133880. * @returns this
  133881. */
  133882. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133883. /**
  133884. * Creates the polygon
  133885. * @param updatable If the mesh should be updatable
  133886. * @param depth The depth of the mesh created
  133887. * @returns the created mesh
  133888. */
  133889. build(updatable?: boolean, depth?: number): Mesh;
  133890. /**
  133891. * Creates the polygon
  133892. * @param depth The depth of the mesh created
  133893. * @returns the created VertexData
  133894. */
  133895. buildVertexData(depth?: number): VertexData;
  133896. /**
  133897. * Adds a side to the polygon
  133898. * @param positions points that make the polygon
  133899. * @param normals normals of the polygon
  133900. * @param uvs uvs of the polygon
  133901. * @param indices indices of the polygon
  133902. * @param bounds bounds of the polygon
  133903. * @param points points of the polygon
  133904. * @param depth depth of the polygon
  133905. * @param flip flip of the polygon
  133906. */
  133907. private addSide;
  133908. }
  133909. }
  133910. declare module BABYLON {
  133911. /**
  133912. * Class containing static functions to help procedurally build meshes
  133913. */
  133914. export class PolygonBuilder {
  133915. /**
  133916. * Creates a polygon mesh
  133917. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133918. * * 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
  133919. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133922. * * Remember you can only change the shape positions, not their number when updating a polygon
  133923. * @param name defines the name of the mesh
  133924. * @param options defines the options used to create the mesh
  133925. * @param scene defines the hosting scene
  133926. * @param earcutInjection can be used to inject your own earcut reference
  133927. * @returns the polygon mesh
  133928. */
  133929. static CreatePolygon(name: string, options: {
  133930. shape: Vector3[];
  133931. holes?: Vector3[][];
  133932. depth?: number;
  133933. faceUV?: Vector4[];
  133934. faceColors?: Color4[];
  133935. updatable?: boolean;
  133936. sideOrientation?: number;
  133937. frontUVs?: Vector4;
  133938. backUVs?: Vector4;
  133939. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133940. /**
  133941. * Creates an extruded polygon mesh, with depth in the Y direction.
  133942. * * 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)
  133943. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133944. * @param name defines the name of the mesh
  133945. * @param options defines the options used to create the mesh
  133946. * @param scene defines the hosting scene
  133947. * @param earcutInjection can be used to inject your own earcut reference
  133948. * @returns the polygon mesh
  133949. */
  133950. static ExtrudePolygon(name: string, options: {
  133951. shape: Vector3[];
  133952. holes?: Vector3[][];
  133953. depth?: number;
  133954. faceUV?: Vector4[];
  133955. faceColors?: Color4[];
  133956. updatable?: boolean;
  133957. sideOrientation?: number;
  133958. frontUVs?: Vector4;
  133959. backUVs?: Vector4;
  133960. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133961. }
  133962. }
  133963. declare module BABYLON {
  133964. /**
  133965. * Class containing static functions to help procedurally build meshes
  133966. */
  133967. export class LatheBuilder {
  133968. /**
  133969. * Creates lathe mesh.
  133970. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133971. * * 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
  133972. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133973. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133974. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133975. * * 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
  133976. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133977. * * 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
  133978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133982. * @param name defines the name of the mesh
  133983. * @param options defines the options used to create the mesh
  133984. * @param scene defines the hosting scene
  133985. * @returns the lathe mesh
  133986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133987. */
  133988. static CreateLathe(name: string, options: {
  133989. shape: Vector3[];
  133990. radius?: number;
  133991. tessellation?: number;
  133992. clip?: number;
  133993. arc?: number;
  133994. closed?: boolean;
  133995. updatable?: boolean;
  133996. sideOrientation?: number;
  133997. frontUVs?: Vector4;
  133998. backUVs?: Vector4;
  133999. cap?: number;
  134000. invertUV?: boolean;
  134001. }, scene?: Nullable<Scene>): Mesh;
  134002. }
  134003. }
  134004. declare module BABYLON {
  134005. /**
  134006. * Class containing static functions to help procedurally build meshes
  134007. */
  134008. export class TiledPlaneBuilder {
  134009. /**
  134010. * Creates a tiled plane mesh
  134011. * * The parameter `pattern` will, depending on value, do nothing or
  134012. * * * flip (reflect about central vertical) alternate tiles across and up
  134013. * * * flip every tile on alternate rows
  134014. * * * rotate (180 degs) alternate tiles across and up
  134015. * * * rotate every tile on alternate rows
  134016. * * * flip and rotate alternate tiles across and up
  134017. * * * flip and rotate every tile on alternate rows
  134018. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134019. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134022. * * 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)
  134023. * * 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)
  134024. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134025. * @param name defines the name of the mesh
  134026. * @param options defines the options used to create the mesh
  134027. * @param scene defines the hosting scene
  134028. * @returns the box mesh
  134029. */
  134030. static CreateTiledPlane(name: string, options: {
  134031. pattern?: number;
  134032. tileSize?: number;
  134033. tileWidth?: number;
  134034. tileHeight?: number;
  134035. size?: number;
  134036. width?: number;
  134037. height?: number;
  134038. alignHorizontal?: number;
  134039. alignVertical?: number;
  134040. sideOrientation?: number;
  134041. frontUVs?: Vector4;
  134042. backUVs?: Vector4;
  134043. updatable?: boolean;
  134044. }, scene?: Nullable<Scene>): Mesh;
  134045. }
  134046. }
  134047. declare module BABYLON {
  134048. /**
  134049. * Class containing static functions to help procedurally build meshes
  134050. */
  134051. export class TubeBuilder {
  134052. /**
  134053. * Creates a tube mesh.
  134054. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134055. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134056. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134057. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134058. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134059. * * 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)
  134060. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134061. * * 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
  134062. * * 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
  134063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134067. * @param name defines the name of the mesh
  134068. * @param options defines the options used to create the mesh
  134069. * @param scene defines the hosting scene
  134070. * @returns the tube mesh
  134071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134072. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134073. */
  134074. static CreateTube(name: string, options: {
  134075. path: Vector3[];
  134076. radius?: number;
  134077. tessellation?: number;
  134078. radiusFunction?: {
  134079. (i: number, distance: number): number;
  134080. };
  134081. cap?: number;
  134082. arc?: number;
  134083. updatable?: boolean;
  134084. sideOrientation?: number;
  134085. frontUVs?: Vector4;
  134086. backUVs?: Vector4;
  134087. instance?: Mesh;
  134088. invertUV?: boolean;
  134089. }, scene?: Nullable<Scene>): Mesh;
  134090. }
  134091. }
  134092. declare module BABYLON {
  134093. /**
  134094. * Class containing static functions to help procedurally build meshes
  134095. */
  134096. export class IcoSphereBuilder {
  134097. /**
  134098. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134099. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134100. * * 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`)
  134101. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134102. * * 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
  134103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134106. * @param name defines the name of the mesh
  134107. * @param options defines the options used to create the mesh
  134108. * @param scene defines the hosting scene
  134109. * @returns the icosahedron mesh
  134110. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134111. */
  134112. static CreateIcoSphere(name: string, options: {
  134113. radius?: number;
  134114. radiusX?: number;
  134115. radiusY?: number;
  134116. radiusZ?: number;
  134117. flat?: boolean;
  134118. subdivisions?: number;
  134119. sideOrientation?: number;
  134120. frontUVs?: Vector4;
  134121. backUVs?: Vector4;
  134122. updatable?: boolean;
  134123. }, scene?: Nullable<Scene>): Mesh;
  134124. }
  134125. }
  134126. declare module BABYLON {
  134127. /**
  134128. * Class containing static functions to help procedurally build meshes
  134129. */
  134130. export class DecalBuilder {
  134131. /**
  134132. * Creates a decal mesh.
  134133. * 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
  134134. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134135. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134136. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134137. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134138. * @param name defines the name of the mesh
  134139. * @param sourceMesh defines the mesh where the decal must be applied
  134140. * @param options defines the options used to create the mesh
  134141. * @param scene defines the hosting scene
  134142. * @returns the decal mesh
  134143. * @see https://doc.babylonjs.com/how_to/decals
  134144. */
  134145. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134146. position?: Vector3;
  134147. normal?: Vector3;
  134148. size?: Vector3;
  134149. angle?: number;
  134150. }): Mesh;
  134151. }
  134152. }
  134153. declare module BABYLON {
  134154. /**
  134155. * Class containing static functions to help procedurally build meshes
  134156. */
  134157. export class MeshBuilder {
  134158. /**
  134159. * Creates a box mesh
  134160. * * The parameter `size` sets the size (float) of each box side (default 1)
  134161. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134162. * * 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)
  134163. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134167. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134168. * @param name defines the name of the mesh
  134169. * @param options defines the options used to create the mesh
  134170. * @param scene defines the hosting scene
  134171. * @returns the box mesh
  134172. */
  134173. static CreateBox(name: string, options: {
  134174. size?: number;
  134175. width?: number;
  134176. height?: number;
  134177. depth?: number;
  134178. faceUV?: Vector4[];
  134179. faceColors?: Color4[];
  134180. sideOrientation?: number;
  134181. frontUVs?: Vector4;
  134182. backUVs?: Vector4;
  134183. updatable?: boolean;
  134184. }, scene?: Nullable<Scene>): Mesh;
  134185. /**
  134186. * Creates a tiled box mesh
  134187. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134189. * @param name defines the name of the mesh
  134190. * @param options defines the options used to create the mesh
  134191. * @param scene defines the hosting scene
  134192. * @returns the tiled box mesh
  134193. */
  134194. static CreateTiledBox(name: string, options: {
  134195. pattern?: number;
  134196. size?: number;
  134197. width?: number;
  134198. height?: number;
  134199. depth: number;
  134200. tileSize?: number;
  134201. tileWidth?: number;
  134202. tileHeight?: number;
  134203. faceUV?: Vector4[];
  134204. faceColors?: Color4[];
  134205. alignHorizontal?: number;
  134206. alignVertical?: number;
  134207. sideOrientation?: number;
  134208. updatable?: boolean;
  134209. }, scene?: Nullable<Scene>): Mesh;
  134210. /**
  134211. * Creates a sphere mesh
  134212. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134213. * * 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`)
  134214. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134215. * * 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
  134216. * * 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)
  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. * @param name defines the name of the mesh
  134221. * @param options defines the options used to create the mesh
  134222. * @param scene defines the hosting scene
  134223. * @returns the sphere mesh
  134224. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134225. */
  134226. static CreateSphere(name: string, options: {
  134227. segments?: number;
  134228. diameter?: number;
  134229. diameterX?: number;
  134230. diameterY?: number;
  134231. diameterZ?: number;
  134232. arc?: number;
  134233. slice?: number;
  134234. sideOrientation?: number;
  134235. frontUVs?: Vector4;
  134236. backUVs?: Vector4;
  134237. updatable?: boolean;
  134238. }, scene?: Nullable<Scene>): Mesh;
  134239. /**
  134240. * Creates a plane polygonal mesh. By default, this is a disc
  134241. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134242. * * 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
  134243. * * 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
  134244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134247. * @param name defines the name of the mesh
  134248. * @param options defines the options used to create the mesh
  134249. * @param scene defines the hosting scene
  134250. * @returns the plane polygonal mesh
  134251. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134252. */
  134253. static CreateDisc(name: string, options: {
  134254. radius?: number;
  134255. tessellation?: number;
  134256. arc?: number;
  134257. updatable?: boolean;
  134258. sideOrientation?: number;
  134259. frontUVs?: Vector4;
  134260. backUVs?: Vector4;
  134261. }, scene?: Nullable<Scene>): Mesh;
  134262. /**
  134263. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134264. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134265. * * 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`)
  134266. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134267. * * 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
  134268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134271. * @param name defines the name of the mesh
  134272. * @param options defines the options used to create the mesh
  134273. * @param scene defines the hosting scene
  134274. * @returns the icosahedron mesh
  134275. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134276. */
  134277. static CreateIcoSphere(name: string, options: {
  134278. radius?: number;
  134279. radiusX?: number;
  134280. radiusY?: number;
  134281. radiusZ?: number;
  134282. flat?: boolean;
  134283. subdivisions?: number;
  134284. sideOrientation?: number;
  134285. frontUVs?: Vector4;
  134286. backUVs?: Vector4;
  134287. updatable?: boolean;
  134288. }, scene?: Nullable<Scene>): Mesh;
  134289. /**
  134290. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134291. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134292. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134293. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134294. * * 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
  134295. * * 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
  134296. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134300. * * 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
  134301. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134302. * * 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
  134303. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134305. * @param name defines the name of the mesh
  134306. * @param options defines the options used to create the mesh
  134307. * @param scene defines the hosting scene
  134308. * @returns the ribbon mesh
  134309. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134310. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134311. */
  134312. static CreateRibbon(name: string, options: {
  134313. pathArray: Vector3[][];
  134314. closeArray?: boolean;
  134315. closePath?: boolean;
  134316. offset?: number;
  134317. updatable?: boolean;
  134318. sideOrientation?: number;
  134319. frontUVs?: Vector4;
  134320. backUVs?: Vector4;
  134321. instance?: Mesh;
  134322. invertUV?: boolean;
  134323. uvs?: Vector2[];
  134324. colors?: Color4[];
  134325. }, scene?: Nullable<Scene>): Mesh;
  134326. /**
  134327. * Creates a cylinder or a cone mesh
  134328. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134329. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134330. * * 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.
  134331. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134332. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134333. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134334. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134335. * * 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).
  134336. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134337. * * 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).
  134338. * * 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
  134339. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134340. * * 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
  134341. * * 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.
  134342. * * If `enclose` is false, a ring surface is one element.
  134343. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134344. * * 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
  134345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134348. * @param name defines the name of the mesh
  134349. * @param options defines the options used to create the mesh
  134350. * @param scene defines the hosting scene
  134351. * @returns the cylinder mesh
  134352. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134353. */
  134354. static CreateCylinder(name: string, options: {
  134355. height?: number;
  134356. diameterTop?: number;
  134357. diameterBottom?: number;
  134358. diameter?: number;
  134359. tessellation?: number;
  134360. subdivisions?: number;
  134361. arc?: number;
  134362. faceColors?: Color4[];
  134363. faceUV?: Vector4[];
  134364. updatable?: boolean;
  134365. hasRings?: boolean;
  134366. enclose?: boolean;
  134367. cap?: number;
  134368. sideOrientation?: number;
  134369. frontUVs?: Vector4;
  134370. backUVs?: Vector4;
  134371. }, scene?: Nullable<Scene>): Mesh;
  134372. /**
  134373. * Creates a torus mesh
  134374. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134375. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134376. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134380. * @param name defines the name of the mesh
  134381. * @param options defines the options used to create the mesh
  134382. * @param scene defines the hosting scene
  134383. * @returns the torus mesh
  134384. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134385. */
  134386. static CreateTorus(name: string, options: {
  134387. diameter?: number;
  134388. thickness?: number;
  134389. tessellation?: number;
  134390. updatable?: boolean;
  134391. sideOrientation?: number;
  134392. frontUVs?: Vector4;
  134393. backUVs?: Vector4;
  134394. }, scene?: Nullable<Scene>): Mesh;
  134395. /**
  134396. * Creates a torus knot mesh
  134397. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134398. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134399. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134400. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134404. * @param name defines the name of the mesh
  134405. * @param options defines the options used to create the mesh
  134406. * @param scene defines the hosting scene
  134407. * @returns the torus knot mesh
  134408. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134409. */
  134410. static CreateTorusKnot(name: string, options: {
  134411. radius?: number;
  134412. tube?: number;
  134413. radialSegments?: number;
  134414. tubularSegments?: number;
  134415. p?: number;
  134416. q?: number;
  134417. updatable?: boolean;
  134418. sideOrientation?: number;
  134419. frontUVs?: Vector4;
  134420. backUVs?: Vector4;
  134421. }, scene?: Nullable<Scene>): Mesh;
  134422. /**
  134423. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134424. * * 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
  134425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134426. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134427. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134428. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134429. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134430. * * 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
  134431. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134434. * @param name defines the name of the new line system
  134435. * @param options defines the options used to create the line system
  134436. * @param scene defines the hosting scene
  134437. * @returns a new line system mesh
  134438. */
  134439. static CreateLineSystem(name: string, options: {
  134440. lines: Vector3[][];
  134441. updatable?: boolean;
  134442. instance?: Nullable<LinesMesh>;
  134443. colors?: Nullable<Color4[][]>;
  134444. useVertexAlpha?: boolean;
  134445. }, scene: Nullable<Scene>): LinesMesh;
  134446. /**
  134447. * Creates a line mesh
  134448. * 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
  134449. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134450. * * The parameter `points` is an array successive Vector3
  134451. * * 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
  134452. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134453. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134454. * * When updating an instance, remember that only point positions can change, not the number of points
  134455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134457. * @param name defines the name of the new line system
  134458. * @param options defines the options used to create the line system
  134459. * @param scene defines the hosting scene
  134460. * @returns a new line mesh
  134461. */
  134462. static CreateLines(name: string, options: {
  134463. points: Vector3[];
  134464. updatable?: boolean;
  134465. instance?: Nullable<LinesMesh>;
  134466. colors?: Color4[];
  134467. useVertexAlpha?: boolean;
  134468. }, scene?: Nullable<Scene>): LinesMesh;
  134469. /**
  134470. * Creates a dashed line mesh
  134471. * * 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
  134472. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134473. * * The parameter `points` is an array successive Vector3
  134474. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134475. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134476. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134477. * * 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
  134478. * * When updating an instance, remember that only point positions can change, not the number of points
  134479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134480. * @param name defines the name of the mesh
  134481. * @param options defines the options used to create the mesh
  134482. * @param scene defines the hosting scene
  134483. * @returns the dashed line mesh
  134484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134485. */
  134486. static CreateDashedLines(name: string, options: {
  134487. points: Vector3[];
  134488. dashSize?: number;
  134489. gapSize?: number;
  134490. dashNb?: number;
  134491. updatable?: boolean;
  134492. instance?: LinesMesh;
  134493. }, scene?: Nullable<Scene>): LinesMesh;
  134494. /**
  134495. * 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.
  134496. * * 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.
  134497. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134498. * * 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.
  134499. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134500. * * 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
  134501. * * 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
  134502. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134507. * @param name defines the name of the mesh
  134508. * @param options defines the options used to create the mesh
  134509. * @param scene defines the hosting scene
  134510. * @returns the extruded shape mesh
  134511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134513. */
  134514. static ExtrudeShape(name: string, options: {
  134515. shape: Vector3[];
  134516. path: Vector3[];
  134517. scale?: number;
  134518. rotation?: number;
  134519. cap?: number;
  134520. updatable?: boolean;
  134521. sideOrientation?: number;
  134522. frontUVs?: Vector4;
  134523. backUVs?: Vector4;
  134524. instance?: Mesh;
  134525. invertUV?: boolean;
  134526. }, scene?: Nullable<Scene>): Mesh;
  134527. /**
  134528. * Creates an custom extruded shape mesh.
  134529. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134530. * * 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.
  134531. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134532. * * 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
  134533. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134534. * * 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
  134535. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134536. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134537. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134538. * * 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
  134539. * * 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
  134540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134545. * @param name defines the name of the mesh
  134546. * @param options defines the options used to create the mesh
  134547. * @param scene defines the hosting scene
  134548. * @returns the custom extruded shape mesh
  134549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134550. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134552. */
  134553. static ExtrudeShapeCustom(name: string, options: {
  134554. shape: Vector3[];
  134555. path: Vector3[];
  134556. scaleFunction?: any;
  134557. rotationFunction?: any;
  134558. ribbonCloseArray?: boolean;
  134559. ribbonClosePath?: boolean;
  134560. cap?: number;
  134561. updatable?: boolean;
  134562. sideOrientation?: number;
  134563. frontUVs?: Vector4;
  134564. backUVs?: Vector4;
  134565. instance?: Mesh;
  134566. invertUV?: boolean;
  134567. }, scene?: Nullable<Scene>): Mesh;
  134568. /**
  134569. * Creates lathe mesh.
  134570. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134571. * * 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
  134572. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134573. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134574. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134575. * * 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
  134576. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134577. * * 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
  134578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134582. * @param name defines the name of the mesh
  134583. * @param options defines the options used to create the mesh
  134584. * @param scene defines the hosting scene
  134585. * @returns the lathe mesh
  134586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134587. */
  134588. static CreateLathe(name: string, options: {
  134589. shape: Vector3[];
  134590. radius?: number;
  134591. tessellation?: number;
  134592. clip?: number;
  134593. arc?: number;
  134594. closed?: boolean;
  134595. updatable?: boolean;
  134596. sideOrientation?: number;
  134597. frontUVs?: Vector4;
  134598. backUVs?: Vector4;
  134599. cap?: number;
  134600. invertUV?: boolean;
  134601. }, scene?: Nullable<Scene>): Mesh;
  134602. /**
  134603. * Creates a tiled plane mesh
  134604. * * You can set a limited pattern arrangement with the tiles
  134605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134608. * @param name defines the name of the mesh
  134609. * @param options defines the options used to create the mesh
  134610. * @param scene defines the hosting scene
  134611. * @returns the plane mesh
  134612. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134613. */
  134614. static CreateTiledPlane(name: string, options: {
  134615. pattern?: number;
  134616. tileSize?: number;
  134617. tileWidth?: number;
  134618. tileHeight?: number;
  134619. size?: number;
  134620. width?: number;
  134621. height?: number;
  134622. alignHorizontal?: number;
  134623. alignVertical?: number;
  134624. sideOrientation?: number;
  134625. frontUVs?: Vector4;
  134626. backUVs?: Vector4;
  134627. updatable?: boolean;
  134628. }, scene?: Nullable<Scene>): Mesh;
  134629. /**
  134630. * Creates a plane mesh
  134631. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134632. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134633. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134637. * @param name defines the name of the mesh
  134638. * @param options defines the options used to create the mesh
  134639. * @param scene defines the hosting scene
  134640. * @returns the plane mesh
  134641. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134642. */
  134643. static CreatePlane(name: string, options: {
  134644. size?: number;
  134645. width?: number;
  134646. height?: number;
  134647. sideOrientation?: number;
  134648. frontUVs?: Vector4;
  134649. backUVs?: Vector4;
  134650. updatable?: boolean;
  134651. sourcePlane?: Plane;
  134652. }, scene?: Nullable<Scene>): Mesh;
  134653. /**
  134654. * Creates a ground mesh
  134655. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134656. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134658. * @param name defines the name of the mesh
  134659. * @param options defines the options used to create the mesh
  134660. * @param scene defines the hosting scene
  134661. * @returns the ground mesh
  134662. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134663. */
  134664. static CreateGround(name: string, options: {
  134665. width?: number;
  134666. height?: number;
  134667. subdivisions?: number;
  134668. subdivisionsX?: number;
  134669. subdivisionsY?: number;
  134670. updatable?: boolean;
  134671. }, scene?: Nullable<Scene>): Mesh;
  134672. /**
  134673. * Creates a tiled ground mesh
  134674. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134675. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134676. * * 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
  134677. * * 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
  134678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134679. * @param name defines the name of the mesh
  134680. * @param options defines the options used to create the mesh
  134681. * @param scene defines the hosting scene
  134682. * @returns the tiled ground mesh
  134683. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134684. */
  134685. static CreateTiledGround(name: string, options: {
  134686. xmin: number;
  134687. zmin: number;
  134688. xmax: number;
  134689. zmax: number;
  134690. subdivisions?: {
  134691. w: number;
  134692. h: number;
  134693. };
  134694. precision?: {
  134695. w: number;
  134696. h: number;
  134697. };
  134698. updatable?: boolean;
  134699. }, scene?: Nullable<Scene>): Mesh;
  134700. /**
  134701. * Creates a ground mesh from a height map
  134702. * * The parameter `url` sets the URL of the height map image resource.
  134703. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134704. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134705. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134706. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134707. * * 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.
  134708. * * 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).
  134709. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  134713. * @param options defines the options used to create the mesh
  134714. * @param scene defines the hosting scene
  134715. * @returns the ground mesh
  134716. * @see https://doc.babylonjs.com/babylon101/height_map
  134717. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134718. */
  134719. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134720. width?: number;
  134721. height?: number;
  134722. subdivisions?: number;
  134723. minHeight?: number;
  134724. maxHeight?: number;
  134725. colorFilter?: Color3;
  134726. alphaFilter?: number;
  134727. updatable?: boolean;
  134728. onReady?: (mesh: GroundMesh) => void;
  134729. }, scene?: Nullable<Scene>): GroundMesh;
  134730. /**
  134731. * Creates a polygon mesh
  134732. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134733. * * 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
  134734. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134737. * * Remember you can only change the shape positions, not their number when updating a polygon
  134738. * @param name defines the name of the mesh
  134739. * @param options defines the options used to create the mesh
  134740. * @param scene defines the hosting scene
  134741. * @param earcutInjection can be used to inject your own earcut reference
  134742. * @returns the polygon mesh
  134743. */
  134744. static CreatePolygon(name: string, options: {
  134745. shape: Vector3[];
  134746. holes?: Vector3[][];
  134747. depth?: number;
  134748. faceUV?: Vector4[];
  134749. faceColors?: Color4[];
  134750. updatable?: boolean;
  134751. sideOrientation?: number;
  134752. frontUVs?: Vector4;
  134753. backUVs?: Vector4;
  134754. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134755. /**
  134756. * Creates an extruded polygon mesh, with depth in the Y direction.
  134757. * * 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)
  134758. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134759. * @param name defines the name of the mesh
  134760. * @param options defines the options used to create the mesh
  134761. * @param scene defines the hosting scene
  134762. * @param earcutInjection can be used to inject your own earcut reference
  134763. * @returns the polygon mesh
  134764. */
  134765. static ExtrudePolygon(name: string, options: {
  134766. shape: Vector3[];
  134767. holes?: Vector3[][];
  134768. depth?: number;
  134769. faceUV?: Vector4[];
  134770. faceColors?: Color4[];
  134771. updatable?: boolean;
  134772. sideOrientation?: number;
  134773. frontUVs?: Vector4;
  134774. backUVs?: Vector4;
  134775. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134776. /**
  134777. * Creates a tube mesh.
  134778. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134779. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134780. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134781. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134782. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134783. * * 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)
  134784. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134785. * * 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
  134786. * * 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
  134787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134789. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the tube mesh
  134795. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134796. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134797. */
  134798. static CreateTube(name: string, options: {
  134799. path: Vector3[];
  134800. radius?: number;
  134801. tessellation?: number;
  134802. radiusFunction?: {
  134803. (i: number, distance: number): number;
  134804. };
  134805. cap?: number;
  134806. arc?: number;
  134807. updatable?: boolean;
  134808. sideOrientation?: number;
  134809. frontUVs?: Vector4;
  134810. backUVs?: Vector4;
  134811. instance?: Mesh;
  134812. invertUV?: boolean;
  134813. }, scene?: Nullable<Scene>): Mesh;
  134814. /**
  134815. * Creates a polyhedron mesh
  134816. * * 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
  134817. * * The parameter `size` (positive float, default 1) sets the polygon size
  134818. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134819. * * 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`
  134820. * * 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
  134821. * * 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)`)
  134822. * * 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
  134823. * * 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
  134824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134827. * @param name defines the name of the mesh
  134828. * @param options defines the options used to create the mesh
  134829. * @param scene defines the hosting scene
  134830. * @returns the polyhedron mesh
  134831. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134832. */
  134833. static CreatePolyhedron(name: string, options: {
  134834. type?: number;
  134835. size?: number;
  134836. sizeX?: number;
  134837. sizeY?: number;
  134838. sizeZ?: number;
  134839. custom?: any;
  134840. faceUV?: Vector4[];
  134841. faceColors?: Color4[];
  134842. flat?: boolean;
  134843. updatable?: boolean;
  134844. sideOrientation?: number;
  134845. frontUVs?: Vector4;
  134846. backUVs?: Vector4;
  134847. }, scene?: Nullable<Scene>): Mesh;
  134848. /**
  134849. * Creates a decal mesh.
  134850. * 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
  134851. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134852. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134853. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134854. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134855. * @param name defines the name of the mesh
  134856. * @param sourceMesh defines the mesh where the decal must be applied
  134857. * @param options defines the options used to create the mesh
  134858. * @param scene defines the hosting scene
  134859. * @returns the decal mesh
  134860. * @see https://doc.babylonjs.com/how_to/decals
  134861. */
  134862. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134863. position?: Vector3;
  134864. normal?: Vector3;
  134865. size?: Vector3;
  134866. angle?: number;
  134867. }): Mesh;
  134868. }
  134869. }
  134870. declare module BABYLON {
  134871. /**
  134872. * A simplifier interface for future simplification implementations
  134873. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134874. */
  134875. export interface ISimplifier {
  134876. /**
  134877. * Simplification of a given mesh according to the given settings.
  134878. * Since this requires computation, it is assumed that the function runs async.
  134879. * @param settings The settings of the simplification, including quality and distance
  134880. * @param successCallback A callback that will be called after the mesh was simplified.
  134881. * @param errorCallback in case of an error, this callback will be called. optional.
  134882. */
  134883. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134884. }
  134885. /**
  134886. * Expected simplification settings.
  134887. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134888. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134889. */
  134890. export interface ISimplificationSettings {
  134891. /**
  134892. * Gets or sets the expected quality
  134893. */
  134894. quality: number;
  134895. /**
  134896. * Gets or sets the distance when this optimized version should be used
  134897. */
  134898. distance: number;
  134899. /**
  134900. * Gets an already optimized mesh
  134901. */
  134902. optimizeMesh?: boolean;
  134903. }
  134904. /**
  134905. * Class used to specify simplification options
  134906. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134907. */
  134908. export class SimplificationSettings implements ISimplificationSettings {
  134909. /** expected quality */
  134910. quality: number;
  134911. /** distance when this optimized version should be used */
  134912. distance: number;
  134913. /** already optimized mesh */
  134914. optimizeMesh?: boolean | undefined;
  134915. /**
  134916. * Creates a SimplificationSettings
  134917. * @param quality expected quality
  134918. * @param distance distance when this optimized version should be used
  134919. * @param optimizeMesh already optimized mesh
  134920. */
  134921. constructor(
  134922. /** expected quality */
  134923. quality: number,
  134924. /** distance when this optimized version should be used */
  134925. distance: number,
  134926. /** already optimized mesh */
  134927. optimizeMesh?: boolean | undefined);
  134928. }
  134929. /**
  134930. * Interface used to define a simplification task
  134931. */
  134932. export interface ISimplificationTask {
  134933. /**
  134934. * Array of settings
  134935. */
  134936. settings: Array<ISimplificationSettings>;
  134937. /**
  134938. * Simplification type
  134939. */
  134940. simplificationType: SimplificationType;
  134941. /**
  134942. * Mesh to simplify
  134943. */
  134944. mesh: Mesh;
  134945. /**
  134946. * Callback called on success
  134947. */
  134948. successCallback?: () => void;
  134949. /**
  134950. * Defines if parallel processing can be used
  134951. */
  134952. parallelProcessing: boolean;
  134953. }
  134954. /**
  134955. * Queue used to order the simplification tasks
  134956. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134957. */
  134958. export class SimplificationQueue {
  134959. private _simplificationArray;
  134960. /**
  134961. * Gets a boolean indicating that the process is still running
  134962. */
  134963. running: boolean;
  134964. /**
  134965. * Creates a new queue
  134966. */
  134967. constructor();
  134968. /**
  134969. * Adds a new simplification task
  134970. * @param task defines a task to add
  134971. */
  134972. addTask(task: ISimplificationTask): void;
  134973. /**
  134974. * Execute next task
  134975. */
  134976. executeNext(): void;
  134977. /**
  134978. * Execute a simplification task
  134979. * @param task defines the task to run
  134980. */
  134981. runSimplification(task: ISimplificationTask): void;
  134982. private getSimplifier;
  134983. }
  134984. /**
  134985. * The implemented types of simplification
  134986. * At the moment only Quadratic Error Decimation is implemented
  134987. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134988. */
  134989. export enum SimplificationType {
  134990. /** Quadratic error decimation */
  134991. QUADRATIC = 0
  134992. }
  134993. }
  134994. declare module BABYLON {
  134995. interface Scene {
  134996. /** @hidden (Backing field) */
  134997. _simplificationQueue: SimplificationQueue;
  134998. /**
  134999. * Gets or sets the simplification queue attached to the scene
  135000. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135001. */
  135002. simplificationQueue: SimplificationQueue;
  135003. }
  135004. interface Mesh {
  135005. /**
  135006. * Simplify the mesh according to the given array of settings.
  135007. * Function will return immediately and will simplify async
  135008. * @param settings a collection of simplification settings
  135009. * @param parallelProcessing should all levels calculate parallel or one after the other
  135010. * @param simplificationType the type of simplification to run
  135011. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135012. * @returns the current mesh
  135013. */
  135014. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135015. }
  135016. /**
  135017. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135018. * created in a scene
  135019. */
  135020. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135021. /**
  135022. * The component name helpfull to identify the component in the list of scene components.
  135023. */
  135024. readonly name: string;
  135025. /**
  135026. * The scene the component belongs to.
  135027. */
  135028. scene: Scene;
  135029. /**
  135030. * Creates a new instance of the component for the given scene
  135031. * @param scene Defines the scene to register the component in
  135032. */
  135033. constructor(scene: Scene);
  135034. /**
  135035. * Registers the component in a given scene
  135036. */
  135037. register(): void;
  135038. /**
  135039. * Rebuilds the elements related to this component in case of
  135040. * context lost for instance.
  135041. */
  135042. rebuild(): void;
  135043. /**
  135044. * Disposes the component and the associated ressources
  135045. */
  135046. dispose(): void;
  135047. private _beforeCameraUpdate;
  135048. }
  135049. }
  135050. declare module BABYLON {
  135051. /**
  135052. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135053. */
  135054. export interface INavigationEnginePlugin {
  135055. /**
  135056. * plugin name
  135057. */
  135058. name: string;
  135059. /**
  135060. * Creates a navigation mesh
  135061. * @param meshes array of all the geometry used to compute the navigatio mesh
  135062. * @param parameters bunch of parameters used to filter geometry
  135063. */
  135064. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135065. /**
  135066. * Create a navigation mesh debug mesh
  135067. * @param scene is where the mesh will be added
  135068. * @returns debug display mesh
  135069. */
  135070. createDebugNavMesh(scene: Scene): Mesh;
  135071. /**
  135072. * Get a navigation mesh constrained position, closest to the parameter position
  135073. * @param position world position
  135074. * @returns the closest point to position constrained by the navigation mesh
  135075. */
  135076. getClosestPoint(position: Vector3): Vector3;
  135077. /**
  135078. * Get a navigation mesh constrained position, within a particular radius
  135079. * @param position world position
  135080. * @param maxRadius the maximum distance to the constrained world position
  135081. * @returns the closest point to position constrained by the navigation mesh
  135082. */
  135083. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135084. /**
  135085. * Compute the final position from a segment made of destination-position
  135086. * @param position world position
  135087. * @param destination world position
  135088. * @returns the resulting point along the navmesh
  135089. */
  135090. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135091. /**
  135092. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135093. * @param start world position
  135094. * @param end world position
  135095. * @returns array containing world position composing the path
  135096. */
  135097. computePath(start: Vector3, end: Vector3): Vector3[];
  135098. /**
  135099. * If this plugin is supported
  135100. * @returns true if plugin is supported
  135101. */
  135102. isSupported(): boolean;
  135103. /**
  135104. * Create a new Crowd so you can add agents
  135105. * @param maxAgents the maximum agent count in the crowd
  135106. * @param maxAgentRadius the maximum radius an agent can have
  135107. * @param scene to attach the crowd to
  135108. * @returns the crowd you can add agents to
  135109. */
  135110. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135111. /**
  135112. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135113. * The queries will try to find a solution within those bounds
  135114. * default is (1,1,1)
  135115. * @param extent x,y,z value that define the extent around the queries point of reference
  135116. */
  135117. setDefaultQueryExtent(extent: Vector3): void;
  135118. /**
  135119. * Get the Bounding box extent specified by setDefaultQueryExtent
  135120. * @returns the box extent values
  135121. */
  135122. getDefaultQueryExtent(): Vector3;
  135123. /**
  135124. * Release all resources
  135125. */
  135126. dispose(): void;
  135127. }
  135128. /**
  135129. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135130. */
  135131. export interface ICrowd {
  135132. /**
  135133. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135134. * You can attach anything to that node. The node position is updated in the scene update tick.
  135135. * @param pos world position that will be constrained by the navigation mesh
  135136. * @param parameters agent parameters
  135137. * @param transform hooked to the agent that will be update by the scene
  135138. * @returns agent index
  135139. */
  135140. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135141. /**
  135142. * Returns the agent position in world space
  135143. * @param index agent index returned by addAgent
  135144. * @returns world space position
  135145. */
  135146. getAgentPosition(index: number): Vector3;
  135147. /**
  135148. * Gets the agent velocity in world space
  135149. * @param index agent index returned by addAgent
  135150. * @returns world space velocity
  135151. */
  135152. getAgentVelocity(index: number): Vector3;
  135153. /**
  135154. * remove a particular agent previously created
  135155. * @param index agent index returned by addAgent
  135156. */
  135157. removeAgent(index: number): void;
  135158. /**
  135159. * get the list of all agents attached to this crowd
  135160. * @returns list of agent indices
  135161. */
  135162. getAgents(): number[];
  135163. /**
  135164. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135165. * @param deltaTime in seconds
  135166. */
  135167. update(deltaTime: number): void;
  135168. /**
  135169. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135170. * @param index agent index returned by addAgent
  135171. * @param destination targeted world position
  135172. */
  135173. agentGoto(index: number, destination: Vector3): void;
  135174. /**
  135175. * Teleport the agent to a new position
  135176. * @param index agent index returned by addAgent
  135177. * @param destination targeted world position
  135178. */
  135179. agentTeleport(index: number, destination: Vector3): void;
  135180. /**
  135181. * Update agent parameters
  135182. * @param index agent index returned by addAgent
  135183. * @param parameters agent parameters
  135184. */
  135185. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135186. /**
  135187. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135188. * The queries will try to find a solution within those bounds
  135189. * default is (1,1,1)
  135190. * @param extent x,y,z value that define the extent around the queries point of reference
  135191. */
  135192. setDefaultQueryExtent(extent: Vector3): void;
  135193. /**
  135194. * Get the Bounding box extent specified by setDefaultQueryExtent
  135195. * @returns the box extent values
  135196. */
  135197. getDefaultQueryExtent(): Vector3;
  135198. /**
  135199. * Release all resources
  135200. */
  135201. dispose(): void;
  135202. }
  135203. /**
  135204. * Configures an agent
  135205. */
  135206. export interface IAgentParameters {
  135207. /**
  135208. * Agent radius. [Limit: >= 0]
  135209. */
  135210. radius: number;
  135211. /**
  135212. * Agent height. [Limit: > 0]
  135213. */
  135214. height: number;
  135215. /**
  135216. * Maximum allowed acceleration. [Limit: >= 0]
  135217. */
  135218. maxAcceleration: number;
  135219. /**
  135220. * Maximum allowed speed. [Limit: >= 0]
  135221. */
  135222. maxSpeed: number;
  135223. /**
  135224. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135225. */
  135226. collisionQueryRange: number;
  135227. /**
  135228. * The path visibility optimization range. [Limit: > 0]
  135229. */
  135230. pathOptimizationRange: number;
  135231. /**
  135232. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135233. */
  135234. separationWeight: number;
  135235. }
  135236. /**
  135237. * Configures the navigation mesh creation
  135238. */
  135239. export interface INavMeshParameters {
  135240. /**
  135241. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135242. */
  135243. cs: number;
  135244. /**
  135245. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135246. */
  135247. ch: number;
  135248. /**
  135249. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135250. */
  135251. walkableSlopeAngle: number;
  135252. /**
  135253. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135254. * be considered walkable. [Limit: >= 3] [Units: vx]
  135255. */
  135256. walkableHeight: number;
  135257. /**
  135258. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135259. */
  135260. walkableClimb: number;
  135261. /**
  135262. * The distance to erode/shrink the walkable area of the heightfield away from
  135263. * obstructions. [Limit: >=0] [Units: vx]
  135264. */
  135265. walkableRadius: number;
  135266. /**
  135267. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135268. */
  135269. maxEdgeLen: number;
  135270. /**
  135271. * The maximum distance a simplfied contour's border edges should deviate
  135272. * the original raw contour. [Limit: >=0] [Units: vx]
  135273. */
  135274. maxSimplificationError: number;
  135275. /**
  135276. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135277. */
  135278. minRegionArea: number;
  135279. /**
  135280. * Any regions with a span count smaller than this value will, if possible,
  135281. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135282. */
  135283. mergeRegionArea: number;
  135284. /**
  135285. * The maximum number of vertices allowed for polygons generated during the
  135286. * contour to polygon conversion process. [Limit: >= 3]
  135287. */
  135288. maxVertsPerPoly: number;
  135289. /**
  135290. * Sets the sampling distance to use when generating the detail mesh.
  135291. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135292. */
  135293. detailSampleDist: number;
  135294. /**
  135295. * The maximum distance the detail mesh surface should deviate from heightfield
  135296. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135297. */
  135298. detailSampleMaxError: number;
  135299. }
  135300. }
  135301. declare module BABYLON {
  135302. /**
  135303. * RecastJS navigation plugin
  135304. */
  135305. export class RecastJSPlugin implements INavigationEnginePlugin {
  135306. /**
  135307. * Reference to the Recast library
  135308. */
  135309. bjsRECAST: any;
  135310. /**
  135311. * plugin name
  135312. */
  135313. name: string;
  135314. /**
  135315. * the first navmesh created. We might extend this to support multiple navmeshes
  135316. */
  135317. navMesh: any;
  135318. /**
  135319. * Initializes the recastJS plugin
  135320. * @param recastInjection can be used to inject your own recast reference
  135321. */
  135322. constructor(recastInjection?: any);
  135323. /**
  135324. * Creates a navigation mesh
  135325. * @param meshes array of all the geometry used to compute the navigatio mesh
  135326. * @param parameters bunch of parameters used to filter geometry
  135327. */
  135328. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135329. /**
  135330. * Create a navigation mesh debug mesh
  135331. * @param scene is where the mesh will be added
  135332. * @returns debug display mesh
  135333. */
  135334. createDebugNavMesh(scene: Scene): Mesh;
  135335. /**
  135336. * Get a navigation mesh constrained position, closest to the parameter position
  135337. * @param position world position
  135338. * @returns the closest point to position constrained by the navigation mesh
  135339. */
  135340. getClosestPoint(position: Vector3): Vector3;
  135341. /**
  135342. * Get a navigation mesh constrained position, within a particular radius
  135343. * @param position world position
  135344. * @param maxRadius the maximum distance to the constrained world position
  135345. * @returns the closest point to position constrained by the navigation mesh
  135346. */
  135347. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135348. /**
  135349. * Compute the final position from a segment made of destination-position
  135350. * @param position world position
  135351. * @param destination world position
  135352. * @returns the resulting point along the navmesh
  135353. */
  135354. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135355. /**
  135356. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135357. * @param start world position
  135358. * @param end world position
  135359. * @returns array containing world position composing the path
  135360. */
  135361. computePath(start: Vector3, end: Vector3): Vector3[];
  135362. /**
  135363. * Create a new Crowd so you can add agents
  135364. * @param maxAgents the maximum agent count in the crowd
  135365. * @param maxAgentRadius the maximum radius an agent can have
  135366. * @param scene to attach the crowd to
  135367. * @returns the crowd you can add agents to
  135368. */
  135369. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135370. /**
  135371. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135372. * The queries will try to find a solution within those bounds
  135373. * default is (1,1,1)
  135374. * @param extent x,y,z value that define the extent around the queries point of reference
  135375. */
  135376. setDefaultQueryExtent(extent: Vector3): void;
  135377. /**
  135378. * Get the Bounding box extent specified by setDefaultQueryExtent
  135379. * @returns the box extent values
  135380. */
  135381. getDefaultQueryExtent(): Vector3;
  135382. /**
  135383. * Disposes
  135384. */
  135385. dispose(): void;
  135386. /**
  135387. * If this plugin is supported
  135388. * @returns true if plugin is supported
  135389. */
  135390. isSupported(): boolean;
  135391. }
  135392. /**
  135393. * Recast detour crowd implementation
  135394. */
  135395. export class RecastJSCrowd implements ICrowd {
  135396. /**
  135397. * Recast/detour plugin
  135398. */
  135399. bjsRECASTPlugin: RecastJSPlugin;
  135400. /**
  135401. * Link to the detour crowd
  135402. */
  135403. recastCrowd: any;
  135404. /**
  135405. * One transform per agent
  135406. */
  135407. transforms: TransformNode[];
  135408. /**
  135409. * All agents created
  135410. */
  135411. agents: number[];
  135412. /**
  135413. * Link to the scene is kept to unregister the crowd from the scene
  135414. */
  135415. private _scene;
  135416. /**
  135417. * Observer for crowd updates
  135418. */
  135419. private _onBeforeAnimationsObserver;
  135420. /**
  135421. * Constructor
  135422. * @param plugin recastJS plugin
  135423. * @param maxAgents the maximum agent count in the crowd
  135424. * @param maxAgentRadius the maximum radius an agent can have
  135425. * @param scene to attach the crowd to
  135426. * @returns the crowd you can add agents to
  135427. */
  135428. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135429. /**
  135430. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135431. * You can attach anything to that node. The node position is updated in the scene update tick.
  135432. * @param pos world position that will be constrained by the navigation mesh
  135433. * @param parameters agent parameters
  135434. * @param transform hooked to the agent that will be update by the scene
  135435. * @returns agent index
  135436. */
  135437. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135438. /**
  135439. * Returns the agent position in world space
  135440. * @param index agent index returned by addAgent
  135441. * @returns world space position
  135442. */
  135443. getAgentPosition(index: number): Vector3;
  135444. /**
  135445. * Returns the agent velocity in world space
  135446. * @param index agent index returned by addAgent
  135447. * @returns world space velocity
  135448. */
  135449. getAgentVelocity(index: number): Vector3;
  135450. /**
  135451. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135452. * @param index agent index returned by addAgent
  135453. * @param destination targeted world position
  135454. */
  135455. agentGoto(index: number, destination: Vector3): void;
  135456. /**
  135457. * Teleport the agent to a new position
  135458. * @param index agent index returned by addAgent
  135459. * @param destination targeted world position
  135460. */
  135461. agentTeleport(index: number, destination: Vector3): void;
  135462. /**
  135463. * Update agent parameters
  135464. * @param index agent index returned by addAgent
  135465. * @param parameters agent parameters
  135466. */
  135467. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135468. /**
  135469. * remove a particular agent previously created
  135470. * @param index agent index returned by addAgent
  135471. */
  135472. removeAgent(index: number): void;
  135473. /**
  135474. * get the list of all agents attached to this crowd
  135475. * @returns list of agent indices
  135476. */
  135477. getAgents(): number[];
  135478. /**
  135479. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135480. * @param deltaTime in seconds
  135481. */
  135482. update(deltaTime: number): void;
  135483. /**
  135484. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135485. * The queries will try to find a solution within those bounds
  135486. * default is (1,1,1)
  135487. * @param extent x,y,z value that define the extent around the queries point of reference
  135488. */
  135489. setDefaultQueryExtent(extent: Vector3): void;
  135490. /**
  135491. * Get the Bounding box extent specified by setDefaultQueryExtent
  135492. * @returns the box extent values
  135493. */
  135494. getDefaultQueryExtent(): Vector3;
  135495. /**
  135496. * Release all resources
  135497. */
  135498. dispose(): void;
  135499. }
  135500. }
  135501. declare module BABYLON {
  135502. /**
  135503. * Class used to enable access to IndexedDB
  135504. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135505. */
  135506. export class Database implements IOfflineProvider {
  135507. private _callbackManifestChecked;
  135508. private _currentSceneUrl;
  135509. private _db;
  135510. private _enableSceneOffline;
  135511. private _enableTexturesOffline;
  135512. private _manifestVersionFound;
  135513. private _mustUpdateRessources;
  135514. private _hasReachedQuota;
  135515. private _isSupported;
  135516. private _idbFactory;
  135517. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135518. private static IsUASupportingBlobStorage;
  135519. /**
  135520. * Gets a boolean indicating if Database storate is enabled (off by default)
  135521. */
  135522. static IDBStorageEnabled: boolean;
  135523. /**
  135524. * Gets a boolean indicating if scene must be saved in the database
  135525. */
  135526. get enableSceneOffline(): boolean;
  135527. /**
  135528. * Gets a boolean indicating if textures must be saved in the database
  135529. */
  135530. get enableTexturesOffline(): boolean;
  135531. /**
  135532. * Creates a new Database
  135533. * @param urlToScene defines the url to load the scene
  135534. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135535. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135536. */
  135537. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135538. private static _ParseURL;
  135539. private static _ReturnFullUrlLocation;
  135540. private _checkManifestFile;
  135541. /**
  135542. * Open the database and make it available
  135543. * @param successCallback defines the callback to call on success
  135544. * @param errorCallback defines the callback to call on error
  135545. */
  135546. open(successCallback: () => void, errorCallback: () => void): void;
  135547. /**
  135548. * Loads an image from the database
  135549. * @param url defines the url to load from
  135550. * @param image defines the target DOM image
  135551. */
  135552. loadImage(url: string, image: HTMLImageElement): void;
  135553. private _loadImageFromDBAsync;
  135554. private _saveImageIntoDBAsync;
  135555. private _checkVersionFromDB;
  135556. private _loadVersionFromDBAsync;
  135557. private _saveVersionIntoDBAsync;
  135558. /**
  135559. * Loads a file from database
  135560. * @param url defines the URL to load from
  135561. * @param sceneLoaded defines a callback to call on success
  135562. * @param progressCallBack defines a callback to call when progress changed
  135563. * @param errorCallback defines a callback to call on error
  135564. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135565. */
  135566. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135567. private _loadFileAsync;
  135568. private _saveFileAsync;
  135569. /**
  135570. * Validates if xhr data is correct
  135571. * @param xhr defines the request to validate
  135572. * @param dataType defines the expected data type
  135573. * @returns true if data is correct
  135574. */
  135575. private static _ValidateXHRData;
  135576. }
  135577. }
  135578. declare module BABYLON {
  135579. /** @hidden */
  135580. export var gpuUpdateParticlesPixelShader: {
  135581. name: string;
  135582. shader: string;
  135583. };
  135584. }
  135585. declare module BABYLON {
  135586. /** @hidden */
  135587. export var gpuUpdateParticlesVertexShader: {
  135588. name: string;
  135589. shader: string;
  135590. };
  135591. }
  135592. declare module BABYLON {
  135593. /** @hidden */
  135594. export var clipPlaneFragmentDeclaration2: {
  135595. name: string;
  135596. shader: string;
  135597. };
  135598. }
  135599. declare module BABYLON {
  135600. /** @hidden */
  135601. export var gpuRenderParticlesPixelShader: {
  135602. name: string;
  135603. shader: string;
  135604. };
  135605. }
  135606. declare module BABYLON {
  135607. /** @hidden */
  135608. export var clipPlaneVertexDeclaration2: {
  135609. name: string;
  135610. shader: string;
  135611. };
  135612. }
  135613. declare module BABYLON {
  135614. /** @hidden */
  135615. export var gpuRenderParticlesVertexShader: {
  135616. name: string;
  135617. shader: string;
  135618. };
  135619. }
  135620. declare module BABYLON {
  135621. /**
  135622. * This represents a GPU particle system in Babylon
  135623. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135624. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135625. */
  135626. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135627. /**
  135628. * The layer mask we are rendering the particles through.
  135629. */
  135630. layerMask: number;
  135631. private _capacity;
  135632. private _activeCount;
  135633. private _currentActiveCount;
  135634. private _accumulatedCount;
  135635. private _renderEffect;
  135636. private _updateEffect;
  135637. private _buffer0;
  135638. private _buffer1;
  135639. private _spriteBuffer;
  135640. private _updateVAO;
  135641. private _renderVAO;
  135642. private _targetIndex;
  135643. private _sourceBuffer;
  135644. private _targetBuffer;
  135645. private _engine;
  135646. private _currentRenderId;
  135647. private _started;
  135648. private _stopped;
  135649. private _timeDelta;
  135650. private _randomTexture;
  135651. private _randomTexture2;
  135652. private _attributesStrideSize;
  135653. private _updateEffectOptions;
  135654. private _randomTextureSize;
  135655. private _actualFrame;
  135656. private readonly _rawTextureWidth;
  135657. /**
  135658. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135659. */
  135660. static get IsSupported(): boolean;
  135661. /**
  135662. * An event triggered when the system is disposed.
  135663. */
  135664. onDisposeObservable: Observable<GPUParticleSystem>;
  135665. /**
  135666. * Gets the maximum number of particles active at the same time.
  135667. * @returns The max number of active particles.
  135668. */
  135669. getCapacity(): number;
  135670. /**
  135671. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135672. * to override the particles.
  135673. */
  135674. forceDepthWrite: boolean;
  135675. /**
  135676. * Gets or set the number of active particles
  135677. */
  135678. get activeParticleCount(): number;
  135679. set activeParticleCount(value: number);
  135680. private _preWarmDone;
  135681. /**
  135682. * Is this system ready to be used/rendered
  135683. * @return true if the system is ready
  135684. */
  135685. isReady(): boolean;
  135686. /**
  135687. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135688. * @returns True if it has been started, otherwise false.
  135689. */
  135690. isStarted(): boolean;
  135691. /**
  135692. * Starts the particle system and begins to emit
  135693. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135694. */
  135695. start(delay?: number): void;
  135696. /**
  135697. * Stops the particle system.
  135698. */
  135699. stop(): void;
  135700. /**
  135701. * Remove all active particles
  135702. */
  135703. reset(): void;
  135704. /**
  135705. * Returns the string "GPUParticleSystem"
  135706. * @returns a string containing the class name
  135707. */
  135708. getClassName(): string;
  135709. private _colorGradientsTexture;
  135710. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135711. /**
  135712. * Adds a new color gradient
  135713. * @param gradient defines the gradient to use (between 0 and 1)
  135714. * @param color1 defines the color to affect to the specified gradient
  135715. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135716. * @returns the current particle system
  135717. */
  135718. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135719. /**
  135720. * Remove a specific color gradient
  135721. * @param gradient defines the gradient to remove
  135722. * @returns the current particle system
  135723. */
  135724. removeColorGradient(gradient: number): GPUParticleSystem;
  135725. private _angularSpeedGradientsTexture;
  135726. private _sizeGradientsTexture;
  135727. private _velocityGradientsTexture;
  135728. private _limitVelocityGradientsTexture;
  135729. private _dragGradientsTexture;
  135730. private _addFactorGradient;
  135731. /**
  135732. * Adds a new size gradient
  135733. * @param gradient defines the gradient to use (between 0 and 1)
  135734. * @param factor defines the size factor to affect to the specified gradient
  135735. * @returns the current particle system
  135736. */
  135737. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135738. /**
  135739. * Remove a specific size gradient
  135740. * @param gradient defines the gradient to remove
  135741. * @returns the current particle system
  135742. */
  135743. removeSizeGradient(gradient: number): GPUParticleSystem;
  135744. /**
  135745. * Adds a new angular speed gradient
  135746. * @param gradient defines the gradient to use (between 0 and 1)
  135747. * @param factor defines the angular speed to affect to the specified gradient
  135748. * @returns the current particle system
  135749. */
  135750. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135751. /**
  135752. * Remove a specific angular speed gradient
  135753. * @param gradient defines the gradient to remove
  135754. * @returns the current particle system
  135755. */
  135756. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135757. /**
  135758. * Adds a new velocity gradient
  135759. * @param gradient defines the gradient to use (between 0 and 1)
  135760. * @param factor defines the velocity to affect to the specified gradient
  135761. * @returns the current particle system
  135762. */
  135763. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135764. /**
  135765. * Remove a specific velocity gradient
  135766. * @param gradient defines the gradient to remove
  135767. * @returns the current particle system
  135768. */
  135769. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135770. /**
  135771. * Adds a new limit velocity gradient
  135772. * @param gradient defines the gradient to use (between 0 and 1)
  135773. * @param factor defines the limit velocity value to affect to the specified gradient
  135774. * @returns the current particle system
  135775. */
  135776. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135777. /**
  135778. * Remove a specific limit velocity gradient
  135779. * @param gradient defines the gradient to remove
  135780. * @returns the current particle system
  135781. */
  135782. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135783. /**
  135784. * Adds a new drag gradient
  135785. * @param gradient defines the gradient to use (between 0 and 1)
  135786. * @param factor defines the drag value to affect to the specified gradient
  135787. * @returns the current particle system
  135788. */
  135789. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135790. /**
  135791. * Remove a specific drag gradient
  135792. * @param gradient defines the gradient to remove
  135793. * @returns the current particle system
  135794. */
  135795. removeDragGradient(gradient: number): GPUParticleSystem;
  135796. /**
  135797. * Not supported by GPUParticleSystem
  135798. * @param gradient defines the gradient to use (between 0 and 1)
  135799. * @param factor defines the emit rate value to affect to the specified gradient
  135800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135801. * @returns the current particle system
  135802. */
  135803. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135804. /**
  135805. * Not supported by GPUParticleSystem
  135806. * @param gradient defines the gradient to remove
  135807. * @returns the current particle system
  135808. */
  135809. removeEmitRateGradient(gradient: number): IParticleSystem;
  135810. /**
  135811. * Not supported by GPUParticleSystem
  135812. * @param gradient defines the gradient to use (between 0 and 1)
  135813. * @param factor defines the start size value to affect to the specified gradient
  135814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135815. * @returns the current particle system
  135816. */
  135817. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135818. /**
  135819. * Not supported by GPUParticleSystem
  135820. * @param gradient defines the gradient to remove
  135821. * @returns the current particle system
  135822. */
  135823. removeStartSizeGradient(gradient: number): IParticleSystem;
  135824. /**
  135825. * Not supported by GPUParticleSystem
  135826. * @param gradient defines the gradient to use (between 0 and 1)
  135827. * @param min defines the color remap minimal range
  135828. * @param max defines the color remap maximal range
  135829. * @returns the current particle system
  135830. */
  135831. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135832. /**
  135833. * Not supported by GPUParticleSystem
  135834. * @param gradient defines the gradient to remove
  135835. * @returns the current particle system
  135836. */
  135837. removeColorRemapGradient(): IParticleSystem;
  135838. /**
  135839. * Not supported by GPUParticleSystem
  135840. * @param gradient defines the gradient to use (between 0 and 1)
  135841. * @param min defines the alpha remap minimal range
  135842. * @param max defines the alpha remap maximal range
  135843. * @returns the current particle system
  135844. */
  135845. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135846. /**
  135847. * Not supported by GPUParticleSystem
  135848. * @param gradient defines the gradient to remove
  135849. * @returns the current particle system
  135850. */
  135851. removeAlphaRemapGradient(): IParticleSystem;
  135852. /**
  135853. * Not supported by GPUParticleSystem
  135854. * @param gradient defines the gradient to use (between 0 and 1)
  135855. * @param color defines the color to affect to the specified gradient
  135856. * @returns the current particle system
  135857. */
  135858. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135859. /**
  135860. * Not supported by GPUParticleSystem
  135861. * @param gradient defines the gradient to remove
  135862. * @returns the current particle system
  135863. */
  135864. removeRampGradient(): IParticleSystem;
  135865. /**
  135866. * Not supported by GPUParticleSystem
  135867. * @returns the list of ramp gradients
  135868. */
  135869. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135870. /**
  135871. * Not supported by GPUParticleSystem
  135872. * Gets or sets a boolean indicating that ramp gradients must be used
  135873. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135874. */
  135875. get useRampGradients(): boolean;
  135876. set useRampGradients(value: boolean);
  135877. /**
  135878. * Not supported by GPUParticleSystem
  135879. * @param gradient defines the gradient to use (between 0 and 1)
  135880. * @param factor defines the life time factor to affect to the specified gradient
  135881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135882. * @returns the current particle system
  135883. */
  135884. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135885. /**
  135886. * Not supported by GPUParticleSystem
  135887. * @param gradient defines the gradient to remove
  135888. * @returns the current particle system
  135889. */
  135890. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135891. /**
  135892. * Instantiates a GPU particle system.
  135893. * 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.
  135894. * @param name The name of the particle system
  135895. * @param options The options used to create the system
  135896. * @param scene The scene the particle system belongs to
  135897. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135898. */
  135899. constructor(name: string, options: Partial<{
  135900. capacity: number;
  135901. randomTextureSize: number;
  135902. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135903. protected _reset(): void;
  135904. private _createUpdateVAO;
  135905. private _createRenderVAO;
  135906. private _initialize;
  135907. /** @hidden */
  135908. _recreateUpdateEffect(): void;
  135909. /** @hidden */
  135910. _recreateRenderEffect(): void;
  135911. /**
  135912. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135913. * @param preWarm defines if we are in the pre-warmimg phase
  135914. */
  135915. animate(preWarm?: boolean): void;
  135916. private _createFactorGradientTexture;
  135917. private _createSizeGradientTexture;
  135918. private _createAngularSpeedGradientTexture;
  135919. private _createVelocityGradientTexture;
  135920. private _createLimitVelocityGradientTexture;
  135921. private _createDragGradientTexture;
  135922. private _createColorGradientTexture;
  135923. /**
  135924. * Renders the particle system in its current state
  135925. * @param preWarm defines if the system should only update the particles but not render them
  135926. * @returns the current number of particles
  135927. */
  135928. render(preWarm?: boolean): number;
  135929. /**
  135930. * Rebuilds the particle system
  135931. */
  135932. rebuild(): void;
  135933. private _releaseBuffers;
  135934. private _releaseVAOs;
  135935. /**
  135936. * Disposes the particle system and free the associated resources
  135937. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135938. */
  135939. dispose(disposeTexture?: boolean): void;
  135940. /**
  135941. * Clones the particle system.
  135942. * @param name The name of the cloned object
  135943. * @param newEmitter The new emitter to use
  135944. * @returns the cloned particle system
  135945. */
  135946. clone(name: string, newEmitter: any): GPUParticleSystem;
  135947. /**
  135948. * Serializes the particle system to a JSON object.
  135949. * @returns the JSON object
  135950. */
  135951. serialize(): any;
  135952. /**
  135953. * Parses a JSON object to create a GPU particle system.
  135954. * @param parsedParticleSystem The JSON object to parse
  135955. * @param scene The scene to create the particle system in
  135956. * @param rootUrl The root url to use to load external dependencies like texture
  135957. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135958. * @returns the parsed GPU particle system
  135959. */
  135960. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135961. }
  135962. }
  135963. declare module BABYLON {
  135964. /**
  135965. * Represents a set of particle systems working together to create a specific effect
  135966. */
  135967. export class ParticleSystemSet implements IDisposable {
  135968. /**
  135969. * Gets or sets base Assets URL
  135970. */
  135971. static BaseAssetsUrl: string;
  135972. private _emitterCreationOptions;
  135973. private _emitterNode;
  135974. /**
  135975. * Gets the particle system list
  135976. */
  135977. systems: IParticleSystem[];
  135978. /**
  135979. * Gets the emitter node used with this set
  135980. */
  135981. get emitterNode(): Nullable<TransformNode>;
  135982. /**
  135983. * Creates a new emitter mesh as a sphere
  135984. * @param options defines the options used to create the sphere
  135985. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135986. * @param scene defines the hosting scene
  135987. */
  135988. setEmitterAsSphere(options: {
  135989. diameter: number;
  135990. segments: number;
  135991. color: Color3;
  135992. }, renderingGroupId: number, scene: Scene): void;
  135993. /**
  135994. * Starts all particle systems of the set
  135995. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135996. */
  135997. start(emitter?: AbstractMesh): void;
  135998. /**
  135999. * Release all associated resources
  136000. */
  136001. dispose(): void;
  136002. /**
  136003. * Serialize the set into a JSON compatible object
  136004. * @returns a JSON compatible representation of the set
  136005. */
  136006. serialize(): any;
  136007. /**
  136008. * Parse a new ParticleSystemSet from a serialized source
  136009. * @param data defines a JSON compatible representation of the set
  136010. * @param scene defines the hosting scene
  136011. * @param gpu defines if we want GPU particles or CPU particles
  136012. * @returns a new ParticleSystemSet
  136013. */
  136014. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136015. }
  136016. }
  136017. declare module BABYLON {
  136018. /**
  136019. * This class is made for on one-liner static method to help creating particle system set.
  136020. */
  136021. export class ParticleHelper {
  136022. /**
  136023. * Gets or sets base Assets URL
  136024. */
  136025. static BaseAssetsUrl: string;
  136026. /**
  136027. * Create a default particle system that you can tweak
  136028. * @param emitter defines the emitter to use
  136029. * @param capacity defines the system capacity (default is 500 particles)
  136030. * @param scene defines the hosting scene
  136031. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136032. * @returns the new Particle system
  136033. */
  136034. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136035. /**
  136036. * This is the main static method (one-liner) of this helper to create different particle systems
  136037. * @param type This string represents the type to the particle system to create
  136038. * @param scene The scene where the particle system should live
  136039. * @param gpu If the system will use gpu
  136040. * @returns the ParticleSystemSet created
  136041. */
  136042. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136043. /**
  136044. * Static function used to export a particle system to a ParticleSystemSet variable.
  136045. * Please note that the emitter shape is not exported
  136046. * @param systems defines the particle systems to export
  136047. * @returns the created particle system set
  136048. */
  136049. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136050. }
  136051. }
  136052. declare module BABYLON {
  136053. interface Engine {
  136054. /**
  136055. * Create an effect to use with particle systems.
  136056. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136057. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136058. * @param uniformsNames defines a list of attribute names
  136059. * @param samplers defines an array of string used to represent textures
  136060. * @param defines defines the string containing the defines to use to compile the shaders
  136061. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136062. * @param onCompiled defines a function to call when the effect creation is successful
  136063. * @param onError defines a function to call when the effect creation has failed
  136064. * @returns the new Effect
  136065. */
  136066. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136067. }
  136068. interface Mesh {
  136069. /**
  136070. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136071. * @returns an array of IParticleSystem
  136072. */
  136073. getEmittedParticleSystems(): IParticleSystem[];
  136074. /**
  136075. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136076. * @returns an array of IParticleSystem
  136077. */
  136078. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136079. }
  136080. /**
  136081. * @hidden
  136082. */
  136083. export var _IDoNeedToBeInTheBuild: number;
  136084. }
  136085. declare module BABYLON {
  136086. /** Defines the 4 color options */
  136087. export enum PointColor {
  136088. /** color value */
  136089. Color = 2,
  136090. /** uv value */
  136091. UV = 1,
  136092. /** random value */
  136093. Random = 0,
  136094. /** stated value */
  136095. Stated = 3
  136096. }
  136097. /**
  136098. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136099. * 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.
  136100. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136101. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136102. *
  136103. * Full documentation here : TO BE ENTERED
  136104. */
  136105. export class PointsCloudSystem implements IDisposable {
  136106. /**
  136107. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136108. * Example : var p = SPS.particles[i];
  136109. */
  136110. particles: CloudPoint[];
  136111. /**
  136112. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136113. */
  136114. nbParticles: number;
  136115. /**
  136116. * This a counter for your own usage. It's not set by any SPS functions.
  136117. */
  136118. counter: number;
  136119. /**
  136120. * The PCS name. This name is also given to the underlying mesh.
  136121. */
  136122. name: string;
  136123. /**
  136124. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136125. */
  136126. mesh: Mesh;
  136127. /**
  136128. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136129. * Please read :
  136130. */
  136131. vars: any;
  136132. /**
  136133. * @hidden
  136134. */
  136135. _size: number;
  136136. private _scene;
  136137. private _promises;
  136138. private _positions;
  136139. private _indices;
  136140. private _normals;
  136141. private _colors;
  136142. private _uvs;
  136143. private _indices32;
  136144. private _positions32;
  136145. private _colors32;
  136146. private _uvs32;
  136147. private _updatable;
  136148. private _isVisibilityBoxLocked;
  136149. private _alwaysVisible;
  136150. private _groups;
  136151. private _groupCounter;
  136152. private _computeParticleColor;
  136153. private _computeParticleTexture;
  136154. private _computeParticleRotation;
  136155. private _computeBoundingBox;
  136156. private _isReady;
  136157. /**
  136158. * Creates a PCS (Points Cloud System) object
  136159. * @param name (String) is the PCS name, this will be the underlying mesh name
  136160. * @param pointSize (number) is the size for each point
  136161. * @param scene (Scene) is the scene in which the PCS is added
  136162. * @param options defines the options of the PCS e.g.
  136163. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136164. */
  136165. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136166. updatable?: boolean;
  136167. });
  136168. /**
  136169. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136170. * If no points were added to the PCS, the returned mesh is just a single point.
  136171. * @returns a promise for the created mesh
  136172. */
  136173. buildMeshAsync(): Promise<Mesh>;
  136174. /**
  136175. * @hidden
  136176. */
  136177. private _buildMesh;
  136178. private _addParticle;
  136179. private _randomUnitVector;
  136180. private _getColorIndicesForCoord;
  136181. private _setPointsColorOrUV;
  136182. private _colorFromTexture;
  136183. private _calculateDensity;
  136184. /**
  136185. * Adds points to the PCS in random positions within a unit sphere
  136186. * @param nb (positive integer) the number of particles to be created from this model
  136187. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136188. * @returns the number of groups in the system
  136189. */
  136190. addPoints(nb: number, pointFunction?: any): number;
  136191. /**
  136192. * Adds points to the PCS from the surface of the model shape
  136193. * @param mesh is any Mesh object that will be used as a surface model for the points
  136194. * @param nb (positive integer) the number of particles to be created from this model
  136195. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136196. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136197. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136198. * @returns the number of groups in the system
  136199. */
  136200. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136201. /**
  136202. * Adds points to the PCS inside the model shape
  136203. * @param mesh is any Mesh object that will be used as a surface model for the points
  136204. * @param nb (positive integer) the number of particles to be created from this model
  136205. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136206. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136207. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136208. * @returns the number of groups in the system
  136209. */
  136210. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136211. /**
  136212. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136213. * This method calls `updateParticle()` for each particle of the SPS.
  136214. * For an animated SPS, it is usually called within the render loop.
  136215. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136216. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136217. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136218. * @returns the PCS.
  136219. */
  136220. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136221. /**
  136222. * Disposes the PCS.
  136223. */
  136224. dispose(): void;
  136225. /**
  136226. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136227. * doc :
  136228. * @returns the PCS.
  136229. */
  136230. refreshVisibleSize(): PointsCloudSystem;
  136231. /**
  136232. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136233. * @param size the size (float) of the visibility box
  136234. * note : this doesn't lock the PCS mesh bounding box.
  136235. * doc :
  136236. */
  136237. setVisibilityBox(size: number): void;
  136238. /**
  136239. * Gets whether the PCS is always visible or not
  136240. * doc :
  136241. */
  136242. get isAlwaysVisible(): boolean;
  136243. /**
  136244. * Sets the PCS as always visible or not
  136245. * doc :
  136246. */
  136247. set isAlwaysVisible(val: boolean);
  136248. /**
  136249. * Tells to `setParticles()` to compute the particle rotations or not
  136250. * Default value : false. The PCS is faster when it's set to false
  136251. * Note : particle rotations are only applied to parent particles
  136252. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136253. */
  136254. set computeParticleRotation(val: boolean);
  136255. /**
  136256. * Tells to `setParticles()` to compute the particle colors or not.
  136257. * Default value : true. The PCS is faster when it's set to false.
  136258. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136259. */
  136260. set computeParticleColor(val: boolean);
  136261. set computeParticleTexture(val: boolean);
  136262. /**
  136263. * Gets if `setParticles()` computes the particle colors or not.
  136264. * Default value : false. The PCS is faster when it's set to false.
  136265. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136266. */
  136267. get computeParticleColor(): boolean;
  136268. /**
  136269. * Gets if `setParticles()` computes the particle textures or not.
  136270. * Default value : false. The PCS is faster when it's set to false.
  136271. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136272. */
  136273. get computeParticleTexture(): boolean;
  136274. /**
  136275. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136276. */
  136277. set computeBoundingBox(val: boolean);
  136278. /**
  136279. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136280. */
  136281. get computeBoundingBox(): boolean;
  136282. /**
  136283. * This function does nothing. It may be overwritten to set all the particle first values.
  136284. * The PCS doesn't call this function, you may have to call it by your own.
  136285. * doc :
  136286. */
  136287. initParticles(): void;
  136288. /**
  136289. * This function does nothing. It may be overwritten to recycle a particle
  136290. * The PCS doesn't call this function, you can to call it
  136291. * doc :
  136292. * @param particle The particle to recycle
  136293. * @returns the recycled particle
  136294. */
  136295. recycleParticle(particle: CloudPoint): CloudPoint;
  136296. /**
  136297. * Updates a particle : this function should be overwritten by the user.
  136298. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136299. * doc :
  136300. * @example : just set a particle position or velocity and recycle conditions
  136301. * @param particle The particle to update
  136302. * @returns the updated particle
  136303. */
  136304. updateParticle(particle: CloudPoint): CloudPoint;
  136305. /**
  136306. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136307. * This does nothing and may be overwritten by the user.
  136308. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136309. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136310. * @param update the boolean update value actually passed to setParticles()
  136311. */
  136312. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136313. /**
  136314. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136315. * This will be passed three parameters.
  136316. * This does nothing and may be overwritten by the user.
  136317. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136318. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136319. * @param update the boolean update value actually passed to setParticles()
  136320. */
  136321. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136322. }
  136323. }
  136324. declare module BABYLON {
  136325. /**
  136326. * Represents one particle of a points cloud system.
  136327. */
  136328. export class CloudPoint {
  136329. /**
  136330. * particle global index
  136331. */
  136332. idx: number;
  136333. /**
  136334. * The color of the particle
  136335. */
  136336. color: Nullable<Color4>;
  136337. /**
  136338. * The world space position of the particle.
  136339. */
  136340. position: Vector3;
  136341. /**
  136342. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136343. */
  136344. rotation: Vector3;
  136345. /**
  136346. * The world space rotation quaternion of the particle.
  136347. */
  136348. rotationQuaternion: Nullable<Quaternion>;
  136349. /**
  136350. * The uv of the particle.
  136351. */
  136352. uv: Nullable<Vector2>;
  136353. /**
  136354. * The current speed of the particle.
  136355. */
  136356. velocity: Vector3;
  136357. /**
  136358. * The pivot point in the particle local space.
  136359. */
  136360. pivot: Vector3;
  136361. /**
  136362. * Must the particle be translated from its pivot point in its local space ?
  136363. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136364. * Default : false
  136365. */
  136366. translateFromPivot: boolean;
  136367. /**
  136368. * Index of this particle in the global "positions" array (Internal use)
  136369. * @hidden
  136370. */
  136371. _pos: number;
  136372. /**
  136373. * @hidden Index of this particle in the global "indices" array (Internal use)
  136374. */
  136375. _ind: number;
  136376. /**
  136377. * Group this particle belongs to
  136378. */
  136379. _group: PointsGroup;
  136380. /**
  136381. * Group id of this particle
  136382. */
  136383. groupId: number;
  136384. /**
  136385. * Index of the particle in its group id (Internal use)
  136386. */
  136387. idxInGroup: number;
  136388. /**
  136389. * @hidden Particle BoundingInfo object (Internal use)
  136390. */
  136391. _boundingInfo: BoundingInfo;
  136392. /**
  136393. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136394. */
  136395. _pcs: PointsCloudSystem;
  136396. /**
  136397. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136398. */
  136399. _stillInvisible: boolean;
  136400. /**
  136401. * @hidden Last computed particle rotation matrix
  136402. */
  136403. _rotationMatrix: number[];
  136404. /**
  136405. * Parent particle Id, if any.
  136406. * Default null.
  136407. */
  136408. parentId: Nullable<number>;
  136409. /**
  136410. * @hidden Internal global position in the PCS.
  136411. */
  136412. _globalPosition: Vector3;
  136413. /**
  136414. * Creates a Point Cloud object.
  136415. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136416. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136417. * @param group (PointsGroup) is the group the particle belongs to
  136418. * @param groupId (integer) is the group identifier in the PCS.
  136419. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136420. * @param pcs defines the PCS it is associated to
  136421. */
  136422. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136423. /**
  136424. * get point size
  136425. */
  136426. get size(): Vector3;
  136427. /**
  136428. * Set point size
  136429. */
  136430. set size(scale: Vector3);
  136431. /**
  136432. * Legacy support, changed quaternion to rotationQuaternion
  136433. */
  136434. get quaternion(): Nullable<Quaternion>;
  136435. /**
  136436. * Legacy support, changed quaternion to rotationQuaternion
  136437. */
  136438. set quaternion(q: Nullable<Quaternion>);
  136439. /**
  136440. * Returns a boolean. True if the particle intersects a mesh, else false
  136441. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136442. * @param target is the object (point or mesh) what the intersection is computed against
  136443. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136444. * @returns true if it intersects
  136445. */
  136446. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136447. /**
  136448. * get the rotation matrix of the particle
  136449. * @hidden
  136450. */
  136451. getRotationMatrix(m: Matrix): void;
  136452. }
  136453. /**
  136454. * Represents a group of points in a points cloud system
  136455. * * PCS internal tool, don't use it manually.
  136456. */
  136457. export class PointsGroup {
  136458. /**
  136459. * The group id
  136460. * @hidden
  136461. */
  136462. groupID: number;
  136463. /**
  136464. * image data for group (internal use)
  136465. * @hidden
  136466. */
  136467. _groupImageData: Nullable<ArrayBufferView>;
  136468. /**
  136469. * Image Width (internal use)
  136470. * @hidden
  136471. */
  136472. _groupImgWidth: number;
  136473. /**
  136474. * Image Height (internal use)
  136475. * @hidden
  136476. */
  136477. _groupImgHeight: number;
  136478. /**
  136479. * Custom position function (internal use)
  136480. * @hidden
  136481. */
  136482. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136483. /**
  136484. * density per facet for surface points
  136485. * @hidden
  136486. */
  136487. _groupDensity: number[];
  136488. /**
  136489. * Only when points are colored by texture carries pointer to texture list array
  136490. * @hidden
  136491. */
  136492. _textureNb: number;
  136493. /**
  136494. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136495. * PCS internal tool, don't use it manually.
  136496. * @hidden
  136497. */
  136498. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136499. }
  136500. }
  136501. declare module BABYLON {
  136502. interface Scene {
  136503. /** @hidden (Backing field) */
  136504. _physicsEngine: Nullable<IPhysicsEngine>;
  136505. /** @hidden */
  136506. _physicsTimeAccumulator: number;
  136507. /**
  136508. * Gets the current physics engine
  136509. * @returns a IPhysicsEngine or null if none attached
  136510. */
  136511. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136512. /**
  136513. * Enables physics to the current scene
  136514. * @param gravity defines the scene's gravity for the physics engine
  136515. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136516. * @return a boolean indicating if the physics engine was initialized
  136517. */
  136518. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136519. /**
  136520. * Disables and disposes the physics engine associated with the scene
  136521. */
  136522. disablePhysicsEngine(): void;
  136523. /**
  136524. * Gets a boolean indicating if there is an active physics engine
  136525. * @returns a boolean indicating if there is an active physics engine
  136526. */
  136527. isPhysicsEnabled(): boolean;
  136528. /**
  136529. * Deletes a physics compound impostor
  136530. * @param compound defines the compound to delete
  136531. */
  136532. deleteCompoundImpostor(compound: any): void;
  136533. /**
  136534. * An event triggered when physic simulation is about to be run
  136535. */
  136536. onBeforePhysicsObservable: Observable<Scene>;
  136537. /**
  136538. * An event triggered when physic simulation has been done
  136539. */
  136540. onAfterPhysicsObservable: Observable<Scene>;
  136541. }
  136542. interface AbstractMesh {
  136543. /** @hidden */
  136544. _physicsImpostor: Nullable<PhysicsImpostor>;
  136545. /**
  136546. * Gets or sets impostor used for physic simulation
  136547. * @see http://doc.babylonjs.com/features/physics_engine
  136548. */
  136549. physicsImpostor: Nullable<PhysicsImpostor>;
  136550. /**
  136551. * Gets the current physics impostor
  136552. * @see http://doc.babylonjs.com/features/physics_engine
  136553. * @returns a physics impostor or null
  136554. */
  136555. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136556. /** Apply a physic impulse to the mesh
  136557. * @param force defines the force to apply
  136558. * @param contactPoint defines where to apply the force
  136559. * @returns the current mesh
  136560. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136561. */
  136562. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136563. /**
  136564. * Creates a physic joint between two meshes
  136565. * @param otherMesh defines the other mesh to use
  136566. * @param pivot1 defines the pivot to use on this mesh
  136567. * @param pivot2 defines the pivot to use on the other mesh
  136568. * @param options defines additional options (can be plugin dependent)
  136569. * @returns the current mesh
  136570. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136571. */
  136572. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136573. /** @hidden */
  136574. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136575. }
  136576. /**
  136577. * Defines the physics engine scene component responsible to manage a physics engine
  136578. */
  136579. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136580. /**
  136581. * The component name helpful to identify the component in the list of scene components.
  136582. */
  136583. readonly name: string;
  136584. /**
  136585. * The scene the component belongs to.
  136586. */
  136587. scene: Scene;
  136588. /**
  136589. * Creates a new instance of the component for the given scene
  136590. * @param scene Defines the scene to register the component in
  136591. */
  136592. constructor(scene: Scene);
  136593. /**
  136594. * Registers the component in a given scene
  136595. */
  136596. register(): void;
  136597. /**
  136598. * Rebuilds the elements related to this component in case of
  136599. * context lost for instance.
  136600. */
  136601. rebuild(): void;
  136602. /**
  136603. * Disposes the component and the associated ressources
  136604. */
  136605. dispose(): void;
  136606. }
  136607. }
  136608. declare module BABYLON {
  136609. /**
  136610. * A helper for physics simulations
  136611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136612. */
  136613. export class PhysicsHelper {
  136614. private _scene;
  136615. private _physicsEngine;
  136616. /**
  136617. * Initializes the Physics helper
  136618. * @param scene Babylon.js scene
  136619. */
  136620. constructor(scene: Scene);
  136621. /**
  136622. * Applies a radial explosion impulse
  136623. * @param origin the origin of the explosion
  136624. * @param radiusOrEventOptions the radius or the options of radial explosion
  136625. * @param strength the explosion strength
  136626. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136627. * @returns A physics radial explosion event, or null
  136628. */
  136629. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136630. /**
  136631. * Applies a radial explosion force
  136632. * @param origin the origin of the explosion
  136633. * @param radiusOrEventOptions the radius or the options of radial explosion
  136634. * @param strength the explosion strength
  136635. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136636. * @returns A physics radial explosion event, or null
  136637. */
  136638. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136639. /**
  136640. * Creates a gravitational field
  136641. * @param origin the origin of the explosion
  136642. * @param radiusOrEventOptions the radius or the options of radial explosion
  136643. * @param strength the explosion strength
  136644. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136645. * @returns A physics gravitational field event, or null
  136646. */
  136647. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136648. /**
  136649. * Creates a physics updraft event
  136650. * @param origin the origin of the updraft
  136651. * @param radiusOrEventOptions the radius or the options of the updraft
  136652. * @param strength the strength of the updraft
  136653. * @param height the height of the updraft
  136654. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136655. * @returns A physics updraft event, or null
  136656. */
  136657. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136658. /**
  136659. * Creates a physics vortex event
  136660. * @param origin the of the vortex
  136661. * @param radiusOrEventOptions the radius or the options of the vortex
  136662. * @param strength the strength of the vortex
  136663. * @param height the height of the vortex
  136664. * @returns a Physics vortex event, or null
  136665. * A physics vortex event or null
  136666. */
  136667. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136668. }
  136669. /**
  136670. * Represents a physics radial explosion event
  136671. */
  136672. class PhysicsRadialExplosionEvent {
  136673. private _scene;
  136674. private _options;
  136675. private _sphere;
  136676. private _dataFetched;
  136677. /**
  136678. * Initializes a radial explosioin event
  136679. * @param _scene BabylonJS scene
  136680. * @param _options The options for the vortex event
  136681. */
  136682. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136683. /**
  136684. * Returns the data related to the radial explosion event (sphere).
  136685. * @returns The radial explosion event data
  136686. */
  136687. getData(): PhysicsRadialExplosionEventData;
  136688. /**
  136689. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136690. * @param impostor A physics imposter
  136691. * @param origin the origin of the explosion
  136692. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136693. */
  136694. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136695. /**
  136696. * Triggers affecterd impostors callbacks
  136697. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136698. */
  136699. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136700. /**
  136701. * Disposes the sphere.
  136702. * @param force Specifies if the sphere should be disposed by force
  136703. */
  136704. dispose(force?: boolean): void;
  136705. /*** Helpers ***/
  136706. private _prepareSphere;
  136707. private _intersectsWithSphere;
  136708. }
  136709. /**
  136710. * Represents a gravitational field event
  136711. */
  136712. class PhysicsGravitationalFieldEvent {
  136713. private _physicsHelper;
  136714. private _scene;
  136715. private _origin;
  136716. private _options;
  136717. private _tickCallback;
  136718. private _sphere;
  136719. private _dataFetched;
  136720. /**
  136721. * Initializes the physics gravitational field event
  136722. * @param _physicsHelper A physics helper
  136723. * @param _scene BabylonJS scene
  136724. * @param _origin The origin position of the gravitational field event
  136725. * @param _options The options for the vortex event
  136726. */
  136727. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136728. /**
  136729. * Returns the data related to the gravitational field event (sphere).
  136730. * @returns A gravitational field event
  136731. */
  136732. getData(): PhysicsGravitationalFieldEventData;
  136733. /**
  136734. * Enables the gravitational field.
  136735. */
  136736. enable(): void;
  136737. /**
  136738. * Disables the gravitational field.
  136739. */
  136740. disable(): void;
  136741. /**
  136742. * Disposes the sphere.
  136743. * @param force The force to dispose from the gravitational field event
  136744. */
  136745. dispose(force?: boolean): void;
  136746. private _tick;
  136747. }
  136748. /**
  136749. * Represents a physics updraft event
  136750. */
  136751. class PhysicsUpdraftEvent {
  136752. private _scene;
  136753. private _origin;
  136754. private _options;
  136755. private _physicsEngine;
  136756. private _originTop;
  136757. private _originDirection;
  136758. private _tickCallback;
  136759. private _cylinder;
  136760. private _cylinderPosition;
  136761. private _dataFetched;
  136762. /**
  136763. * Initializes the physics updraft event
  136764. * @param _scene BabylonJS scene
  136765. * @param _origin The origin position of the updraft
  136766. * @param _options The options for the updraft event
  136767. */
  136768. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136769. /**
  136770. * Returns the data related to the updraft event (cylinder).
  136771. * @returns A physics updraft event
  136772. */
  136773. getData(): PhysicsUpdraftEventData;
  136774. /**
  136775. * Enables the updraft.
  136776. */
  136777. enable(): void;
  136778. /**
  136779. * Disables the updraft.
  136780. */
  136781. disable(): void;
  136782. /**
  136783. * Disposes the cylinder.
  136784. * @param force Specifies if the updraft should be disposed by force
  136785. */
  136786. dispose(force?: boolean): void;
  136787. private getImpostorHitData;
  136788. private _tick;
  136789. /*** Helpers ***/
  136790. private _prepareCylinder;
  136791. private _intersectsWithCylinder;
  136792. }
  136793. /**
  136794. * Represents a physics vortex event
  136795. */
  136796. class PhysicsVortexEvent {
  136797. private _scene;
  136798. private _origin;
  136799. private _options;
  136800. private _physicsEngine;
  136801. private _originTop;
  136802. private _tickCallback;
  136803. private _cylinder;
  136804. private _cylinderPosition;
  136805. private _dataFetched;
  136806. /**
  136807. * Initializes the physics vortex event
  136808. * @param _scene The BabylonJS scene
  136809. * @param _origin The origin position of the vortex
  136810. * @param _options The options for the vortex event
  136811. */
  136812. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136813. /**
  136814. * Returns the data related to the vortex event (cylinder).
  136815. * @returns The physics vortex event data
  136816. */
  136817. getData(): PhysicsVortexEventData;
  136818. /**
  136819. * Enables the vortex.
  136820. */
  136821. enable(): void;
  136822. /**
  136823. * Disables the cortex.
  136824. */
  136825. disable(): void;
  136826. /**
  136827. * Disposes the sphere.
  136828. * @param force
  136829. */
  136830. dispose(force?: boolean): void;
  136831. private getImpostorHitData;
  136832. private _tick;
  136833. /*** Helpers ***/
  136834. private _prepareCylinder;
  136835. private _intersectsWithCylinder;
  136836. }
  136837. /**
  136838. * Options fot the radial explosion event
  136839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136840. */
  136841. export class PhysicsRadialExplosionEventOptions {
  136842. /**
  136843. * The radius of the sphere for the radial explosion.
  136844. */
  136845. radius: number;
  136846. /**
  136847. * The strenth of the explosion.
  136848. */
  136849. strength: number;
  136850. /**
  136851. * The strenght of the force in correspondence to the distance of the affected object
  136852. */
  136853. falloff: PhysicsRadialImpulseFalloff;
  136854. /**
  136855. * Sphere options for the radial explosion.
  136856. */
  136857. sphere: {
  136858. segments: number;
  136859. diameter: number;
  136860. };
  136861. /**
  136862. * Sphere options for the radial explosion.
  136863. */
  136864. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136865. }
  136866. /**
  136867. * Options fot the updraft event
  136868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136869. */
  136870. export class PhysicsUpdraftEventOptions {
  136871. /**
  136872. * The radius of the cylinder for the vortex
  136873. */
  136874. radius: number;
  136875. /**
  136876. * The strenth of the updraft.
  136877. */
  136878. strength: number;
  136879. /**
  136880. * The height of the cylinder for the updraft.
  136881. */
  136882. height: number;
  136883. /**
  136884. * The mode for the the updraft.
  136885. */
  136886. updraftMode: PhysicsUpdraftMode;
  136887. }
  136888. /**
  136889. * Options fot the vortex event
  136890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136891. */
  136892. export class PhysicsVortexEventOptions {
  136893. /**
  136894. * The radius of the cylinder for the vortex
  136895. */
  136896. radius: number;
  136897. /**
  136898. * The strenth of the vortex.
  136899. */
  136900. strength: number;
  136901. /**
  136902. * The height of the cylinder for the vortex.
  136903. */
  136904. height: number;
  136905. /**
  136906. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136907. */
  136908. centripetalForceThreshold: number;
  136909. /**
  136910. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136911. */
  136912. centripetalForceMultiplier: number;
  136913. /**
  136914. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136915. */
  136916. centrifugalForceMultiplier: number;
  136917. /**
  136918. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136919. */
  136920. updraftForceMultiplier: number;
  136921. }
  136922. /**
  136923. * The strenght of the force in correspondence to the distance of the affected object
  136924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136925. */
  136926. export enum PhysicsRadialImpulseFalloff {
  136927. /** Defines that impulse is constant in strength across it's whole radius */
  136928. Constant = 0,
  136929. /** Defines that impulse gets weaker if it's further from the origin */
  136930. Linear = 1
  136931. }
  136932. /**
  136933. * The strength of the force in correspondence to the distance of the affected object
  136934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136935. */
  136936. export enum PhysicsUpdraftMode {
  136937. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136938. Center = 0,
  136939. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136940. Perpendicular = 1
  136941. }
  136942. /**
  136943. * Interface for a physics hit data
  136944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136945. */
  136946. export interface PhysicsHitData {
  136947. /**
  136948. * The force applied at the contact point
  136949. */
  136950. force: Vector3;
  136951. /**
  136952. * The contact point
  136953. */
  136954. contactPoint: Vector3;
  136955. /**
  136956. * The distance from the origin to the contact point
  136957. */
  136958. distanceFromOrigin: number;
  136959. }
  136960. /**
  136961. * Interface for radial explosion event data
  136962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136963. */
  136964. export interface PhysicsRadialExplosionEventData {
  136965. /**
  136966. * A sphere used for the radial explosion event
  136967. */
  136968. sphere: Mesh;
  136969. }
  136970. /**
  136971. * Interface for gravitational field event data
  136972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136973. */
  136974. export interface PhysicsGravitationalFieldEventData {
  136975. /**
  136976. * A sphere mesh used for the gravitational field event
  136977. */
  136978. sphere: Mesh;
  136979. }
  136980. /**
  136981. * Interface for updraft event data
  136982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136983. */
  136984. export interface PhysicsUpdraftEventData {
  136985. /**
  136986. * A cylinder used for the updraft event
  136987. */
  136988. cylinder: Mesh;
  136989. }
  136990. /**
  136991. * Interface for vortex event data
  136992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136993. */
  136994. export interface PhysicsVortexEventData {
  136995. /**
  136996. * A cylinder used for the vortex event
  136997. */
  136998. cylinder: Mesh;
  136999. }
  137000. /**
  137001. * Interface for an affected physics impostor
  137002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137003. */
  137004. export interface PhysicsAffectedImpostorWithData {
  137005. /**
  137006. * The impostor affected by the effect
  137007. */
  137008. impostor: PhysicsImpostor;
  137009. /**
  137010. * The data about the hit/horce from the explosion
  137011. */
  137012. hitData: PhysicsHitData;
  137013. }
  137014. }
  137015. declare module BABYLON {
  137016. /** @hidden */
  137017. export var blackAndWhitePixelShader: {
  137018. name: string;
  137019. shader: string;
  137020. };
  137021. }
  137022. declare module BABYLON {
  137023. /**
  137024. * Post process used to render in black and white
  137025. */
  137026. export class BlackAndWhitePostProcess extends PostProcess {
  137027. /**
  137028. * Linear about to convert he result to black and white (default: 1)
  137029. */
  137030. degree: number;
  137031. /**
  137032. * Creates a black and white post process
  137033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137034. * @param name The name of the effect.
  137035. * @param options The required width/height ratio to downsize to before computing the render pass.
  137036. * @param camera The camera to apply the render pass to.
  137037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137038. * @param engine The engine which the post process will be applied. (default: current engine)
  137039. * @param reusable If the post process can be reused on the same frame. (default: false)
  137040. */
  137041. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137042. }
  137043. }
  137044. declare module BABYLON {
  137045. /**
  137046. * This represents a set of one or more post processes in Babylon.
  137047. * A post process can be used to apply a shader to a texture after it is rendered.
  137048. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137049. */
  137050. export class PostProcessRenderEffect {
  137051. private _postProcesses;
  137052. private _getPostProcesses;
  137053. private _singleInstance;
  137054. private _cameras;
  137055. private _indicesForCamera;
  137056. /**
  137057. * Name of the effect
  137058. * @hidden
  137059. */
  137060. _name: string;
  137061. /**
  137062. * Instantiates a post process render effect.
  137063. * A post process can be used to apply a shader to a texture after it is rendered.
  137064. * @param engine The engine the effect is tied to
  137065. * @param name The name of the effect
  137066. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137067. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137068. */
  137069. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137070. /**
  137071. * Checks if all the post processes in the effect are supported.
  137072. */
  137073. get isSupported(): boolean;
  137074. /**
  137075. * Updates the current state of the effect
  137076. * @hidden
  137077. */
  137078. _update(): void;
  137079. /**
  137080. * Attaches the effect on cameras
  137081. * @param cameras The camera to attach to.
  137082. * @hidden
  137083. */
  137084. _attachCameras(cameras: Camera): void;
  137085. /**
  137086. * Attaches the effect on cameras
  137087. * @param cameras The camera to attach to.
  137088. * @hidden
  137089. */
  137090. _attachCameras(cameras: Camera[]): void;
  137091. /**
  137092. * Detaches the effect on cameras
  137093. * @param cameras The camera to detatch from.
  137094. * @hidden
  137095. */
  137096. _detachCameras(cameras: Camera): void;
  137097. /**
  137098. * Detatches the effect on cameras
  137099. * @param cameras The camera to detatch from.
  137100. * @hidden
  137101. */
  137102. _detachCameras(cameras: Camera[]): void;
  137103. /**
  137104. * Enables the effect on given cameras
  137105. * @param cameras The camera to enable.
  137106. * @hidden
  137107. */
  137108. _enable(cameras: Camera): void;
  137109. /**
  137110. * Enables the effect on given cameras
  137111. * @param cameras The camera to enable.
  137112. * @hidden
  137113. */
  137114. _enable(cameras: Nullable<Camera[]>): void;
  137115. /**
  137116. * Disables the effect on the given cameras
  137117. * @param cameras The camera to disable.
  137118. * @hidden
  137119. */
  137120. _disable(cameras: Camera): void;
  137121. /**
  137122. * Disables the effect on the given cameras
  137123. * @param cameras The camera to disable.
  137124. * @hidden
  137125. */
  137126. _disable(cameras: Nullable<Camera[]>): void;
  137127. /**
  137128. * Gets a list of the post processes contained in the effect.
  137129. * @param camera The camera to get the post processes on.
  137130. * @returns The list of the post processes in the effect.
  137131. */
  137132. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137133. }
  137134. }
  137135. declare module BABYLON {
  137136. /** @hidden */
  137137. export var extractHighlightsPixelShader: {
  137138. name: string;
  137139. shader: string;
  137140. };
  137141. }
  137142. declare module BABYLON {
  137143. /**
  137144. * 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.
  137145. */
  137146. export class ExtractHighlightsPostProcess extends PostProcess {
  137147. /**
  137148. * The luminance threshold, pixels below this value will be set to black.
  137149. */
  137150. threshold: number;
  137151. /** @hidden */
  137152. _exposure: number;
  137153. /**
  137154. * Post process which has the input texture to be used when performing highlight extraction
  137155. * @hidden
  137156. */
  137157. _inputPostProcess: Nullable<PostProcess>;
  137158. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137159. }
  137160. }
  137161. declare module BABYLON {
  137162. /** @hidden */
  137163. export var bloomMergePixelShader: {
  137164. name: string;
  137165. shader: string;
  137166. };
  137167. }
  137168. declare module BABYLON {
  137169. /**
  137170. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137171. */
  137172. export class BloomMergePostProcess extends PostProcess {
  137173. /** Weight of the bloom to be added to the original input. */
  137174. weight: number;
  137175. /**
  137176. * Creates a new instance of @see BloomMergePostProcess
  137177. * @param name The name of the effect.
  137178. * @param originalFromInput Post process which's input will be used for the merge.
  137179. * @param blurred Blurred highlights post process which's output will be used.
  137180. * @param weight Weight of the bloom to be added to the original input.
  137181. * @param options The required width/height ratio to downsize to before computing the render pass.
  137182. * @param camera The camera to apply the render pass to.
  137183. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137184. * @param engine The engine which the post process will be applied. (default: current engine)
  137185. * @param reusable If the post process can be reused on the same frame. (default: false)
  137186. * @param textureType Type of textures used when performing the post process. (default: 0)
  137187. * @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)
  137188. */
  137189. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137190. /** Weight of the bloom to be added to the original input. */
  137191. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137192. }
  137193. }
  137194. declare module BABYLON {
  137195. /**
  137196. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137197. */
  137198. export class BloomEffect extends PostProcessRenderEffect {
  137199. private bloomScale;
  137200. /**
  137201. * @hidden Internal
  137202. */
  137203. _effects: Array<PostProcess>;
  137204. /**
  137205. * @hidden Internal
  137206. */
  137207. _downscale: ExtractHighlightsPostProcess;
  137208. private _blurX;
  137209. private _blurY;
  137210. private _merge;
  137211. /**
  137212. * The luminance threshold to find bright areas of the image to bloom.
  137213. */
  137214. get threshold(): number;
  137215. set threshold(value: number);
  137216. /**
  137217. * The strength of the bloom.
  137218. */
  137219. get weight(): number;
  137220. set weight(value: number);
  137221. /**
  137222. * Specifies the size of the bloom blur kernel, relative to the final output size
  137223. */
  137224. get kernel(): number;
  137225. set kernel(value: number);
  137226. /**
  137227. * Creates a new instance of @see BloomEffect
  137228. * @param scene The scene the effect belongs to.
  137229. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137230. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137231. * @param bloomWeight The the strength of bloom.
  137232. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137233. * @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)
  137234. */
  137235. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137236. /**
  137237. * Disposes each of the internal effects for a given camera.
  137238. * @param camera The camera to dispose the effect on.
  137239. */
  137240. disposeEffects(camera: Camera): void;
  137241. /**
  137242. * @hidden Internal
  137243. */
  137244. _updateEffects(): void;
  137245. /**
  137246. * Internal
  137247. * @returns if all the contained post processes are ready.
  137248. * @hidden
  137249. */
  137250. _isReady(): boolean;
  137251. }
  137252. }
  137253. declare module BABYLON {
  137254. /** @hidden */
  137255. export var chromaticAberrationPixelShader: {
  137256. name: string;
  137257. shader: string;
  137258. };
  137259. }
  137260. declare module BABYLON {
  137261. /**
  137262. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137263. */
  137264. export class ChromaticAberrationPostProcess extends PostProcess {
  137265. /**
  137266. * The amount of seperation of rgb channels (default: 30)
  137267. */
  137268. aberrationAmount: number;
  137269. /**
  137270. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137271. */
  137272. radialIntensity: number;
  137273. /**
  137274. * 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))
  137275. */
  137276. direction: Vector2;
  137277. /**
  137278. * 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))
  137279. */
  137280. centerPosition: Vector2;
  137281. /**
  137282. * Creates a new instance ChromaticAberrationPostProcess
  137283. * @param name The name of the effect.
  137284. * @param screenWidth The width of the screen to apply the effect on.
  137285. * @param screenHeight The height of the screen to apply the effect on.
  137286. * @param options The required width/height ratio to downsize to before computing the render pass.
  137287. * @param camera The camera to apply the render pass to.
  137288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137289. * @param engine The engine which the post process will be applied. (default: current engine)
  137290. * @param reusable If the post process can be reused on the same frame. (default: false)
  137291. * @param textureType Type of textures used when performing the post process. (default: 0)
  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(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137295. }
  137296. }
  137297. declare module BABYLON {
  137298. /** @hidden */
  137299. export var circleOfConfusionPixelShader: {
  137300. name: string;
  137301. shader: string;
  137302. };
  137303. }
  137304. declare module BABYLON {
  137305. /**
  137306. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137307. */
  137308. export class CircleOfConfusionPostProcess extends PostProcess {
  137309. /**
  137310. * 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.
  137311. */
  137312. lensSize: number;
  137313. /**
  137314. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137315. */
  137316. fStop: number;
  137317. /**
  137318. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137319. */
  137320. focusDistance: number;
  137321. /**
  137322. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137323. */
  137324. focalLength: number;
  137325. private _depthTexture;
  137326. /**
  137327. * Creates a new instance CircleOfConfusionPostProcess
  137328. * @param name The name of the effect.
  137329. * @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.
  137330. * @param options The required width/height ratio to downsize to before computing the render pass.
  137331. * @param camera The camera to apply the render pass to.
  137332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137333. * @param engine The engine which the post process will be applied. (default: current engine)
  137334. * @param reusable If the post process can be reused on the same frame. (default: false)
  137335. * @param textureType Type of textures used when performing the post process. (default: 0)
  137336. * @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)
  137337. */
  137338. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137339. /**
  137340. * 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.
  137341. */
  137342. set depthTexture(value: RenderTargetTexture);
  137343. }
  137344. }
  137345. declare module BABYLON {
  137346. /** @hidden */
  137347. export var colorCorrectionPixelShader: {
  137348. name: string;
  137349. shader: string;
  137350. };
  137351. }
  137352. declare module BABYLON {
  137353. /**
  137354. *
  137355. * This post-process allows the modification of rendered colors by using
  137356. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137357. *
  137358. * The object needs to be provided an url to a texture containing the color
  137359. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137360. * Use an image editing software to tweak the LUT to match your needs.
  137361. *
  137362. * For an example of a color LUT, see here:
  137363. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137364. * For explanations on color grading, see here:
  137365. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137366. *
  137367. */
  137368. export class ColorCorrectionPostProcess extends PostProcess {
  137369. private _colorTableTexture;
  137370. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137371. }
  137372. }
  137373. declare module BABYLON {
  137374. /** @hidden */
  137375. export var convolutionPixelShader: {
  137376. name: string;
  137377. shader: string;
  137378. };
  137379. }
  137380. declare module BABYLON {
  137381. /**
  137382. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137383. * input texture to perform effects such as edge detection or sharpening
  137384. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137385. */
  137386. export class ConvolutionPostProcess extends PostProcess {
  137387. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137388. kernel: number[];
  137389. /**
  137390. * Creates a new instance ConvolutionPostProcess
  137391. * @param name The name of the effect.
  137392. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137393. * @param options The required width/height ratio to downsize to before computing the render pass.
  137394. * @param camera The camera to apply the render pass to.
  137395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137396. * @param engine The engine which the post process will be applied. (default: current engine)
  137397. * @param reusable If the post process can be reused on the same frame. (default: false)
  137398. * @param textureType Type of textures used when performing the post process. (default: 0)
  137399. */
  137400. constructor(name: string,
  137401. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137402. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137403. /**
  137404. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137405. */
  137406. static EdgeDetect0Kernel: number[];
  137407. /**
  137408. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137409. */
  137410. static EdgeDetect1Kernel: number[];
  137411. /**
  137412. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137413. */
  137414. static EdgeDetect2Kernel: number[];
  137415. /**
  137416. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137417. */
  137418. static SharpenKernel: number[];
  137419. /**
  137420. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137421. */
  137422. static EmbossKernel: number[];
  137423. /**
  137424. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137425. */
  137426. static GaussianKernel: number[];
  137427. }
  137428. }
  137429. declare module BABYLON {
  137430. /**
  137431. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137432. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137433. * based on samples that have a large difference in distance than the center pixel.
  137434. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137435. */
  137436. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137437. direction: Vector2;
  137438. /**
  137439. * Creates a new instance CircleOfConfusionPostProcess
  137440. * @param name The name of the effect.
  137441. * @param scene The scene the effect belongs to.
  137442. * @param direction The direction the blur should be applied.
  137443. * @param kernel The size of the kernel used to blur.
  137444. * @param options The required width/height ratio to downsize to before computing the render pass.
  137445. * @param camera The camera to apply the render pass to.
  137446. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137447. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137449. * @param engine The engine which the post process will be applied. (default: current engine)
  137450. * @param reusable If the post process can be reused on the same frame. (default: false)
  137451. * @param textureType Type of textures used when performing the post process. (default: 0)
  137452. * @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)
  137453. */
  137454. 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);
  137455. }
  137456. }
  137457. declare module BABYLON {
  137458. /** @hidden */
  137459. export var depthOfFieldMergePixelShader: {
  137460. name: string;
  137461. shader: string;
  137462. };
  137463. }
  137464. declare module BABYLON {
  137465. /**
  137466. * Options to be set when merging outputs from the default pipeline.
  137467. */
  137468. export class DepthOfFieldMergePostProcessOptions {
  137469. /**
  137470. * The original image to merge on top of
  137471. */
  137472. originalFromInput: PostProcess;
  137473. /**
  137474. * Parameters to perform the merge of the depth of field effect
  137475. */
  137476. depthOfField?: {
  137477. circleOfConfusion: PostProcess;
  137478. blurSteps: Array<PostProcess>;
  137479. };
  137480. /**
  137481. * Parameters to perform the merge of bloom effect
  137482. */
  137483. bloom?: {
  137484. blurred: PostProcess;
  137485. weight: number;
  137486. };
  137487. }
  137488. /**
  137489. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137490. */
  137491. export class DepthOfFieldMergePostProcess extends PostProcess {
  137492. private blurSteps;
  137493. /**
  137494. * Creates a new instance of DepthOfFieldMergePostProcess
  137495. * @param name The name of the effect.
  137496. * @param originalFromInput Post process which's input will be used for the merge.
  137497. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137498. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137499. * @param options The required width/height ratio to downsize to before computing the render pass.
  137500. * @param camera The camera to apply the render pass to.
  137501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137502. * @param engine The engine which the post process will be applied. (default: current engine)
  137503. * @param reusable If the post process can be reused on the same frame. (default: false)
  137504. * @param textureType Type of textures used when performing the post process. (default: 0)
  137505. * @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)
  137506. */
  137507. 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);
  137508. /**
  137509. * Updates the effect with the current post process compile time values and recompiles the shader.
  137510. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137511. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137512. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137513. * @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
  137514. * @param onCompiled Called when the shader has been compiled.
  137515. * @param onError Called if there is an error when compiling a shader.
  137516. */
  137517. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137518. }
  137519. }
  137520. declare module BABYLON {
  137521. /**
  137522. * Specifies the level of max blur that should be applied when using the depth of field effect
  137523. */
  137524. export enum DepthOfFieldEffectBlurLevel {
  137525. /**
  137526. * Subtle blur
  137527. */
  137528. Low = 0,
  137529. /**
  137530. * Medium blur
  137531. */
  137532. Medium = 1,
  137533. /**
  137534. * Large blur
  137535. */
  137536. High = 2
  137537. }
  137538. /**
  137539. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137540. */
  137541. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137542. private _circleOfConfusion;
  137543. /**
  137544. * @hidden Internal, blurs from high to low
  137545. */
  137546. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137547. private _depthOfFieldBlurY;
  137548. private _dofMerge;
  137549. /**
  137550. * @hidden Internal post processes in depth of field effect
  137551. */
  137552. _effects: Array<PostProcess>;
  137553. /**
  137554. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137555. */
  137556. set focalLength(value: number);
  137557. get focalLength(): number;
  137558. /**
  137559. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137560. */
  137561. set fStop(value: number);
  137562. get fStop(): number;
  137563. /**
  137564. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137565. */
  137566. set focusDistance(value: number);
  137567. get focusDistance(): number;
  137568. /**
  137569. * 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.
  137570. */
  137571. set lensSize(value: number);
  137572. get lensSize(): number;
  137573. /**
  137574. * Creates a new instance DepthOfFieldEffect
  137575. * @param scene The scene the effect belongs to.
  137576. * @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.
  137577. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137578. * @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)
  137579. */
  137580. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137581. /**
  137582. * Get the current class name of the current effet
  137583. * @returns "DepthOfFieldEffect"
  137584. */
  137585. getClassName(): string;
  137586. /**
  137587. * 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.
  137588. */
  137589. set depthTexture(value: RenderTargetTexture);
  137590. /**
  137591. * Disposes each of the internal effects for a given camera.
  137592. * @param camera The camera to dispose the effect on.
  137593. */
  137594. disposeEffects(camera: Camera): void;
  137595. /**
  137596. * @hidden Internal
  137597. */
  137598. _updateEffects(): void;
  137599. /**
  137600. * Internal
  137601. * @returns if all the contained post processes are ready.
  137602. * @hidden
  137603. */
  137604. _isReady(): boolean;
  137605. }
  137606. }
  137607. declare module BABYLON {
  137608. /** @hidden */
  137609. export var displayPassPixelShader: {
  137610. name: string;
  137611. shader: string;
  137612. };
  137613. }
  137614. declare module BABYLON {
  137615. /**
  137616. * DisplayPassPostProcess which produces an output the same as it's input
  137617. */
  137618. export class DisplayPassPostProcess extends PostProcess {
  137619. /**
  137620. * Creates the DisplayPassPostProcess
  137621. * @param name The name of the effect.
  137622. * @param options The required width/height ratio to downsize to before computing the render pass.
  137623. * @param camera The camera to apply the render pass to.
  137624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137625. * @param engine The engine which the post process will be applied. (default: current engine)
  137626. * @param reusable If the post process can be reused on the same frame. (default: false)
  137627. */
  137628. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137629. }
  137630. }
  137631. declare module BABYLON {
  137632. /** @hidden */
  137633. export var filterPixelShader: {
  137634. name: string;
  137635. shader: string;
  137636. };
  137637. }
  137638. declare module BABYLON {
  137639. /**
  137640. * Applies a kernel filter to the image
  137641. */
  137642. export class FilterPostProcess extends PostProcess {
  137643. /** The matrix to be applied to the image */
  137644. kernelMatrix: Matrix;
  137645. /**
  137646. *
  137647. * @param name The name of the effect.
  137648. * @param kernelMatrix The matrix to be applied to the image
  137649. * @param options The required width/height ratio to downsize to before computing the render pass.
  137650. * @param camera The camera to apply the render pass to.
  137651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137652. * @param engine The engine which the post process will be applied. (default: current engine)
  137653. * @param reusable If the post process can be reused on the same frame. (default: false)
  137654. */
  137655. constructor(name: string,
  137656. /** The matrix to be applied to the image */
  137657. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137658. }
  137659. }
  137660. declare module BABYLON {
  137661. /** @hidden */
  137662. export var fxaaPixelShader: {
  137663. name: string;
  137664. shader: string;
  137665. };
  137666. }
  137667. declare module BABYLON {
  137668. /** @hidden */
  137669. export var fxaaVertexShader: {
  137670. name: string;
  137671. shader: string;
  137672. };
  137673. }
  137674. declare module BABYLON {
  137675. /**
  137676. * Fxaa post process
  137677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137678. */
  137679. export class FxaaPostProcess extends PostProcess {
  137680. /** @hidden */
  137681. texelWidth: number;
  137682. /** @hidden */
  137683. texelHeight: number;
  137684. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137685. private _getDefines;
  137686. }
  137687. }
  137688. declare module BABYLON {
  137689. /** @hidden */
  137690. export var grainPixelShader: {
  137691. name: string;
  137692. shader: string;
  137693. };
  137694. }
  137695. declare module BABYLON {
  137696. /**
  137697. * The GrainPostProcess adds noise to the image at mid luminance levels
  137698. */
  137699. export class GrainPostProcess extends PostProcess {
  137700. /**
  137701. * The intensity of the grain added (default: 30)
  137702. */
  137703. intensity: number;
  137704. /**
  137705. * If the grain should be randomized on every frame
  137706. */
  137707. animated: boolean;
  137708. /**
  137709. * Creates a new instance of @see GrainPostProcess
  137710. * @param name The name of the effect.
  137711. * @param options The required width/height ratio to downsize to before computing the render pass.
  137712. * @param camera The camera to apply the render pass to.
  137713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137714. * @param engine The engine which the post process will be applied. (default: current engine)
  137715. * @param reusable If the post process can be reused on the same frame. (default: false)
  137716. * @param textureType Type of textures used when performing the post process. (default: 0)
  137717. * @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)
  137718. */
  137719. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137720. }
  137721. }
  137722. declare module BABYLON {
  137723. /** @hidden */
  137724. export var highlightsPixelShader: {
  137725. name: string;
  137726. shader: string;
  137727. };
  137728. }
  137729. declare module BABYLON {
  137730. /**
  137731. * Extracts highlights from the image
  137732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137733. */
  137734. export class HighlightsPostProcess extends PostProcess {
  137735. /**
  137736. * Extracts highlights from the image
  137737. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137738. * @param name The name of the effect.
  137739. * @param options The required width/height ratio to downsize to before computing the render pass.
  137740. * @param camera The camera to apply the render pass to.
  137741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137742. * @param engine The engine which the post process will be applied. (default: current engine)
  137743. * @param reusable If the post process can be reused on the same frame. (default: false)
  137744. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137745. */
  137746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137747. }
  137748. }
  137749. declare module BABYLON {
  137750. /** @hidden */
  137751. export var mrtFragmentDeclaration: {
  137752. name: string;
  137753. shader: string;
  137754. };
  137755. }
  137756. declare module BABYLON {
  137757. /** @hidden */
  137758. export var geometryPixelShader: {
  137759. name: string;
  137760. shader: string;
  137761. };
  137762. }
  137763. declare module BABYLON {
  137764. /** @hidden */
  137765. export var geometryVertexShader: {
  137766. name: string;
  137767. shader: string;
  137768. };
  137769. }
  137770. declare module BABYLON {
  137771. /** @hidden */
  137772. interface ISavedTransformationMatrix {
  137773. world: Matrix;
  137774. viewProjection: Matrix;
  137775. }
  137776. /**
  137777. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137778. */
  137779. export class GeometryBufferRenderer {
  137780. /**
  137781. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137782. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137783. */
  137784. static readonly POSITION_TEXTURE_TYPE: number;
  137785. /**
  137786. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137787. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137788. */
  137789. static readonly VELOCITY_TEXTURE_TYPE: number;
  137790. /**
  137791. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137792. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137793. */
  137794. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137795. /**
  137796. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137797. * in order to compute objects velocities when enableVelocity is set to "true"
  137798. * @hidden
  137799. */
  137800. _previousTransformationMatrices: {
  137801. [index: number]: ISavedTransformationMatrix;
  137802. };
  137803. /**
  137804. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137805. * in order to compute objects velocities when enableVelocity is set to "true"
  137806. * @hidden
  137807. */
  137808. _previousBonesTransformationMatrices: {
  137809. [index: number]: Float32Array;
  137810. };
  137811. /**
  137812. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137813. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137814. */
  137815. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137816. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137817. renderTransparentMeshes: boolean;
  137818. private _scene;
  137819. private _multiRenderTarget;
  137820. private _ratio;
  137821. private _enablePosition;
  137822. private _enableVelocity;
  137823. private _enableReflectivity;
  137824. private _positionIndex;
  137825. private _velocityIndex;
  137826. private _reflectivityIndex;
  137827. protected _effect: Effect;
  137828. protected _cachedDefines: string;
  137829. /**
  137830. * Set the render list (meshes to be rendered) used in the G buffer.
  137831. */
  137832. set renderList(meshes: Mesh[]);
  137833. /**
  137834. * Gets wether or not G buffer are supported by the running hardware.
  137835. * This requires draw buffer supports
  137836. */
  137837. get isSupported(): boolean;
  137838. /**
  137839. * Returns the index of the given texture type in the G-Buffer textures array
  137840. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137841. * @returns the index of the given texture type in the G-Buffer textures array
  137842. */
  137843. getTextureIndex(textureType: number): number;
  137844. /**
  137845. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137846. */
  137847. get enablePosition(): boolean;
  137848. /**
  137849. * Sets whether or not objects positions are enabled for the G buffer.
  137850. */
  137851. set enablePosition(enable: boolean);
  137852. /**
  137853. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137854. */
  137855. get enableVelocity(): boolean;
  137856. /**
  137857. * Sets wether or not objects velocities are enabled for the G buffer.
  137858. */
  137859. set enableVelocity(enable: boolean);
  137860. /**
  137861. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137862. */
  137863. get enableReflectivity(): boolean;
  137864. /**
  137865. * Sets wether or not objects roughness are enabled for the G buffer.
  137866. */
  137867. set enableReflectivity(enable: boolean);
  137868. /**
  137869. * Gets the scene associated with the buffer.
  137870. */
  137871. get scene(): Scene;
  137872. /**
  137873. * Gets the ratio used by the buffer during its creation.
  137874. * How big is the buffer related to the main canvas.
  137875. */
  137876. get ratio(): number;
  137877. /** @hidden */
  137878. static _SceneComponentInitialization: (scene: Scene) => void;
  137879. /**
  137880. * Creates a new G Buffer for the scene
  137881. * @param scene The scene the buffer belongs to
  137882. * @param ratio How big is the buffer related to the main canvas.
  137883. */
  137884. constructor(scene: Scene, ratio?: number);
  137885. /**
  137886. * Checks wether everything is ready to render a submesh to the G buffer.
  137887. * @param subMesh the submesh to check readiness for
  137888. * @param useInstances is the mesh drawn using instance or not
  137889. * @returns true if ready otherwise false
  137890. */
  137891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137892. /**
  137893. * Gets the current underlying G Buffer.
  137894. * @returns the buffer
  137895. */
  137896. getGBuffer(): MultiRenderTarget;
  137897. /**
  137898. * Gets the number of samples used to render the buffer (anti aliasing).
  137899. */
  137900. get samples(): number;
  137901. /**
  137902. * Sets the number of samples used to render the buffer (anti aliasing).
  137903. */
  137904. set samples(value: number);
  137905. /**
  137906. * Disposes the renderer and frees up associated resources.
  137907. */
  137908. dispose(): void;
  137909. protected _createRenderTargets(): void;
  137910. private _copyBonesTransformationMatrices;
  137911. }
  137912. }
  137913. declare module BABYLON {
  137914. interface Scene {
  137915. /** @hidden (Backing field) */
  137916. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137917. /**
  137918. * Gets or Sets the current geometry buffer associated to the scene.
  137919. */
  137920. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137921. /**
  137922. * Enables a GeometryBufferRender and associates it with the scene
  137923. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137924. * @returns the GeometryBufferRenderer
  137925. */
  137926. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137927. /**
  137928. * Disables the GeometryBufferRender associated with the scene
  137929. */
  137930. disableGeometryBufferRenderer(): void;
  137931. }
  137932. /**
  137933. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137934. * in several rendering techniques.
  137935. */
  137936. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137937. /**
  137938. * The component name helpful to identify the component in the list of scene components.
  137939. */
  137940. readonly name: string;
  137941. /**
  137942. * The scene the component belongs to.
  137943. */
  137944. scene: Scene;
  137945. /**
  137946. * Creates a new instance of the component for the given scene
  137947. * @param scene Defines the scene to register the component in
  137948. */
  137949. constructor(scene: Scene);
  137950. /**
  137951. * Registers the component in a given scene
  137952. */
  137953. register(): void;
  137954. /**
  137955. * Rebuilds the elements related to this component in case of
  137956. * context lost for instance.
  137957. */
  137958. rebuild(): void;
  137959. /**
  137960. * Disposes the component and the associated ressources
  137961. */
  137962. dispose(): void;
  137963. private _gatherRenderTargets;
  137964. }
  137965. }
  137966. declare module BABYLON {
  137967. /** @hidden */
  137968. export var motionBlurPixelShader: {
  137969. name: string;
  137970. shader: string;
  137971. };
  137972. }
  137973. declare module BABYLON {
  137974. /**
  137975. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137976. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137977. * As an example, all you have to do is to create the post-process:
  137978. * var mb = new BABYLON.MotionBlurPostProcess(
  137979. * 'mb', // The name of the effect.
  137980. * scene, // The scene containing the objects to blur according to their velocity.
  137981. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137982. * camera // The camera to apply the render pass to.
  137983. * );
  137984. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137985. */
  137986. export class MotionBlurPostProcess extends PostProcess {
  137987. /**
  137988. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137989. */
  137990. motionStrength: number;
  137991. /**
  137992. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137993. */
  137994. get motionBlurSamples(): number;
  137995. /**
  137996. * Sets the number of iterations to be used for motion blur quality
  137997. */
  137998. set motionBlurSamples(samples: number);
  137999. private _motionBlurSamples;
  138000. private _geometryBufferRenderer;
  138001. /**
  138002. * Creates a new instance MotionBlurPostProcess
  138003. * @param name The name of the effect.
  138004. * @param scene The scene containing the objects to blur according to their velocity.
  138005. * @param options The required width/height ratio to downsize to before computing the render pass.
  138006. * @param camera The camera to apply the render pass to.
  138007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138008. * @param engine The engine which the post process will be applied. (default: current engine)
  138009. * @param reusable If the post process can be reused on the same frame. (default: false)
  138010. * @param textureType Type of textures used when performing the post process. (default: 0)
  138011. * @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)
  138012. */
  138013. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138014. /**
  138015. * Excludes the given skinned mesh from computing bones velocities.
  138016. * 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.
  138017. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138018. */
  138019. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138020. /**
  138021. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138022. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138023. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138024. */
  138025. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138026. /**
  138027. * Disposes the post process.
  138028. * @param camera The camera to dispose the post process on.
  138029. */
  138030. dispose(camera?: Camera): void;
  138031. }
  138032. }
  138033. declare module BABYLON {
  138034. /** @hidden */
  138035. export var refractionPixelShader: {
  138036. name: string;
  138037. shader: string;
  138038. };
  138039. }
  138040. declare module BABYLON {
  138041. /**
  138042. * Post process which applies a refractin texture
  138043. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138044. */
  138045. export class RefractionPostProcess extends PostProcess {
  138046. /** the base color of the refraction (used to taint the rendering) */
  138047. color: Color3;
  138048. /** simulated refraction depth */
  138049. depth: number;
  138050. /** the coefficient of the base color (0 to remove base color tainting) */
  138051. colorLevel: number;
  138052. private _refTexture;
  138053. private _ownRefractionTexture;
  138054. /**
  138055. * Gets or sets the refraction texture
  138056. * Please note that you are responsible for disposing the texture if you set it manually
  138057. */
  138058. get refractionTexture(): Texture;
  138059. set refractionTexture(value: Texture);
  138060. /**
  138061. * Initializes the RefractionPostProcess
  138062. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138063. * @param name The name of the effect.
  138064. * @param refractionTextureUrl Url of the refraction texture to use
  138065. * @param color the base color of the refraction (used to taint the rendering)
  138066. * @param depth simulated refraction depth
  138067. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138068. * @param camera The camera to apply the render pass to.
  138069. * @param options The required width/height ratio to downsize to before computing the render pass.
  138070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138071. * @param engine The engine which the post process will be applied. (default: current engine)
  138072. * @param reusable If the post process can be reused on the same frame. (default: false)
  138073. */
  138074. constructor(name: string, refractionTextureUrl: string,
  138075. /** the base color of the refraction (used to taint the rendering) */
  138076. color: Color3,
  138077. /** simulated refraction depth */
  138078. depth: number,
  138079. /** the coefficient of the base color (0 to remove base color tainting) */
  138080. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138081. /**
  138082. * Disposes of the post process
  138083. * @param camera Camera to dispose post process on
  138084. */
  138085. dispose(camera: Camera): void;
  138086. }
  138087. }
  138088. declare module BABYLON {
  138089. /** @hidden */
  138090. export var sharpenPixelShader: {
  138091. name: string;
  138092. shader: string;
  138093. };
  138094. }
  138095. declare module BABYLON {
  138096. /**
  138097. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138098. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138099. */
  138100. export class SharpenPostProcess extends PostProcess {
  138101. /**
  138102. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138103. */
  138104. colorAmount: number;
  138105. /**
  138106. * How much sharpness should be applied (default: 0.3)
  138107. */
  138108. edgeAmount: number;
  138109. /**
  138110. * Creates a new instance ConvolutionPostProcess
  138111. * @param name The name of the effect.
  138112. * @param options The required width/height ratio to downsize to before computing the render pass.
  138113. * @param camera The camera to apply the render pass to.
  138114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138115. * @param engine The engine which the post process will be applied. (default: current engine)
  138116. * @param reusable If the post process can be reused on the same frame. (default: false)
  138117. * @param textureType Type of textures used when performing the post process. (default: 0)
  138118. * @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)
  138119. */
  138120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138121. }
  138122. }
  138123. declare module BABYLON {
  138124. /**
  138125. * PostProcessRenderPipeline
  138126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138127. */
  138128. export class PostProcessRenderPipeline {
  138129. private engine;
  138130. private _renderEffects;
  138131. private _renderEffectsForIsolatedPass;
  138132. /**
  138133. * List of inspectable custom properties (used by the Inspector)
  138134. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138135. */
  138136. inspectableCustomProperties: IInspectable[];
  138137. /**
  138138. * @hidden
  138139. */
  138140. protected _cameras: Camera[];
  138141. /** @hidden */
  138142. _name: string;
  138143. /**
  138144. * Gets pipeline name
  138145. */
  138146. get name(): string;
  138147. /** Gets the list of attached cameras */
  138148. get cameras(): Camera[];
  138149. /**
  138150. * Initializes a PostProcessRenderPipeline
  138151. * @param engine engine to add the pipeline to
  138152. * @param name name of the pipeline
  138153. */
  138154. constructor(engine: Engine, name: string);
  138155. /**
  138156. * Gets the class name
  138157. * @returns "PostProcessRenderPipeline"
  138158. */
  138159. getClassName(): string;
  138160. /**
  138161. * If all the render effects in the pipeline are supported
  138162. */
  138163. get isSupported(): boolean;
  138164. /**
  138165. * Adds an effect to the pipeline
  138166. * @param renderEffect the effect to add
  138167. */
  138168. addEffect(renderEffect: PostProcessRenderEffect): void;
  138169. /** @hidden */
  138170. _rebuild(): void;
  138171. /** @hidden */
  138172. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138173. /** @hidden */
  138174. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138175. /** @hidden */
  138176. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138177. /** @hidden */
  138178. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138179. /** @hidden */
  138180. _attachCameras(cameras: Camera, unique: boolean): void;
  138181. /** @hidden */
  138182. _attachCameras(cameras: Camera[], unique: boolean): void;
  138183. /** @hidden */
  138184. _detachCameras(cameras: Camera): void;
  138185. /** @hidden */
  138186. _detachCameras(cameras: Nullable<Camera[]>): void;
  138187. /** @hidden */
  138188. _update(): void;
  138189. /** @hidden */
  138190. _reset(): void;
  138191. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138192. /**
  138193. * Disposes of the pipeline
  138194. */
  138195. dispose(): void;
  138196. }
  138197. }
  138198. declare module BABYLON {
  138199. /**
  138200. * PostProcessRenderPipelineManager class
  138201. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138202. */
  138203. export class PostProcessRenderPipelineManager {
  138204. private _renderPipelines;
  138205. /**
  138206. * Initializes a PostProcessRenderPipelineManager
  138207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138208. */
  138209. constructor();
  138210. /**
  138211. * Gets the list of supported render pipelines
  138212. */
  138213. get supportedPipelines(): PostProcessRenderPipeline[];
  138214. /**
  138215. * Adds a pipeline to the manager
  138216. * @param renderPipeline The pipeline to add
  138217. */
  138218. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138219. /**
  138220. * Attaches a camera to the pipeline
  138221. * @param renderPipelineName The name of the pipeline to attach to
  138222. * @param cameras the camera to attach
  138223. * @param unique if the camera can be attached multiple times to the pipeline
  138224. */
  138225. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138226. /**
  138227. * Detaches a camera from the pipeline
  138228. * @param renderPipelineName The name of the pipeline to detach from
  138229. * @param cameras the camera to detach
  138230. */
  138231. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138232. /**
  138233. * Enables an effect by name on a pipeline
  138234. * @param renderPipelineName the name of the pipeline to enable the effect in
  138235. * @param renderEffectName the name of the effect to enable
  138236. * @param cameras the cameras that the effect should be enabled on
  138237. */
  138238. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138239. /**
  138240. * Disables an effect by name on a pipeline
  138241. * @param renderPipelineName the name of the pipeline to disable the effect in
  138242. * @param renderEffectName the name of the effect to disable
  138243. * @param cameras the cameras that the effect should be disabled on
  138244. */
  138245. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138246. /**
  138247. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138248. */
  138249. update(): void;
  138250. /** @hidden */
  138251. _rebuild(): void;
  138252. /**
  138253. * Disposes of the manager and pipelines
  138254. */
  138255. dispose(): void;
  138256. }
  138257. }
  138258. declare module BABYLON {
  138259. interface Scene {
  138260. /** @hidden (Backing field) */
  138261. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138262. /**
  138263. * Gets the postprocess render pipeline manager
  138264. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138265. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138266. */
  138267. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138268. }
  138269. /**
  138270. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138271. */
  138272. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138273. /**
  138274. * The component name helpfull to identify the component in the list of scene components.
  138275. */
  138276. readonly name: string;
  138277. /**
  138278. * The scene the component belongs to.
  138279. */
  138280. scene: Scene;
  138281. /**
  138282. * Creates a new instance of the component for the given scene
  138283. * @param scene Defines the scene to register the component in
  138284. */
  138285. constructor(scene: Scene);
  138286. /**
  138287. * Registers the component in a given scene
  138288. */
  138289. register(): void;
  138290. /**
  138291. * Rebuilds the elements related to this component in case of
  138292. * context lost for instance.
  138293. */
  138294. rebuild(): void;
  138295. /**
  138296. * Disposes the component and the associated ressources
  138297. */
  138298. dispose(): void;
  138299. private _gatherRenderTargets;
  138300. }
  138301. }
  138302. declare module BABYLON {
  138303. /**
  138304. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138305. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138306. */
  138307. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138308. private _scene;
  138309. private _camerasToBeAttached;
  138310. /**
  138311. * ID of the sharpen post process,
  138312. */
  138313. private readonly SharpenPostProcessId;
  138314. /**
  138315. * @ignore
  138316. * ID of the image processing post process;
  138317. */
  138318. readonly ImageProcessingPostProcessId: string;
  138319. /**
  138320. * @ignore
  138321. * ID of the Fast Approximate Anti-Aliasing post process;
  138322. */
  138323. readonly FxaaPostProcessId: string;
  138324. /**
  138325. * ID of the chromatic aberration post process,
  138326. */
  138327. private readonly ChromaticAberrationPostProcessId;
  138328. /**
  138329. * ID of the grain post process
  138330. */
  138331. private readonly GrainPostProcessId;
  138332. /**
  138333. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138334. */
  138335. sharpen: SharpenPostProcess;
  138336. private _sharpenEffect;
  138337. private bloom;
  138338. /**
  138339. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138340. */
  138341. depthOfField: DepthOfFieldEffect;
  138342. /**
  138343. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138344. */
  138345. fxaa: FxaaPostProcess;
  138346. /**
  138347. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138348. */
  138349. imageProcessing: ImageProcessingPostProcess;
  138350. /**
  138351. * Chromatic aberration post process which will shift rgb colors in the image
  138352. */
  138353. chromaticAberration: ChromaticAberrationPostProcess;
  138354. private _chromaticAberrationEffect;
  138355. /**
  138356. * Grain post process which add noise to the image
  138357. */
  138358. grain: GrainPostProcess;
  138359. private _grainEffect;
  138360. /**
  138361. * Glow post process which adds a glow to emissive areas of the image
  138362. */
  138363. private _glowLayer;
  138364. /**
  138365. * Animations which can be used to tweak settings over a period of time
  138366. */
  138367. animations: Animation[];
  138368. private _imageProcessingConfigurationObserver;
  138369. private _sharpenEnabled;
  138370. private _bloomEnabled;
  138371. private _depthOfFieldEnabled;
  138372. private _depthOfFieldBlurLevel;
  138373. private _fxaaEnabled;
  138374. private _imageProcessingEnabled;
  138375. private _defaultPipelineTextureType;
  138376. private _bloomScale;
  138377. private _chromaticAberrationEnabled;
  138378. private _grainEnabled;
  138379. private _buildAllowed;
  138380. /**
  138381. * Gets active scene
  138382. */
  138383. get scene(): Scene;
  138384. /**
  138385. * Enable or disable the sharpen process from the pipeline
  138386. */
  138387. set sharpenEnabled(enabled: boolean);
  138388. get sharpenEnabled(): boolean;
  138389. private _resizeObserver;
  138390. private _hardwareScaleLevel;
  138391. private _bloomKernel;
  138392. /**
  138393. * Specifies the size of the bloom blur kernel, relative to the final output size
  138394. */
  138395. get bloomKernel(): number;
  138396. set bloomKernel(value: number);
  138397. /**
  138398. * Specifies the weight of the bloom in the final rendering
  138399. */
  138400. private _bloomWeight;
  138401. /**
  138402. * Specifies the luma threshold for the area that will be blurred by the bloom
  138403. */
  138404. private _bloomThreshold;
  138405. private _hdr;
  138406. /**
  138407. * The strength of the bloom.
  138408. */
  138409. set bloomWeight(value: number);
  138410. get bloomWeight(): number;
  138411. /**
  138412. * The strength of the bloom.
  138413. */
  138414. set bloomThreshold(value: number);
  138415. get bloomThreshold(): number;
  138416. /**
  138417. * The scale of the bloom, lower value will provide better performance.
  138418. */
  138419. set bloomScale(value: number);
  138420. get bloomScale(): number;
  138421. /**
  138422. * Enable or disable the bloom from the pipeline
  138423. */
  138424. set bloomEnabled(enabled: boolean);
  138425. get bloomEnabled(): boolean;
  138426. private _rebuildBloom;
  138427. /**
  138428. * If the depth of field is enabled.
  138429. */
  138430. get depthOfFieldEnabled(): boolean;
  138431. set depthOfFieldEnabled(enabled: boolean);
  138432. /**
  138433. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138434. */
  138435. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138436. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138437. /**
  138438. * If the anti aliasing is enabled.
  138439. */
  138440. set fxaaEnabled(enabled: boolean);
  138441. get fxaaEnabled(): boolean;
  138442. private _samples;
  138443. /**
  138444. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138445. */
  138446. set samples(sampleCount: number);
  138447. get samples(): number;
  138448. /**
  138449. * If image processing is enabled.
  138450. */
  138451. set imageProcessingEnabled(enabled: boolean);
  138452. get imageProcessingEnabled(): boolean;
  138453. /**
  138454. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138455. */
  138456. set glowLayerEnabled(enabled: boolean);
  138457. get glowLayerEnabled(): boolean;
  138458. /**
  138459. * Gets the glow layer (or null if not defined)
  138460. */
  138461. get glowLayer(): Nullable<GlowLayer>;
  138462. /**
  138463. * Enable or disable the chromaticAberration process from the pipeline
  138464. */
  138465. set chromaticAberrationEnabled(enabled: boolean);
  138466. get chromaticAberrationEnabled(): boolean;
  138467. /**
  138468. * Enable or disable the grain process from the pipeline
  138469. */
  138470. set grainEnabled(enabled: boolean);
  138471. get grainEnabled(): boolean;
  138472. /**
  138473. * @constructor
  138474. * @param name - The rendering pipeline name (default: "")
  138475. * @param hdr - If high dynamic range textures should be used (default: true)
  138476. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138477. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138478. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138479. */
  138480. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138481. /**
  138482. * Get the class name
  138483. * @returns "DefaultRenderingPipeline"
  138484. */
  138485. getClassName(): string;
  138486. /**
  138487. * Force the compilation of the entire pipeline.
  138488. */
  138489. prepare(): void;
  138490. private _hasCleared;
  138491. private _prevPostProcess;
  138492. private _prevPrevPostProcess;
  138493. private _setAutoClearAndTextureSharing;
  138494. private _depthOfFieldSceneObserver;
  138495. private _buildPipeline;
  138496. private _disposePostProcesses;
  138497. /**
  138498. * Adds a camera to the pipeline
  138499. * @param camera the camera to be added
  138500. */
  138501. addCamera(camera: Camera): void;
  138502. /**
  138503. * Removes a camera from the pipeline
  138504. * @param camera the camera to remove
  138505. */
  138506. removeCamera(camera: Camera): void;
  138507. /**
  138508. * Dispose of the pipeline and stop all post processes
  138509. */
  138510. dispose(): void;
  138511. /**
  138512. * Serialize the rendering pipeline (Used when exporting)
  138513. * @returns the serialized object
  138514. */
  138515. serialize(): any;
  138516. /**
  138517. * Parse the serialized pipeline
  138518. * @param source Source pipeline.
  138519. * @param scene The scene to load the pipeline to.
  138520. * @param rootUrl The URL of the serialized pipeline.
  138521. * @returns An instantiated pipeline from the serialized object.
  138522. */
  138523. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138524. }
  138525. }
  138526. declare module BABYLON {
  138527. /** @hidden */
  138528. export var lensHighlightsPixelShader: {
  138529. name: string;
  138530. shader: string;
  138531. };
  138532. }
  138533. declare module BABYLON {
  138534. /** @hidden */
  138535. export var depthOfFieldPixelShader: {
  138536. name: string;
  138537. shader: string;
  138538. };
  138539. }
  138540. declare module BABYLON {
  138541. /**
  138542. * BABYLON.JS Chromatic Aberration GLSL Shader
  138543. * Author: Olivier Guyot
  138544. * Separates very slightly R, G and B colors on the edges of the screen
  138545. * Inspired by Francois Tarlier & Martins Upitis
  138546. */
  138547. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138548. /**
  138549. * @ignore
  138550. * The chromatic aberration PostProcess id in the pipeline
  138551. */
  138552. LensChromaticAberrationEffect: string;
  138553. /**
  138554. * @ignore
  138555. * The highlights enhancing PostProcess id in the pipeline
  138556. */
  138557. HighlightsEnhancingEffect: string;
  138558. /**
  138559. * @ignore
  138560. * The depth-of-field PostProcess id in the pipeline
  138561. */
  138562. LensDepthOfFieldEffect: string;
  138563. private _scene;
  138564. private _depthTexture;
  138565. private _grainTexture;
  138566. private _chromaticAberrationPostProcess;
  138567. private _highlightsPostProcess;
  138568. private _depthOfFieldPostProcess;
  138569. private _edgeBlur;
  138570. private _grainAmount;
  138571. private _chromaticAberration;
  138572. private _distortion;
  138573. private _highlightsGain;
  138574. private _highlightsThreshold;
  138575. private _dofDistance;
  138576. private _dofAperture;
  138577. private _dofDarken;
  138578. private _dofPentagon;
  138579. private _blurNoise;
  138580. /**
  138581. * @constructor
  138582. *
  138583. * Effect parameters are as follow:
  138584. * {
  138585. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138586. * edge_blur: number; // from 0 to x (1 for realism)
  138587. * distortion: number; // from 0 to x (1 for realism)
  138588. * grain_amount: number; // from 0 to 1
  138589. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138590. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138591. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138592. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138593. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138594. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138595. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138596. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138597. * }
  138598. * Note: if an effect parameter is unset, effect is disabled
  138599. *
  138600. * @param name The rendering pipeline name
  138601. * @param parameters - An object containing all parameters (see above)
  138602. * @param scene The scene linked to this pipeline
  138603. * @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)
  138604. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138605. */
  138606. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138607. /**
  138608. * Get the class name
  138609. * @returns "LensRenderingPipeline"
  138610. */
  138611. getClassName(): string;
  138612. /**
  138613. * Gets associated scene
  138614. */
  138615. get scene(): Scene;
  138616. /**
  138617. * Gets or sets the edge blur
  138618. */
  138619. get edgeBlur(): number;
  138620. set edgeBlur(value: number);
  138621. /**
  138622. * Gets or sets the grain amount
  138623. */
  138624. get grainAmount(): number;
  138625. set grainAmount(value: number);
  138626. /**
  138627. * Gets or sets the chromatic aberration amount
  138628. */
  138629. get chromaticAberration(): number;
  138630. set chromaticAberration(value: number);
  138631. /**
  138632. * Gets or sets the depth of field aperture
  138633. */
  138634. get dofAperture(): number;
  138635. set dofAperture(value: number);
  138636. /**
  138637. * Gets or sets the edge distortion
  138638. */
  138639. get edgeDistortion(): number;
  138640. set edgeDistortion(value: number);
  138641. /**
  138642. * Gets or sets the depth of field distortion
  138643. */
  138644. get dofDistortion(): number;
  138645. set dofDistortion(value: number);
  138646. /**
  138647. * Gets or sets the darken out of focus amount
  138648. */
  138649. get darkenOutOfFocus(): number;
  138650. set darkenOutOfFocus(value: number);
  138651. /**
  138652. * Gets or sets a boolean indicating if blur noise is enabled
  138653. */
  138654. get blurNoise(): boolean;
  138655. set blurNoise(value: boolean);
  138656. /**
  138657. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138658. */
  138659. get pentagonBokeh(): boolean;
  138660. set pentagonBokeh(value: boolean);
  138661. /**
  138662. * Gets or sets the highlight grain amount
  138663. */
  138664. get highlightsGain(): number;
  138665. set highlightsGain(value: number);
  138666. /**
  138667. * Gets or sets the highlight threshold
  138668. */
  138669. get highlightsThreshold(): number;
  138670. set highlightsThreshold(value: number);
  138671. /**
  138672. * Sets the amount of blur at the edges
  138673. * @param amount blur amount
  138674. */
  138675. setEdgeBlur(amount: number): void;
  138676. /**
  138677. * Sets edge blur to 0
  138678. */
  138679. disableEdgeBlur(): void;
  138680. /**
  138681. * Sets the amout of grain
  138682. * @param amount Amount of grain
  138683. */
  138684. setGrainAmount(amount: number): void;
  138685. /**
  138686. * Set grain amount to 0
  138687. */
  138688. disableGrain(): void;
  138689. /**
  138690. * Sets the chromatic aberration amount
  138691. * @param amount amount of chromatic aberration
  138692. */
  138693. setChromaticAberration(amount: number): void;
  138694. /**
  138695. * Sets chromatic aberration amount to 0
  138696. */
  138697. disableChromaticAberration(): void;
  138698. /**
  138699. * Sets the EdgeDistortion amount
  138700. * @param amount amount of EdgeDistortion
  138701. */
  138702. setEdgeDistortion(amount: number): void;
  138703. /**
  138704. * Sets edge distortion to 0
  138705. */
  138706. disableEdgeDistortion(): void;
  138707. /**
  138708. * Sets the FocusDistance amount
  138709. * @param amount amount of FocusDistance
  138710. */
  138711. setFocusDistance(amount: number): void;
  138712. /**
  138713. * Disables depth of field
  138714. */
  138715. disableDepthOfField(): void;
  138716. /**
  138717. * Sets the Aperture amount
  138718. * @param amount amount of Aperture
  138719. */
  138720. setAperture(amount: number): void;
  138721. /**
  138722. * Sets the DarkenOutOfFocus amount
  138723. * @param amount amount of DarkenOutOfFocus
  138724. */
  138725. setDarkenOutOfFocus(amount: number): void;
  138726. private _pentagonBokehIsEnabled;
  138727. /**
  138728. * Creates a pentagon bokeh effect
  138729. */
  138730. enablePentagonBokeh(): void;
  138731. /**
  138732. * Disables the pentagon bokeh effect
  138733. */
  138734. disablePentagonBokeh(): void;
  138735. /**
  138736. * Enables noise blur
  138737. */
  138738. enableNoiseBlur(): void;
  138739. /**
  138740. * Disables noise blur
  138741. */
  138742. disableNoiseBlur(): void;
  138743. /**
  138744. * Sets the HighlightsGain amount
  138745. * @param amount amount of HighlightsGain
  138746. */
  138747. setHighlightsGain(amount: number): void;
  138748. /**
  138749. * Sets the HighlightsThreshold amount
  138750. * @param amount amount of HighlightsThreshold
  138751. */
  138752. setHighlightsThreshold(amount: number): void;
  138753. /**
  138754. * Disables highlights
  138755. */
  138756. disableHighlights(): void;
  138757. /**
  138758. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138759. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138760. */
  138761. dispose(disableDepthRender?: boolean): void;
  138762. private _createChromaticAberrationPostProcess;
  138763. private _createHighlightsPostProcess;
  138764. private _createDepthOfFieldPostProcess;
  138765. private _createGrainTexture;
  138766. }
  138767. }
  138768. declare module BABYLON {
  138769. /** @hidden */
  138770. export var ssao2PixelShader: {
  138771. name: string;
  138772. shader: string;
  138773. };
  138774. }
  138775. declare module BABYLON {
  138776. /** @hidden */
  138777. export var ssaoCombinePixelShader: {
  138778. name: string;
  138779. shader: string;
  138780. };
  138781. }
  138782. declare module BABYLON {
  138783. /**
  138784. * Render pipeline to produce ssao effect
  138785. */
  138786. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138787. /**
  138788. * @ignore
  138789. * The PassPostProcess id in the pipeline that contains the original scene color
  138790. */
  138791. SSAOOriginalSceneColorEffect: string;
  138792. /**
  138793. * @ignore
  138794. * The SSAO PostProcess id in the pipeline
  138795. */
  138796. SSAORenderEffect: string;
  138797. /**
  138798. * @ignore
  138799. * The horizontal blur PostProcess id in the pipeline
  138800. */
  138801. SSAOBlurHRenderEffect: string;
  138802. /**
  138803. * @ignore
  138804. * The vertical blur PostProcess id in the pipeline
  138805. */
  138806. SSAOBlurVRenderEffect: string;
  138807. /**
  138808. * @ignore
  138809. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138810. */
  138811. SSAOCombineRenderEffect: string;
  138812. /**
  138813. * The output strength of the SSAO post-process. Default value is 1.0.
  138814. */
  138815. totalStrength: number;
  138816. /**
  138817. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138818. */
  138819. maxZ: number;
  138820. /**
  138821. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138822. */
  138823. minZAspect: number;
  138824. private _samples;
  138825. /**
  138826. * Number of samples used for the SSAO calculations. Default value is 8
  138827. */
  138828. set samples(n: number);
  138829. get samples(): number;
  138830. private _textureSamples;
  138831. /**
  138832. * Number of samples to use for antialiasing
  138833. */
  138834. set textureSamples(n: number);
  138835. get textureSamples(): number;
  138836. /**
  138837. * Ratio object used for SSAO ratio and blur ratio
  138838. */
  138839. private _ratio;
  138840. /**
  138841. * Dynamically generated sphere sampler.
  138842. */
  138843. private _sampleSphere;
  138844. /**
  138845. * Blur filter offsets
  138846. */
  138847. private _samplerOffsets;
  138848. private _expensiveBlur;
  138849. /**
  138850. * If bilateral blur should be used
  138851. */
  138852. set expensiveBlur(b: boolean);
  138853. get expensiveBlur(): boolean;
  138854. /**
  138855. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138856. */
  138857. radius: number;
  138858. /**
  138859. * The base color of the SSAO post-process
  138860. * The final result is "base + ssao" between [0, 1]
  138861. */
  138862. base: number;
  138863. /**
  138864. * Support test.
  138865. */
  138866. static get IsSupported(): boolean;
  138867. private _scene;
  138868. private _depthTexture;
  138869. private _normalTexture;
  138870. private _randomTexture;
  138871. private _originalColorPostProcess;
  138872. private _ssaoPostProcess;
  138873. private _blurHPostProcess;
  138874. private _blurVPostProcess;
  138875. private _ssaoCombinePostProcess;
  138876. /**
  138877. * Gets active scene
  138878. */
  138879. get scene(): Scene;
  138880. /**
  138881. * @constructor
  138882. * @param name The rendering pipeline name
  138883. * @param scene The scene linked to this pipeline
  138884. * @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 }
  138885. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138886. */
  138887. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138888. /**
  138889. * Get the class name
  138890. * @returns "SSAO2RenderingPipeline"
  138891. */
  138892. getClassName(): string;
  138893. /**
  138894. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138895. */
  138896. dispose(disableGeometryBufferRenderer?: boolean): void;
  138897. private _createBlurPostProcess;
  138898. /** @hidden */
  138899. _rebuild(): void;
  138900. private _bits;
  138901. private _radicalInverse_VdC;
  138902. private _hammersley;
  138903. private _hemisphereSample_uniform;
  138904. private _generateHemisphere;
  138905. private _createSSAOPostProcess;
  138906. private _createSSAOCombinePostProcess;
  138907. private _createRandomTexture;
  138908. /**
  138909. * Serialize the rendering pipeline (Used when exporting)
  138910. * @returns the serialized object
  138911. */
  138912. serialize(): any;
  138913. /**
  138914. * Parse the serialized pipeline
  138915. * @param source Source pipeline.
  138916. * @param scene The scene to load the pipeline to.
  138917. * @param rootUrl The URL of the serialized pipeline.
  138918. * @returns An instantiated pipeline from the serialized object.
  138919. */
  138920. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138921. }
  138922. }
  138923. declare module BABYLON {
  138924. /** @hidden */
  138925. export var ssaoPixelShader: {
  138926. name: string;
  138927. shader: string;
  138928. };
  138929. }
  138930. declare module BABYLON {
  138931. /**
  138932. * Render pipeline to produce ssao effect
  138933. */
  138934. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138935. /**
  138936. * @ignore
  138937. * The PassPostProcess id in the pipeline that contains the original scene color
  138938. */
  138939. SSAOOriginalSceneColorEffect: string;
  138940. /**
  138941. * @ignore
  138942. * The SSAO PostProcess id in the pipeline
  138943. */
  138944. SSAORenderEffect: string;
  138945. /**
  138946. * @ignore
  138947. * The horizontal blur PostProcess id in the pipeline
  138948. */
  138949. SSAOBlurHRenderEffect: string;
  138950. /**
  138951. * @ignore
  138952. * The vertical blur PostProcess id in the pipeline
  138953. */
  138954. SSAOBlurVRenderEffect: string;
  138955. /**
  138956. * @ignore
  138957. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138958. */
  138959. SSAOCombineRenderEffect: string;
  138960. /**
  138961. * The output strength of the SSAO post-process. Default value is 1.0.
  138962. */
  138963. totalStrength: number;
  138964. /**
  138965. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138966. */
  138967. radius: number;
  138968. /**
  138969. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138970. * Must not be equal to fallOff and superior to fallOff.
  138971. * Default value is 0.0075
  138972. */
  138973. area: number;
  138974. /**
  138975. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138976. * Must not be equal to area and inferior to area.
  138977. * Default value is 0.000001
  138978. */
  138979. fallOff: number;
  138980. /**
  138981. * The base color of the SSAO post-process
  138982. * The final result is "base + ssao" between [0, 1]
  138983. */
  138984. base: number;
  138985. private _scene;
  138986. private _depthTexture;
  138987. private _randomTexture;
  138988. private _originalColorPostProcess;
  138989. private _ssaoPostProcess;
  138990. private _blurHPostProcess;
  138991. private _blurVPostProcess;
  138992. private _ssaoCombinePostProcess;
  138993. private _firstUpdate;
  138994. /**
  138995. * Gets active scene
  138996. */
  138997. get scene(): Scene;
  138998. /**
  138999. * @constructor
  139000. * @param name - The rendering pipeline name
  139001. * @param scene - The scene linked to this pipeline
  139002. * @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 }
  139003. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139004. */
  139005. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139006. /**
  139007. * Get the class name
  139008. * @returns "SSAORenderingPipeline"
  139009. */
  139010. getClassName(): string;
  139011. /**
  139012. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139013. */
  139014. dispose(disableDepthRender?: boolean): void;
  139015. private _createBlurPostProcess;
  139016. /** @hidden */
  139017. _rebuild(): void;
  139018. private _createSSAOPostProcess;
  139019. private _createSSAOCombinePostProcess;
  139020. private _createRandomTexture;
  139021. }
  139022. }
  139023. declare module BABYLON {
  139024. /** @hidden */
  139025. export var screenSpaceReflectionPixelShader: {
  139026. name: string;
  139027. shader: string;
  139028. };
  139029. }
  139030. declare module BABYLON {
  139031. /**
  139032. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139033. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139034. */
  139035. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139036. /**
  139037. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139038. */
  139039. threshold: number;
  139040. /**
  139041. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139042. */
  139043. strength: number;
  139044. /**
  139045. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139046. */
  139047. reflectionSpecularFalloffExponent: number;
  139048. /**
  139049. * 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]
  139050. */
  139051. step: number;
  139052. /**
  139053. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139054. */
  139055. roughnessFactor: number;
  139056. private _geometryBufferRenderer;
  139057. private _enableSmoothReflections;
  139058. private _reflectionSamples;
  139059. private _smoothSteps;
  139060. /**
  139061. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139062. * @param name The name of the effect.
  139063. * @param scene The scene containing the objects to calculate reflections.
  139064. * @param options The required width/height ratio to downsize to before computing the render pass.
  139065. * @param camera The camera to apply the render pass to.
  139066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139067. * @param engine The engine which the post process will be applied. (default: current engine)
  139068. * @param reusable If the post process can be reused on the same frame. (default: false)
  139069. * @param textureType Type of textures used when performing the post process. (default: 0)
  139070. * @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)
  139071. */
  139072. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139073. /**
  139074. * Gets wether or not smoothing reflections is enabled.
  139075. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139076. */
  139077. get enableSmoothReflections(): boolean;
  139078. /**
  139079. * Sets wether or not smoothing reflections is enabled.
  139080. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139081. */
  139082. set enableSmoothReflections(enabled: boolean);
  139083. /**
  139084. * Gets the number of samples taken while computing reflections. More samples count is high,
  139085. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139086. */
  139087. get reflectionSamples(): number;
  139088. /**
  139089. * Sets the number of samples taken while computing reflections. More samples count is high,
  139090. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139091. */
  139092. set reflectionSamples(samples: number);
  139093. /**
  139094. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139095. * more the post-process will require GPU power and can generate a drop in FPS.
  139096. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139097. */
  139098. get smoothSteps(): number;
  139099. set smoothSteps(steps: number);
  139100. private _updateEffectDefines;
  139101. }
  139102. }
  139103. declare module BABYLON {
  139104. /** @hidden */
  139105. export var standardPixelShader: {
  139106. name: string;
  139107. shader: string;
  139108. };
  139109. }
  139110. declare module BABYLON {
  139111. /**
  139112. * Standard rendering pipeline
  139113. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139114. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139115. */
  139116. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139117. /**
  139118. * Public members
  139119. */
  139120. /**
  139121. * Post-process which contains the original scene color before the pipeline applies all the effects
  139122. */
  139123. originalPostProcess: Nullable<PostProcess>;
  139124. /**
  139125. * Post-process used to down scale an image x4
  139126. */
  139127. downSampleX4PostProcess: Nullable<PostProcess>;
  139128. /**
  139129. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139130. */
  139131. brightPassPostProcess: Nullable<PostProcess>;
  139132. /**
  139133. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139134. */
  139135. blurHPostProcesses: PostProcess[];
  139136. /**
  139137. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139138. */
  139139. blurVPostProcesses: PostProcess[];
  139140. /**
  139141. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139142. */
  139143. textureAdderPostProcess: Nullable<PostProcess>;
  139144. /**
  139145. * Post-process used to create volumetric lighting effect
  139146. */
  139147. volumetricLightPostProcess: Nullable<PostProcess>;
  139148. /**
  139149. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139150. */
  139151. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139152. /**
  139153. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139154. */
  139155. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139156. /**
  139157. * Post-process used to merge the volumetric light effect and the real scene color
  139158. */
  139159. volumetricLightMergePostProces: Nullable<PostProcess>;
  139160. /**
  139161. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139162. */
  139163. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139164. /**
  139165. * Base post-process used to calculate the average luminance of the final image for HDR
  139166. */
  139167. luminancePostProcess: Nullable<PostProcess>;
  139168. /**
  139169. * Post-processes used to create down sample post-processes in order to get
  139170. * the average luminance of the final image for HDR
  139171. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139172. */
  139173. luminanceDownSamplePostProcesses: PostProcess[];
  139174. /**
  139175. * Post-process used to create a HDR effect (light adaptation)
  139176. */
  139177. hdrPostProcess: Nullable<PostProcess>;
  139178. /**
  139179. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139180. */
  139181. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139182. /**
  139183. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139184. */
  139185. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139186. /**
  139187. * Post-process used to merge the final HDR post-process and the real scene color
  139188. */
  139189. hdrFinalPostProcess: Nullable<PostProcess>;
  139190. /**
  139191. * Post-process used to create a lens flare effect
  139192. */
  139193. lensFlarePostProcess: Nullable<PostProcess>;
  139194. /**
  139195. * Post-process that merges the result of the lens flare post-process and the real scene color
  139196. */
  139197. lensFlareComposePostProcess: Nullable<PostProcess>;
  139198. /**
  139199. * Post-process used to create a motion blur effect
  139200. */
  139201. motionBlurPostProcess: Nullable<PostProcess>;
  139202. /**
  139203. * Post-process used to create a depth of field effect
  139204. */
  139205. depthOfFieldPostProcess: Nullable<PostProcess>;
  139206. /**
  139207. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139208. */
  139209. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139210. /**
  139211. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139212. */
  139213. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139214. /**
  139215. * Represents the brightness threshold in order to configure the illuminated surfaces
  139216. */
  139217. brightThreshold: number;
  139218. /**
  139219. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139220. */
  139221. blurWidth: number;
  139222. /**
  139223. * Sets if the blur for highlighted surfaces must be only horizontal
  139224. */
  139225. horizontalBlur: boolean;
  139226. /**
  139227. * Gets the overall exposure used by the pipeline
  139228. */
  139229. get exposure(): number;
  139230. /**
  139231. * Sets the overall exposure used by the pipeline
  139232. */
  139233. set exposure(value: number);
  139234. /**
  139235. * Texture used typically to simulate "dirty" on camera lens
  139236. */
  139237. lensTexture: Nullable<Texture>;
  139238. /**
  139239. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139240. */
  139241. volumetricLightCoefficient: number;
  139242. /**
  139243. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139244. */
  139245. volumetricLightPower: number;
  139246. /**
  139247. * Used the set the blur intensity to smooth the volumetric lights
  139248. */
  139249. volumetricLightBlurScale: number;
  139250. /**
  139251. * Light (spot or directional) used to generate the volumetric lights rays
  139252. * The source light must have a shadow generate so the pipeline can get its
  139253. * depth map
  139254. */
  139255. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139256. /**
  139257. * For eye adaptation, represents the minimum luminance the eye can see
  139258. */
  139259. hdrMinimumLuminance: number;
  139260. /**
  139261. * For eye adaptation, represents the decrease luminance speed
  139262. */
  139263. hdrDecreaseRate: number;
  139264. /**
  139265. * For eye adaptation, represents the increase luminance speed
  139266. */
  139267. hdrIncreaseRate: number;
  139268. /**
  139269. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139270. */
  139271. get hdrAutoExposure(): boolean;
  139272. /**
  139273. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139274. */
  139275. set hdrAutoExposure(value: boolean);
  139276. /**
  139277. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139278. */
  139279. lensColorTexture: Nullable<Texture>;
  139280. /**
  139281. * The overall strengh for the lens flare effect
  139282. */
  139283. lensFlareStrength: number;
  139284. /**
  139285. * Dispersion coefficient for lens flare ghosts
  139286. */
  139287. lensFlareGhostDispersal: number;
  139288. /**
  139289. * Main lens flare halo width
  139290. */
  139291. lensFlareHaloWidth: number;
  139292. /**
  139293. * Based on the lens distortion effect, defines how much the lens flare result
  139294. * is distorted
  139295. */
  139296. lensFlareDistortionStrength: number;
  139297. /**
  139298. * Configures the blur intensity used for for lens flare (halo)
  139299. */
  139300. lensFlareBlurWidth: number;
  139301. /**
  139302. * Lens star texture must be used to simulate rays on the flares and is available
  139303. * in the documentation
  139304. */
  139305. lensStarTexture: Nullable<Texture>;
  139306. /**
  139307. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139308. * flare effect by taking account of the dirt texture
  139309. */
  139310. lensFlareDirtTexture: Nullable<Texture>;
  139311. /**
  139312. * Represents the focal length for the depth of field effect
  139313. */
  139314. depthOfFieldDistance: number;
  139315. /**
  139316. * Represents the blur intensity for the blurred part of the depth of field effect
  139317. */
  139318. depthOfFieldBlurWidth: number;
  139319. /**
  139320. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139321. */
  139322. get motionStrength(): number;
  139323. /**
  139324. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139325. */
  139326. set motionStrength(strength: number);
  139327. /**
  139328. * Gets wether or not the motion blur post-process is object based or screen based.
  139329. */
  139330. get objectBasedMotionBlur(): boolean;
  139331. /**
  139332. * Sets wether or not the motion blur post-process should be object based or screen based
  139333. */
  139334. set objectBasedMotionBlur(value: boolean);
  139335. /**
  139336. * List of animations for the pipeline (IAnimatable implementation)
  139337. */
  139338. animations: Animation[];
  139339. /**
  139340. * Private members
  139341. */
  139342. private _scene;
  139343. private _currentDepthOfFieldSource;
  139344. private _basePostProcess;
  139345. private _fixedExposure;
  139346. private _currentExposure;
  139347. private _hdrAutoExposure;
  139348. private _hdrCurrentLuminance;
  139349. private _motionStrength;
  139350. private _isObjectBasedMotionBlur;
  139351. private _floatTextureType;
  139352. private _camerasToBeAttached;
  139353. private _ratio;
  139354. private _bloomEnabled;
  139355. private _depthOfFieldEnabled;
  139356. private _vlsEnabled;
  139357. private _lensFlareEnabled;
  139358. private _hdrEnabled;
  139359. private _motionBlurEnabled;
  139360. private _fxaaEnabled;
  139361. private _screenSpaceReflectionsEnabled;
  139362. private _motionBlurSamples;
  139363. private _volumetricLightStepsCount;
  139364. private _samples;
  139365. /**
  139366. * @ignore
  139367. * Specifies if the bloom pipeline is enabled
  139368. */
  139369. get BloomEnabled(): boolean;
  139370. set BloomEnabled(enabled: boolean);
  139371. /**
  139372. * @ignore
  139373. * Specifies if the depth of field pipeline is enabed
  139374. */
  139375. get DepthOfFieldEnabled(): boolean;
  139376. set DepthOfFieldEnabled(enabled: boolean);
  139377. /**
  139378. * @ignore
  139379. * Specifies if the lens flare pipeline is enabed
  139380. */
  139381. get LensFlareEnabled(): boolean;
  139382. set LensFlareEnabled(enabled: boolean);
  139383. /**
  139384. * @ignore
  139385. * Specifies if the HDR pipeline is enabled
  139386. */
  139387. get HDREnabled(): boolean;
  139388. set HDREnabled(enabled: boolean);
  139389. /**
  139390. * @ignore
  139391. * Specifies if the volumetric lights scattering effect is enabled
  139392. */
  139393. get VLSEnabled(): boolean;
  139394. set VLSEnabled(enabled: boolean);
  139395. /**
  139396. * @ignore
  139397. * Specifies if the motion blur effect is enabled
  139398. */
  139399. get MotionBlurEnabled(): boolean;
  139400. set MotionBlurEnabled(enabled: boolean);
  139401. /**
  139402. * Specifies if anti-aliasing is enabled
  139403. */
  139404. get fxaaEnabled(): boolean;
  139405. set fxaaEnabled(enabled: boolean);
  139406. /**
  139407. * Specifies if screen space reflections are enabled.
  139408. */
  139409. get screenSpaceReflectionsEnabled(): boolean;
  139410. set screenSpaceReflectionsEnabled(enabled: boolean);
  139411. /**
  139412. * Specifies the number of steps used to calculate the volumetric lights
  139413. * Typically in interval [50, 200]
  139414. */
  139415. get volumetricLightStepsCount(): number;
  139416. set volumetricLightStepsCount(count: number);
  139417. /**
  139418. * Specifies the number of samples used for the motion blur effect
  139419. * Typically in interval [16, 64]
  139420. */
  139421. get motionBlurSamples(): number;
  139422. set motionBlurSamples(samples: number);
  139423. /**
  139424. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139425. */
  139426. get samples(): number;
  139427. set samples(sampleCount: number);
  139428. /**
  139429. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139430. * @constructor
  139431. * @param name The rendering pipeline name
  139432. * @param scene The scene linked to this pipeline
  139433. * @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)
  139434. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139435. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139436. */
  139437. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139438. private _buildPipeline;
  139439. private _createDownSampleX4PostProcess;
  139440. private _createBrightPassPostProcess;
  139441. private _createBlurPostProcesses;
  139442. private _createTextureAdderPostProcess;
  139443. private _createVolumetricLightPostProcess;
  139444. private _createLuminancePostProcesses;
  139445. private _createHdrPostProcess;
  139446. private _createLensFlarePostProcess;
  139447. private _createDepthOfFieldPostProcess;
  139448. private _createMotionBlurPostProcess;
  139449. private _getDepthTexture;
  139450. private _disposePostProcesses;
  139451. /**
  139452. * Dispose of the pipeline and stop all post processes
  139453. */
  139454. dispose(): void;
  139455. /**
  139456. * Serialize the rendering pipeline (Used when exporting)
  139457. * @returns the serialized object
  139458. */
  139459. serialize(): any;
  139460. /**
  139461. * Parse the serialized pipeline
  139462. * @param source Source pipeline.
  139463. * @param scene The scene to load the pipeline to.
  139464. * @param rootUrl The URL of the serialized pipeline.
  139465. * @returns An instantiated pipeline from the serialized object.
  139466. */
  139467. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139468. /**
  139469. * Luminance steps
  139470. */
  139471. static LuminanceSteps: number;
  139472. }
  139473. }
  139474. declare module BABYLON {
  139475. /** @hidden */
  139476. export var tonemapPixelShader: {
  139477. name: string;
  139478. shader: string;
  139479. };
  139480. }
  139481. declare module BABYLON {
  139482. /** Defines operator used for tonemapping */
  139483. export enum TonemappingOperator {
  139484. /** Hable */
  139485. Hable = 0,
  139486. /** Reinhard */
  139487. Reinhard = 1,
  139488. /** HejiDawson */
  139489. HejiDawson = 2,
  139490. /** Photographic */
  139491. Photographic = 3
  139492. }
  139493. /**
  139494. * Defines a post process to apply tone mapping
  139495. */
  139496. export class TonemapPostProcess extends PostProcess {
  139497. private _operator;
  139498. /** Defines the required exposure adjustement */
  139499. exposureAdjustment: number;
  139500. /**
  139501. * Creates a new TonemapPostProcess
  139502. * @param name defines the name of the postprocess
  139503. * @param _operator defines the operator to use
  139504. * @param exposureAdjustment defines the required exposure adjustement
  139505. * @param camera defines the camera to use (can be null)
  139506. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139507. * @param engine defines the hosting engine (can be ignore if camera is set)
  139508. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139509. */
  139510. constructor(name: string, _operator: TonemappingOperator,
  139511. /** Defines the required exposure adjustement */
  139512. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139513. }
  139514. }
  139515. declare module BABYLON {
  139516. /** @hidden */
  139517. export var volumetricLightScatteringPixelShader: {
  139518. name: string;
  139519. shader: string;
  139520. };
  139521. }
  139522. declare module BABYLON {
  139523. /** @hidden */
  139524. export var volumetricLightScatteringPassVertexShader: {
  139525. name: string;
  139526. shader: string;
  139527. };
  139528. }
  139529. declare module BABYLON {
  139530. /** @hidden */
  139531. export var volumetricLightScatteringPassPixelShader: {
  139532. name: string;
  139533. shader: string;
  139534. };
  139535. }
  139536. declare module BABYLON {
  139537. /**
  139538. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139539. */
  139540. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139541. private _volumetricLightScatteringPass;
  139542. private _volumetricLightScatteringRTT;
  139543. private _viewPort;
  139544. private _screenCoordinates;
  139545. private _cachedDefines;
  139546. /**
  139547. * If not undefined, the mesh position is computed from the attached node position
  139548. */
  139549. attachedNode: {
  139550. position: Vector3;
  139551. };
  139552. /**
  139553. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139554. */
  139555. customMeshPosition: Vector3;
  139556. /**
  139557. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139558. */
  139559. useCustomMeshPosition: boolean;
  139560. /**
  139561. * If the post-process should inverse the light scattering direction
  139562. */
  139563. invert: boolean;
  139564. /**
  139565. * The internal mesh used by the post-process
  139566. */
  139567. mesh: Mesh;
  139568. /**
  139569. * @hidden
  139570. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139571. */
  139572. get useDiffuseColor(): boolean;
  139573. set useDiffuseColor(useDiffuseColor: boolean);
  139574. /**
  139575. * Array containing the excluded meshes not rendered in the internal pass
  139576. */
  139577. excludedMeshes: AbstractMesh[];
  139578. /**
  139579. * Controls the overall intensity of the post-process
  139580. */
  139581. exposure: number;
  139582. /**
  139583. * Dissipates each sample's contribution in range [0, 1]
  139584. */
  139585. decay: number;
  139586. /**
  139587. * Controls the overall intensity of each sample
  139588. */
  139589. weight: number;
  139590. /**
  139591. * Controls the density of each sample
  139592. */
  139593. density: number;
  139594. /**
  139595. * @constructor
  139596. * @param name The post-process name
  139597. * @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)
  139598. * @param camera The camera that the post-process will be attached to
  139599. * @param mesh The mesh used to create the light scattering
  139600. * @param samples The post-process quality, default 100
  139601. * @param samplingModeThe post-process filtering mode
  139602. * @param engine The babylon engine
  139603. * @param reusable If the post-process is reusable
  139604. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139605. */
  139606. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139607. /**
  139608. * Returns the string "VolumetricLightScatteringPostProcess"
  139609. * @returns "VolumetricLightScatteringPostProcess"
  139610. */
  139611. getClassName(): string;
  139612. private _isReady;
  139613. /**
  139614. * Sets the new light position for light scattering effect
  139615. * @param position The new custom light position
  139616. */
  139617. setCustomMeshPosition(position: Vector3): void;
  139618. /**
  139619. * Returns the light position for light scattering effect
  139620. * @return Vector3 The custom light position
  139621. */
  139622. getCustomMeshPosition(): Vector3;
  139623. /**
  139624. * Disposes the internal assets and detaches the post-process from the camera
  139625. */
  139626. dispose(camera: Camera): void;
  139627. /**
  139628. * Returns the render target texture used by the post-process
  139629. * @return the render target texture used by the post-process
  139630. */
  139631. getPass(): RenderTargetTexture;
  139632. private _meshExcluded;
  139633. private _createPass;
  139634. private _updateMeshScreenCoordinates;
  139635. /**
  139636. * Creates a default mesh for the Volumeric Light Scattering post-process
  139637. * @param name The mesh name
  139638. * @param scene The scene where to create the mesh
  139639. * @return the default mesh
  139640. */
  139641. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139642. }
  139643. }
  139644. declare module BABYLON {
  139645. interface Scene {
  139646. /** @hidden (Backing field) */
  139647. _boundingBoxRenderer: BoundingBoxRenderer;
  139648. /** @hidden (Backing field) */
  139649. _forceShowBoundingBoxes: boolean;
  139650. /**
  139651. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139652. */
  139653. forceShowBoundingBoxes: boolean;
  139654. /**
  139655. * Gets the bounding box renderer associated with the scene
  139656. * @returns a BoundingBoxRenderer
  139657. */
  139658. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139659. }
  139660. interface AbstractMesh {
  139661. /** @hidden (Backing field) */
  139662. _showBoundingBox: boolean;
  139663. /**
  139664. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139665. */
  139666. showBoundingBox: boolean;
  139667. }
  139668. /**
  139669. * Component responsible of rendering the bounding box of the meshes in a scene.
  139670. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139671. */
  139672. export class BoundingBoxRenderer implements ISceneComponent {
  139673. /**
  139674. * The component name helpfull to identify the component in the list of scene components.
  139675. */
  139676. readonly name: string;
  139677. /**
  139678. * The scene the component belongs to.
  139679. */
  139680. scene: Scene;
  139681. /**
  139682. * Color of the bounding box lines placed in front of an object
  139683. */
  139684. frontColor: Color3;
  139685. /**
  139686. * Color of the bounding box lines placed behind an object
  139687. */
  139688. backColor: Color3;
  139689. /**
  139690. * Defines if the renderer should show the back lines or not
  139691. */
  139692. showBackLines: boolean;
  139693. /**
  139694. * @hidden
  139695. */
  139696. renderList: SmartArray<BoundingBox>;
  139697. private _colorShader;
  139698. private _vertexBuffers;
  139699. private _indexBuffer;
  139700. private _fillIndexBuffer;
  139701. private _fillIndexData;
  139702. /**
  139703. * Instantiates a new bounding box renderer in a scene.
  139704. * @param scene the scene the renderer renders in
  139705. */
  139706. constructor(scene: Scene);
  139707. /**
  139708. * Registers the component in a given scene
  139709. */
  139710. register(): void;
  139711. private _evaluateSubMesh;
  139712. private _activeMesh;
  139713. private _prepareRessources;
  139714. private _createIndexBuffer;
  139715. /**
  139716. * Rebuilds the elements related to this component in case of
  139717. * context lost for instance.
  139718. */
  139719. rebuild(): void;
  139720. /**
  139721. * @hidden
  139722. */
  139723. reset(): void;
  139724. /**
  139725. * Render the bounding boxes of a specific rendering group
  139726. * @param renderingGroupId defines the rendering group to render
  139727. */
  139728. render(renderingGroupId: number): void;
  139729. /**
  139730. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139731. * @param mesh Define the mesh to render the occlusion bounding box for
  139732. */
  139733. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139734. /**
  139735. * Dispose and release the resources attached to this renderer.
  139736. */
  139737. dispose(): void;
  139738. }
  139739. }
  139740. declare module BABYLON {
  139741. interface Scene {
  139742. /** @hidden (Backing field) */
  139743. _depthRenderer: {
  139744. [id: string]: DepthRenderer;
  139745. };
  139746. /**
  139747. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139748. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139749. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139750. * @returns the created depth renderer
  139751. */
  139752. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139753. /**
  139754. * Disables a depth renderer for a given camera
  139755. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139756. */
  139757. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139758. }
  139759. /**
  139760. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139761. * in several rendering techniques.
  139762. */
  139763. export class DepthRendererSceneComponent implements ISceneComponent {
  139764. /**
  139765. * The component name helpfull to identify the component in the list of scene components.
  139766. */
  139767. readonly name: string;
  139768. /**
  139769. * The scene the component belongs to.
  139770. */
  139771. scene: Scene;
  139772. /**
  139773. * Creates a new instance of the component for the given scene
  139774. * @param scene Defines the scene to register the component in
  139775. */
  139776. constructor(scene: Scene);
  139777. /**
  139778. * Registers the component in a given scene
  139779. */
  139780. register(): void;
  139781. /**
  139782. * Rebuilds the elements related to this component in case of
  139783. * context lost for instance.
  139784. */
  139785. rebuild(): void;
  139786. /**
  139787. * Disposes the component and the associated ressources
  139788. */
  139789. dispose(): void;
  139790. private _gatherRenderTargets;
  139791. private _gatherActiveCameraRenderTargets;
  139792. }
  139793. }
  139794. declare module BABYLON {
  139795. /** @hidden */
  139796. export var outlinePixelShader: {
  139797. name: string;
  139798. shader: string;
  139799. };
  139800. }
  139801. declare module BABYLON {
  139802. /** @hidden */
  139803. export var outlineVertexShader: {
  139804. name: string;
  139805. shader: string;
  139806. };
  139807. }
  139808. declare module BABYLON {
  139809. interface Scene {
  139810. /** @hidden */
  139811. _outlineRenderer: OutlineRenderer;
  139812. /**
  139813. * Gets the outline renderer associated with the scene
  139814. * @returns a OutlineRenderer
  139815. */
  139816. getOutlineRenderer(): OutlineRenderer;
  139817. }
  139818. interface AbstractMesh {
  139819. /** @hidden (Backing field) */
  139820. _renderOutline: boolean;
  139821. /**
  139822. * Gets or sets a boolean indicating if the outline must be rendered as well
  139823. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139824. */
  139825. renderOutline: boolean;
  139826. /** @hidden (Backing field) */
  139827. _renderOverlay: boolean;
  139828. /**
  139829. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139830. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139831. */
  139832. renderOverlay: boolean;
  139833. }
  139834. /**
  139835. * This class is responsible to draw bothe outline/overlay of meshes.
  139836. * It should not be used directly but through the available method on mesh.
  139837. */
  139838. export class OutlineRenderer implements ISceneComponent {
  139839. /**
  139840. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139841. */
  139842. private static _StencilReference;
  139843. /**
  139844. * The name of the component. Each component must have a unique name.
  139845. */
  139846. name: string;
  139847. /**
  139848. * The scene the component belongs to.
  139849. */
  139850. scene: Scene;
  139851. /**
  139852. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139853. */
  139854. zOffset: number;
  139855. private _engine;
  139856. private _effect;
  139857. private _cachedDefines;
  139858. private _savedDepthWrite;
  139859. /**
  139860. * Instantiates a new outline renderer. (There could be only one per scene).
  139861. * @param scene Defines the scene it belongs to
  139862. */
  139863. constructor(scene: Scene);
  139864. /**
  139865. * Register the component to one instance of a scene.
  139866. */
  139867. register(): void;
  139868. /**
  139869. * Rebuilds the elements related to this component in case of
  139870. * context lost for instance.
  139871. */
  139872. rebuild(): void;
  139873. /**
  139874. * Disposes the component and the associated ressources.
  139875. */
  139876. dispose(): void;
  139877. /**
  139878. * Renders the outline in the canvas.
  139879. * @param subMesh Defines the sumesh to render
  139880. * @param batch Defines the batch of meshes in case of instances
  139881. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139882. */
  139883. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139884. /**
  139885. * Returns whether or not the outline renderer is ready for a given submesh.
  139886. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139887. * @param subMesh Defines the submesh to check readyness for
  139888. * @param useInstances Defines wheter wee are trying to render instances or not
  139889. * @returns true if ready otherwise false
  139890. */
  139891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139892. private _beforeRenderingMesh;
  139893. private _afterRenderingMesh;
  139894. }
  139895. }
  139896. declare module BABYLON {
  139897. /**
  139898. * Defines the basic options interface of a Sprite Frame Source Size.
  139899. */
  139900. export interface ISpriteJSONSpriteSourceSize {
  139901. /**
  139902. * number of the original width of the Frame
  139903. */
  139904. w: number;
  139905. /**
  139906. * number of the original height of the Frame
  139907. */
  139908. h: number;
  139909. }
  139910. /**
  139911. * Defines the basic options interface of a Sprite Frame Data.
  139912. */
  139913. export interface ISpriteJSONSpriteFrameData {
  139914. /**
  139915. * number of the x offset of the Frame
  139916. */
  139917. x: number;
  139918. /**
  139919. * number of the y offset of the Frame
  139920. */
  139921. y: number;
  139922. /**
  139923. * number of the width of the Frame
  139924. */
  139925. w: number;
  139926. /**
  139927. * number of the height of the Frame
  139928. */
  139929. h: number;
  139930. }
  139931. /**
  139932. * Defines the basic options interface of a JSON Sprite.
  139933. */
  139934. export interface ISpriteJSONSprite {
  139935. /**
  139936. * string name of the Frame
  139937. */
  139938. filename: string;
  139939. /**
  139940. * ISpriteJSONSpriteFrame basic object of the frame data
  139941. */
  139942. frame: ISpriteJSONSpriteFrameData;
  139943. /**
  139944. * boolean to flag is the frame was rotated.
  139945. */
  139946. rotated: boolean;
  139947. /**
  139948. * boolean to flag is the frame was trimmed.
  139949. */
  139950. trimmed: boolean;
  139951. /**
  139952. * ISpriteJSONSpriteFrame basic object of the source data
  139953. */
  139954. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139955. /**
  139956. * ISpriteJSONSpriteFrame basic object of the source data
  139957. */
  139958. sourceSize: ISpriteJSONSpriteSourceSize;
  139959. }
  139960. /**
  139961. * Defines the basic options interface of a JSON atlas.
  139962. */
  139963. export interface ISpriteJSONAtlas {
  139964. /**
  139965. * Array of objects that contain the frame data.
  139966. */
  139967. frames: Array<ISpriteJSONSprite>;
  139968. /**
  139969. * object basic object containing the sprite meta data.
  139970. */
  139971. meta?: object;
  139972. }
  139973. }
  139974. declare module BABYLON {
  139975. /** @hidden */
  139976. export var spriteMapPixelShader: {
  139977. name: string;
  139978. shader: string;
  139979. };
  139980. }
  139981. declare module BABYLON {
  139982. /** @hidden */
  139983. export var spriteMapVertexShader: {
  139984. name: string;
  139985. shader: string;
  139986. };
  139987. }
  139988. declare module BABYLON {
  139989. /**
  139990. * Defines the basic options interface of a SpriteMap
  139991. */
  139992. export interface ISpriteMapOptions {
  139993. /**
  139994. * Vector2 of the number of cells in the grid.
  139995. */
  139996. stageSize?: Vector2;
  139997. /**
  139998. * Vector2 of the size of the output plane in World Units.
  139999. */
  140000. outputSize?: Vector2;
  140001. /**
  140002. * Vector3 of the position of the output plane in World Units.
  140003. */
  140004. outputPosition?: Vector3;
  140005. /**
  140006. * Vector3 of the rotation of the output plane.
  140007. */
  140008. outputRotation?: Vector3;
  140009. /**
  140010. * number of layers that the system will reserve in resources.
  140011. */
  140012. layerCount?: number;
  140013. /**
  140014. * number of max animation frames a single cell will reserve in resources.
  140015. */
  140016. maxAnimationFrames?: number;
  140017. /**
  140018. * number cell index of the base tile when the system compiles.
  140019. */
  140020. baseTile?: number;
  140021. /**
  140022. * boolean flip the sprite after its been repositioned by the framing data.
  140023. */
  140024. flipU?: boolean;
  140025. /**
  140026. * Vector3 scalar of the global RGB values of the SpriteMap.
  140027. */
  140028. colorMultiply?: Vector3;
  140029. }
  140030. /**
  140031. * Defines the IDisposable interface in order to be cleanable from resources.
  140032. */
  140033. export interface ISpriteMap extends IDisposable {
  140034. /**
  140035. * String name of the SpriteMap.
  140036. */
  140037. name: string;
  140038. /**
  140039. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140040. */
  140041. atlasJSON: ISpriteJSONAtlas;
  140042. /**
  140043. * Texture of the SpriteMap.
  140044. */
  140045. spriteSheet: Texture;
  140046. /**
  140047. * The parameters to initialize the SpriteMap with.
  140048. */
  140049. options: ISpriteMapOptions;
  140050. }
  140051. /**
  140052. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140053. */
  140054. export class SpriteMap implements ISpriteMap {
  140055. /** The Name of the spriteMap */
  140056. name: string;
  140057. /** The JSON file with the frame and meta data */
  140058. atlasJSON: ISpriteJSONAtlas;
  140059. /** The systems Sprite Sheet Texture */
  140060. spriteSheet: Texture;
  140061. /** Arguments passed with the Constructor */
  140062. options: ISpriteMapOptions;
  140063. /** Public Sprite Storage array, parsed from atlasJSON */
  140064. sprites: Array<ISpriteJSONSprite>;
  140065. /** Returns the Number of Sprites in the System */
  140066. get spriteCount(): number;
  140067. /** Returns the Position of Output Plane*/
  140068. get position(): Vector3;
  140069. /** Returns the Position of Output Plane*/
  140070. set position(v: Vector3);
  140071. /** Returns the Rotation of Output Plane*/
  140072. get rotation(): Vector3;
  140073. /** Returns the Rotation of Output Plane*/
  140074. set rotation(v: Vector3);
  140075. /** Sets the AnimationMap*/
  140076. get animationMap(): RawTexture;
  140077. /** Sets the AnimationMap*/
  140078. set animationMap(v: RawTexture);
  140079. /** Scene that the SpriteMap was created in */
  140080. private _scene;
  140081. /** Texture Buffer of Float32 that holds tile frame data*/
  140082. private _frameMap;
  140083. /** Texture Buffers of Float32 that holds tileMap data*/
  140084. private _tileMaps;
  140085. /** Texture Buffer of Float32 that holds Animation Data*/
  140086. private _animationMap;
  140087. /** Custom ShaderMaterial Central to the System*/
  140088. private _material;
  140089. /** Custom ShaderMaterial Central to the System*/
  140090. private _output;
  140091. /** Systems Time Ticker*/
  140092. private _time;
  140093. /**
  140094. * Creates a new SpriteMap
  140095. * @param name defines the SpriteMaps Name
  140096. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140097. * @param spriteSheet is the Texture that the Sprites are on.
  140098. * @param options a basic deployment configuration
  140099. * @param scene The Scene that the map is deployed on
  140100. */
  140101. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140102. /**
  140103. * Returns tileID location
  140104. * @returns Vector2 the cell position ID
  140105. */
  140106. getTileID(): Vector2;
  140107. /**
  140108. * Gets the UV location of the mouse over the SpriteMap.
  140109. * @returns Vector2 the UV position of the mouse interaction
  140110. */
  140111. getMousePosition(): Vector2;
  140112. /**
  140113. * Creates the "frame" texture Buffer
  140114. * -------------------------------------
  140115. * Structure of frames
  140116. * "filename": "Falling-Water-2.png",
  140117. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140118. * "rotated": true,
  140119. * "trimmed": true,
  140120. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140121. * "sourceSize": {"w":32,"h":32}
  140122. * @returns RawTexture of the frameMap
  140123. */
  140124. private _createFrameBuffer;
  140125. /**
  140126. * Creates the tileMap texture Buffer
  140127. * @param buffer normally and array of numbers, or a false to generate from scratch
  140128. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140129. * @returns RawTexture of the tileMap
  140130. */
  140131. private _createTileBuffer;
  140132. /**
  140133. * Modifies the data of the tileMaps
  140134. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140135. * @param pos is the iVector2 Coordinates of the Tile
  140136. * @param tile The SpriteIndex of the new Tile
  140137. */
  140138. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140139. /**
  140140. * Creates the animationMap texture Buffer
  140141. * @param buffer normally and array of numbers, or a false to generate from scratch
  140142. * @returns RawTexture of the animationMap
  140143. */
  140144. private _createTileAnimationBuffer;
  140145. /**
  140146. * Modifies the data of the animationMap
  140147. * @param cellID is the Index of the Sprite
  140148. * @param _frame is the target Animation frame
  140149. * @param toCell is the Target Index of the next frame of the animation
  140150. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140151. * @param speed is a global scalar of the time variable on the map.
  140152. */
  140153. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140154. /**
  140155. * Exports the .tilemaps file
  140156. */
  140157. saveTileMaps(): void;
  140158. /**
  140159. * Imports the .tilemaps file
  140160. * @param url of the .tilemaps file
  140161. */
  140162. loadTileMaps(url: string): void;
  140163. /**
  140164. * Release associated resources
  140165. */
  140166. dispose(): void;
  140167. }
  140168. }
  140169. declare module BABYLON {
  140170. /**
  140171. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140172. * @see http://doc.babylonjs.com/babylon101/sprites
  140173. */
  140174. export class SpritePackedManager extends SpriteManager {
  140175. /** defines the packed manager's name */
  140176. name: string;
  140177. /**
  140178. * Creates a new sprite manager from a packed sprite sheet
  140179. * @param name defines the manager's name
  140180. * @param imgUrl defines the sprite sheet url
  140181. * @param capacity defines the maximum allowed number of sprites
  140182. * @param scene defines the hosting scene
  140183. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140184. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140185. * @param samplingMode defines the smapling mode to use with spritesheet
  140186. * @param fromPacked set to true; do not alter
  140187. */
  140188. constructor(
  140189. /** defines the packed manager's name */
  140190. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140191. }
  140192. }
  140193. declare module BABYLON {
  140194. /**
  140195. * Defines the list of states available for a task inside a AssetsManager
  140196. */
  140197. export enum AssetTaskState {
  140198. /**
  140199. * Initialization
  140200. */
  140201. INIT = 0,
  140202. /**
  140203. * Running
  140204. */
  140205. RUNNING = 1,
  140206. /**
  140207. * Done
  140208. */
  140209. DONE = 2,
  140210. /**
  140211. * Error
  140212. */
  140213. ERROR = 3
  140214. }
  140215. /**
  140216. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140217. */
  140218. export abstract class AbstractAssetTask {
  140219. /**
  140220. * Task name
  140221. */ name: string;
  140222. /**
  140223. * Callback called when the task is successful
  140224. */
  140225. onSuccess: (task: any) => void;
  140226. /**
  140227. * Callback called when the task is not successful
  140228. */
  140229. onError: (task: any, message?: string, exception?: any) => void;
  140230. /**
  140231. * Creates a new AssetsManager
  140232. * @param name defines the name of the task
  140233. */
  140234. constructor(
  140235. /**
  140236. * Task name
  140237. */ name: string);
  140238. private _isCompleted;
  140239. private _taskState;
  140240. private _errorObject;
  140241. /**
  140242. * Get if the task is completed
  140243. */
  140244. get isCompleted(): boolean;
  140245. /**
  140246. * Gets the current state of the task
  140247. */
  140248. get taskState(): AssetTaskState;
  140249. /**
  140250. * Gets the current error object (if task is in error)
  140251. */
  140252. get errorObject(): {
  140253. message?: string;
  140254. exception?: any;
  140255. };
  140256. /**
  140257. * Internal only
  140258. * @hidden
  140259. */
  140260. _setErrorObject(message?: string, exception?: any): void;
  140261. /**
  140262. * Execute the current task
  140263. * @param scene defines the scene where you want your assets to be loaded
  140264. * @param onSuccess is a callback called when the task is successfully executed
  140265. * @param onError is a callback called if an error occurs
  140266. */
  140267. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140268. /**
  140269. * Execute the current task
  140270. * @param scene defines the scene where you want your assets to be loaded
  140271. * @param onSuccess is a callback called when the task is successfully executed
  140272. * @param onError is a callback called if an error occurs
  140273. */
  140274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140275. /**
  140276. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140277. * This can be used with failed tasks that have the reason for failure fixed.
  140278. */
  140279. reset(): void;
  140280. private onErrorCallback;
  140281. private onDoneCallback;
  140282. }
  140283. /**
  140284. * Define the interface used by progress events raised during assets loading
  140285. */
  140286. export interface IAssetsProgressEvent {
  140287. /**
  140288. * Defines the number of remaining tasks to process
  140289. */
  140290. remainingCount: number;
  140291. /**
  140292. * Defines the total number of tasks
  140293. */
  140294. totalCount: number;
  140295. /**
  140296. * Defines the task that was just processed
  140297. */
  140298. task: AbstractAssetTask;
  140299. }
  140300. /**
  140301. * Class used to share progress information about assets loading
  140302. */
  140303. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140304. /**
  140305. * Defines the number of remaining tasks to process
  140306. */
  140307. remainingCount: number;
  140308. /**
  140309. * Defines the total number of tasks
  140310. */
  140311. totalCount: number;
  140312. /**
  140313. * Defines the task that was just processed
  140314. */
  140315. task: AbstractAssetTask;
  140316. /**
  140317. * Creates a AssetsProgressEvent
  140318. * @param remainingCount defines the number of remaining tasks to process
  140319. * @param totalCount defines the total number of tasks
  140320. * @param task defines the task that was just processed
  140321. */
  140322. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140323. }
  140324. /**
  140325. * Define a task used by AssetsManager to load meshes
  140326. */
  140327. export class MeshAssetTask extends AbstractAssetTask {
  140328. /**
  140329. * Defines the name of the task
  140330. */
  140331. name: string;
  140332. /**
  140333. * Defines the list of mesh's names you want to load
  140334. */
  140335. meshesNames: any;
  140336. /**
  140337. * Defines the root url to use as a base to load your meshes and associated resources
  140338. */
  140339. rootUrl: string;
  140340. /**
  140341. * Defines the filename of the scene to load from
  140342. */
  140343. sceneFilename: string;
  140344. /**
  140345. * Gets the list of loaded meshes
  140346. */
  140347. loadedMeshes: Array<AbstractMesh>;
  140348. /**
  140349. * Gets the list of loaded particle systems
  140350. */
  140351. loadedParticleSystems: Array<IParticleSystem>;
  140352. /**
  140353. * Gets the list of loaded skeletons
  140354. */
  140355. loadedSkeletons: Array<Skeleton>;
  140356. /**
  140357. * Gets the list of loaded animation groups
  140358. */
  140359. loadedAnimationGroups: Array<AnimationGroup>;
  140360. /**
  140361. * Callback called when the task is successful
  140362. */
  140363. onSuccess: (task: MeshAssetTask) => void;
  140364. /**
  140365. * Callback called when the task is successful
  140366. */
  140367. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140368. /**
  140369. * Creates a new MeshAssetTask
  140370. * @param name defines the name of the task
  140371. * @param meshesNames defines the list of mesh's names you want to load
  140372. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140373. * @param sceneFilename defines the filename of the scene to load from
  140374. */
  140375. constructor(
  140376. /**
  140377. * Defines the name of the task
  140378. */
  140379. name: string,
  140380. /**
  140381. * Defines the list of mesh's names you want to load
  140382. */
  140383. meshesNames: any,
  140384. /**
  140385. * Defines the root url to use as a base to load your meshes and associated resources
  140386. */
  140387. rootUrl: string,
  140388. /**
  140389. * Defines the filename of the scene to load from
  140390. */
  140391. sceneFilename: string);
  140392. /**
  140393. * Execute the current task
  140394. * @param scene defines the scene where you want your assets to be loaded
  140395. * @param onSuccess is a callback called when the task is successfully executed
  140396. * @param onError is a callback called if an error occurs
  140397. */
  140398. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140399. }
  140400. /**
  140401. * Define a task used by AssetsManager to load text content
  140402. */
  140403. export class TextFileAssetTask extends AbstractAssetTask {
  140404. /**
  140405. * Defines the name of the task
  140406. */
  140407. name: string;
  140408. /**
  140409. * Defines the location of the file to load
  140410. */
  140411. url: string;
  140412. /**
  140413. * Gets the loaded text string
  140414. */
  140415. text: string;
  140416. /**
  140417. * Callback called when the task is successful
  140418. */
  140419. onSuccess: (task: TextFileAssetTask) => void;
  140420. /**
  140421. * Callback called when the task is successful
  140422. */
  140423. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140424. /**
  140425. * Creates a new TextFileAssetTask object
  140426. * @param name defines the name of the task
  140427. * @param url defines the location of the file to load
  140428. */
  140429. constructor(
  140430. /**
  140431. * Defines the name of the task
  140432. */
  140433. name: string,
  140434. /**
  140435. * Defines the location of the file to load
  140436. */
  140437. url: string);
  140438. /**
  140439. * Execute the current task
  140440. * @param scene defines the scene where you want your assets to be loaded
  140441. * @param onSuccess is a callback called when the task is successfully executed
  140442. * @param onError is a callback called if an error occurs
  140443. */
  140444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140445. }
  140446. /**
  140447. * Define a task used by AssetsManager to load binary data
  140448. */
  140449. export class BinaryFileAssetTask extends AbstractAssetTask {
  140450. /**
  140451. * Defines the name of the task
  140452. */
  140453. name: string;
  140454. /**
  140455. * Defines the location of the file to load
  140456. */
  140457. url: string;
  140458. /**
  140459. * Gets the lodaded data (as an array buffer)
  140460. */
  140461. data: ArrayBuffer;
  140462. /**
  140463. * Callback called when the task is successful
  140464. */
  140465. onSuccess: (task: BinaryFileAssetTask) => void;
  140466. /**
  140467. * Callback called when the task is successful
  140468. */
  140469. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140470. /**
  140471. * Creates a new BinaryFileAssetTask object
  140472. * @param name defines the name of the new task
  140473. * @param url defines the location of the file to load
  140474. */
  140475. constructor(
  140476. /**
  140477. * Defines the name of the task
  140478. */
  140479. name: string,
  140480. /**
  140481. * Defines the location of the file to load
  140482. */
  140483. url: string);
  140484. /**
  140485. * Execute the current task
  140486. * @param scene defines the scene where you want your assets to be loaded
  140487. * @param onSuccess is a callback called when the task is successfully executed
  140488. * @param onError is a callback called if an error occurs
  140489. */
  140490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140491. }
  140492. /**
  140493. * Define a task used by AssetsManager to load images
  140494. */
  140495. export class ImageAssetTask extends AbstractAssetTask {
  140496. /**
  140497. * Defines the name of the task
  140498. */
  140499. name: string;
  140500. /**
  140501. * Defines the location of the image to load
  140502. */
  140503. url: string;
  140504. /**
  140505. * Gets the loaded images
  140506. */
  140507. image: HTMLImageElement;
  140508. /**
  140509. * Callback called when the task is successful
  140510. */
  140511. onSuccess: (task: ImageAssetTask) => void;
  140512. /**
  140513. * Callback called when the task is successful
  140514. */
  140515. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140516. /**
  140517. * Creates a new ImageAssetTask
  140518. * @param name defines the name of the task
  140519. * @param url defines the location of the image to load
  140520. */
  140521. constructor(
  140522. /**
  140523. * Defines the name of the task
  140524. */
  140525. name: string,
  140526. /**
  140527. * Defines the location of the image to load
  140528. */
  140529. url: string);
  140530. /**
  140531. * Execute the current task
  140532. * @param scene defines the scene where you want your assets to be loaded
  140533. * @param onSuccess is a callback called when the task is successfully executed
  140534. * @param onError is a callback called if an error occurs
  140535. */
  140536. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140537. }
  140538. /**
  140539. * Defines the interface used by texture loading tasks
  140540. */
  140541. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140542. /**
  140543. * Gets the loaded texture
  140544. */
  140545. texture: TEX;
  140546. }
  140547. /**
  140548. * Define a task used by AssetsManager to load 2D textures
  140549. */
  140550. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140551. /**
  140552. * Defines the name of the task
  140553. */
  140554. name: string;
  140555. /**
  140556. * Defines the location of the file to load
  140557. */
  140558. url: string;
  140559. /**
  140560. * Defines if mipmap should not be generated (default is false)
  140561. */
  140562. noMipmap?: boolean | undefined;
  140563. /**
  140564. * Defines if texture must be inverted on Y axis (default is false)
  140565. */
  140566. invertY?: boolean | undefined;
  140567. /**
  140568. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140569. */
  140570. samplingMode: number;
  140571. /**
  140572. * Gets the loaded texture
  140573. */
  140574. texture: Texture;
  140575. /**
  140576. * Callback called when the task is successful
  140577. */
  140578. onSuccess: (task: TextureAssetTask) => void;
  140579. /**
  140580. * Callback called when the task is successful
  140581. */
  140582. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140583. /**
  140584. * Creates a new TextureAssetTask object
  140585. * @param name defines the name of the task
  140586. * @param url defines the location of the file to load
  140587. * @param noMipmap defines if mipmap should not be generated (default is false)
  140588. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140589. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140590. */
  140591. constructor(
  140592. /**
  140593. * Defines the name of the task
  140594. */
  140595. name: string,
  140596. /**
  140597. * Defines the location of the file to load
  140598. */
  140599. url: string,
  140600. /**
  140601. * Defines if mipmap should not be generated (default is false)
  140602. */
  140603. noMipmap?: boolean | undefined,
  140604. /**
  140605. * Defines if texture must be inverted on Y axis (default is false)
  140606. */
  140607. invertY?: boolean | undefined,
  140608. /**
  140609. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140610. */
  140611. samplingMode?: number);
  140612. /**
  140613. * Execute the current task
  140614. * @param scene defines the scene where you want your assets to be loaded
  140615. * @param onSuccess is a callback called when the task is successfully executed
  140616. * @param onError is a callback called if an error occurs
  140617. */
  140618. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140619. }
  140620. /**
  140621. * Define a task used by AssetsManager to load cube textures
  140622. */
  140623. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140624. /**
  140625. * Defines the name of the task
  140626. */
  140627. name: string;
  140628. /**
  140629. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140630. */
  140631. url: string;
  140632. /**
  140633. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140634. */
  140635. extensions?: string[] | undefined;
  140636. /**
  140637. * Defines if mipmaps should not be generated (default is false)
  140638. */
  140639. noMipmap?: boolean | undefined;
  140640. /**
  140641. * Defines the explicit list of files (undefined by default)
  140642. */
  140643. files?: string[] | undefined;
  140644. /**
  140645. * Gets the loaded texture
  140646. */
  140647. texture: CubeTexture;
  140648. /**
  140649. * Callback called when the task is successful
  140650. */
  140651. onSuccess: (task: CubeTextureAssetTask) => void;
  140652. /**
  140653. * Callback called when the task is successful
  140654. */
  140655. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140656. /**
  140657. * Creates a new CubeTextureAssetTask
  140658. * @param name defines the name of the task
  140659. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140660. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140661. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140662. * @param files defines the explicit list of files (undefined by default)
  140663. */
  140664. constructor(
  140665. /**
  140666. * Defines the name of the task
  140667. */
  140668. name: string,
  140669. /**
  140670. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140671. */
  140672. url: string,
  140673. /**
  140674. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140675. */
  140676. extensions?: string[] | undefined,
  140677. /**
  140678. * Defines if mipmaps should not be generated (default is false)
  140679. */
  140680. noMipmap?: boolean | undefined,
  140681. /**
  140682. * Defines the explicit list of files (undefined by default)
  140683. */
  140684. files?: string[] | undefined);
  140685. /**
  140686. * Execute the current task
  140687. * @param scene defines the scene where you want your assets to be loaded
  140688. * @param onSuccess is a callback called when the task is successfully executed
  140689. * @param onError is a callback called if an error occurs
  140690. */
  140691. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140692. }
  140693. /**
  140694. * Define a task used by AssetsManager to load HDR cube textures
  140695. */
  140696. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140697. /**
  140698. * Defines the name of the task
  140699. */
  140700. name: string;
  140701. /**
  140702. * Defines the location of the file to load
  140703. */
  140704. url: string;
  140705. /**
  140706. * Defines the desired size (the more it increases the longer the generation will be)
  140707. */
  140708. size: number;
  140709. /**
  140710. * Defines if mipmaps should not be generated (default is false)
  140711. */
  140712. noMipmap: boolean;
  140713. /**
  140714. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140715. */
  140716. generateHarmonics: boolean;
  140717. /**
  140718. * 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)
  140719. */
  140720. gammaSpace: boolean;
  140721. /**
  140722. * Internal Use Only
  140723. */
  140724. reserved: boolean;
  140725. /**
  140726. * Gets the loaded texture
  140727. */
  140728. texture: HDRCubeTexture;
  140729. /**
  140730. * Callback called when the task is successful
  140731. */
  140732. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140733. /**
  140734. * Callback called when the task is successful
  140735. */
  140736. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140737. /**
  140738. * Creates a new HDRCubeTextureAssetTask object
  140739. * @param name defines the name of the task
  140740. * @param url defines the location of the file to load
  140741. * @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.
  140742. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140743. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140744. * @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)
  140745. * @param reserved Internal use only
  140746. */
  140747. constructor(
  140748. /**
  140749. * Defines the name of the task
  140750. */
  140751. name: string,
  140752. /**
  140753. * Defines the location of the file to load
  140754. */
  140755. url: string,
  140756. /**
  140757. * Defines the desired size (the more it increases the longer the generation will be)
  140758. */
  140759. size: number,
  140760. /**
  140761. * Defines if mipmaps should not be generated (default is false)
  140762. */
  140763. noMipmap?: boolean,
  140764. /**
  140765. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140766. */
  140767. generateHarmonics?: boolean,
  140768. /**
  140769. * 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)
  140770. */
  140771. gammaSpace?: boolean,
  140772. /**
  140773. * Internal Use Only
  140774. */
  140775. reserved?: boolean);
  140776. /**
  140777. * Execute the current task
  140778. * @param scene defines the scene where you want your assets to be loaded
  140779. * @param onSuccess is a callback called when the task is successfully executed
  140780. * @param onError is a callback called if an error occurs
  140781. */
  140782. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140783. }
  140784. /**
  140785. * Define a task used by AssetsManager to load Equirectangular cube textures
  140786. */
  140787. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140788. /**
  140789. * Defines the name of the task
  140790. */
  140791. name: string;
  140792. /**
  140793. * Defines the location of the file to load
  140794. */
  140795. url: string;
  140796. /**
  140797. * Defines the desired size (the more it increases the longer the generation will be)
  140798. */
  140799. size: number;
  140800. /**
  140801. * Defines if mipmaps should not be generated (default is false)
  140802. */
  140803. noMipmap: boolean;
  140804. /**
  140805. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140806. * but the standard material would require them in Gamma space) (default is true)
  140807. */
  140808. gammaSpace: boolean;
  140809. /**
  140810. * Gets the loaded texture
  140811. */
  140812. texture: EquiRectangularCubeTexture;
  140813. /**
  140814. * Callback called when the task is successful
  140815. */
  140816. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140817. /**
  140818. * Callback called when the task is successful
  140819. */
  140820. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140821. /**
  140822. * Creates a new EquiRectangularCubeTextureAssetTask object
  140823. * @param name defines the name of the task
  140824. * @param url defines the location of the file to load
  140825. * @param size defines the desired size (the more it increases the longer the generation will be)
  140826. * If the size is omitted this implies you are using a preprocessed cubemap.
  140827. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140828. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140829. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140830. * (default is true)
  140831. */
  140832. constructor(
  140833. /**
  140834. * Defines the name of the task
  140835. */
  140836. name: string,
  140837. /**
  140838. * Defines the location of the file to load
  140839. */
  140840. url: string,
  140841. /**
  140842. * Defines the desired size (the more it increases the longer the generation will be)
  140843. */
  140844. size: number,
  140845. /**
  140846. * Defines if mipmaps should not be generated (default is false)
  140847. */
  140848. noMipmap?: boolean,
  140849. /**
  140850. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140851. * but the standard material would require them in Gamma space) (default is true)
  140852. */
  140853. gammaSpace?: boolean);
  140854. /**
  140855. * Execute the current task
  140856. * @param scene defines the scene where you want your assets to be loaded
  140857. * @param onSuccess is a callback called when the task is successfully executed
  140858. * @param onError is a callback called if an error occurs
  140859. */
  140860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140861. }
  140862. /**
  140863. * This class can be used to easily import assets into a scene
  140864. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140865. */
  140866. export class AssetsManager {
  140867. private _scene;
  140868. private _isLoading;
  140869. protected _tasks: AbstractAssetTask[];
  140870. protected _waitingTasksCount: number;
  140871. protected _totalTasksCount: number;
  140872. /**
  140873. * Callback called when all tasks are processed
  140874. */
  140875. onFinish: (tasks: AbstractAssetTask[]) => void;
  140876. /**
  140877. * Callback called when a task is successful
  140878. */
  140879. onTaskSuccess: (task: AbstractAssetTask) => void;
  140880. /**
  140881. * Callback called when a task had an error
  140882. */
  140883. onTaskError: (task: AbstractAssetTask) => void;
  140884. /**
  140885. * Callback called when a task is done (whatever the result is)
  140886. */
  140887. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140888. /**
  140889. * Observable called when all tasks are processed
  140890. */
  140891. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140892. /**
  140893. * Observable called when a task had an error
  140894. */
  140895. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140896. /**
  140897. * Observable called when all tasks were executed
  140898. */
  140899. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140900. /**
  140901. * Observable called when a task is done (whatever the result is)
  140902. */
  140903. onProgressObservable: Observable<IAssetsProgressEvent>;
  140904. /**
  140905. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140906. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140907. */
  140908. useDefaultLoadingScreen: boolean;
  140909. /**
  140910. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140911. * when all assets have been downloaded.
  140912. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140913. */
  140914. autoHideLoadingUI: boolean;
  140915. /**
  140916. * Creates a new AssetsManager
  140917. * @param scene defines the scene to work on
  140918. */
  140919. constructor(scene: Scene);
  140920. /**
  140921. * Add a MeshAssetTask to the list of active tasks
  140922. * @param taskName defines the name of the new task
  140923. * @param meshesNames defines the name of meshes to load
  140924. * @param rootUrl defines the root url to use to locate files
  140925. * @param sceneFilename defines the filename of the scene file
  140926. * @returns a new MeshAssetTask object
  140927. */
  140928. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140929. /**
  140930. * Add a TextFileAssetTask to the list of active tasks
  140931. * @param taskName defines the name of the new task
  140932. * @param url defines the url of the file to load
  140933. * @returns a new TextFileAssetTask object
  140934. */
  140935. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140936. /**
  140937. * Add a BinaryFileAssetTask to the list of active tasks
  140938. * @param taskName defines the name of the new task
  140939. * @param url defines the url of the file to load
  140940. * @returns a new BinaryFileAssetTask object
  140941. */
  140942. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140943. /**
  140944. * Add a ImageAssetTask to the list of active tasks
  140945. * @param taskName defines the name of the new task
  140946. * @param url defines the url of the file to load
  140947. * @returns a new ImageAssetTask object
  140948. */
  140949. addImageTask(taskName: string, url: string): ImageAssetTask;
  140950. /**
  140951. * Add a TextureAssetTask to the list of active tasks
  140952. * @param taskName defines the name of the new task
  140953. * @param url defines the url of the file to load
  140954. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140955. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140956. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140957. * @returns a new TextureAssetTask object
  140958. */
  140959. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140960. /**
  140961. * Add a CubeTextureAssetTask to the list of active tasks
  140962. * @param taskName defines the name of the new task
  140963. * @param url defines the url of the file to load
  140964. * @param extensions defines the extension to use to load the cube map (can be null)
  140965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140966. * @param files defines the list of files to load (can be null)
  140967. * @returns a new CubeTextureAssetTask object
  140968. */
  140969. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140970. /**
  140971. *
  140972. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140973. * @param taskName defines the name of the new task
  140974. * @param url defines the url of the file to load
  140975. * @param size defines the size you want for the cubemap (can be null)
  140976. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140977. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140978. * @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)
  140979. * @param reserved Internal use only
  140980. * @returns a new HDRCubeTextureAssetTask object
  140981. */
  140982. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140983. /**
  140984. *
  140985. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140986. * @param taskName defines the name of the new task
  140987. * @param url defines the url of the file to load
  140988. * @param size defines the size you want for the cubemap (can be null)
  140989. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140990. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140991. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140992. * @returns a new EquiRectangularCubeTextureAssetTask object
  140993. */
  140994. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140995. /**
  140996. * Remove a task from the assets manager.
  140997. * @param task the task to remove
  140998. */
  140999. removeTask(task: AbstractAssetTask): void;
  141000. private _decreaseWaitingTasksCount;
  141001. private _runTask;
  141002. /**
  141003. * Reset the AssetsManager and remove all tasks
  141004. * @return the current instance of the AssetsManager
  141005. */
  141006. reset(): AssetsManager;
  141007. /**
  141008. * Start the loading process
  141009. * @return the current instance of the AssetsManager
  141010. */
  141011. load(): AssetsManager;
  141012. /**
  141013. * Start the loading process as an async operation
  141014. * @return a promise returning the list of failed tasks
  141015. */
  141016. loadAsync(): Promise<void>;
  141017. }
  141018. }
  141019. declare module BABYLON {
  141020. /**
  141021. * Wrapper class for promise with external resolve and reject.
  141022. */
  141023. export class Deferred<T> {
  141024. /**
  141025. * The promise associated with this deferred object.
  141026. */
  141027. readonly promise: Promise<T>;
  141028. private _resolve;
  141029. private _reject;
  141030. /**
  141031. * The resolve method of the promise associated with this deferred object.
  141032. */
  141033. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141034. /**
  141035. * The reject method of the promise associated with this deferred object.
  141036. */
  141037. get reject(): (reason?: any) => void;
  141038. /**
  141039. * Constructor for this deferred object.
  141040. */
  141041. constructor();
  141042. }
  141043. }
  141044. declare module BABYLON {
  141045. /**
  141046. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141047. */
  141048. export class MeshExploder {
  141049. private _centerMesh;
  141050. private _meshes;
  141051. private _meshesOrigins;
  141052. private _toCenterVectors;
  141053. private _scaledDirection;
  141054. private _newPosition;
  141055. private _centerPosition;
  141056. /**
  141057. * Explodes meshes from a center mesh.
  141058. * @param meshes The meshes to explode.
  141059. * @param centerMesh The mesh to be center of explosion.
  141060. */
  141061. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141062. private _setCenterMesh;
  141063. /**
  141064. * Get class name
  141065. * @returns "MeshExploder"
  141066. */
  141067. getClassName(): string;
  141068. /**
  141069. * "Exploded meshes"
  141070. * @returns Array of meshes with the centerMesh at index 0.
  141071. */
  141072. getMeshes(): Array<Mesh>;
  141073. /**
  141074. * Explodes meshes giving a specific direction
  141075. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141076. */
  141077. explode(direction?: number): void;
  141078. }
  141079. }
  141080. declare module BABYLON {
  141081. /**
  141082. * Class used to help managing file picking and drag'n'drop
  141083. */
  141084. export class FilesInput {
  141085. /**
  141086. * List of files ready to be loaded
  141087. */
  141088. static get FilesToLoad(): {
  141089. [key: string]: File;
  141090. };
  141091. /**
  141092. * Callback called when a file is processed
  141093. */
  141094. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141095. private _engine;
  141096. private _currentScene;
  141097. private _sceneLoadedCallback;
  141098. private _progressCallback;
  141099. private _additionalRenderLoopLogicCallback;
  141100. private _textureLoadingCallback;
  141101. private _startingProcessingFilesCallback;
  141102. private _onReloadCallback;
  141103. private _errorCallback;
  141104. private _elementToMonitor;
  141105. private _sceneFileToLoad;
  141106. private _filesToLoad;
  141107. /**
  141108. * Creates a new FilesInput
  141109. * @param engine defines the rendering engine
  141110. * @param scene defines the hosting scene
  141111. * @param sceneLoadedCallback callback called when scene is loaded
  141112. * @param progressCallback callback called to track progress
  141113. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141114. * @param textureLoadingCallback callback called when a texture is loading
  141115. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141116. * @param onReloadCallback callback called when a reload is requested
  141117. * @param errorCallback callback call if an error occurs
  141118. */
  141119. 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);
  141120. private _dragEnterHandler;
  141121. private _dragOverHandler;
  141122. private _dropHandler;
  141123. /**
  141124. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141125. * @param elementToMonitor defines the DOM element to track
  141126. */
  141127. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141128. /**
  141129. * Release all associated resources
  141130. */
  141131. dispose(): void;
  141132. private renderFunction;
  141133. private drag;
  141134. private drop;
  141135. private _traverseFolder;
  141136. private _processFiles;
  141137. /**
  141138. * Load files from a drop event
  141139. * @param event defines the drop event to use as source
  141140. */
  141141. loadFiles(event: any): void;
  141142. private _processReload;
  141143. /**
  141144. * Reload the current scene from the loaded files
  141145. */
  141146. reload(): void;
  141147. }
  141148. }
  141149. declare module BABYLON {
  141150. /**
  141151. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141152. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141153. */
  141154. export class SceneOptimization {
  141155. /**
  141156. * Defines the priority of this optimization (0 by default which means first in the list)
  141157. */
  141158. priority: number;
  141159. /**
  141160. * Gets a string describing the action executed by the current optimization
  141161. * @returns description string
  141162. */
  141163. getDescription(): string;
  141164. /**
  141165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141166. * @param scene defines the current scene where to apply this optimization
  141167. * @param optimizer defines the current optimizer
  141168. * @returns true if everything that can be done was applied
  141169. */
  141170. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141171. /**
  141172. * Creates the SceneOptimization object
  141173. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141174. * @param desc defines the description associated with the optimization
  141175. */
  141176. constructor(
  141177. /**
  141178. * Defines the priority of this optimization (0 by default which means first in the list)
  141179. */
  141180. priority?: number);
  141181. }
  141182. /**
  141183. * Defines an optimization used to reduce the size of render target textures
  141184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141185. */
  141186. export class TextureOptimization extends SceneOptimization {
  141187. /**
  141188. * Defines the priority of this optimization (0 by default which means first in the list)
  141189. */
  141190. priority: number;
  141191. /**
  141192. * 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
  141193. */
  141194. maximumSize: number;
  141195. /**
  141196. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141197. */
  141198. step: number;
  141199. /**
  141200. * Gets a string describing the action executed by the current optimization
  141201. * @returns description string
  141202. */
  141203. getDescription(): string;
  141204. /**
  141205. * Creates the TextureOptimization object
  141206. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141207. * @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
  141208. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141209. */
  141210. constructor(
  141211. /**
  141212. * Defines the priority of this optimization (0 by default which means first in the list)
  141213. */
  141214. priority?: number,
  141215. /**
  141216. * 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
  141217. */
  141218. maximumSize?: number,
  141219. /**
  141220. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141221. */
  141222. step?: number);
  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. /**
  141232. * Defines an optimization used to increase or decrease the rendering resolution
  141233. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141234. */
  141235. export class HardwareScalingOptimization extends SceneOptimization {
  141236. /**
  141237. * Defines the priority of this optimization (0 by default which means first in the list)
  141238. */
  141239. priority: number;
  141240. /**
  141241. * Defines the maximum scale to use (2 by default)
  141242. */
  141243. maximumScale: number;
  141244. /**
  141245. * Defines the step to use between two passes (0.5 by default)
  141246. */
  141247. step: number;
  141248. private _currentScale;
  141249. private _directionOffset;
  141250. /**
  141251. * Gets a string describing the action executed by the current optimization
  141252. * @return description string
  141253. */
  141254. getDescription(): string;
  141255. /**
  141256. * Creates the HardwareScalingOptimization object
  141257. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141258. * @param maximumScale defines the maximum scale to use (2 by default)
  141259. * @param step defines the step to use between two passes (0.5 by default)
  141260. */
  141261. constructor(
  141262. /**
  141263. * Defines the priority of this optimization (0 by default which means first in the list)
  141264. */
  141265. priority?: number,
  141266. /**
  141267. * Defines the maximum scale to use (2 by default)
  141268. */
  141269. maximumScale?: number,
  141270. /**
  141271. * Defines the step to use between two passes (0.5 by default)
  141272. */
  141273. step?: number);
  141274. /**
  141275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141276. * @param scene defines the current scene where to apply this optimization
  141277. * @param optimizer defines the current optimizer
  141278. * @returns true if everything that can be done was applied
  141279. */
  141280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141281. }
  141282. /**
  141283. * Defines an optimization used to remove shadows
  141284. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141285. */
  141286. export class ShadowsOptimization extends SceneOptimization {
  141287. /**
  141288. * Gets a string describing the action executed by the current optimization
  141289. * @return description string
  141290. */
  141291. getDescription(): string;
  141292. /**
  141293. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141294. * @param scene defines the current scene where to apply this optimization
  141295. * @param optimizer defines the current optimizer
  141296. * @returns true if everything that can be done was applied
  141297. */
  141298. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141299. }
  141300. /**
  141301. * Defines an optimization used to turn post-processes off
  141302. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141303. */
  141304. export class PostProcessesOptimization extends SceneOptimization {
  141305. /**
  141306. * Gets a string describing the action executed by the current optimization
  141307. * @return description string
  141308. */
  141309. getDescription(): string;
  141310. /**
  141311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141312. * @param scene defines the current scene where to apply this optimization
  141313. * @param optimizer defines the current optimizer
  141314. * @returns true if everything that can be done was applied
  141315. */
  141316. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141317. }
  141318. /**
  141319. * Defines an optimization used to turn lens flares off
  141320. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141321. */
  141322. export class LensFlaresOptimization extends SceneOptimization {
  141323. /**
  141324. * Gets a string describing the action executed by the current optimization
  141325. * @return description string
  141326. */
  141327. getDescription(): string;
  141328. /**
  141329. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141330. * @param scene defines the current scene where to apply this optimization
  141331. * @param optimizer defines the current optimizer
  141332. * @returns true if everything that can be done was applied
  141333. */
  141334. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141335. }
  141336. /**
  141337. * Defines an optimization based on user defined callback.
  141338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141339. */
  141340. export class CustomOptimization extends SceneOptimization {
  141341. /**
  141342. * Callback called to apply the custom optimization.
  141343. */
  141344. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141345. /**
  141346. * Callback called to get custom description
  141347. */
  141348. onGetDescription: () => string;
  141349. /**
  141350. * Gets a string describing the action executed by the current optimization
  141351. * @returns description string
  141352. */
  141353. getDescription(): string;
  141354. /**
  141355. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141356. * @param scene defines the current scene where to apply this optimization
  141357. * @param optimizer defines the current optimizer
  141358. * @returns true if everything that can be done was applied
  141359. */
  141360. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141361. }
  141362. /**
  141363. * Defines an optimization used to turn particles off
  141364. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141365. */
  141366. export class ParticlesOptimization extends SceneOptimization {
  141367. /**
  141368. * Gets a string describing the action executed by the current optimization
  141369. * @return description string
  141370. */
  141371. getDescription(): string;
  141372. /**
  141373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141374. * @param scene defines the current scene where to apply this optimization
  141375. * @param optimizer defines the current optimizer
  141376. * @returns true if everything that can be done was applied
  141377. */
  141378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141379. }
  141380. /**
  141381. * Defines an optimization used to turn render targets off
  141382. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141383. */
  141384. export class RenderTargetsOptimization extends SceneOptimization {
  141385. /**
  141386. * Gets a string describing the action executed by the current optimization
  141387. * @return description string
  141388. */
  141389. getDescription(): string;
  141390. /**
  141391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141392. * @param scene defines the current scene where to apply this optimization
  141393. * @param optimizer defines the current optimizer
  141394. * @returns true if everything that can be done was applied
  141395. */
  141396. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141397. }
  141398. /**
  141399. * Defines an optimization used to merge meshes with compatible materials
  141400. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141401. */
  141402. export class MergeMeshesOptimization extends SceneOptimization {
  141403. private static _UpdateSelectionTree;
  141404. /**
  141405. * Gets or sets a boolean which defines if optimization octree has to be updated
  141406. */
  141407. static get UpdateSelectionTree(): boolean;
  141408. /**
  141409. * Gets or sets a boolean which defines if optimization octree has to be updated
  141410. */
  141411. static set UpdateSelectionTree(value: boolean);
  141412. /**
  141413. * Gets a string describing the action executed by the current optimization
  141414. * @return description string
  141415. */
  141416. getDescription(): string;
  141417. private _canBeMerged;
  141418. /**
  141419. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141420. * @param scene defines the current scene where to apply this optimization
  141421. * @param optimizer defines the current optimizer
  141422. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141423. * @returns true if everything that can be done was applied
  141424. */
  141425. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141426. }
  141427. /**
  141428. * Defines a list of options used by SceneOptimizer
  141429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141430. */
  141431. export class SceneOptimizerOptions {
  141432. /**
  141433. * Defines the target frame rate to reach (60 by default)
  141434. */
  141435. targetFrameRate: number;
  141436. /**
  141437. * Defines the interval between two checkes (2000ms by default)
  141438. */
  141439. trackerDuration: number;
  141440. /**
  141441. * Gets the list of optimizations to apply
  141442. */
  141443. optimizations: SceneOptimization[];
  141444. /**
  141445. * Creates a new list of options used by SceneOptimizer
  141446. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141447. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141448. */
  141449. constructor(
  141450. /**
  141451. * Defines the target frame rate to reach (60 by default)
  141452. */
  141453. targetFrameRate?: number,
  141454. /**
  141455. * Defines the interval between two checkes (2000ms by default)
  141456. */
  141457. trackerDuration?: number);
  141458. /**
  141459. * Add a new optimization
  141460. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141461. * @returns the current SceneOptimizerOptions
  141462. */
  141463. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141464. /**
  141465. * Add a new custom optimization
  141466. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141467. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141468. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141469. * @returns the current SceneOptimizerOptions
  141470. */
  141471. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141472. /**
  141473. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141474. * @param targetFrameRate defines the target frame rate (60 by default)
  141475. * @returns a SceneOptimizerOptions object
  141476. */
  141477. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141478. /**
  141479. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141480. * @param targetFrameRate defines the target frame rate (60 by default)
  141481. * @returns a SceneOptimizerOptions object
  141482. */
  141483. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141484. /**
  141485. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141486. * @param targetFrameRate defines the target frame rate (60 by default)
  141487. * @returns a SceneOptimizerOptions object
  141488. */
  141489. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141490. }
  141491. /**
  141492. * Class used to run optimizations in order to reach a target frame rate
  141493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141494. */
  141495. export class SceneOptimizer implements IDisposable {
  141496. private _isRunning;
  141497. private _options;
  141498. private _scene;
  141499. private _currentPriorityLevel;
  141500. private _targetFrameRate;
  141501. private _trackerDuration;
  141502. private _currentFrameRate;
  141503. private _sceneDisposeObserver;
  141504. private _improvementMode;
  141505. /**
  141506. * Defines an observable called when the optimizer reaches the target frame rate
  141507. */
  141508. onSuccessObservable: Observable<SceneOptimizer>;
  141509. /**
  141510. * Defines an observable called when the optimizer enables an optimization
  141511. */
  141512. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141513. /**
  141514. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141515. */
  141516. onFailureObservable: Observable<SceneOptimizer>;
  141517. /**
  141518. * Gets a boolean indicating if the optimizer is in improvement mode
  141519. */
  141520. get isInImprovementMode(): boolean;
  141521. /**
  141522. * Gets the current priority level (0 at start)
  141523. */
  141524. get currentPriorityLevel(): number;
  141525. /**
  141526. * Gets the current frame rate checked by the SceneOptimizer
  141527. */
  141528. get currentFrameRate(): number;
  141529. /**
  141530. * Gets or sets the current target frame rate (60 by default)
  141531. */
  141532. get targetFrameRate(): number;
  141533. /**
  141534. * Gets or sets the current target frame rate (60 by default)
  141535. */
  141536. set targetFrameRate(value: number);
  141537. /**
  141538. * Gets or sets the current interval between two checks (every 2000ms by default)
  141539. */
  141540. get trackerDuration(): number;
  141541. /**
  141542. * Gets or sets the current interval between two checks (every 2000ms by default)
  141543. */
  141544. set trackerDuration(value: number);
  141545. /**
  141546. * Gets the list of active optimizations
  141547. */
  141548. get optimizations(): SceneOptimization[];
  141549. /**
  141550. * Creates a new SceneOptimizer
  141551. * @param scene defines the scene to work on
  141552. * @param options defines the options to use with the SceneOptimizer
  141553. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141554. * @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)
  141555. */
  141556. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141557. /**
  141558. * Stops the current optimizer
  141559. */
  141560. stop(): void;
  141561. /**
  141562. * Reset the optimizer to initial step (current priority level = 0)
  141563. */
  141564. reset(): void;
  141565. /**
  141566. * Start the optimizer. By default it will try to reach a specific framerate
  141567. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141568. */
  141569. start(): void;
  141570. private _checkCurrentState;
  141571. /**
  141572. * Release all resources
  141573. */
  141574. dispose(): void;
  141575. /**
  141576. * Helper function to create a SceneOptimizer with one single line of code
  141577. * @param scene defines the scene to work on
  141578. * @param options defines the options to use with the SceneOptimizer
  141579. * @param onSuccess defines a callback to call on success
  141580. * @param onFailure defines a callback to call on failure
  141581. * @returns the new SceneOptimizer object
  141582. */
  141583. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141584. }
  141585. }
  141586. declare module BABYLON {
  141587. /**
  141588. * Class used to serialize a scene into a string
  141589. */
  141590. export class SceneSerializer {
  141591. /**
  141592. * Clear cache used by a previous serialization
  141593. */
  141594. static ClearCache(): void;
  141595. /**
  141596. * Serialize a scene into a JSON compatible object
  141597. * @param scene defines the scene to serialize
  141598. * @returns a JSON compatible object
  141599. */
  141600. static Serialize(scene: Scene): any;
  141601. /**
  141602. * Serialize a mesh into a JSON compatible object
  141603. * @param toSerialize defines the mesh to serialize
  141604. * @param withParents defines if parents must be serialized as well
  141605. * @param withChildren defines if children must be serialized as well
  141606. * @returns a JSON compatible object
  141607. */
  141608. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141609. }
  141610. }
  141611. declare module BABYLON {
  141612. /**
  141613. * Class used to host texture specific utilities
  141614. */
  141615. export class TextureTools {
  141616. /**
  141617. * Uses the GPU to create a copy texture rescaled at a given size
  141618. * @param texture Texture to copy from
  141619. * @param width defines the desired width
  141620. * @param height defines the desired height
  141621. * @param useBilinearMode defines if bilinear mode has to be used
  141622. * @return the generated texture
  141623. */
  141624. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141625. }
  141626. }
  141627. declare module BABYLON {
  141628. /**
  141629. * This represents the different options available for the video capture.
  141630. */
  141631. export interface VideoRecorderOptions {
  141632. /** Defines the mime type of the video. */
  141633. mimeType: string;
  141634. /** Defines the FPS the video should be recorded at. */
  141635. fps: number;
  141636. /** Defines the chunk size for the recording data. */
  141637. recordChunckSize: number;
  141638. /** The audio tracks to attach to the recording. */
  141639. audioTracks?: MediaStreamTrack[];
  141640. }
  141641. /**
  141642. * This can help with recording videos from BabylonJS.
  141643. * This is based on the available WebRTC functionalities of the browser.
  141644. *
  141645. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141646. */
  141647. export class VideoRecorder {
  141648. private static readonly _defaultOptions;
  141649. /**
  141650. * Returns whether or not the VideoRecorder is available in your browser.
  141651. * @param engine Defines the Babylon Engine.
  141652. * @returns true if supported otherwise false.
  141653. */
  141654. static IsSupported(engine: Engine): boolean;
  141655. private readonly _options;
  141656. private _canvas;
  141657. private _mediaRecorder;
  141658. private _recordedChunks;
  141659. private _fileName;
  141660. private _resolve;
  141661. private _reject;
  141662. /**
  141663. * True when a recording is already in progress.
  141664. */
  141665. get isRecording(): boolean;
  141666. /**
  141667. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141668. * @param engine Defines the BabylonJS Engine you wish to record.
  141669. * @param options Defines options that can be used to customize the capture.
  141670. */
  141671. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141672. /**
  141673. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141674. */
  141675. stopRecording(): void;
  141676. /**
  141677. * Starts recording the canvas for a max duration specified in parameters.
  141678. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141679. * If null no automatic download will start and you can rely on the promise to get the data back.
  141680. * @param maxDuration Defines the maximum recording time in seconds.
  141681. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141682. * @return A promise callback at the end of the recording with the video data in Blob.
  141683. */
  141684. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141685. /**
  141686. * Releases internal resources used during the recording.
  141687. */
  141688. dispose(): void;
  141689. private _handleDataAvailable;
  141690. private _handleError;
  141691. private _handleStop;
  141692. }
  141693. }
  141694. declare module BABYLON {
  141695. /**
  141696. * Class containing a set of static utilities functions for screenshots
  141697. */
  141698. export class ScreenshotTools {
  141699. /**
  141700. * Captures a screenshot of the current rendering
  141701. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141702. * @param engine defines the rendering engine
  141703. * @param camera defines the source camera
  141704. * @param size This parameter can be set to a single number or to an object with the
  141705. * following (optional) properties: precision, width, height. If a single number is passed,
  141706. * it will be used for both width and height. If an object is passed, the screenshot size
  141707. * will be derived from the parameters. The precision property is a multiplier allowing
  141708. * rendering at a higher or lower resolution
  141709. * @param successCallback defines the callback receives a single parameter which contains the
  141710. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141711. * src parameter of an <img> to display it
  141712. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141713. * Check your browser for supported MIME types
  141714. */
  141715. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141716. /**
  141717. * Captures a screenshot of the current rendering
  141718. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141719. * @param engine defines the rendering engine
  141720. * @param camera defines the source camera
  141721. * @param size This parameter can be set to a single number or to an object with the
  141722. * following (optional) properties: precision, width, height. If a single number is passed,
  141723. * it will be used for both width and height. If an object is passed, the screenshot size
  141724. * will be derived from the parameters. The precision property is a multiplier allowing
  141725. * rendering at a higher or lower resolution
  141726. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141727. * Check your browser for supported MIME types
  141728. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141729. * to the src parameter of an <img> to display it
  141730. */
  141731. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141732. /**
  141733. * Generates an image screenshot from the specified camera.
  141734. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141735. * @param engine The engine to use for rendering
  141736. * @param camera The camera to use for rendering
  141737. * @param size This parameter can be set to a single number or to an object with the
  141738. * following (optional) properties: precision, width, height. If a single number is passed,
  141739. * it will be used for both width and height. If an object is passed, the screenshot size
  141740. * will be derived from the parameters. The precision property is a multiplier allowing
  141741. * rendering at a higher or lower resolution
  141742. * @param successCallback The callback receives a single parameter which contains the
  141743. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141744. * src parameter of an <img> to display it
  141745. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141746. * Check your browser for supported MIME types
  141747. * @param samples Texture samples (default: 1)
  141748. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141749. * @param fileName A name for for the downloaded file.
  141750. */
  141751. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  141752. /**
  141753. * Generates an image screenshot from the specified camera.
  141754. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141755. * @param engine The engine to use for rendering
  141756. * @param camera The camera to use for rendering
  141757. * @param size This parameter can be set to a single number or to an object with the
  141758. * following (optional) properties: precision, width, height. If a single number is passed,
  141759. * it will be used for both width and height. If an object is passed, the screenshot size
  141760. * will be derived from the parameters. The precision property is a multiplier allowing
  141761. * rendering at a higher or lower resolution
  141762. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141763. * Check your browser for supported MIME types
  141764. * @param samples Texture samples (default: 1)
  141765. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141766. * @param fileName A name for for the downloaded file.
  141767. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141768. * to the src parameter of an <img> to display it
  141769. */
  141770. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141771. /**
  141772. * Gets height and width for screenshot size
  141773. * @private
  141774. */
  141775. private static _getScreenshotSize;
  141776. }
  141777. }
  141778. declare module BABYLON {
  141779. /**
  141780. * Interface for a data buffer
  141781. */
  141782. export interface IDataBuffer {
  141783. /**
  141784. * Reads bytes from the data buffer.
  141785. * @param byteOffset The byte offset to read
  141786. * @param byteLength The byte length to read
  141787. * @returns A promise that resolves when the bytes are read
  141788. */
  141789. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141790. /**
  141791. * The byte length of the buffer.
  141792. */
  141793. readonly byteLength: number;
  141794. }
  141795. /**
  141796. * Utility class for reading from a data buffer
  141797. */
  141798. export class DataReader {
  141799. /**
  141800. * The data buffer associated with this data reader.
  141801. */
  141802. readonly buffer: IDataBuffer;
  141803. /**
  141804. * The current byte offset from the beginning of the data buffer.
  141805. */
  141806. byteOffset: number;
  141807. private _dataView;
  141808. private _dataByteOffset;
  141809. /**
  141810. * Constructor
  141811. * @param buffer The buffer to read
  141812. */
  141813. constructor(buffer: IDataBuffer);
  141814. /**
  141815. * Loads the given byte length.
  141816. * @param byteLength The byte length to load
  141817. * @returns A promise that resolves when the load is complete
  141818. */
  141819. loadAsync(byteLength: number): Promise<void>;
  141820. /**
  141821. * Read a unsigned 32-bit integer from the currently loaded data range.
  141822. * @returns The 32-bit integer read
  141823. */
  141824. readUint32(): number;
  141825. /**
  141826. * Read a byte array from the currently loaded data range.
  141827. * @param byteLength The byte length to read
  141828. * @returns The byte array read
  141829. */
  141830. readUint8Array(byteLength: number): Uint8Array;
  141831. /**
  141832. * Read a string from the currently loaded data range.
  141833. * @param byteLength The byte length to read
  141834. * @returns The string read
  141835. */
  141836. readString(byteLength: number): string;
  141837. /**
  141838. * Skips the given byte length the currently loaded data range.
  141839. * @param byteLength The byte length to skip
  141840. */
  141841. skipBytes(byteLength: number): void;
  141842. }
  141843. }
  141844. declare module BABYLON {
  141845. /**
  141846. * Options used for hit testing
  141847. */
  141848. export interface IWebXRHitTestOptions {
  141849. /**
  141850. * Only test when user interacted with the scene. Default - hit test every frame
  141851. */
  141852. testOnPointerDownOnly?: boolean;
  141853. /**
  141854. * The node to use to transform the local results to world coordinates
  141855. */
  141856. worldParentNode?: TransformNode;
  141857. }
  141858. /**
  141859. * Interface defining the babylon result of raycasting/hit-test
  141860. */
  141861. export interface IWebXRHitResult {
  141862. /**
  141863. * The native hit test result
  141864. */
  141865. xrHitResult: XRHitResult;
  141866. /**
  141867. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141868. */
  141869. transformationMatrix: Matrix;
  141870. }
  141871. /**
  141872. * The currently-working hit-test module.
  141873. * Hit test (or raycasting) is used to interact with the real world.
  141874. * For further information read here - https://github.com/immersive-web/hit-test
  141875. */
  141876. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141877. /**
  141878. * options to use when constructing this feature
  141879. */
  141880. readonly options: IWebXRHitTestOptions;
  141881. /**
  141882. * The module's name
  141883. */
  141884. static readonly Name: string;
  141885. /**
  141886. * The (Babylon) version of this module.
  141887. * This is an integer representing the implementation version.
  141888. * This number does not correspond to the webxr specs version
  141889. */
  141890. static readonly Version: number;
  141891. /**
  141892. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141893. * @param event the (select) event to use to select with
  141894. * @param referenceSpace the reference space to use for this hit test
  141895. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141896. */
  141897. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141898. /**
  141899. * execute a hit test with an XR Ray
  141900. *
  141901. * @param xrSession a native xrSession that will execute this hit test
  141902. * @param xrRay the ray (position and direction) to use for raycasting
  141903. * @param referenceSpace native XR reference space to use for the hit-test
  141904. * @param filter filter function that will filter the results
  141905. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141906. */
  141907. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141908. /**
  141909. * Triggered when new babylon (transformed) hit test results are available
  141910. */
  141911. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141912. private _onSelectEnabled;
  141913. /**
  141914. * Creates a new instance of the (legacy version) hit test feature
  141915. * @param _xrSessionManager an instance of WebXRSessionManager
  141916. * @param options options to use when constructing this feature
  141917. */
  141918. constructor(_xrSessionManager: WebXRSessionManager,
  141919. /**
  141920. * options to use when constructing this feature
  141921. */
  141922. options?: IWebXRHitTestOptions);
  141923. /**
  141924. * Populated with the last native XR Hit Results
  141925. */
  141926. lastNativeXRHitResults: XRHitResult[];
  141927. /**
  141928. * attach this feature
  141929. * Will usually be called by the features manager
  141930. *
  141931. * @returns true if successful.
  141932. */
  141933. attach(): boolean;
  141934. /**
  141935. * detach this feature.
  141936. * Will usually be called by the features manager
  141937. *
  141938. * @returns true if successful.
  141939. */
  141940. detach(): boolean;
  141941. private _onHitTestResults;
  141942. private _origin;
  141943. private _direction;
  141944. private _mat;
  141945. protected _onXRFrame(frame: XRFrame): void;
  141946. private _onSelect;
  141947. /**
  141948. * Dispose this feature and all of the resources attached
  141949. */
  141950. dispose(): void;
  141951. }
  141952. }
  141953. declare module BABYLON {
  141954. /**
  141955. * Options used in the plane detector module
  141956. */
  141957. export interface IWebXRPlaneDetectorOptions {
  141958. /**
  141959. * The node to use to transform the local results to world coordinates
  141960. */
  141961. worldParentNode?: TransformNode;
  141962. }
  141963. /**
  141964. * A babylon interface for a webxr plane.
  141965. * A Plane is actually a polygon, built from N points in space
  141966. *
  141967. * Supported in chrome 79, not supported in canary 81 ATM
  141968. */
  141969. export interface IWebXRPlane {
  141970. /**
  141971. * a babylon-assigned ID for this polygon
  141972. */
  141973. id: number;
  141974. /**
  141975. * the native xr-plane object
  141976. */
  141977. xrPlane: XRPlane;
  141978. /**
  141979. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  141980. */
  141981. polygonDefinition: Array<Vector3>;
  141982. /**
  141983. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  141984. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  141985. */
  141986. transformationMatrix: Matrix;
  141987. }
  141988. /**
  141989. * The plane detector is used to detect planes in the real world when in AR
  141990. * For more information see https://github.com/immersive-web/real-world-geometry/
  141991. */
  141992. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  141993. private _options;
  141994. /**
  141995. * The module's name
  141996. */
  141997. static readonly Name: string;
  141998. /**
  141999. * The (Babylon) version of this module.
  142000. * This is an integer representing the implementation version.
  142001. * This number does not correspond to the webxr specs version
  142002. */
  142003. static readonly Version: number;
  142004. /**
  142005. * Observers registered here will be executed when a new plane was added to the session
  142006. */
  142007. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142008. /**
  142009. * Observers registered here will be executed when a plane is no longer detected in the session
  142010. */
  142011. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142012. /**
  142013. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142014. * This can execute N times every frame
  142015. */
  142016. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142017. private _enabled;
  142018. private _detectedPlanes;
  142019. private _lastFrameDetected;
  142020. /**
  142021. * construct a new Plane Detector
  142022. * @param _xrSessionManager an instance of xr Session manager
  142023. * @param _options configuration to use when constructing this feature
  142024. */
  142025. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142026. private _init;
  142027. protected _onXRFrame(frame: XRFrame): void;
  142028. /**
  142029. * Dispose this feature and all of the resources attached
  142030. */
  142031. dispose(): void;
  142032. private _updatePlaneWithXRPlane;
  142033. /**
  142034. * avoiding using Array.find for global support.
  142035. * @param xrPlane the plane to find in the array
  142036. */
  142037. private findIndexInPlaneArray;
  142038. }
  142039. }
  142040. declare module BABYLON {
  142041. /**
  142042. * Configuration options of the anchor system
  142043. */
  142044. export interface IWebXRAnchorSystemOptions {
  142045. /**
  142046. * a node that will be used to convert local to world coordinates
  142047. */
  142048. worldParentNode?: TransformNode;
  142049. /**
  142050. * should the anchor system use plane detection.
  142051. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142052. */
  142053. usePlaneDetection?: boolean;
  142054. /**
  142055. * Should a new anchor be added every time a select event is triggered
  142056. */
  142057. addAnchorOnSelect?: boolean;
  142058. }
  142059. /**
  142060. * A babylon container for an XR Anchor
  142061. */
  142062. export interface IWebXRAnchor {
  142063. /**
  142064. * A babylon-assigned ID for this anchor
  142065. */
  142066. id: number;
  142067. /**
  142068. * The native anchor object
  142069. */
  142070. xrAnchor: XRAnchor;
  142071. /**
  142072. * Transformation matrix to apply to an object attached to this anchor
  142073. */
  142074. transformationMatrix: Matrix;
  142075. }
  142076. /**
  142077. * An implementation of the anchor system of WebXR.
  142078. * Note that the current documented implementation is not available in any browser. Future implementations
  142079. * will use the frame to create an anchor and not the session or a detected plane
  142080. * For further information see https://github.com/immersive-web/anchors/
  142081. */
  142082. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142083. private _options;
  142084. /**
  142085. * The module's name
  142086. */
  142087. static readonly Name: string;
  142088. /**
  142089. * The (Babylon) version of this module.
  142090. * This is an integer representing the implementation version.
  142091. * This number does not correspond to the webxr specs version
  142092. */
  142093. static readonly Version: number;
  142094. /**
  142095. * Observers registered here will be executed when a new anchor was added to the session
  142096. */
  142097. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142098. /**
  142099. * Observers registered here will be executed when an existing anchor updates
  142100. * This can execute N times every frame
  142101. */
  142102. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142103. /**
  142104. * Observers registered here will be executed when an anchor was removed from the session
  142105. */
  142106. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142107. private _planeDetector;
  142108. private _hitTestModule;
  142109. private _enabled;
  142110. private _trackedAnchors;
  142111. private _lastFrameDetected;
  142112. /**
  142113. * constructs a new anchor system
  142114. * @param _xrSessionManager an instance of WebXRSessionManager
  142115. * @param _options configuration object for this feature
  142116. */
  142117. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142118. /**
  142119. * set the plane detector to use in order to create anchors from frames
  142120. * @param planeDetector the plane-detector module to use
  142121. * @param enable enable plane-anchors. default is true
  142122. */
  142123. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142124. /**
  142125. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142126. * @param hitTestModule the hit-test module to use.
  142127. */
  142128. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142129. /**
  142130. * attach this feature
  142131. * Will usually be called by the features manager
  142132. *
  142133. * @returns true if successful.
  142134. */
  142135. attach(): boolean;
  142136. /**
  142137. * detach this feature.
  142138. * Will usually be called by the features manager
  142139. *
  142140. * @returns true if successful.
  142141. */
  142142. detach(): boolean;
  142143. /**
  142144. * Dispose this feature and all of the resources attached
  142145. */
  142146. dispose(): void;
  142147. protected _onXRFrame(frame: XRFrame): void;
  142148. private _onSelect;
  142149. /**
  142150. * Add anchor at a specific XR point.
  142151. *
  142152. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142153. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142154. * @returns a promise the fulfills when the anchor was created
  142155. */
  142156. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142157. private _updateAnchorWithXRFrame;
  142158. /**
  142159. * avoiding using Array.find for global support.
  142160. * @param xrAnchor the plane to find in the array
  142161. */
  142162. private _findIndexInAnchorArray;
  142163. }
  142164. }
  142165. declare module BABYLON {
  142166. /**
  142167. * Options interface for the background remover plugin
  142168. */
  142169. export interface IWebXRBackgroundRemoverOptions {
  142170. /**
  142171. * don't disable the environment helper
  142172. */
  142173. ignoreEnvironmentHelper?: boolean;
  142174. /**
  142175. * flags to configure the removal of the environment helper.
  142176. * If not set, the entire background will be removed. If set, flags should be set as well.
  142177. */
  142178. environmentHelperRemovalFlags?: {
  142179. /**
  142180. * Should the skybox be removed (default false)
  142181. */
  142182. skyBox?: boolean;
  142183. /**
  142184. * Should the ground be removed (default false)
  142185. */
  142186. ground?: boolean;
  142187. };
  142188. /**
  142189. * Further background meshes to disable when entering AR
  142190. */
  142191. backgroundMeshes?: AbstractMesh[];
  142192. }
  142193. /**
  142194. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142195. */
  142196. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142197. /**
  142198. * read-only options to be used in this module
  142199. */
  142200. readonly options: IWebXRBackgroundRemoverOptions;
  142201. /**
  142202. * The module's name
  142203. */
  142204. static readonly Name: string;
  142205. /**
  142206. * The (Babylon) version of this module.
  142207. * This is an integer representing the implementation version.
  142208. * This number does not correspond to the webxr specs version
  142209. */
  142210. static readonly Version: number;
  142211. /**
  142212. * registered observers will be triggered when the background state changes
  142213. */
  142214. onBackgroundStateChangedObservable: Observable<boolean>;
  142215. /**
  142216. * constructs a new background remover module
  142217. * @param _xrSessionManager the session manager for this module
  142218. * @param options read-only options to be used in this module
  142219. */
  142220. constructor(_xrSessionManager: WebXRSessionManager,
  142221. /**
  142222. * read-only options to be used in this module
  142223. */
  142224. options?: IWebXRBackgroundRemoverOptions);
  142225. /**
  142226. * attach this feature
  142227. * Will usually be called by the features manager
  142228. *
  142229. * @returns true if successful.
  142230. */
  142231. attach(): boolean;
  142232. /**
  142233. * detach this feature.
  142234. * Will usually be called by the features manager
  142235. *
  142236. * @returns true if successful.
  142237. */
  142238. detach(): boolean;
  142239. private _setBackgroundState;
  142240. /**
  142241. * Dispose this feature and all of the resources attached
  142242. */
  142243. dispose(): void;
  142244. protected _onXRFrame(_xrFrame: XRFrame): void;
  142245. }
  142246. }
  142247. declare module BABYLON {
  142248. /**
  142249. * Options for the controller physics feature
  142250. */
  142251. export class IWebXRControllerPhysicsOptions {
  142252. /**
  142253. * the xr input to use with this pointer selection
  142254. */
  142255. xrInput: WebXRInput;
  142256. /**
  142257. * The physics properties of the future impostors
  142258. */
  142259. physicsProperties?: {
  142260. /**
  142261. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142262. * Note that this requires a physics engine that supports mesh impostors!
  142263. */
  142264. useControllerMesh?: boolean;
  142265. /**
  142266. * The type of impostor to create. Default is sphere
  142267. */
  142268. impostorType?: number;
  142269. /**
  142270. * the size of the impostor. Defaults to 10cm
  142271. */
  142272. impostorSize?: number | {
  142273. width: number;
  142274. height: number;
  142275. depth: number;
  142276. };
  142277. /**
  142278. * Friction definitions
  142279. */
  142280. friction?: number;
  142281. /**
  142282. * Restitution
  142283. */
  142284. restitution?: number;
  142285. };
  142286. }
  142287. /**
  142288. * Add physics impostor to your webxr controllers,
  142289. * including naive calculation of their linear and angular velocity
  142290. */
  142291. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142292. private readonly _options;
  142293. /**
  142294. * The module's name
  142295. */
  142296. static readonly Name: string;
  142297. /**
  142298. * The (Babylon) version of this module.
  142299. * This is an integer representing the implementation version.
  142300. * This number does not correspond to the webxr specs version
  142301. */
  142302. static readonly Version: number;
  142303. private _lastTimestamp;
  142304. private _delta;
  142305. private _controllers;
  142306. private _tmpVector;
  142307. private _tmpQuaternion;
  142308. /**
  142309. * Construct a new Controller Physics Feature
  142310. * @param _xrSessionManager the corresponding xr session manager
  142311. * @param _options options to create this feature with
  142312. */
  142313. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142314. /**
  142315. * Update the physics properties provided in the constructor
  142316. * @param newProperties the new properties object
  142317. */
  142318. setPhysicsProperties(newProperties: {
  142319. impostorType?: number;
  142320. impostorSize?: number | {
  142321. width: number;
  142322. height: number;
  142323. depth: number;
  142324. };
  142325. friction?: number;
  142326. restitution?: number;
  142327. }): void;
  142328. /**
  142329. * attach this feature
  142330. * Will usually be called by the features manager
  142331. *
  142332. * @returns true if successful.
  142333. */
  142334. attach(): boolean;
  142335. /**
  142336. * detach this feature.
  142337. * Will usually be called by the features manager
  142338. *
  142339. * @returns true if successful.
  142340. */
  142341. detach(): boolean;
  142342. /**
  142343. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142344. * @param xrController the controller to add
  142345. */
  142346. addController(xrController: WebXRInputSource): void;
  142347. private _debugMode;
  142348. /**
  142349. * @hidden
  142350. * enable debugging - will show console outputs and the impostor mesh
  142351. */
  142352. _enablePhysicsDebug(): void;
  142353. private _attachController;
  142354. private _detachController;
  142355. protected _onXRFrame(_xrFrame: any): void;
  142356. }
  142357. }
  142358. declare module BABYLON {
  142359. /**
  142360. * The motion controller class for all microsoft mixed reality controllers
  142361. */
  142362. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142363. /**
  142364. * The base url used to load the left and right controller models
  142365. */
  142366. static MODEL_BASE_URL: string;
  142367. /**
  142368. * The name of the left controller model file
  142369. */
  142370. static MODEL_LEFT_FILENAME: string;
  142371. /**
  142372. * The name of the right controller model file
  142373. */
  142374. static MODEL_RIGHT_FILENAME: string;
  142375. profileId: string;
  142376. protected readonly _mapping: {
  142377. defaultButton: {
  142378. "valueNodeName": string;
  142379. "unpressedNodeName": string;
  142380. "pressedNodeName": string;
  142381. };
  142382. defaultAxis: {
  142383. "valueNodeName": string;
  142384. "minNodeName": string;
  142385. "maxNodeName": string;
  142386. };
  142387. buttons: {
  142388. "xr-standard-trigger": {
  142389. "rootNodeName": string;
  142390. "componentProperty": string;
  142391. "states": string[];
  142392. };
  142393. "xr-standard-squeeze": {
  142394. "rootNodeName": string;
  142395. "componentProperty": string;
  142396. "states": string[];
  142397. };
  142398. "xr-standard-touchpad": {
  142399. "rootNodeName": string;
  142400. "labelAnchorNodeName": string;
  142401. "touchPointNodeName": string;
  142402. };
  142403. "xr-standard-thumbstick": {
  142404. "rootNodeName": string;
  142405. "componentProperty": string;
  142406. "states": string[];
  142407. };
  142408. };
  142409. axes: {
  142410. "xr-standard-touchpad": {
  142411. "x-axis": {
  142412. "rootNodeName": string;
  142413. };
  142414. "y-axis": {
  142415. "rootNodeName": string;
  142416. };
  142417. };
  142418. "xr-standard-thumbstick": {
  142419. "x-axis": {
  142420. "rootNodeName": string;
  142421. };
  142422. "y-axis": {
  142423. "rootNodeName": string;
  142424. };
  142425. };
  142426. };
  142427. };
  142428. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142429. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142430. protected _getFilenameAndPath(): {
  142431. filename: string;
  142432. path: string;
  142433. };
  142434. protected _updateModel(): void;
  142435. protected _getModelLoadingConstraints(): boolean;
  142436. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142437. }
  142438. }
  142439. declare module BABYLON {
  142440. /**
  142441. * The motion controller class for oculus touch (quest, rift).
  142442. * This class supports legacy mapping as well the standard xr mapping
  142443. */
  142444. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142445. private _forceLegacyControllers;
  142446. /**
  142447. * The base url used to load the left and right controller models
  142448. */
  142449. static MODEL_BASE_URL: string;
  142450. /**
  142451. * The name of the left controller model file
  142452. */
  142453. static MODEL_LEFT_FILENAME: string;
  142454. /**
  142455. * The name of the right controller model file
  142456. */
  142457. static MODEL_RIGHT_FILENAME: string;
  142458. /**
  142459. * Base Url for the Quest controller model.
  142460. */
  142461. static QUEST_MODEL_BASE_URL: string;
  142462. profileId: string;
  142463. private _modelRootNode;
  142464. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142465. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142466. protected _getFilenameAndPath(): {
  142467. filename: string;
  142468. path: string;
  142469. };
  142470. /**
  142471. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142472. * between the touch and touch 2.
  142473. */
  142474. private _isQuest;
  142475. protected _updateModel(): void;
  142476. protected _getModelLoadingConstraints(): boolean;
  142477. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142478. }
  142479. }
  142480. declare module BABYLON {
  142481. /**
  142482. * The motion controller class for the standard HTC-Vive controllers
  142483. */
  142484. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142485. /**
  142486. * The base url used to load the left and right controller models
  142487. */
  142488. static MODEL_BASE_URL: string;
  142489. /**
  142490. * File name for the controller model.
  142491. */
  142492. static MODEL_FILENAME: string;
  142493. profileId: string;
  142494. private _modelRootNode;
  142495. /**
  142496. * Create a new Vive motion controller object
  142497. * @param scene the scene to use to create this controller
  142498. * @param gamepadObject the corresponding gamepad object
  142499. * @param handness the handness of the controller
  142500. */
  142501. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142502. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142503. protected _getFilenameAndPath(): {
  142504. filename: string;
  142505. path: string;
  142506. };
  142507. protected _updateModel(): void;
  142508. protected _getModelLoadingConstraints(): boolean;
  142509. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142510. }
  142511. }
  142512. declare module BABYLON {
  142513. /**
  142514. * A cursor which tracks a point on a path
  142515. */
  142516. export class PathCursor {
  142517. private path;
  142518. /**
  142519. * Stores path cursor callbacks for when an onchange event is triggered
  142520. */
  142521. private _onchange;
  142522. /**
  142523. * The value of the path cursor
  142524. */
  142525. value: number;
  142526. /**
  142527. * The animation array of the path cursor
  142528. */
  142529. animations: Animation[];
  142530. /**
  142531. * Initializes the path cursor
  142532. * @param path The path to track
  142533. */
  142534. constructor(path: Path2);
  142535. /**
  142536. * Gets the cursor point on the path
  142537. * @returns A point on the path cursor at the cursor location
  142538. */
  142539. getPoint(): Vector3;
  142540. /**
  142541. * Moves the cursor ahead by the step amount
  142542. * @param step The amount to move the cursor forward
  142543. * @returns This path cursor
  142544. */
  142545. moveAhead(step?: number): PathCursor;
  142546. /**
  142547. * Moves the cursor behind by the step amount
  142548. * @param step The amount to move the cursor back
  142549. * @returns This path cursor
  142550. */
  142551. moveBack(step?: number): PathCursor;
  142552. /**
  142553. * Moves the cursor by the step amount
  142554. * If the step amount is greater than one, an exception is thrown
  142555. * @param step The amount to move the cursor
  142556. * @returns This path cursor
  142557. */
  142558. move(step: number): PathCursor;
  142559. /**
  142560. * Ensures that the value is limited between zero and one
  142561. * @returns This path cursor
  142562. */
  142563. private ensureLimits;
  142564. /**
  142565. * Runs onchange callbacks on change (used by the animation engine)
  142566. * @returns This path cursor
  142567. */
  142568. private raiseOnChange;
  142569. /**
  142570. * Executes a function on change
  142571. * @param f A path cursor onchange callback
  142572. * @returns This path cursor
  142573. */
  142574. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142575. }
  142576. }
  142577. declare module BABYLON {
  142578. /** @hidden */
  142579. export var blurPixelShader: {
  142580. name: string;
  142581. shader: string;
  142582. };
  142583. }
  142584. declare module BABYLON {
  142585. /** @hidden */
  142586. export var pointCloudVertexDeclaration: {
  142587. name: string;
  142588. shader: string;
  142589. };
  142590. }
  142591. // Mixins
  142592. interface Window {
  142593. mozIndexedDB: IDBFactory;
  142594. webkitIndexedDB: IDBFactory;
  142595. msIndexedDB: IDBFactory;
  142596. webkitURL: typeof URL;
  142597. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142598. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142599. WebGLRenderingContext: WebGLRenderingContext;
  142600. MSGesture: MSGesture;
  142601. CANNON: any;
  142602. AudioContext: AudioContext;
  142603. webkitAudioContext: AudioContext;
  142604. PointerEvent: any;
  142605. Math: Math;
  142606. Uint8Array: Uint8ArrayConstructor;
  142607. Float32Array: Float32ArrayConstructor;
  142608. mozURL: typeof URL;
  142609. msURL: typeof URL;
  142610. VRFrameData: any; // WebVR, from specs 1.1
  142611. DracoDecoderModule: any;
  142612. setImmediate(handler: (...args: any[]) => void): number;
  142613. }
  142614. interface HTMLCanvasElement {
  142615. requestPointerLock(): void;
  142616. msRequestPointerLock?(): void;
  142617. mozRequestPointerLock?(): void;
  142618. webkitRequestPointerLock?(): void;
  142619. /** Track wether a record is in progress */
  142620. isRecording: boolean;
  142621. /** Capture Stream method defined by some browsers */
  142622. captureStream(fps?: number): MediaStream;
  142623. }
  142624. interface CanvasRenderingContext2D {
  142625. msImageSmoothingEnabled: boolean;
  142626. }
  142627. interface MouseEvent {
  142628. mozMovementX: number;
  142629. mozMovementY: number;
  142630. webkitMovementX: number;
  142631. webkitMovementY: number;
  142632. msMovementX: number;
  142633. msMovementY: number;
  142634. }
  142635. interface Navigator {
  142636. mozGetVRDevices: (any: any) => any;
  142637. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142638. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142639. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142640. webkitGetGamepads(): Gamepad[];
  142641. msGetGamepads(): Gamepad[];
  142642. webkitGamepads(): Gamepad[];
  142643. }
  142644. interface HTMLVideoElement {
  142645. mozSrcObject: any;
  142646. }
  142647. interface Math {
  142648. fround(x: number): number;
  142649. imul(a: number, b: number): number;
  142650. }
  142651. interface WebGLRenderingContext {
  142652. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142653. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142654. vertexAttribDivisor(index: number, divisor: number): void;
  142655. createVertexArray(): any;
  142656. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142657. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142658. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142659. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142660. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142661. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142662. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142663. // Queries
  142664. createQuery(): WebGLQuery;
  142665. deleteQuery(query: WebGLQuery): void;
  142666. beginQuery(target: number, query: WebGLQuery): void;
  142667. endQuery(target: number): void;
  142668. getQueryParameter(query: WebGLQuery, pname: number): any;
  142669. getQuery(target: number, pname: number): any;
  142670. MAX_SAMPLES: number;
  142671. RGBA8: number;
  142672. READ_FRAMEBUFFER: number;
  142673. DRAW_FRAMEBUFFER: number;
  142674. UNIFORM_BUFFER: number;
  142675. HALF_FLOAT_OES: number;
  142676. RGBA16F: number;
  142677. RGBA32F: number;
  142678. R32F: number;
  142679. RG32F: number;
  142680. RGB32F: number;
  142681. R16F: number;
  142682. RG16F: number;
  142683. RGB16F: number;
  142684. RED: number;
  142685. RG: number;
  142686. R8: number;
  142687. RG8: number;
  142688. UNSIGNED_INT_24_8: number;
  142689. DEPTH24_STENCIL8: number;
  142690. MIN: number;
  142691. MAX: number;
  142692. /* Multiple Render Targets */
  142693. drawBuffers(buffers: number[]): void;
  142694. readBuffer(src: number): void;
  142695. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142696. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142697. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142698. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142699. // Occlusion Query
  142700. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142701. ANY_SAMPLES_PASSED: number;
  142702. QUERY_RESULT_AVAILABLE: number;
  142703. QUERY_RESULT: number;
  142704. }
  142705. interface WebGLProgram {
  142706. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142707. }
  142708. interface EXT_disjoint_timer_query {
  142709. QUERY_COUNTER_BITS_EXT: number;
  142710. TIME_ELAPSED_EXT: number;
  142711. TIMESTAMP_EXT: number;
  142712. GPU_DISJOINT_EXT: number;
  142713. QUERY_RESULT_EXT: number;
  142714. QUERY_RESULT_AVAILABLE_EXT: number;
  142715. queryCounterEXT(query: WebGLQuery, target: number): void;
  142716. createQueryEXT(): WebGLQuery;
  142717. beginQueryEXT(target: number, query: WebGLQuery): void;
  142718. endQueryEXT(target: number): void;
  142719. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142720. deleteQueryEXT(query: WebGLQuery): void;
  142721. }
  142722. interface WebGLUniformLocation {
  142723. _currentState: any;
  142724. }
  142725. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142726. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142727. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142728. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142729. interface WebGLRenderingContext {
  142730. readonly RASTERIZER_DISCARD: number;
  142731. readonly DEPTH_COMPONENT24: number;
  142732. readonly TEXTURE_3D: number;
  142733. readonly TEXTURE_2D_ARRAY: number;
  142734. readonly TEXTURE_COMPARE_FUNC: number;
  142735. readonly TEXTURE_COMPARE_MODE: number;
  142736. readonly COMPARE_REF_TO_TEXTURE: number;
  142737. readonly TEXTURE_WRAP_R: number;
  142738. readonly HALF_FLOAT: number;
  142739. readonly RGB8: number;
  142740. readonly RED_INTEGER: number;
  142741. readonly RG_INTEGER: number;
  142742. readonly RGB_INTEGER: number;
  142743. readonly RGBA_INTEGER: number;
  142744. readonly R8_SNORM: number;
  142745. readonly RG8_SNORM: number;
  142746. readonly RGB8_SNORM: number;
  142747. readonly RGBA8_SNORM: number;
  142748. readonly R8I: number;
  142749. readonly RG8I: number;
  142750. readonly RGB8I: number;
  142751. readonly RGBA8I: number;
  142752. readonly R8UI: number;
  142753. readonly RG8UI: number;
  142754. readonly RGB8UI: number;
  142755. readonly RGBA8UI: number;
  142756. readonly R16I: number;
  142757. readonly RG16I: number;
  142758. readonly RGB16I: number;
  142759. readonly RGBA16I: number;
  142760. readonly R16UI: number;
  142761. readonly RG16UI: number;
  142762. readonly RGB16UI: number;
  142763. readonly RGBA16UI: number;
  142764. readonly R32I: number;
  142765. readonly RG32I: number;
  142766. readonly RGB32I: number;
  142767. readonly RGBA32I: number;
  142768. readonly R32UI: number;
  142769. readonly RG32UI: number;
  142770. readonly RGB32UI: number;
  142771. readonly RGBA32UI: number;
  142772. readonly RGB10_A2UI: number;
  142773. readonly R11F_G11F_B10F: number;
  142774. readonly RGB9_E5: number;
  142775. readonly RGB10_A2: number;
  142776. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142777. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142778. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142779. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142780. readonly DEPTH_COMPONENT32F: number;
  142781. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142782. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142783. 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;
  142784. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142785. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142786. readonly TRANSFORM_FEEDBACK: number;
  142787. readonly INTERLEAVED_ATTRIBS: number;
  142788. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142789. createTransformFeedback(): WebGLTransformFeedback;
  142790. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142791. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142792. beginTransformFeedback(primitiveMode: number): void;
  142793. endTransformFeedback(): void;
  142794. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142795. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142796. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142797. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142798. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142799. }
  142800. interface ImageBitmap {
  142801. readonly width: number;
  142802. readonly height: number;
  142803. close(): void;
  142804. }
  142805. interface WebGLQuery extends WebGLObject {
  142806. }
  142807. declare var WebGLQuery: {
  142808. prototype: WebGLQuery;
  142809. new(): WebGLQuery;
  142810. };
  142811. interface WebGLSampler extends WebGLObject {
  142812. }
  142813. declare var WebGLSampler: {
  142814. prototype: WebGLSampler;
  142815. new(): WebGLSampler;
  142816. };
  142817. interface WebGLSync extends WebGLObject {
  142818. }
  142819. declare var WebGLSync: {
  142820. prototype: WebGLSync;
  142821. new(): WebGLSync;
  142822. };
  142823. interface WebGLTransformFeedback extends WebGLObject {
  142824. }
  142825. declare var WebGLTransformFeedback: {
  142826. prototype: WebGLTransformFeedback;
  142827. new(): WebGLTransformFeedback;
  142828. };
  142829. interface WebGLVertexArrayObject extends WebGLObject {
  142830. }
  142831. declare var WebGLVertexArrayObject: {
  142832. prototype: WebGLVertexArrayObject;
  142833. new(): WebGLVertexArrayObject;
  142834. };
  142835. // Type definitions for WebVR API
  142836. // Project: https://w3c.github.io/webvr/
  142837. // Definitions by: six a <https://github.com/lostfictions>
  142838. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142839. interface VRDisplay extends EventTarget {
  142840. /**
  142841. * Dictionary of capabilities describing the VRDisplay.
  142842. */
  142843. readonly capabilities: VRDisplayCapabilities;
  142844. /**
  142845. * z-depth defining the far plane of the eye view frustum
  142846. * enables mapping of values in the render target depth
  142847. * attachment to scene coordinates. Initially set to 10000.0.
  142848. */
  142849. depthFar: number;
  142850. /**
  142851. * z-depth defining the near plane of the eye view frustum
  142852. * enables mapping of values in the render target depth
  142853. * attachment to scene coordinates. Initially set to 0.01.
  142854. */
  142855. depthNear: number;
  142856. /**
  142857. * An identifier for this distinct VRDisplay. Used as an
  142858. * association point in the Gamepad API.
  142859. */
  142860. readonly displayId: number;
  142861. /**
  142862. * A display name, a user-readable name identifying it.
  142863. */
  142864. readonly displayName: string;
  142865. readonly isConnected: boolean;
  142866. readonly isPresenting: boolean;
  142867. /**
  142868. * If this VRDisplay supports room-scale experiences, the optional
  142869. * stage attribute contains details on the room-scale parameters.
  142870. */
  142871. readonly stageParameters: VRStageParameters | null;
  142872. /**
  142873. * Passing the value returned by `requestAnimationFrame` to
  142874. * `cancelAnimationFrame` will unregister the callback.
  142875. * @param handle Define the hanle of the request to cancel
  142876. */
  142877. cancelAnimationFrame(handle: number): void;
  142878. /**
  142879. * Stops presenting to the VRDisplay.
  142880. * @returns a promise to know when it stopped
  142881. */
  142882. exitPresent(): Promise<void>;
  142883. /**
  142884. * Return the current VREyeParameters for the given eye.
  142885. * @param whichEye Define the eye we want the parameter for
  142886. * @returns the eye parameters
  142887. */
  142888. getEyeParameters(whichEye: string): VREyeParameters;
  142889. /**
  142890. * Populates the passed VRFrameData with the information required to render
  142891. * the current frame.
  142892. * @param frameData Define the data structure to populate
  142893. * @returns true if ok otherwise false
  142894. */
  142895. getFrameData(frameData: VRFrameData): boolean;
  142896. /**
  142897. * Get the layers currently being presented.
  142898. * @returns the list of VR layers
  142899. */
  142900. getLayers(): VRLayer[];
  142901. /**
  142902. * Return a VRPose containing the future predicted pose of the VRDisplay
  142903. * when the current frame will be presented. The value returned will not
  142904. * change until JavaScript has returned control to the browser.
  142905. *
  142906. * The VRPose will contain the position, orientation, velocity,
  142907. * and acceleration of each of these properties.
  142908. * @returns the pose object
  142909. */
  142910. getPose(): VRPose;
  142911. /**
  142912. * Return the current instantaneous pose of the VRDisplay, with no
  142913. * prediction applied.
  142914. * @returns the current instantaneous pose
  142915. */
  142916. getImmediatePose(): VRPose;
  142917. /**
  142918. * The callback passed to `requestAnimationFrame` will be called
  142919. * any time a new frame should be rendered. When the VRDisplay is
  142920. * presenting the callback will be called at the native refresh
  142921. * rate of the HMD. When not presenting this function acts
  142922. * identically to how window.requestAnimationFrame acts. Content should
  142923. * make no assumptions of frame rate or vsync behavior as the HMD runs
  142924. * asynchronously from other displays and at differing refresh rates.
  142925. * @param callback Define the eaction to run next frame
  142926. * @returns the request handle it
  142927. */
  142928. requestAnimationFrame(callback: FrameRequestCallback): number;
  142929. /**
  142930. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  142931. * Repeat calls while already presenting will update the VRLayers being displayed.
  142932. * @param layers Define the list of layer to present
  142933. * @returns a promise to know when the request has been fulfilled
  142934. */
  142935. requestPresent(layers: VRLayer[]): Promise<void>;
  142936. /**
  142937. * Reset the pose for this display, treating its current position and
  142938. * orientation as the "origin/zero" values. VRPose.position,
  142939. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  142940. * updated when calling resetPose(). This should be called in only
  142941. * sitting-space experiences.
  142942. */
  142943. resetPose(): void;
  142944. /**
  142945. * The VRLayer provided to the VRDisplay will be captured and presented
  142946. * in the HMD. Calling this function has the same effect on the source
  142947. * canvas as any other operation that uses its source image, and canvases
  142948. * created without preserveDrawingBuffer set to true will be cleared.
  142949. * @param pose Define the pose to submit
  142950. */
  142951. submitFrame(pose?: VRPose): void;
  142952. }
  142953. declare var VRDisplay: {
  142954. prototype: VRDisplay;
  142955. new(): VRDisplay;
  142956. };
  142957. interface VRLayer {
  142958. leftBounds?: number[] | Float32Array | null;
  142959. rightBounds?: number[] | Float32Array | null;
  142960. source?: HTMLCanvasElement | null;
  142961. }
  142962. interface VRDisplayCapabilities {
  142963. readonly canPresent: boolean;
  142964. readonly hasExternalDisplay: boolean;
  142965. readonly hasOrientation: boolean;
  142966. readonly hasPosition: boolean;
  142967. readonly maxLayers: number;
  142968. }
  142969. interface VREyeParameters {
  142970. /** @deprecated */
  142971. readonly fieldOfView: VRFieldOfView;
  142972. readonly offset: Float32Array;
  142973. readonly renderHeight: number;
  142974. readonly renderWidth: number;
  142975. }
  142976. interface VRFieldOfView {
  142977. readonly downDegrees: number;
  142978. readonly leftDegrees: number;
  142979. readonly rightDegrees: number;
  142980. readonly upDegrees: number;
  142981. }
  142982. interface VRFrameData {
  142983. readonly leftProjectionMatrix: Float32Array;
  142984. readonly leftViewMatrix: Float32Array;
  142985. readonly pose: VRPose;
  142986. readonly rightProjectionMatrix: Float32Array;
  142987. readonly rightViewMatrix: Float32Array;
  142988. readonly timestamp: number;
  142989. }
  142990. interface VRPose {
  142991. readonly angularAcceleration: Float32Array | null;
  142992. readonly angularVelocity: Float32Array | null;
  142993. readonly linearAcceleration: Float32Array | null;
  142994. readonly linearVelocity: Float32Array | null;
  142995. readonly orientation: Float32Array | null;
  142996. readonly position: Float32Array | null;
  142997. readonly timestamp: number;
  142998. }
  142999. interface VRStageParameters {
  143000. sittingToStandingTransform?: Float32Array;
  143001. sizeX?: number;
  143002. sizeY?: number;
  143003. }
  143004. interface Navigator {
  143005. getVRDisplays(): Promise<VRDisplay[]>;
  143006. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143007. }
  143008. interface Window {
  143009. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143010. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143011. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143012. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143013. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143014. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143015. }
  143016. interface Gamepad {
  143017. readonly displayId: number;
  143018. }
  143019. type XRSessionMode =
  143020. | "inline"
  143021. | "immersive-vr"
  143022. | "immersive-ar";
  143023. type XRReferenceSpaceType =
  143024. | "viewer"
  143025. | "local"
  143026. | "local-floor"
  143027. | "bounded-floor"
  143028. | "unbounded";
  143029. type XREnvironmentBlendMode =
  143030. | "opaque"
  143031. | "additive"
  143032. | "alpha-blend";
  143033. type XRVisibilityState =
  143034. | "visible"
  143035. | "visible-blurred"
  143036. | "hidden";
  143037. type XRHandedness =
  143038. | "none"
  143039. | "left"
  143040. | "right";
  143041. type XRTargetRayMode =
  143042. | "gaze"
  143043. | "tracked-pointer"
  143044. | "screen";
  143045. type XREye =
  143046. | "none"
  143047. | "left"
  143048. | "right";
  143049. interface XRSpace extends EventTarget {
  143050. }
  143051. interface XRRenderState {
  143052. depthNear?: number;
  143053. depthFar?: number;
  143054. inlineVerticalFieldOfView?: number;
  143055. baseLayer?: XRWebGLLayer;
  143056. }
  143057. interface XRInputSource {
  143058. handedness: XRHandedness;
  143059. targetRayMode: XRTargetRayMode;
  143060. targetRaySpace: XRSpace;
  143061. gripSpace: XRSpace | undefined;
  143062. gamepad: Gamepad | undefined;
  143063. profiles: Array<string>;
  143064. }
  143065. interface XRSessionInit {
  143066. optionalFeatures?: XRReferenceSpaceType[];
  143067. requiredFeatures?: XRReferenceSpaceType[];
  143068. }
  143069. interface XRSession extends XRAnchorCreator {
  143070. addEventListener: Function;
  143071. removeEventListener: Function;
  143072. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143073. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143074. requestAnimationFrame: Function;
  143075. end(): Promise<void>;
  143076. renderState: XRRenderState;
  143077. inputSources: Array<XRInputSource>;
  143078. // AR hit test
  143079. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143080. updateWorldTrackingState(options: {
  143081. planeDetectionState?: { enabled: boolean; }
  143082. }): void;
  143083. }
  143084. interface XRReferenceSpace extends XRSpace {
  143085. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143086. onreset: any;
  143087. }
  143088. type XRPlaneSet = Set<XRPlane>;
  143089. type XRAnchorSet = Set<XRAnchor>;
  143090. interface XRFrame {
  143091. session: XRSession;
  143092. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143093. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143094. // Anchors
  143095. trackedAnchors?: XRAnchorSet;
  143096. // Planes
  143097. worldInformation: {
  143098. detectedPlanes?: XRPlaneSet;
  143099. };
  143100. }
  143101. interface XRViewerPose extends XRPose {
  143102. views: Array<XRView>;
  143103. }
  143104. interface XRPose {
  143105. transform: XRRigidTransform;
  143106. emulatedPosition: boolean;
  143107. }
  143108. interface XRWebGLLayerOptions {
  143109. antialias?: boolean;
  143110. depth?: boolean;
  143111. stencil?: boolean;
  143112. alpha?: boolean;
  143113. multiview?: boolean;
  143114. framebufferScaleFactor?: number;
  143115. }
  143116. declare var XRWebGLLayer: {
  143117. prototype: XRWebGLLayer;
  143118. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143119. };
  143120. interface XRWebGLLayer {
  143121. framebuffer: WebGLFramebuffer;
  143122. framebufferWidth: number;
  143123. framebufferHeight: number;
  143124. getViewport: Function;
  143125. }
  143126. declare class XRRigidTransform {
  143127. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143128. position: DOMPointReadOnly;
  143129. orientation: DOMPointReadOnly;
  143130. matrix: Float32Array;
  143131. inverse: XRRigidTransform;
  143132. }
  143133. interface XRView {
  143134. eye: XREye;
  143135. projectionMatrix: Float32Array;
  143136. transform: XRRigidTransform;
  143137. }
  143138. interface XRInputSourceChangeEvent {
  143139. session: XRSession;
  143140. removed: Array<XRInputSource>;
  143141. added: Array<XRInputSource>;
  143142. }
  143143. interface XRInputSourceEvent extends Event {
  143144. readonly frame: XRFrame;
  143145. readonly inputSource: XRInputSource;
  143146. }
  143147. // Experimental(er) features
  143148. declare class XRRay {
  143149. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143150. origin: DOMPointReadOnly;
  143151. direction: DOMPointReadOnly;
  143152. matrix: Float32Array;
  143153. }
  143154. interface XRHitResult {
  143155. hitMatrix: Float32Array;
  143156. }
  143157. interface XRAnchor {
  143158. // remove?
  143159. id?: string;
  143160. anchorSpace: XRSpace;
  143161. lastChangedTime: number;
  143162. detach(): void;
  143163. }
  143164. interface XRPlane extends XRAnchorCreator {
  143165. orientation: "Horizontal" | "Vertical";
  143166. planeSpace: XRSpace;
  143167. polygon: Array<DOMPointReadOnly>;
  143168. lastChangedTime: number;
  143169. }
  143170. interface XRAnchorCreator {
  143171. // AR Anchors
  143172. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143173. }